[Lldb-commits] [lldb] r247939 - Get the process ID from a minidump.

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 17 13:52:30 PDT 2015


Author: amccarth
Date: Thu Sep 17 15:52:29 2015
New Revision: 247939

URL: http://llvm.org/viewvc/llvm-project?rev=247939&view=rev
Log:
Get the process ID from a minidump.

Modified:
    lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
    lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
    lldb/trunk/test/functionalities/postmortem/minidump/TestMiniDump.py

Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=247939&r1=247938&r2=247939&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp Thu Sep 17 15:52:29 2015
@@ -164,6 +164,7 @@ ProcessWinMiniDump::DoLoadCore()
     }
 
     GetTarget().SetArchitecture(DetermineArchitecture());
+    ReadMiscInfo();  // notably for process ID
     ReadModuleList();
     ReadExceptionRecord();
 
@@ -433,7 +434,8 @@ ProcessWinMiniDump::DetermineArchitectur
 }
 
 void
-ProcessWinMiniDump::ReadExceptionRecord() {
+ProcessWinMiniDump::ReadExceptionRecord()
+{
     size_t size = 0;
     auto exception_stream_ptr = static_cast<MINIDUMP_EXCEPTION_STREAM*>(FindDumpStream(ExceptionStream, &size));
     if (exception_stream_ptr)
@@ -443,7 +445,23 @@ ProcessWinMiniDump::ReadExceptionRecord(
 }
 
 void
-ProcessWinMiniDump::ReadModuleList() {
+ProcessWinMiniDump::ReadMiscInfo()
+{
+    size_t size = 0;
+    const auto misc_info_ptr = static_cast<MINIDUMP_MISC_INFO*>(FindDumpStream(MiscInfoStream, &size));
+    if (!misc_info_ptr || size < sizeof(MINIDUMP_MISC_INFO)) {
+        return;
+    }
+
+    if ((misc_info_ptr->Flags1 & MINIDUMP_MISC1_PROCESS_ID) != 0) {
+        // This misc info record has the process ID.
+        SetID(misc_info_ptr->ProcessId);
+    }
+}
+
+void
+ProcessWinMiniDump::ReadModuleList()
+{
     size_t size = 0;
     auto module_list_ptr = static_cast<MINIDUMP_MODULE_LIST*>(FindDumpStream(ModuleListStream, &size));
     if (!module_list_ptr || module_list_ptr->NumberOfModules == 0)

Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h?rev=247939&r1=247938&r2=247939&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h Thu Sep 17 15:52:29 2015
@@ -117,6 +117,9 @@ private:
     ReadExceptionRecord();
 
     void
+    ReadMiscInfo();
+
+    void
     ReadModuleList();
 
     // A thin wrapper around WinAPI's MiniDumpReadDumpStream to avoid redundant

Modified: lldb/trunk/test/functionalities/postmortem/minidump/TestMiniDump.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/postmortem/minidump/TestMiniDump.py?rev=247939&r1=247938&r2=247939&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/postmortem/minidump/TestMiniDump.py (original)
+++ lldb/trunk/test/functionalities/postmortem/minidump/TestMiniDump.py Thu Sep 17 15:52:29 2015
@@ -16,7 +16,7 @@ class MiniDumpTestCase(TestBase):
         """Test that lldb can read the process information from the minidump."""
         self.assertTrue(self.process, PROCESS_IS_VALID)
         self.assertEqual(self.process.GetNumThreads(), 1)
-        # TODO(amccarth):  Check the process ID.
+        self.assertEqual(self.process.GetProcessID(), 4440)
 
     def test_thread_info_in_mini_dump(self):
         """Test that lldb can read the thread information from the minidump."""




More information about the lldb-commits mailing list