/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/FileLineResolver.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
9 | | #include "lldb/Core/FileLineResolver.h" |
10 | | |
11 | | #include "lldb/Symbol/CompileUnit.h" |
12 | | #include "lldb/Symbol/LineTable.h" |
13 | | #include "lldb/Utility/ConstString.h" |
14 | | #include "lldb/Utility/FileSpecList.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: |
27 | | FileLineResolver::FileLineResolver(const FileSpec &file_spec, uint32_t line_no, |
28 | | bool check_inlines) |
29 | 0 | : Searcher(), m_file_spec(file_spec), m_line_number(line_no), |
30 | 0 | m_inlines(check_inlines) {} |
31 | | |
32 | 6.08k | FileLineResolver::~FileLineResolver() = default; |
33 | | |
34 | | Searcher::CallbackReturn |
35 | | FileLineResolver::SearchCallback(SearchFilter &filter, SymbolContext &context, |
36 | 1 | Address *addr) { |
37 | 1 | CompileUnit *cu = context.comp_unit; |
38 | | |
39 | 1 | if (m_inlines || m_file_spec.Compare(cu->GetPrimaryFile(), m_file_spec, |
40 | 1 | (bool)m_file_spec.GetDirectory())) { |
41 | 1 | uint32_t start_file_idx = 0; |
42 | 1 | uint32_t file_idx = |
43 | 1 | cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false); |
44 | 1 | if (file_idx != UINT32_MAX) { |
45 | 1 | LineTable *line_table = cu->GetLineTable(); |
46 | 1 | if (line_table) { |
47 | 1 | if (m_line_number == 0) { |
48 | | // Match all lines in a file... |
49 | 1 | const bool append = true; |
50 | 2 | while (file_idx != UINT32_MAX) { |
51 | 1 | line_table->FindLineEntriesForFileIndex(file_idx, append, |
52 | 1 | m_sc_list); |
53 | | // Get the next file index in case we have multiple file entries |
54 | | // for the same file |
55 | 1 | file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1, |
56 | 1 | m_file_spec, false); |
57 | 1 | } |
58 | 1 | } else { |
59 | | // Match a specific line in a file... |
60 | 0 | } |
61 | 1 | } |
62 | 1 | } |
63 | 1 | } |
64 | 1 | return Searcher::eCallbackReturnContinue; |
65 | 1 | } |
66 | | |
67 | 44 | lldb::SearchDepth FileLineResolver::GetDepth() { |
68 | 44 | return lldb::eSearchDepthCompUnit; |
69 | 44 | } |
70 | | |
71 | 0 | void FileLineResolver::GetDescription(Stream *s) { |
72 | 0 | s->Printf("File and line resolver for file: \"%s\" line: %u", |
73 | 0 | m_file_spec.GetPath().c_str(), m_line_number); |
74 | 0 | } |
75 | | |
76 | 10 | void FileLineResolver::Clear() { |
77 | 10 | m_file_spec.Clear(); |
78 | 10 | m_line_number = UINT32_MAX; |
79 | 10 | m_sc_list.Clear(); |
80 | 10 | m_inlines = true; |
81 | 10 | } |
82 | | |
83 | | void FileLineResolver::Reset(const FileSpec &file_spec, uint32_t line, |
84 | 1 | bool check_inlines) { |
85 | 1 | m_file_spec = file_spec; |
86 | 1 | m_line_number = line; |
87 | 1 | m_sc_list.Clear(); |
88 | 1 | m_inlines = check_inlines; |
89 | 1 | } |