-
Notifications
You must be signed in to change notification settings - Fork 14.3k
DEBUGINFOD based DWP acquisition for LLDB #70996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
190fb15
DEBUGINFOD based DWP acquisition for LLDB
9189c39
All the non-contentious, obvious changes from PR feedback are in
kevinfrei 8c57dc0
Moved to a plugin model
kevinfrei a5e6900
Cleaned up leftovers from pre-plugin work
d1f5090
The server-urls property appears to be wired up correctly
a182654
Update llvm/lib/Debuginfod/Debuginfod.cpp
kevinfrei a69e6aa
Fixed memory ownership issues, and @clayborg's feedback
0b7b756
Fixed the autoformatting stuff
eeb93fa
Added a release note item for DEDBUGINFOD
54de13d
Added code to respect the symbols.enable-external-lookup setting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lldb/source/Plugins/SymbolLocator/Debuginfod/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
lldb_tablegen(SymbolLocatorDebuginfodProperties.inc -gen-lldb-property-defs | ||
SOURCE SymbolLocatorDebuginfodProperties.td | ||
TARGET LLDBPluginSymbolLocatorDebuginfodPropertiesGen) | ||
|
||
lldb_tablegen(SymbolLocatorDebuginfodPropertiesEnum.inc -gen-lldb-property-enum-defs | ||
SOURCE SymbolLocatorDebuginfodProperties.td | ||
TARGET LLDBPluginSymbolLocatorDebuginfodPropertiesEnumGen) | ||
|
||
add_lldb_library(lldbPluginSymbolLocatorDebuginfod PLUGIN | ||
SymbolLocatorDebuginfod.cpp | ||
|
||
LINK_LIBS | ||
lldbCore | ||
lldbHost | ||
lldbSymbol | ||
LLVMDebuginfod | ||
) | ||
|
||
add_dependencies(lldbPluginSymbolLocatorDebuginfod | ||
LLDBPluginSymbolLocatorDebuginfodPropertiesGen | ||
LLDBPluginSymbolLocatorDebuginfodPropertiesEnumGen) |
142 changes: 142 additions & 0 deletions
142
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
//===-- SymbolLocatorDebuginfod.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 "SymbolLocatorDebuginfod.h" | ||
|
||
#include "lldb/Core/PluginManager.h" | ||
#include "lldb/Utility/Args.h" | ||
|
||
#include "llvm/Debuginfod/Debuginfod.h" | ||
#include "llvm/Debuginfod/HTTPClient.h" | ||
|
||
using namespace lldb; | ||
using namespace lldb_private; | ||
|
||
LLDB_PLUGIN_DEFINE(SymbolLocatorDebuginfod) | ||
|
||
namespace { | ||
|
||
#define LLDB_PROPERTIES_symbollocatordebuginfod | ||
#include "SymbolLocatorDebuginfodProperties.inc" | ||
|
||
enum { | ||
#define LLDB_PROPERTIES_symbollocatordebuginfod | ||
#include "SymbolLocatorDebuginfodPropertiesEnum.inc" | ||
}; | ||
|
||
class PluginProperties : public Properties { | ||
public: | ||
static llvm::StringRef GetSettingName() { | ||
return SymbolLocatorDebuginfod::GetPluginNameStatic(); | ||
} | ||
|
||
PluginProperties() { | ||
m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName()); | ||
m_collection_sp->Initialize(g_symbollocatordebuginfod_properties); | ||
|
||
// We need to read the default value first to read the environment variable. | ||
llvm::SmallVector<llvm::StringRef> urls = llvm::getDefaultDebuginfodUrls(); | ||
Args arg_urls{urls}; | ||
m_collection_sp->SetPropertyAtIndexFromArgs(ePropertyServerURLs, arg_urls); | ||
|
||
m_collection_sp->SetValueChangedCallback( | ||
ePropertyServerURLs, [this] { ServerURLsChangedCallback(); }); | ||
} | ||
|
||
Args GetDebugInfoDURLs() const { | ||
Args urls; | ||
m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyServerURLs, urls); | ||
return urls; | ||
} | ||
|
||
private: | ||
void ServerURLsChangedCallback() { | ||
m_server_urls = GetDebugInfoDURLs(); | ||
llvm::SmallVector<llvm::StringRef> dbginfod_urls; | ||
llvm::for_each(m_server_urls, [&](const auto &obj) { | ||
dbginfod_urls.push_back(obj.ref()); | ||
}); | ||
llvm::setDefaultDebuginfodUrls(dbginfod_urls); | ||
} | ||
// Storage for the StringRef's used within the Debuginfod library. | ||
Args m_server_urls; | ||
}; | ||
|
||
} // namespace | ||
|
||
static PluginProperties &GetGlobalPluginProperties() { | ||
static PluginProperties g_settings; | ||
return g_settings; | ||
} | ||
|
||
SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {} | ||
|
||
void SymbolLocatorDebuginfod::Initialize() { | ||
static llvm::once_flag g_once_flag; | ||
|
||
llvm::call_once(g_once_flag, []() { | ||
PluginManager::RegisterPlugin( | ||
GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, | ||
LocateExecutableObjectFile, LocateExecutableSymbolFile, nullptr, | ||
nullptr, SymbolLocatorDebuginfod::DebuggerInitialize); | ||
llvm::HTTPClient::initialize(); | ||
}); | ||
} | ||
|
||
void SymbolLocatorDebuginfod::DebuggerInitialize(Debugger &debugger) { | ||
if (!PluginManager::GetSettingForSymbolLocatorPlugin( | ||
debugger, PluginProperties::GetSettingName())) { | ||
const bool is_global_setting = true; | ||
PluginManager::CreateSettingForSymbolLocatorPlugin( | ||
debugger, GetGlobalPluginProperties().GetValueProperties(), | ||
"Properties for the Debuginfod Symbol Locator plug-in.", | ||
is_global_setting); | ||
} | ||
} | ||
|
||
void SymbolLocatorDebuginfod::Terminate() { | ||
PluginManager::UnregisterPlugin(CreateInstance); | ||
llvm::HTTPClient::cleanup(); | ||
} | ||
|
||
llvm::StringRef SymbolLocatorDebuginfod::GetPluginDescriptionStatic() { | ||
return "Debuginfod symbol locator."; | ||
} | ||
|
||
SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() { | ||
return new SymbolLocatorDebuginfod(); | ||
} | ||
|
||
static std::optional<FileSpec> GetFileForModule( | ||
const ModuleSpec &module_spec, | ||
std::function<llvm::Expected<std::string>(llvm::object::BuildIDRef)> | ||
PullFromServer) { | ||
if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) | ||
return {}; | ||
const UUID &module_uuid = module_spec.GetUUID(); | ||
if (module_uuid.IsValid() && llvm::canUseDebuginfod()) { | ||
llvm::object::BuildID build_id(module_uuid.GetBytes()); | ||
llvm::Expected<std::string> result = PullFromServer(build_id); | ||
if (result) | ||
return FileSpec(*result); | ||
// An error here should be logged as a failure in the Debuginfod library, | ||
// so just consume it here | ||
consumeError(result.takeError()); | ||
} | ||
return {}; | ||
} | ||
|
||
std::optional<ModuleSpec> SymbolLocatorDebuginfod::LocateExecutableObjectFile( | ||
const ModuleSpec &module_spec) { | ||
return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable); | ||
} | ||
|
||
std::optional<FileSpec> SymbolLocatorDebuginfod::LocateExecutableSymbolFile( | ||
const ModuleSpec &module_spec, const FileSpecList &default_search_paths) { | ||
return GetFileForModule(module_spec, llvm::getCachedOrDownloadDebuginfo); | ||
} |
54 changes: 54 additions & 0 deletions
54
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//===-- SymbolLocatorDebuginfod.h -------------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLLOCATOR_DEBUGINFOD_SYMBOLLOCATORDEBUGINFOD_H | ||
#define LLDB_SOURCE_PLUGINS_SYMBOLLOCATOR_DEBUGINFOD_SYMBOLLOCATORDEBUGINFOD_H | ||
|
||
#include "lldb/Core/Debugger.h" | ||
#include "lldb/Symbol/SymbolLocator.h" | ||
#include "lldb/lldb-private.h" | ||
|
||
namespace lldb_private { | ||
|
||
class SymbolLocatorDebuginfod : public SymbolLocator { | ||
public: | ||
SymbolLocatorDebuginfod(); | ||
|
||
static void Initialize(); | ||
static void Terminate(); | ||
static void DebuggerInitialize(Debugger &debugger); | ||
|
||
static llvm::StringRef GetPluginNameStatic() { return "debuginfod"; } | ||
static llvm::StringRef GetPluginDescriptionStatic(); | ||
|
||
static lldb_private::SymbolLocator *CreateInstance(); | ||
|
||
/// PluginInterface protocol. | ||
/// \{ | ||
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } | ||
/// \} | ||
|
||
// Locate the executable file given a module specification. | ||
// | ||
// Locating the file should happen only on the local computer or using the | ||
// current computers global settings. | ||
static std::optional<ModuleSpec> | ||
LocateExecutableObjectFile(const ModuleSpec &module_spec); | ||
|
||
// Locate the symbol file given a module specification. | ||
// | ||
// Locating the file should happen only on the local computer or using the | ||
// current computers global settings. | ||
static std::optional<FileSpec> | ||
LocateExecutableSymbolFile(const ModuleSpec &module_spec, | ||
const FileSpecList &default_search_paths); | ||
}; | ||
|
||
} // namespace lldb_private | ||
|
||
#endif // LLDB_SOURCE_PLUGINS_SYMBOLLOCATOR_DEBUGINFOD_SYMBOLLOCATORDEBUGINFOD_H |
7 changes: 7 additions & 0 deletions
7
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include "../../../../include/lldb/Core/PropertiesBase.td" | ||
|
||
let Definition = "symbollocatordebuginfod" in { | ||
def ServerURLs : Property<"server_urls", "Array">, | ||
ElementType<"String">, | ||
Desc<"An ordered list of Debuginfod server URLs to query for symbols. This defaults to the contents of the DEBUGINFOD_URLS environment variable.">; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.