[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Issue 1628: use a custom crash handler on Windows

From: SteveKing <steveking_at_gmx.ch>
Date: 2005-07-25 20:17:03 CEST

Ok, I guess this will be my last try:

I've changed the crash reporting dll so it can save the zipped report
automatically and print a message with the location to where it was
saved to stderr.
Also, I've added a function to enable/disable the UI part after the dll
was loaded. That way, the svn client could enable the UI part later on
when the command line params are read (I don't know enough to add such a
param myself, I have to leave that to someone else).

By default, all svn apps now use the crash reporter in console mode,
i.e. without popping up a dialog but just saving the report and print
info about it to the console stderr.

I've also uploaded the updated crash report dll to
http://tortoisesvn.tigris.org/files/documents/406/24329/CrashRpt.dll
There's a slight problem: that binary was compiled with VS.NET, so it
relies on the 7.1 C-Runtime. And since svn is compiled with VC6, you
might want to recompile the dll with VC6 too to avoid additional
dependencies.

If you guys find some styling issues with the patch, please just correct
them yourself (or at least specify *what* and *where* the style doesn't
suit your needs, I'm tired of trying to find out what exactly you don't
like) - fixing the style of this patch would take you no more than 5
minutes, but writing a mail about that, me reading it, trying to find
out what's wrong this time, fix it, write another mail, attach the patch
again, ... takes much more time.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.tigris.org

[[[
Load a crash reporting dll on Windows when clients start up.
* subversion/libsvn_subr/cmdline.c(svn_cmdline_init):
  load the crashrpt.dll dynamically
* subversion/libsvn_subr/cmdline.c(cmdline_remove_crashrpt):
  new function to remove the crash reporter when the app exits
* subversion/libsvn_subr/cmdline.c(svn_cmdline_crashhandlerUI):
  new function to enable/disable the UI part of the crash reporter
]]]
Index: subversion/include/svn_cmdline.h
===================================================================
--- subversion/include/svn_cmdline.h (Revision 15423)
+++ subversion/include/svn_cmdline.h (Arbeitskopie)
@@ -47,6 +47,13 @@
  */
 int svn_cmdline_init (const char *progname, FILE *error_stream);
 
+/** Switches the UI part of the crash handler on or off.
+ * The UI part must only be enabled if the application is run as a user
+ * who has access to the UI and not just the console.
+ *
+ * @since new in 1.3
+ */
+void svn_cmdline_crashhandlerUI (svn_boolean_t useUI);
 
 /** Set @a *dest to an output-encoded C string from UTF-8 C string @a
  * src; allocate @a *dest in @a pool.
Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c (Revision 15423)
+++ subversion/libsvn_subr/cmdline.c (Arbeitskopie)
@@ -37,6 +37,7 @@
 #include "svn_error.h"
 #include "svn_nls.h"
 #include "utf_impl.h"
+#include "svn_version.h"
 
 #include "svn_private_config.h"
 
@@ -49,13 +50,96 @@
 /* The stdout encoding. If null, it's the same as the native encoding. */
 static const char *output_encoding = NULL;
 
+#ifdef WIN32
+/* typedef of the GetLogFile function used in the InstallEx function
+ as the first parameter. Even though we pass NULL for that parameter
+ later, the typedef is needed for type checks */
+typedef BOOL (__stdcall *CrashGetLogFile) (void * crashstate);
 
+/* the function to initialize the crash handler. The @a CrashGetLogFile function
+ can be used to add custom files to the crashreport. @a mailto must be set
+ to the mail address the report should be sent to, and @a mailsubject must
+ be set to the subject the mail should have. */
+typedef void * (*InstallEx)(CrashGetLogFile func, const char * mailto,
+ const char * mailsubject, BOOL UseUI);
+
+/* function to remove the custom crash handler. @a crashstate is the pointer
+ to the state variable received in the InstallEx call. */
+typedef void (*UninstallEx)(void * crashstate);
+
+/* function to enable the UI part of the crash handler. */
+typedef void (*EnableUI)(void);
+/* function to disable the UI part of the crash handler. */
+typedef void (*DisableUI)(void);
+
+/* the handle to the crash report dll */
+HMODULE crashDll = 0;
+
+/* the pointer to the crash report state */
+void * crashstate = 0;
+
+/* Removes the crash report handler from the system. After this call
+ exceptions are passed through to the system and not handled by the
+ custom dll anymore. */
+static void cmdline_remove_crashrpt(void)
+{
+ UninstallEx UninstallFunc;
+ if ((crashDll)&&(crashstate))
+ {
+ UninstallFunc = (UninstallEx)GetProcAddress(crashDll, "UninstallEx");
+ if (UninstallFunc)
+ {
+ UninstallFunc(crashstate);
+ crashstate = 0;
+ }
+ }
+ FreeLibrary(crashDll);
+ crashDll = 0;
+}
+
+/* enables or disables the UI part of the crash handler. */
+void svn_cmdline_crashhandlerUI(svn_boolean_t useUI)
+{
+ EnableUI EnableUIFunc;
+ DisableUI DisableUIFunc;
+ if (crashDll)
+ {
+ if (useUI)
+ {
+ EnableUIFunc = (EnableUI)GetProcAddress(crashDll, "EnableUI");
+ if (EnableUIFunc)
+ EnableUIFunc();
+ }
+ else
+ {
+ DisableUIFunc = (DisableUI)GetProcAddress(crashDll, "DisableUI");
+ if (DisableUIFunc)
+ DisableUIFunc();
+ }
+ }
+}
+#endif
+
 int
 svn_cmdline_init (const char *progname, FILE *error_stream)
 {
   apr_status_t status;
   apr_pool_t *pool;
 
+ /* Load the crash reporting dll if it's available */
+#ifdef WIN32
+ InstallEx InstallExFunc;
+ crashDll = LoadLibrary("svn_CrashRpt");
+ if (crashDll)
+ {
+ InstallExFunc = (InstallEx)GetProcAddress(crashDll, "InstallEx");
+ if (InstallExFunc)
+ crashstate = InstallExFunc(NULL,
+ "svn-breakage@subversion.tigris.org",
+ SVN_VER_NUM, 0);
+ }
+ atexit(cmdline_remove_crashrpt);
+#endif
 #ifndef WIN32
   {
     struct stat st;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jul 25 20:17:49 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.