1 //===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/AddressResolverFileLine.h"
13 #include "lldb/Core/Log.h"
14 #include "lldb/Core/StreamString.h"
15 #include "lldb/Symbol/CompileUnit.h"
16 #include "lldb/Symbol/SymbolContext.h"
17 #include "lldb/lldb-private-log.h"
20 using namespace lldb_private;
22 //----------------------------------------------------------------------
23 // AddressResolverFileLine:
24 //----------------------------------------------------------------------
25 AddressResolverFileLine::AddressResolverFileLine
27 const FileSpec &file_spec,
32 m_file_spec (file_spec),
33 m_line_number (line_no),
34 m_inlines (check_inlines)
38 AddressResolverFileLine::~AddressResolverFileLine ()
42 Searcher::CallbackReturn
43 AddressResolverFileLine::SearchCallback
46 SymbolContext &context,
51 SymbolContextList sc_list;
52 uint32_t sc_list_size;
53 CompileUnit *cu = context.comp_unit;
55 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
57 sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything,
59 for (uint32_t i = 0; i < sc_list_size; i++)
62 if (sc_list.GetContextAtIndex(i, sc))
64 Address line_start = sc.line_entry.range.GetBaseAddress();
65 addr_t byte_size = sc.line_entry.range.GetByteSize();
66 if (line_start.IsValid())
68 AddressRange new_range (line_start, byte_size);
69 m_address_ranges.push_back (new_range);
73 //new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
74 //log->Printf ("Added address: %s\n", s.GetData());
80 log->Printf ("error: Unable to resolve address at file address 0x%" PRIx64 " for %s:%d\n",
81 line_start.GetFileAddress(),
82 m_file_spec.GetFilename().AsCString("<Unknown>"),
87 return Searcher::eCallbackReturnContinue;
91 AddressResolverFileLine::GetDepth()
93 return Searcher::eDepthCompUnit;
97 AddressResolverFileLine::GetDescription (Stream *s)
99 s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(), m_line_number);