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
39 if (m_inlines || m_file_spec.Compare(cu->GetPrimaryFile(), m_file_spec,
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
70
72 s->Printf("File and line resolver for file: \"%s\" line: %u",
73 m_file_spec.GetPath().c_str(), m_line_number);
74}
75
77 m_file_spec.Clear();
79 m_sc_list.Clear();
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;
87 m_sc_list.Clear();
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.
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:57
A line table class.
Definition LineTable.h:25
size_t FindLineEntriesForFileIndex(uint32_t file_idx, bool append, SymbolContextList &sc_list)
General Outline: Provides the callback and search depth for the SearchFilter search.
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
Defines a symbol context baton that can be handed other debug core functions.
CompileUnit * comp_unit
The CompileUnit for a given query.
#define UINT32_MAX
A class that represents a running process on the host machine.
@ eSearchDepthCompUnit