llvm-project/clang/test/Modules/ModuleDebugInfoDwoId.cpp
Raphael Isemann 105151ca56 Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
The orignal patch with the missing 'REQUIRES: asserts' as there is a debug-only
flag used in the test.

Original summary:

D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5
uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations
that creates the dwoID in the module from the ASTFileSignature
(`Buffer->Signature` being the array subclass that is now `std::array<uint8_t,
20>` instead of `std::array<uint32_t, 5>`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
```

This code works with the old ASTFileSignature (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the
ASTFileSignature and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module
no longer match (which in turns causes that LLDB keeps warning about the dwoID's
not matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an
uint64_t which makes the dwoID match again (and should prevent issues like that
in the future).

Reviewed By: aprantl, dang

Differential Revision: https://reviews.llvm.org/D84013
2020-08-24 14:52:53 +02:00

23 lines
980 B
C++

// Tests that dwoIds in modules match the dwoIDs in the main file.
// REQUIRES: asserts
// RUN: rm -rf %t.cache
// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 2> %t.mod-out
// RUN: cat %t.ll %t.mod-out | FileCheck %s
// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s
@import DebugDwoId;
Dummy d;
// Find the emitted dwoID for DebugInfoId and compare it against the one in the PCM.
// CHECK: DebugDwoId-{{[A-Z0-9]+}}.pcm
// CHECK-SAME: dwoId: [[DWOID:[0-9]+]]
// CHECK: dwoId: [[DWOID]]
// CHECK-NEXT: !DIFile(filename: "DebugDwoId"
// Make sure the dwo IDs are real IDs and not fallback values (~1ULL).
// CHECK-REALIDS-NOT: dwoId: 18446744073709551615