Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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" |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 15 | #include "lldb/Symbol/CompileUnit.h" |
| 16 | #include "lldb/Symbol/SymbolContext.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/lldb-private-log.h" |
| 18 | |
| 19 | using namespace lldb; |
| 20 | using namespace lldb_private; |
| 21 | |
| 22 | //---------------------------------------------------------------------- |
| 23 | // AddressResolverFileLine: |
| 24 | //---------------------------------------------------------------------- |
| 25 | AddressResolverFileLine::AddressResolverFileLine |
| 26 | ( |
| 27 | const FileSpec &file_spec, |
Greg Clayton | 52c8b6e | 2011-04-19 04:19:37 +0000 | [diff] [blame] | 28 | uint32_t line_no, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | |
| 38 | AddressResolverFileLine::~AddressResolverFileLine () |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | Searcher::CallbackReturn |
| 43 | AddressResolverFileLine::SearchCallback |
| 44 | ( |
| 45 | SearchFilter &filter, |
| 46 | SymbolContext &context, |
Greg Clayton | 52c8b6e | 2011-04-19 04:19:37 +0000 | [diff] [blame] | 47 | Address *addr, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 48 | bool containing |
| 49 | ) |
| 50 | { |
| 51 | SymbolContextList sc_list; |
| 52 | uint32_t sc_list_size; |
| 53 | CompileUnit *cu = context.comp_unit; |
| 54 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 55 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | |
| 57 | sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, |
| 58 | sc_list); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 59 | for (uint32_t i = 0; i < sc_list_size; i++) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 80 | log->Printf ("error: Unable to resolve address at file address 0x%" PRIx64 " for %s:%d\n", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 |
| 91 | AddressResolverFileLine::GetDepth() |
| 92 | { |
| 93 | return Searcher::eDepthCompUnit; |
| 94 | } |
| 95 | |
| 96 | void |
| 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 | |