2020-01-24 08:23:27 +01:00
|
|
|
//===-- FileLineResolver.cpp ----------------------------------------------===//
|
2011-04-19 04:19:37 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// 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
|
2011-04-19 04:19:37 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/Core/FileLineResolver.h"
|
|
|
|
|
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Core/FileSpecList.h"
|
2012-08-29 21:13:06 +00:00
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
2011-04-19 04:19:37 +00:00
|
|
|
#include "lldb/Symbol/LineTable.h"
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Utility/ConstString.h"
|
|
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-04-06 21:28:29 +00:00
|
|
|
|
2018-11-11 23:16:43 +00:00
|
|
|
#include <string>
|
2017-04-06 21:28:29 +00:00
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
|
class Address;
|
|
|
|
|
}
|
2011-04-19 04:19:37 +00:00
|
|
|
|
|
|
|
|
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,
|
2019-10-10 11:26:51 +00:00
|
|
|
Address *addr) {
|
2011-04-19 04:19:37 +00:00
|
|
|
CompileUnit *cu = context.comp_unit;
|
|
|
|
|
|
2019-11-28 16:22:44 +01:00
|
|
|
if (m_inlines || m_file_spec.Compare(cu->GetPrimaryFile(), m_file_spec,
|
|
|
|
|
(bool)m_file_spec.GetDirectory())) {
|
2011-04-19 04:19:37 +00:00
|
|
|
uint32_t start_file_idx = 0;
|
2011-09-23 00:54:11 +00:00
|
|
|
uint32_t file_idx =
|
|
|
|
|
cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false);
|
2011-04-19 04:19:37 +00:00
|
|
|
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);
|
2018-04-30 16:49:04 +00:00
|
|
|
// Get the next file index in case we have multiple file entries
|
|
|
|
|
// for the same file
|
2011-09-23 00:54:11 +00:00
|
|
|
file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1,
|
|
|
|
|
m_file_spec, false);
|
2011-04-19 04:19:37 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Match a specific line in a file...
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-04-19 04:19:37 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-04-19 04:19:37 +00:00
|
|
|
return Searcher::eCallbackReturnContinue;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-07 18:43:04 +00:00
|
|
|
lldb::SearchDepth FileLineResolver::GetDepth() {
|
|
|
|
|
return lldb::eSearchDepthCompUnit;
|
2011-04-19 04:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileLineResolver::GetDescription(Stream *s) {
|
2013-04-29 17:25:54 +00:00
|
|
|
s->Printf("File and line resolver for file: \"%s\" line: %u",
|
|
|
|
|
m_file_spec.GetPath().c_str(), m_line_number);
|
2011-04-19 04:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|