Skip to content

Commit

Permalink
[llvm-debuginfod] Switch to xxh3_64bits
Browse files Browse the repository at this point in the history
Many sources show that xxh3 is much better than xxh64. This particular
instance may or may not have noticeable difference, but this change
moves us toward removing xxHash64.

This change will invalid cache.

Reviewed By: mysterymath

Differential Revision: https://reviews.llvm.org/D155993
  • Loading branch information
MaskRay committed Aug 11, 2023
1 parent a52c6a8 commit 099f4e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion llvm/lib/Debuginfod/Debuginfod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ namespace llvm {

using llvm::object::BuildIDRef;

static std::string uniqueKey(llvm::StringRef S) { return utostr(xxHash64(S)); }
static std::string uniqueKey(llvm::StringRef S) {
return utostr(xxh3_64bits(S));
}

// Returns a binary BuildID as a normalized hex string.
// Uses lowercase for compatibility with common debuginfod servers.
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-debuginfod-find/cache.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ RUN: DEBUGINFOD_CACHE_PATH=%t/cache DEBUGINFOD_URLS=file://%t \
RUN: llvm-debuginfod-find --debuginfo 0123456789012346 > /dev/null
RUN: ls %t/cache | FileCheck --check-prefix=BOTH --match-full-lines --implicit-check-not {{.}} %s

FIRST: llvmcache-6663022027345102449
FIRST: llvmcache-10846399329613630737
FIRST: llvmcache.timestamp

SECOND: llvmcache-6762748755046480574
SECOND: llvmcache-10192351353398627645
SECOND: llvmcache.timestamp

BOTH: llvmcache-6663022027345102449
BOTH: llvmcache-6762748755046480574
BOTH: llvmcache-10192351353398627645
BOTH: llvmcache-10846399329613630737
BOTH: llvmcache.timestamp
16 changes: 8 additions & 8 deletions llvm/test/tools/llvm-objdump/debuginfod.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ RUN: FileCheck %s --check-prefix=NOTFOUND

# Use cp to write the debug binary to an appropriately-named file in the llvm
# debuginfod cache.
RUN: cp %p/Inputs/embedded-source %t/llvmcache-7361776989772977641
RUN: cp %p/Inputs/embedded-source %t/llvmcache-17908201640401622315

# Write a broken "binary" under %t/broken.
RUN: mkdir %t/broken
RUN: echo "bad" > %t/broken/llvmcache-7361776989772977641
RUN: echo "bad" > %t/broken/llvmcache-17908201640401622315

# Write the stripped binary under %t/stripped-cache.
RUN: mkdir %t/stripped-cache
RUN: cp %t/stripped %t/stripped-cache/llvmcache-7361776989772977641
RUN: cp %t/stripped %t/stripped-cache/llvmcache-17908201640401622315

# Write to a debug info directory as well.
RUN: mkdir -p %t/debug/.build-id/15
Expand Down Expand Up @@ -53,7 +53,7 @@ RUN: env DEBUGINFOD_CACHE_PATH=%t/broken llvm-objdump -d --source --debuginfod \
RUN: %t/stripped 2> %t.err | \
RUN: FileCheck %s --check-prefix=NOTFOUND
RUN: FileCheck %s --check-prefix=BADBINARYERROR -DPATH=%t --input-file %t.err
BADBINARYERROR: warning: '[[PATH]]/broken{{[/\\]}}llvmcache-7361776989772977641': The file was not recognized as a valid object file
BADBINARYERROR: warning: '[[PATH]]/broken{{[/\\]}}llvmcache-17908201640401622315': The file was not recognized as a valid object file

# Use the original binary if the fetched binary has no debug info.
RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-cache llvm-objdump -d --source \
Expand Down Expand Up @@ -86,17 +86,17 @@ RUN: FileCheck %s --check-prefix=SYMBOLS

# Use debuginfod to recover section headers, but not symbols.
RUN: mkdir %t/stripped-symbols
RUN: cp %p/Inputs/embedded-source %t/stripped-symbols/llvmcache-7361776989772977641
RUN: llvm-strip %t/stripped-symbols/llvmcache-7361776989772977641
RUN: cp %p/Inputs/embedded-source %t/stripped-symbols/llvmcache-17908201640401622315
RUN: llvm-strip %t/stripped-symbols/llvmcache-17908201640401622315
RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-symbols llvm-objdump -d \
RUN: --debuginfod %t/stripped | \
RUN: FileCheck %s --check-prefix=SECTIONS

# Don't use debuginfod if neither section headers nor symbols can be recovered.
RUN: mkdir %t/stripped-sections
RUN: echo "" | llvm-mc -filetype=obj -triple x86_64 > \
RUN: %t/stripped-sections/llvmcache-7361776989772977641
RUN: llvm-strip --strip-sections %t/stripped-sections/llvmcache-7361776989772977641
RUN: %t/stripped-sections/llvmcache-17908201640401622315
RUN: llvm-strip --strip-sections %t/stripped-sections/llvmcache-17908201640401622315
RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-sections llvm-objdump -d \
RUN: --debuginfod %t/stripped | \
RUN: FileCheck %s --check-prefix=NOSECTIONS
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-symbolizer/debuginfod.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ NOTFOUND-NEXT: ??:0:0
# Use llvm-objcopy to write the debuginfo of the addr.exe binary to an
# appropriately-named file in the llvm debuginfod cache. The filename is
# determined by the debuginfod client's caching scheme, so it is manually
# specified here as llvmcache-98...19
# specified here as llvmcache-\d+
RUN: llvm-objcopy --keep-section=.debug_info %p/Inputs/addr.exe \
RUN: %t/llvmcache-9800707741016212219
RUN: %t/llvmcache-1165050469834211050

# The symbolizer should call the debuginfod client library, which finds the
# debuginfo placed in the cache, enabling symbolization of the address.
Expand Down

0 comments on commit 099f4e2

Please sign in to comment.