OSDN Git Service

[llvm-dwarfdump] --gdb-index: fix uninitialized TuListOffset
authorFangrui Song <maskray@google.com>
Wed, 19 Jun 2019 13:51:29 +0000 (13:51 +0000)
committerFangrui Song <maskray@google.com>
Wed, 19 Jun 2019 13:51:29 +0000 (13:51 +0000)
The test only checks the existence of the `Types CU list` line.
Unfortunately I can't make a better test because
{gcc,clang} -fuse-ld={lld,gold} --gdb-index do not give me a non-empty types CU list.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D63537

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363800 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
test/DebugInfo/dwarfdump-dump-gdbindex.test

index 6b5357f..f5f9755 100644 (file)
@@ -120,7 +120,7 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) {
     return false;
 
   CuListOffset = Data.getU32(&Offset);
-  uint32_t CuTypesOffset = Data.getU32(&Offset);
+  TuListOffset = Data.getU32(&Offset);
   AddressAreaOffset = Data.getU32(&Offset);
   SymbolTableOffset = Data.getU32(&Offset);
   ConstantPoolOffset = Data.getU32(&Offset);
@@ -128,7 +128,7 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) {
   if (Offset != CuListOffset)
     return false;
 
-  uint32_t CuListSize = (CuTypesOffset - CuListOffset) / 16;
+  uint32_t CuListSize = (TuListOffset - CuListOffset) / 16;
   CuList.reserve(CuListSize);
   for (uint32_t i = 0; i < CuListSize; ++i) {
     uint64_t CuOffset = Data.getU64(&Offset);
@@ -138,7 +138,7 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) {
 
   // CU Types are no longer needed as DWARF skeleton type units never made it
   // into the standard.
-  uint32_t TuListSize = (AddressAreaOffset - CuTypesOffset) / 24;
+  uint32_t TuListSize = (AddressAreaOffset - TuListOffset) / 24;
   TuList.resize(TuListSize);
   for (uint32_t I = 0; I < TuListSize; ++I) {
     uint64_t CuOffset = Data.getU64(&Offset);
index 2ff13eb..d81f490 100644 (file)
@@ -17,6 +17,8 @@ RUN: llvm-dwarfdump -gdb-index %p/Inputs/dwarfdump-gdbindex-v7.elf-x86-64 | File
 ; CHECK-NEXT:   0: Offset = 0x0, Length = 0x34
 ; CHECK-NEXT:   1: Offset = 0x34, Length = 0x34
 
+; CHECK:      Types CU list offset = 0x38, has 0 entries:
+
 ; CHECK:      Address area offset = 0x38, has 2 entries:
 ; CHECK-NEXT:   Low/High address = [0x4000e8, 0x4000f3) (Size: 0xb), CU id = 0
 ; CHECK-NEXT:   Low/High address = [0x4000f3, 0x4000fe) (Size: 0xb), CU id = 1