Skip to content

Commit bb6b1b2

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b9496a74eb40' from llvm.org/main into next
2 parents 1762012 + b9496a7 commit bb6b1b2

File tree

13 files changed

+545
-22
lines changed

13 files changed

+545
-22
lines changed

lldb/include/lldb/Host/Config.h.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
#cmakedefine01 LLDB_ENABLE_LZMA
3535

36+
#cmakedefine01 LLVM_ENABLE_CURL
37+
3638
#cmakedefine01 LLDB_ENABLE_CURSES
3739

3840
#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,10 @@ def _get_bool_config_skip_if_decorator(key):
11261126
return unittest.skipIf(not have, "requires " + key)
11271127

11281128

1129+
def skipIfCurlSupportMissing(func):
1130+
return _get_bool_config_skip_if_decorator("curl")(func)
1131+
1132+
11291133
def skipIfCursesSupportMissing(func):
11301134
return _get_bool_config_skip_if_decorator("curses")(func)
11311135

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
5151
#
5252
# GNUWin32 uname gives "windows32" or "server version windows32" while
5353
# some versions of MSYS uname return "MSYS_NT*", but most environments
54-
# standardize on "Windows_NT", so we'll make it consistent here.
54+
# standardize on "Windows_NT", so we'll make it consistent here.
5555
# When running tests from Visual Studio, the environment variable isn't
5656
# inherited all the way down to the process spawned for make.
5757
#----------------------------------------------------------------------
@@ -221,6 +221,12 @@ else
221221
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
222222
DSYM = $(EXE).debug
223223
endif
224+
225+
ifeq "$(MAKE_DWP)" "YES"
226+
MAKE_DWO := YES
227+
DWP_NAME = $(EXE).dwp
228+
DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
229+
endif
224230
endif
225231

226232
LIMIT_DEBUG_INFO_FLAGS =
@@ -371,6 +377,17 @@ ifneq "$(OS)" "Darwin"
371377

372378
OBJCOPY ?= $(call replace_cc_with,objcopy)
373379
ARCHIVER ?= $(call replace_cc_with,ar)
380+
# Look for llvm-dwp or gnu dwp
381+
DWP ?= $(call replace_cc_with,llvm-dwp)
382+
ifeq ($(wildcard $(DWP)),)
383+
DWP = $(call replace_cc_with,dwp)
384+
ifeq ($(wildcard $(DWP)),)
385+
DWP = $(shell command -v llvm-dwp 2> /dev/null)
386+
ifeq ($(wildcard $(DWP)),)
387+
DWP = $(shell command -v dwp 2> /dev/null)
388+
endif
389+
endif
390+
endif
374391
override AR = $(ARCHIVER)
375392
endif
376393

@@ -541,6 +558,10 @@ ifneq "$(CXX)" ""
541558
endif
542559
endif
543560

561+
ifeq "$(GEN_GNU_BUILD_ID)" "YES"
562+
LDFLAGS += -Wl,--build-id
563+
endif
564+
544565
#----------------------------------------------------------------------
545566
# DYLIB_ONLY variable can be used to skip the building of a.out.
546567
# See the sections below regarding dSYM file as well as the building of
@@ -584,11 +605,18 @@ else
584605
endif
585606
else
586607
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
608+
ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
609+
cp "$(EXE)" "$(EXE).unstripped"
610+
endif
587611
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
588612
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
589613
endif
614+
ifeq "$(MAKE_DWP)" "YES"
615+
$(DWP) -o "$(DWP_NAME)" $(DWOS)
616+
endif
590617
endif
591618

619+
592620
ifneq "$(USESWIFTDRIVER)" "1"
593621
#----------------------------------------------------------------------
594622
# Make the dylib
@@ -630,9 +658,15 @@ endif
630658
else
631659
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
632660
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
661+
ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
662+
cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).unstripped"
663+
endif
633664
$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
634665
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
635666
endif
667+
ifeq "$(MAKE_DWP)" "YES"
668+
$(DWP) -o $(DYLIB_DWP_FILE) $(DYLIB_DWOS)
669+
endif
636670
endif
637671

