LLDB  mainline
FileLineResolver.cpp
Go to the documentation of this file.
1 //===-- FileLineResolver.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/FileSpecList.h"
13 #include "lldb/Symbol/LineTable.h"
15 #include "lldb/Utility/Stream.h"
16 
17 #include <string>
18 
19 namespace lldb_private {
20 class Address;
21 }
22 
23 using namespace lldb;
24 using namespace lldb_private;
25 
26 // FileLineResolver:
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, bool containing) {
37  CompileUnit *cu = context.comp_unit;
38 
39  if (m_inlines ||
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->FineLineEntriesForFileIndex(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",
73  m_file_spec.GetPath().c_str(), m_line_number);
74 }
75 
79  m_sc_list.Clear();
80  m_inlines = true;
81 }
82 
83 void 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 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void GetDescription(Stream *s) override
Prints a canonical description for the searcher to the stream s.
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::SearchDepth GetDepth() override
Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr, bool containing) override
CompileUnit * comp_unit
The CompileUnit for a given query.
static int Compare(const FileSpec &lhs, const FileSpec &rhs, bool full)
Compare two FileSpec objects.
Definition: FileSpec.cpp:298
void Clear()
Clears the object state.
Definition: FileSpec.cpp:285
A class that describes a compilation unit.
Definition: CompileUnit.h:35
#define UINT32_MAX
Definition: lldb-defines.h:31
A line table class.
Definition: LineTable.h:37
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:101
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:60
void Clear()
Clear the object&#39;s state.
FileSpecList & GetSupportFiles()
Get the compile unit&#39;s support file list.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
A section + offset based address class.
Definition: Address.h:80
LineTable * GetLineTable()
Get the line table for the compile unit.
void Reset(const FileSpec &file_spec, uint32_t line, bool check_inlines)
ConstString & GetDirectory()
Directory string get accessor.
Definition: FileSpec.cpp:363
Definition: SBAddress.h:15
size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append, SymbolContextList &sc_list)
Definition: LineTable.cpp:363
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:376