[Lldb-commits] [lldb] r358500 - Breakpad: Match the new UUID algorithm in minidumps

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 16 07:51:47 PDT 2019


Author: labath
Date: Tue Apr 16 07:51:47 2019
New Revision: 358500

URL: http://llvm.org/viewvc/llvm-project?rev=358500&view=rev
Log:
Breakpad: Match the new UUID algorithm in minidumps

D59433 and D60501 changed the way UUIDs are computed from minidump
files. This was done to synchronize the U(G)UID representation with the
native tools of given platforms, but it created a mismatch between
minidumps and breakpad files.

This updates the breakpad algorithm to match the one found in minidumps,
and also adds a couple of tests which should fail if these two ever get
out of sync. Incidentally, this means that the module id in the breakpad
files is almost identical to our notion of UUIDs, so the computation
algorithm can be somewhat simplified.

Added:
    lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.syms
    lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.yaml
    lldb/trunk/lit/Modules/Breakpad/uuid-matching-mac.test
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms
Modified:
    lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
    lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
    lldb/trunk/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.syms
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.syms?rev=358500&view=auto
==============================================================================
--- lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.syms Tue Apr 16 07:51:47 2019
@@ -0,0 +1,2 @@
+MODULE mac x86_64 A0AB76409C3B3A279E521045D84FA2DC0 a.out
+FUNC f90 1b 0 main

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.yaml?rev=358500&view=auto
==============================================================================
--- lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.yaml (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/uuid-matching-mac.yaml Tue Apr 16 07:51:47 2019
@@ -0,0 +1,59 @@
+--- !mach-o
+FileHeader:      
+  magic:           0xFEEDFACF
+  cputype:         0x01000007
+  cpusubtype:      0x80000003
+  filetype:        0x00000002
+  ncmds:           14
+  sizeofcmds:      744
+  flags:           0x00200085
+  reserved:        0x00000000
+LoadCommands:    
+  - cmd:             LC_SEGMENT_64
+    cmdsize:         72
+    segname:         __PAGEZERO
+    vmaddr:          0
+    vmsize:          4294967296
+    fileoff:         0
+    filesize:        0
+    maxprot:         0
+    initprot:        0
+    nsects:          0
+    flags:           0
+  - cmd:             LC_SEGMENT_64
+    cmdsize:         232
+    segname:         __TEXT
+    vmaddr:          4294967296
+    vmsize:          4096
+    fileoff:         0
+    filesize:        4096
+    maxprot:         7
+    initprot:        5
+    nsects:          2
+    flags:           0
+    Sections:        
+      - sectname:        __text
+        segname:         __TEXT
+        addr:            0x0000000100000F90
+        size:            27
+        offset:          0x00000F90
+        align:           4
+        reloff:          0x00000000
+        nreloc:          0
+        flags:           0x80000400
+        reserved1:       0x00000000
+        reserved2:       0x00000000
+        reserved3:       0x00000000
+  - cmd:             LC_UUID
+    cmdsize:         24
+    uuid:            A0AB7640-9C3B-3A27-9E52-1045D84FA2DC
+  - cmd:             LC_BUILD_VERSION
+    cmdsize:         32
+    platform:        1
+    minos:           658944
+    sdk:             658944
+    ntools:          1
+    Tools:           
+      - tool:            3
+        version:         29491968
+...

Modified: lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test?rev=358500&r1=358499&r2=358500&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test (original)
+++ lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test Tue Apr 16 07:51:47 2019
@@ -15,7 +15,7 @@ LINUX: Strata: user
 
 MAC: Plugin name: breakpad
 MAC: Architecture: x86_64--macosx
-MAC: UUID: 680E8CD9-8920-1BAA-EACD-6A8C1F16707B
+MAC: UUID: D98C0E68-2089-AA1B-EACD-6A8C1F16707B
 MAC: Executable: false
 MAC: Stripped: false
 MAC: Type: debug info
@@ -23,7 +23,7 @@ MAC: Strata: user
 
 WINDOWS: Plugin name: breakpad
 WINDOWS: Architecture: i386--windows
-WINDOWS: UUID: 5716C9A0-B580-0949-81A1-925EA62165C0-01000000
+WINDOWS: UUID: A0C91657-80B5-4909-81A1-925EA62165C0-00000001
 WINDOWS: Executable: false
 WINDOWS: Stripped: false
 WINDOWS: Type: debug info

Added: lldb/trunk/lit/Modules/Breakpad/uuid-matching-mac.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/uuid-matching-mac.test?rev=358500&view=auto
==============================================================================
--- lldb/trunk/lit/Modules/Breakpad/uuid-matching-mac.test (added)
+++ lldb/trunk/lit/Modules/Breakpad/uuid-matching-mac.test Tue Apr 16 07:51:47 2019
@@ -0,0 +1,13 @@
+# RUN: yaml2obj %S/Inputs/uuid-matching-mac.yaml -o %T/uuid-matching-mac.out
+# RUN: cd %S
+# RUN: %lldb %T/uuid-matching-mac.out -s %s -o exit | FileCheck %s
+
+target symbols add Inputs/uuid-matching-mac.syms
+# CHECK-LABEL: target symbols add
+# CHECK: symbol file '{{.*}}uuid-matching-mac.syms' has been added to '{{.*}}uuid-matching-mac.out'
+
+image lookup -n main
+# CHECK-LABEL: image lookup
+# CHECK: Address: uuid-matching-mac.out[0x0000000100000f90]
+
+

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py?rev=358500&r1=358499&r2=358500&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py Tue Apr 16 07:51:47 2019
@@ -80,6 +80,16 @@ class MiniDumpTestCase(TestBase):
             self.assertEqual(module.file.fullpath, expected['filename'])
             self.assertEqual(module.GetUUIDString(), expected['uuid'])
 
+    def test_breakpad_uuid_matching(self):
+        """Test that the uuid computation algorithms in minidump and breakpad
+        files match."""
+        self.target = self.dbg.CreateTarget("")
+        self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp")
+        self.assertTrue(self.process, PROCESS_IS_VALID)
+        self.expect("target symbols add fizzbuzz.syms", substrs=["symbol file",
+            "fizzbuzz.syms", "has been added to", "fizzbuzz.exe"]),
+        self.assertTrue(self.target.modules[0].FindSymbol("main"))
+
     def test_stack_info_in_mini_dump(self):
         """Test that we can see a trivial stack in a VS-generate mini dump."""
         # target create -c fizzbuzz_no_heap.dmp

Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms?rev=358500&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.syms Tue Apr 16 07:51:47 2019
@@ -0,0 +1,2 @@
+MODULE windows x86 0F45B7919A9646F9BF8F2D6076EA421A11 fizzbuzz.pdb
+PUBLIC 1000 0 main

Modified: lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp?rev=358500&r1=358499&r2=358500&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp Tue Apr 16 07:51:47 2019
@@ -76,26 +76,11 @@ template <typename T> static constexpr s
   return 2 * sizeof(T);
 }
 
