LLDB  mainline
Go to the documentation of this file.
1 //===-- AddressResolverFileLine.cpp ---------------------------------------===//
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 //===----------------------------------------------------------------------===//
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"
24 #include <inttypes.h>
25 #include <vector>
27 using namespace lldb;
28 using namespace lldb_private;
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) {}
41  SymbolContext &context, Address *addr) {
42  SymbolContextList sc_list;
43  CompileUnit *cu = context.comp_unit;
48  eSymbolContextEverything, sc_list);
49  uint32_t sc_list_size = sc_list.GetSize();
50  for (uint32_t i = 0; i < sc_list_size; i++) {
51  SymbolContext sc;
52  if (sc_list.GetContextAtIndex(i, sc)) {
53  Address line_start = sc.line_entry.range.GetBaseAddress();
54  addr_t byte_size = sc.line_entry.range.GetByteSize();
55  if (line_start.IsValid()) {
56  AddressRange new_range(line_start, byte_size);
57  m_address_ranges.push_back(new_range);
58  if (log) {
59  StreamString s;
60  // new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
61  // LLDB_LOGF(log, "Added address: %s\n", s.GetData());
62  }
63  } else {
64  LLDB_LOGF(log,
65  "error: Unable to resolve address at file address 0x%" PRIx64
66  " for %s:%d\n",
67  line_start.GetFileAddress(),
68  m_file_spec.GetFilename().AsCString("<Unknown>"),
70  }
71  }
72  }
74 }
78 }
81  s->Printf("File and line address - file: \"%s\" line: %u",
83 }
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:341
void GetDescription(Stream *s) override
Prints a canonical description for the searcher to the stream s.
Defines a list of symbol context objects.
A class that represents a running process on the host machine.
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:222
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:223
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:56
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:290
CompileUnit * comp_unit
The CompileUnit for a given query.
A class that describes a compilation unit.
Definition: CompileUnit.h:37
uint32_t GetSize() const
Get accessor for a symbol context list size.
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
Definition: Logging.h:19
void 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.
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:83
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:107
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:332
A section + offset based address class.
Definition: Address.h:59
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
#define LLDB_LOGF(log,...)
Definition: Log.h:249
uint64_t addr_t
Definition: lldb-types.h:83
LineEntry line_entry
The LineEntry for a given query.
Definition: SBAddress.h:15
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:210
std::vector< AddressRange > m_address_ranges
A section + offset based address range class.
Definition: AddressRange.h:25
Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr) override
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:139