LLDB  mainline
AddressResolverFileLine.cpp
Go to the documentation of this file.
1 //===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "lldb/Core/Address.h"
12 #include "lldb/Core/AddressRange.h"
14 #include "lldb/Symbol/LineEntry.h"
17 #include "lldb/Utility/Log.h"
18 #include "lldb/Utility/Logging.h"
19 #include "lldb/Utility/Stream.h"
21 #include "lldb/lldb-enumerations.h"
22 #include "lldb/lldb-types.h"
23 
24 #include <inttypes.h>
25 #include <vector>
26 
27 using namespace lldb;
28 using namespace lldb_private;
29 
30 // AddressResolverFileLine:
31 AddressResolverFileLine::AddressResolverFileLine(const FileSpec &file_spec,
32  uint32_t line_no,
33  bool check_inlines)
34  : AddressResolver(), m_file_spec(file_spec), m_line_number(line_no),
35  m_inlines(check_inlines) {}
36 
38 
41  SymbolContext &context, Address *addr,
42  bool containing) {
43  SymbolContextList sc_list;
44  uint32_t sc_list_size;
45  CompileUnit *cu = context.comp_unit;
46 
48 
49  sc_list_size =
51  eSymbolContextEverything, sc_list);
52  for (uint32_t i = 0; i < sc_list_size; i++) {
53  SymbolContext sc;
54  if (sc_list.GetContextAtIndex(i, sc)) {
55  Address line_start = sc.line_entry.range.GetBaseAddress();
56  addr_t byte_size = sc.line_entry.range.GetByteSize();
57  if (line_start.IsValid()) {
58  AddressRange new_range(line_start, byte_size);
59  m_address_ranges.push_back(new_range);
60  if (log) {
61  StreamString s;
62  // new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
63  // log->Printf ("Added address: %s\n", s.GetData());
64  }
65  } else {
66  if (log)
67  log->Printf(
68  "error: Unable to resolve address at file address 0x%" PRIx64
69  " for %s:%d\n",
70  line_start.GetFileAddress(),
72  }
73  }
74  }
76 }
77 
80 }
81 
83  s->Printf("File and line address - file: \"%s\" line: %u",
85 }
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:369
void GetDescription(Stream *s) override
Prints a canonical description for the searcher to the stream s.
Defines a list of symbol context objects.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:232
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:224
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
A file utility class.
Definition: FileSpec.h:55
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:272
CompileUnit * comp_unit
The CompileUnit for a given query.
A class that describes a compilation unit.
Definition: CompileUnit.h:35
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
#define LIBLLDB_LOG_BREAKPOINTS
Definition: Logging.h:19
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:101
General Outline: The AddressResolver is a Searcher.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:343
A section + offset based address class.
Definition: Address.h:80
Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr, bool containing) override
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint64_t addr_t
Definition: lldb-types.h:83
LineEntry line_entry
The LineEntry for a given query.
Definition: SBAddress.h:15
uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, bool exact, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve symbol contexts by file and line.
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:220
std::vector< AddressRange > m_address_ranges
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113
A section + offset based address range class.
Definition: AddressRange.h:32
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:150