-/// Consume the right number of digits from the input StringRef and convert it
-/// to the endian-specific integer N. Return true on success.
-template <typename T> static bool consume_hex_integer(llvm::StringRef &str, T &N) {
-  llvm::StringRef chunk = str.take_front(hex_digits<T>());
-  uintmax_t t;
-  if (!to_integer(chunk, t, 16))
-    return false;
-  N = t;
-  str = str.drop_front(hex_digits<T>());
-  return true;
-}
-
 static UUID parseModuleId(llvm::Triple::OSType os, llvm::StringRef str) {
   struct data_t {
-    struct uuid_t {
-      llvm::support::ulittle32_t part1;
-      llvm::support::ulittle16_t part2[2];
-      uint8_t part3[8];
-    } uuid;
-    llvm::support::ulittle32_t age;
+    using uuid_t = uint8_t[16];
+    uuid_t uuid;
+    llvm::support::ubig32_t age;
   } data;
   static_assert(sizeof(data) == 20, "");
   // The textual module id encoding should be between 33 and 40 bytes long,
@@ -105,19 +90,17 @@ static UUID parseModuleId(llvm::Triple::
   if (str.size() <= hex_digits<data_t::uuid_t>() ||
       str.size() > hex_digits<data_t>())
     return UUID();
-  if (!consume_hex_integer(str, data.uuid.part1))
+  if (!all_of(str, llvm::isHexDigit))
     return UUID();
-  for (auto &t : data.uuid.part2) {
-    if (!consume_hex_integer(str, t))
-      return UUID();
-  }
-  for (auto &t : data.uuid.part3) {
-    if (!consume_hex_integer(str, t))
-      return UUID();
-  }
+
+  llvm::StringRef uuid_str = str.take_front(hex_digits<data_t::uuid_t>());
+  llvm::StringRef age_str = str.drop_front(hex_digits<data_t::uuid_t>());
+
+  llvm::copy(fromHex(uuid_str), data.uuid);
   uint32_t age;
-  if (!to_integer(str, age, 16))
-    return UUID();
+  bool success = to_integer(age_str, age, 16);
+  assert(success);
+  (void)success;
   data.age = age;
 
   // On non-windows, the age field should always be zero, so we don't include to

Modified: lldb/trunk/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp?rev=358500&r1=358499&r2=358500&view=diff
==============================================================================
--- lldb/trunk/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp (original)
+++ lldb/trunk/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp Tue Apr 16 07:51:47 2019
@@ -36,7 +36,7 @@ TEST(ModuleRecord, parse) {
   EXPECT_EQ(ModuleRecord(llvm::Triple::Linux, llvm::Triple::x86_64,
                          UUID::fromData("@ABCDEFGHIJKLMNO", 16)),
             ModuleRecord::parse(
-                "MODULE Linux x86_64 434241404544474648494a4b4c4d4e4f0 a.out"));
+                "MODULE Linux x86_64 404142434445464748494a4b4c4d4e4f0 a.out"));
 
   EXPECT_EQ(llvm::None, ModuleRecord::parse("MODULE"));
   EXPECT_EQ(llvm::None, ModuleRecord::parse("MODULE Linux"));




More information about the lldb-commits mailing list