LLDB mainline
Go to the documentation of this file.
1//===-- AddressResolverFileLine.cpp ---------------------------------------===//
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
11#include "lldb/Core/Address.h"
18#include "lldb/Utility/Log.h"
19#include "lldb/Utility/Stream.h"
22#include "lldb/lldb-types.h"
24#include <cinttypes>
25#include <vector>
27using namespace lldb;
28using namespace lldb_private;
30// AddressResolverFileLine:
32 SourceLocationSpec location_spec)
33 : AddressResolver(), m_src_location_spec(location_spec) {}
39 SymbolContext &context, Address *addr) {
40 SymbolContextList sc_list;
41 CompileUnit *cu = context.comp_unit;
45 // TODO: Handle SourceLocationSpec column information
46 cu->ResolveSymbolContext(m_src_location_spec, eSymbolContextEverything,
47 sc_list);
48 for (const SymbolContext &sc : sc_list) {
49 Address line_start = sc.line_entry.range.GetBaseAddress();
50 addr_t byte_size = sc.line_entry.range.GetByteSize();
51 if (line_start.IsValid()) {
52 AddressRange new_range(line_start, byte_size);
53 m_address_ranges.push_back(new_range);
54 } else {
55 LLDB_LOGF(log,
56 "error: Unable to resolve address at file address 0x%" PRIx64
57 " for %s:%d\n",
58 line_start.GetFileAddress(),
60 "<Unknown>"),
61 m_src_location_spec.GetLine().value_or(0));
62 }
63 }
72 s->Printf(
73 "File and line address - file: \"%s\" line: %u",
75 m_src_location_spec.GetLine().value_or(0));
#define LLDB_LOGF(log,...)
Definition: Log.h:349
A section + offset based address range class.
Definition: AddressRange.h:25
Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr) override
AddressResolverFileLine(SourceLocationSpec location_spec)
void GetDescription(Stream *s) override
Prints a canonical description for the searcher to the stream s.
General Outline: The AddressResolver is a Searcher.
std::vector< AddressRange > m_address_ranges
A section + offset based address class.
Definition: Address.h:62
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:293
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:355
A class that describes a compilation unit.
Definition: CompileUnit.h:41
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve symbol contexts by file and line.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:83
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
std::optional< uint32_t > GetLine() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
Defines a list of symbol context objects.
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
CompileUnit * comp_unit
The CompileUnit for a given query.
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
Definition: SBAddress.h:15
@ eSearchDepthCompUnit
uint64_t addr_t
Definition: lldb-types.h:79