mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 17:43:57 +00:00
808142876c
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
90 lines
2.9 KiB
C++
90 lines
2.9 KiB
C++
//===-- FileLineResolver.cpp ----------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Core/FileLineResolver.h"
|
|
|
|
#include "lldb/Core/FileSpecList.h"
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
#include "lldb/Symbol/LineTable.h"
|
|
#include "lldb/Utility/ConstString.h"
|
|
#include "lldb/Utility/Stream.h"
|
|
|
|
#include <string>
|
|
|
|
namespace lldb_private {
|
|
class Address;
|
|
}
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
// FileLineResolver:
|
|
FileLineResolver::FileLineResolver(const FileSpec &file_spec, uint32_t line_no,
|
|
bool check_inlines)
|
|
: Searcher(), m_file_spec(file_spec), m_line_number(line_no),
|
|
m_inlines(check_inlines) {}
|
|
|
|
FileLineResolver::~FileLineResolver() {}
|
|
|
|
Searcher::CallbackReturn
|
|
FileLineResolver::SearchCallback(SearchFilter &filter, SymbolContext &context,
|
|
Address *addr) {
|
|
CompileUnit *cu = context.comp_unit;
|
|
|
|
if (m_inlines || m_file_spec.Compare(cu->GetPrimaryFile(), m_file_spec,
|
|
(bool)m_file_spec.GetDirectory())) {
|
|
uint32_t start_file_idx = 0;
|
|
uint32_t file_idx =
|
|
cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false);
|
|
if (file_idx != UINT32_MAX) {
|
|
LineTable *line_table = cu->GetLineTable();
|
|
if (line_table) {
|
|
if (m_line_number == 0) {
|
|
// Match all lines in a file...
|
|
const bool append = true;
|
|
while (file_idx != UINT32_MAX) {
|
|
line_table->FineLineEntriesForFileIndex(file_idx, append,
|
|
m_sc_list);
|
|
// Get the next file index in case we have multiple file entries
|
|
// for the same file
|
|
file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1,
|
|
m_file_spec, false);
|
|
}
|
|
} else {
|
|
// Match a specific line in a file...
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Searcher::eCallbackReturnContinue;
|
|
}
|
|
|
|
lldb::SearchDepth FileLineResolver::GetDepth() {
|
|
return lldb::eSearchDepthCompUnit;
|
|
}
|
|
|
|
void FileLineResolver::GetDescription(Stream *s) {
|
|
s->Printf("File and line resolver for file: \"%s\" line: %u",
|
|
m_file_spec.GetPath().c_str(), m_line_number);
|
|
}
|
|
|
|
void FileLineResolver::Clear() {
|
|
m_file_spec.Clear();
|
|
m_line_number = UINT32_MAX;
|
|
m_sc_list.Clear();
|
|
m_inlines = true;
|
|
}
|
|
|
|
void FileLineResolver::Reset(const FileSpec &file_spec, uint32_t line,
|
|
bool check_inlines) {
|
|
m_file_spec = file_spec;
|
|
m_line_number = line;
|
|
m_sc_list.Clear();
|
|
m_inlines = check_inlines;
|
|
}
|