638672
#----------------------------------------------------------------------

lldb/source/API/SBDebugger.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,9 @@ SBStructuredData SBDebugger::GetBuildConfiguration() {
775775
AddBoolConfigEntry(
776776
*config_up, "xml", XMLDocument::XMLEnabled(),
777777
"A boolean value that indicates if XML support is enabled in LLDB");
778+
AddBoolConfigEntry(
779+
*config_up, "curl", LLVM_ENABLE_CURL,
780+
"A boolean value that indicates if CURL support is enabled in LLDB");
778781
AddBoolConfigEntry(
779782
*config_up, "curses", LLDB_ENABLE_CURSES,
780783
"A boolean value that indicates if curses support is enabled in LLDB");
@@ -1730,20 +1733,20 @@ SBDebugger::LoadTraceFromFile(SBError &error,
17301733

17311734
void SBDebugger::RequestInterrupt() {
17321735
LLDB_INSTRUMENT_VA(this);
1733-
1736+
17341737
if (m_opaque_sp)
1735-
m_opaque_sp->RequestInterrupt();
1738+
m_opaque_sp->RequestInterrupt();
17361739
}
17371740
void SBDebugger::CancelInterruptRequest() {
17381741
LLDB_INSTRUMENT_VA(this);
1739-
1742+
17401743
if (m_opaque_sp)
1741-
m_opaque_sp->CancelInterruptRequest();
1744+
m_opaque_sp->CancelInterruptRequest();
17421745
}
17431746

17441747
bool SBDebugger::InterruptRequested() {
17451748
LLDB_INSTRUMENT_VA(this);
1746-
1749+
17471750
if (m_opaque_sp)
17481751
return m_opaque_sp->InterruptRequested();
17491752
return false;

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4392,26 +4392,38 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
43924392
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
43934393
ModuleSpec module_spec;
43944394
module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
4395+
FileSpec dwp_filespec;
43954396
for (const auto &symfile : symfiles.files()) {
43964397
module_spec.GetSymbolFileSpec() =
43974398
FileSpec(symfile.GetPath() + ".dwp", symfile.GetPathStyle());
43984399
LLDB_LOG(log, "Searching for DWP using: \"{0}\"",
43994400
module_spec.GetSymbolFileSpec());
4400-
FileSpec dwp_filespec =
4401+
dwp_filespec =
44014402
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
44024403
if (FileSystem::Instance().Exists(dwp_filespec)) {
4403-
LLDB_LOG(log, "Found DWP file: \"{0}\"", dwp_filespec);
4404-
DataBufferSP dwp_file_data_sp;
4405-
lldb::offset_t dwp_file_data_offset = 0;
4406-
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
4407-
GetObjectFile()->GetModule(), &dwp_filespec, 0,
4408-
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
4409-
dwp_file_data_offset);
4410-
if (dwp_obj_file) {
4411-
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>(
4412-
*this, dwp_obj_file, DIERef::k_file_index_mask);
4413-
break;
4414-
}
4404+
break;
4405+
}
4406+
}
4407+
if (!FileSystem::Instance().Exists(dwp_filespec)) {
4408+
LLDB_LOG(log, "No DWP file found locally");
4409+
// Fill in the UUID for the module we're trying to match for, so we can
4410+
// find the correct DWP file, as the Debuginfod plugin uses *only* this
4411+
// data to correctly match the DWP file with the binary.
4412+
module_spec.GetUUID() = m_objfile_sp->GetUUID();
4413+
dwp_filespec =
4414+
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
4415+
}
4416+
if (FileSystem::Instance().Exists(dwp_filespec)) {
4417+
LLDB_LOG(log, "Found DWP file: \"{0}\"", dwp_filespec);
4418+
DataBufferSP dwp_file_data_sp;
4419+
lldb::offset_t dwp_file_data_offset = 0;
4420+
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
4421+
GetObjectFile()->GetModule(), &dwp_filespec, 0,
4422+
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
4423+
dwp_file_data_offset);
4424+
if (dwp_obj_file) {
4425+
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>(
4426+
*this, dwp_obj_file, DIERef::k_file_index_mask);
44154427
}
44164428
}
44174429
if (!m_dwp_symfile) {

lldb/source/Plugins/SymbolLocator/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
# Order matters here: the first symbol locator prevents further searching.
2+
# For DWARF binaries that are both stripped and split, the Default plugin
3+
# will return the stripped binary when asked for the ObjectFile, which then
4+
# prevents an unstripped binary from being requested from the Debuginfod
5+
# provider.
6+
add_subdirectory(Debuginfod)
17
add_subdirectory(Default)
28
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
39
add_subdirectory(DebugSymbols)
410
endif()
5-
add_subdirectory(Debuginfod)

lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ llvm::StringRef SymbolVendorELF::GetPluginDescriptionStatic() {
4444
"executables.";
4545
}
4646

47+
// If this is needed elsewhere, it can be exported/moved.
48+
static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp,
49+
const FileSpec &file_spec) {
50+
DataBufferSP dwp_file_data_sp;
51+
lldb::offset_t dwp_file_data_offset = 0;
52+
// Try to create an ObjectFile from the file_spec.
53+
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
54+
module_sp, &file_spec, 0, FileSystem::Instance().GetByteSize(file_spec),
55+
dwp_file_data_sp, dwp_file_data_offset);
56+
// The presence of a debug_cu_index section is the key identifying feature of
57+
// a DWP file. Make sure we don't fill in the section list on dwp_obj_file
58+
// (by calling GetSectionList(false)) as this function could be called before
59+
// we may have all the symbol files collected and available.
60+
return dwp_obj_file && ObjectFileELF::classof(dwp_obj_file.get()) &&
61+
dwp_obj_file->GetSectionList(false)->FindSectionByType(
62+
eSectionTypeDWARFDebugCuIndex, false);
63+
}
64+
4765
// CreateInstance
4866
//
4967
// Platforms can register a callback to use when creating symbol vendors to
@@ -87,8 +105,15 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
87105
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
88106
FileSpec dsym_fspec =
89107
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
90-
if (!dsym_fspec)
91-
return nullptr;
108+
if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) {
109+
// If we have a stripped binary or if we got a DWP file, we should prefer
110+
// symbols in the executable acquired through a plugin.
111+
ModuleSpec unstripped_spec =
112+
PluginManager::LocateExecutableObjectFile(module_spec);
113+
if (!unstripped_spec)
114+
return nullptr;
115+
dsym_fspec = unstripped_spec.GetFileSpec();
116+
}
92117

93118
DataBufferSP dsym_file_data_sp;
94119
lldb::offset_t dsym_file_data_offset = 0;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
C_SOURCES := main.c
2+
3+
# For normal (non DWP) Debuginfod tests, we need:
4+
5+
# * The full binary: a.out.unstripped
6+
# Produced by Makefile.rules with SAVE_FULL_DEBUG_BINARY set to YES and
7+
# SPLIT_DEBUG_SYMBOLS set to YES
8+
9+
# * The stripped binary (a.out)
10+
# Produced by Makefile.rules with SPLIT_DEBUG_SYMBOLS set to YES
11+
12+
# * The 'only-keep-debug' binary (a.out.debug)
13+
# Produced below
14+
15+
SPLIT_DEBUG_SYMBOLS := YES
16+
SAVE_FULL_DEBUG_BINARY := YES
17+
GEN_GNU_BUILD_ID := YES
18+
19+
include Makefile.rules

0 commit comments

Comments
 (0)