llvm-project/lldb/source/Core/FileLineResolver.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.9 KiB
C++
Raw Normal View History

//===-- 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"
<rdar://problem/11757916> Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes: - Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". - modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly - Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was. - modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile() Cleaned up header includes a bit as well. llvm-svn: 162860
2012-08-30 05:13:06 +08:00
#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;
}