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 //---------------------------------------------------------------------- 24 AddressResolverFileLine::AddressResolverFileLine(const FileSpec &file_spec, 25 uint32_t line_no, 26 bool check_inlines) 27 : AddressResolver(), m_file_spec(file_spec), m_line_number(line_no), 28 m_inlines(check_inlines) {} 29 30 AddressResolverFileLine::~AddressResolverFileLine() {} 31 32 Searcher::CallbackReturn 33 AddressResolverFileLine::SearchCallback(SearchFilter &filter, 34 SymbolContext &context, Address *addr, 35 bool containing) { 36 SymbolContextList sc_list; 37 uint32_t sc_list_size; 38 CompileUnit *cu = context.comp_unit; 39 40 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); 41 42 sc_list_size = 43 cu->ResolveSymbolContext(m_file_spec, m_line_number, m_inlines, false, 44 eSymbolContextEverything, sc_list); 45 for (uint32_t i = 0; i < sc_list_size; i++) { 46 SymbolContext sc; 47 if (sc_list.GetContextAtIndex(i, sc)) { 48 Address line_start = sc.line_entry.range.GetBaseAddress(); 49 addr_t byte_size = sc.line_entry.range.GetByteSize(); 50 if (line_start.IsValid()) { 51 AddressRange new_range(line_start, byte_size); 52 m_address_ranges.push_back(new_range); 53 if (log) { 54 StreamString s; 55 // new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose); 56 // log->Printf ("Added address: %s\n", s.GetData()); 57 } 58 } else { 59 if (log) 60 log->Printf( 61 "error: Unable to resolve address at file address 0x%" PRIx64 62 " for %s:%d\n", 63 line_start.GetFileAddress(), 64 m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number); 65 } 66 } 67 } 68 return Searcher::eCallbackReturnContinue; 69 } 70 71 Searcher::Depth AddressResolverFileLine::GetDepth() { 72 return Searcher::eDepthCompUnit; 73 } 74 75 void AddressResolverFileLine::GetDescription(Stream *s) { 76 s->Printf("File and line address - file: \"%s\" line: %u", 77 m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number); 78 } 79