harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r523601 - in /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows: hysignal.c hysignal.h
Date Thu, 29 Mar 2007 07:27:59 GMT
Author: apetrenko
Date: Thu Mar 29 00:27:58 2007
New Revision: 523601

URL: http://svn.apache.org/viewvc?view=rev&rev=523601
Log:
Patch for HARMONY-3124 "[classlib][launcher] Generation of minidumps files on crash"

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.c
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.h

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.c?view=diff&rev=523601&r1=523600&r2=523601
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.c
Thu Mar 29 00:27:58 2007
@@ -23,6 +23,8 @@
 #endif /* HY_NO_THR */
 #include "hythread.h"
 #include "hysignal.h"
+#include <stdio.h>
+#include <DbgHelp.h>
 
 typedef struct HyWin32AsyncHandlerRecord
 {
@@ -319,6 +321,54 @@
 }
 
 #undef CDEV_CURRENT_FUNCTION
+static void
+genMiniDumpFile (EXCEPTION_POINTERS * exceptionInfo, char* dumpInfo)
+{
+  typedef BOOL (WINAPI * MINIDUMPPROC)(HANDLE /*hProcess*/, DWORD /*ProcessId*/,
+    HANDLE /*hFile*/, MINIDUMP_TYPE /*DumpType*/, PMINIDUMP_EXCEPTION_INFORMATION /*ExceptionParam*/,
+    PMINIDUMP_USER_STREAM_INFORMATION /*UserStreamParam*/, PMINIDUMP_CALLBACK_INFORMATION
/*CallbackParam*/);
+  MINIDUMPPROC _MiniDumpWriteDump = NULL;
+  HANDLE dmpFile = 0;
+  DWORD uv = 0;
+  char dumpFileName[64] = {0};
+  HMODULE dbghLib = NULL;
+  BOOL res = FALSE;
+	MINIDUMP_EXCEPTION_INFORMATION mei;
+
+  dbghLib = LoadLibrary( "DBGHELP.DLL");
+  if (!dbghLib){
+    sprintf(dumpInfo, "Failed to load DbgHelp library.");
+    return;
+  }
+  _MiniDumpWriteDump = (MINIDUMPPROC)GetProcAddress(dbghLib, "MiniDumpWriteDump");
+  if (!_MiniDumpWriteDump){
+    sprintf(dumpInfo, "Failed to load DbgHelp library.");
+    return;
+  }
+
+  uv = GetTickCount();
+  sprintf(dumpFileName, "hydump_%d.dmp", uv);
+  dmpFile = CreateFile(dumpFileName, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
0);
+  if (dmpFile == INVALID_HANDLE_VALUE){
+    sprintf(dumpInfo, "Failed to create dump file: .%s", dumpFileName);
+    return;
+  }
+
+	mei.ThreadId = GetCurrentThreadId();
+	mei.ExceptionPointers = exceptionInfo;
+	mei.ClientPointers = TRUE;
+
+	res = _MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), dmpFile, MiniDumpNormal,
&mei, 0, 0 );
+  if (!res){
+    sprintf(dumpInfo, "Failed generate dump file.");
+  }
+  else{
+    char dir[_MAX_PATH] = {0};
+    GetCurrentDirectory( _MAX_PATH, dir);
+    sprintf(dumpInfo, "%s\\%s", dir, dumpFileName);
+  }
+	CloseHandle(dmpFile);
+}
 
 #define CDEV_CURRENT_FUNCTION structuredExceptionHandler
 int
@@ -433,7 +483,7 @@
   hyinfo->handlerAddress2 = (void *) structuredExceptionHandler;
   hyinfo->ExceptionRecord = exceptionInfo->ExceptionRecord;
   hyinfo->ContextRecord = exceptionInfo->ContextRecord;
-
+  genMiniDumpFile(exceptionInfo, hyinfo->dumpInfo);
   /* module info is filled on demand */
 }
 
@@ -668,6 +718,10 @@
       *name = "Offset_in_DLL";
       *value = &info->offsetInDLL;
       return HYPORT_SIG_VALUE_32;
+    case 3:
+      *name = "Dumpfile";
+      *value = &info->dumpInfo;
+      return HYPORT_SIG_VALUE_STRING;
     default:
       return HYPORT_SIG_VALUE_UNDEFINED;
     }

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.h?view=diff&rev=523601&r1=523600&r2=523601
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.h
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysignal.h
Thu Mar 29 00:27:58 2007
@@ -30,6 +30,7 @@
   void *moduleBaseAddress;
   U_32 offsetInDLL;
   char moduleName[_MAX_PATH];
+  char dumpInfo[_MAX_PATH];
 } HyWin32SignalInfo;
 
 #endif /* hysignal_h */



Mime
View raw message