LLDB mainline
FileLineResolver.cpp
Go to the documentation of this file.
1//===-- FileLineResolver.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//===----------------------------------------------------------------------===//
8
10
15#include "lldb/Utility/Stream.h"
16
17#include <string>
18
19namespace lldb_private {
20class Address;
21}
22
23using namespace lldb;
24using namespace lldb_private;
25
26// FileLineResolver:
27FileLineResolver::FileLineResolver(const FileSpec &file_spec, uint32_t line_no,
28 bool check_inlines)
29 : Searcher(), m_file_spec(file_spec), m_line_number(line_no),
30 m_inlines(check_inlines) {}
31
33
36 Address *addr) {
37 CompileUnit *cu = context.comp_unit;
38
40 (bool)m_file_spec.GetDirectory())) {
41 uint32_t start_file_idx = 0;
42 uint32_t file_idx =
43 cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false);
44 if (file_idx != UINT32_MAX) {
45 LineTable *line_table = cu->GetLineTable();
46 if (line_table) {
47 if (m_line_number == 0) {
48 // Match all lines in a file...
49 const bool append = true;
50 while (file_idx != UINT32_MAX) {
51 line_table->FindLineEntriesForFileIndex(file_idx, append,
52 m_sc_list);
53 // Get the next file index in case we have multiple file entries
54 // for the same file
55 file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1,
56 m_file_spec, false);
57 }
58 } else {
59 // Match a specific line in a file...
60 }
61 }
62 }
63 }
65}
66
69}
70
72 s->Printf("File and line resolver for file: \"%s\" line: %u",
74}
75
80 m_inlines = true;
81}
82
83void FileLineResolver::Reset(const FileSpec &file_spec, uint32_t line,
84 bool check_inlines) {
85 m_file_spec = file_spec;
86 m_line_number = line;
88 m_inlines = check_inlines;
89}
A section + offset based address class.
Definition: Address.h:62
A class that describes a compilation unit.
Definition: CompileUnit.h:43
const SupportFileList & GetSupportFiles()
Get the compile unit's support file list.
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
Definition: CompileUnit.h:232
LineTable * GetLineTable()
Get the line table for the compile unit.
void GetDescription(Stream *s) override
Prints a canonical description for the searcher to the stream s.
lldb::SearchDepth GetDepth() override
Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr) override
void Reset(const FileSpec &file_spec, uint32_t line, bool check_inlines)
A file utility class.
Definition: FileSpec.h:56
const ConstString & GetDirectory() const
Directory string const get accessor.
Definition: FileSpec.h:223
static int Compare(const FileSpec &lhs, const FileSpec &rhs, bool full)
Compare two FileSpec objects.
Definition: FileSpec.cpp:273
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:367
void Clear()
Clears the object state.
Definition: FileSpec.cpp:259
A line table class.
Definition: LineTable.h:40
size_t FindLineEntriesForFileIndex(uint32_t file_idx, bool append, SymbolContextList &sc_list)
Definition: LineTable.cpp:328
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:83
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:42
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
size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const
void Clear()
Clear the object's state.
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.
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
@ eSearchDepthCompUnit