[lldb][NFC] Fix all formatting errors in .cpp file headers
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
2020-01-24 15:23:27 +08:00
|
|
|
//===-- SymbolVendor.cpp --------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08: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
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
|
|
|
|
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Core/PluginManager.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"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// FindPlugin
|
|
|
|
//
|
2018-05-01 00:49:04 +08:00
|
|
|
// Platforms can register a callback to use when creating symbol vendors to
|
|
|
|
// allow for complex debug information file setups, and to also allow for
|
|
|
|
// finding separate debug information files.
|
2012-12-14 10:15:00 +08:00
|
|
|
SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
|
|
|
|
lldb_private::Stream *feedback_strm) {
|
2019-02-13 14:25:41 +08:00
|
|
|
std::unique_ptr<SymbolVendor> instance_up;
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendorCreateInstance create_callback;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-04-20 21:17:36 +08:00
|
|
|
for (size_t idx = 0;
|
|
|
|
(create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(
|
|
|
|
idx)) != nullptr;
|
|
|
|
++idx) {
|
2019-02-13 14:25:41 +08:00
|
|
|
instance_up.reset(create_callback(module_sp, feedback_strm));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (instance_up) {
|
|
|
|
return instance_up.release();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2018-05-01 00:49:04 +08:00
|
|
|
// The default implementation just tries to create debug information using
|
|
|
|
// the file representation for the module.
|
2019-01-17 23:07:35 +08:00
|
|
|
ObjectFileSP sym_objfile_sp;
|
|
|
|
FileSpec sym_spec = module_sp->GetSymbolFileFileSpec();
|
|
|
|
if (sym_spec && sym_spec != module_sp->GetObjectFile()->GetFileSpec()) {
|
|
|
|
DataBufferSP data_sp;
|
|
|
|
offset_t data_offset = 0;
|
|
|
|
sym_objfile_sp = ObjectFile::FindPlugin(
|
|
|
|
module_sp, &sym_spec, 0, FileSystem::Instance().GetByteSize(sym_spec),
|
|
|
|
data_sp, data_offset);
|
2019-01-17 00:09:13 +08:00
|
|
|
}
|
2019-01-17 23:07:35 +08:00
|
|
|
if (!sym_objfile_sp)
|
|
|
|
sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();
|
2020-06-25 08:44:33 +08:00
|
|
|
instance_up = std::make_unique<SymbolVendor>(module_sp);
|
2019-02-13 14:25:41 +08:00
|
|
|
instance_up->AddSymbolFileRepresentation(sym_objfile_sp);
|
|
|
|
return instance_up.release();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// SymbolVendor constructor
|
2012-02-24 09:59:29 +08:00
|
|
|
SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)
|
2019-07-26 15:03:28 +08:00
|
|
|
: ModuleChild(module_sp), m_sym_file_up() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-07-22 08:16:02 +08:00
|
|
|
// Add a representation given an object file.
|
2011-12-06 09:07:22 +08:00
|
|
|
void SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp) {
|
2012-03-14 07:14:29 +08:00
|
|
|
ModuleSP module_sp(GetModule());
|
|
|
|
if (module_sp) {
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
|
2019-07-31 16:25:25 +08:00
|
|
|
if (objfile_sp)
|
|
|
|
m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|