1 //===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "lldb/Core/AddressResolverFileLine.h"
11
12 // Project includes
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
18 using namespace lldb;
19 using namespace lldb_private;
20
21 //----------------------------------------------------------------------
22 // AddressResolverFileLine:
23 //----------------------------------------------------------------------
AddressResolverFileLine(const FileSpec & file_spec,uint32_t line_no,bool check_inlines)24 AddressResolverFileLine::AddressResolverFileLine
25 (
26 const FileSpec &file_spec,
27 uint32_t line_no,
28 bool check_inlines
29 ) :
30 AddressResolver (),
31 m_file_spec (file_spec),
32 m_line_number (line_no),
33 m_inlines (check_inlines)
34 {
35 }
36
~AddressResolverFileLine()37 AddressResolverFileLine::~AddressResolverFileLine ()
38 {
39 }
40
41 Searcher::CallbackReturn
SearchCallback(SearchFilter & filter,SymbolContext & context,Address * addr,bool containing)42 AddressResolverFileLine::SearchCallback
43 (
44 SearchFilter &filter,
45 SymbolContext &context,
46 Address *addr,
47 bool containing
48 )
49 {
50 SymbolContextList sc_list;
51 uint32_t sc_list_size;
52 CompileUnit *cu = context.comp_unit;
53
54 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
55
56 sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything,
57 sc_list);
58 for (uint32_t i = 0; i < sc_list_size; i++)
59 {
60 SymbolContext sc;
61 if (sc_list.GetContextAtIndex(i, sc))
62 {
63 Address line_start = sc.line_entry.range.GetBaseAddress();
64 addr_t byte_size = sc.line_entry.range.GetByteSize();
65 if (line_start.IsValid())
66 {
67 AddressRange new_range (line_start, byte_size);
68 m_address_ranges.push_back (new_range);
69 if (log)
70 {
71 StreamString s;
72 //new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
73 //log->Printf ("Added address: %s\n", s.GetData());
74 }
75 }
76 else
77 {
78 if (log)
79 log->Printf ("error: Unable to resolve address at file address 0x%" PRIx64 " for %s:%d\n",
80 line_start.GetFileAddress(),
81 m_file_spec.GetFilename().AsCString("<Unknown>"),
82 m_line_number);
83 }
84 }
85 }
86 return Searcher::eCallbackReturnContinue;
87 }
88
89 Searcher::Depth
GetDepth()90 AddressResolverFileLine::GetDepth()
91 {
92 return Searcher::eDepthCompUnit;
93 }
94
95 void
GetDescription(Stream * s)96 AddressResolverFileLine::GetDescription (Stream *s)
97 {
98 s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number);
99 }
100
101
102