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 #include "lldb/lldb-private-log.h"
18
19 using namespace lldb;
20 using namespace lldb_private;
21
22 //----------------------------------------------------------------------
23 // AddressResolverFileLine:
24 //----------------------------------------------------------------------
AddressResolverFileLine(const FileSpec & file_spec,uint32_t line_no,bool check_inlines)25 AddressResolverFileLine::AddressResolverFileLine
26 (
27 const FileSpec &file_spec,
28 uint32_t line_no,
29 bool check_inlines
30 ) :
31 AddressResolver (),
32 m_file_spec (file_spec),
33 m_line_number (line_no),
34 m_inlines (check_inlines)
35 {
36 }
37
~AddressResolverFileLine()38 AddressResolverFileLine::~AddressResolverFileLine ()
39 {
40 }
41
42 Searcher::CallbackReturn
SearchCallback(SearchFilter & filter,SymbolContext & context,Address * addr,bool containing)43 AddressResolverFileLine::SearchCallback
44 (
45 SearchFilter &filter,
46 SymbolContext &context,
47 Address *addr,
48 bool containing
49 )
50 {
51 SymbolContextList sc_list;
52 uint32_t sc_list_size;
53 CompileUnit *cu = context.comp_unit;
54
55 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
56
57 sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything,
58 sc_list);
59 for (uint32_t i = 0; i < sc_list_size; i++)
60 {
61 SymbolContext sc;
62 if (sc_list.GetContextAtIndex(i, sc))
63 {
64 Address line_start = sc.line_entry.range.GetBaseAddress();
65 addr_t byte_size = sc.line_entry.range.GetByteSize();
66 if (line_start.IsValid())
67 {
68 AddressRange new_range (line_start, byte_size);
69 m_address_ranges.push_back (new_range);
70 if (log)
71 {
72 StreamString s;
73 //new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
74 //log->Printf ("Added address: %s\n", s.GetData());
75 }
76 }
77 else
78 {
79 if (log)
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>"),
83 m_line_number);
84 }
85 }
86 }
87 return Searcher::eCallbackReturnContinue;
88 }
89
90 Searcher::Depth
GetDepth()91 AddressResolverFileLine::GetDepth()
92 {
93 return Searcher::eDepthCompUnit;
94 }
95
96 void
GetDescription(Stream * s)97 AddressResolverFileLine::GetDescription (Stream *s)
98 {
99 s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(), m_line_number);
100 }
101
102
103