[bug-buddy/remove_breakpad: 2/3] Remove breakpad segv handling and convert segvhandler to plain C



commit b3635ad333e269948ed3a3c6fda97522f44aaf4b
Author: Fernando Herrera <fherrera onirica com>
Date:   Mon May 31 14:22:52 2010 +0200

    Remove breakpad segv handling and convert segvhandler to plain C

 Makefile.am                                        |   10 +--
 configure.in                                       |   48 +---------
 segv_handler/Makefile.am                           |   42 +-------
 .../{gnome-breakpad.cc => gnome-segvhanlder.c}     |  101 +++++---------------
 4 files changed, 37 insertions(+), 164 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 582fc11..55824aa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,14 +1,8 @@
 ACLOCAL_AMFLAGS = -I m4
 
-if USE_GOOGLE_BREAKPAD
-GOOGLE_BREAKPAD_DIR = google-breakpad
-else
-GOOGLE_BREAKPAD_DIST_DIR = google-breakpad
-endif
+SUBDIRS = po segv_handler src docs data
 
-SUBDIRS = po $(GOOGLE_BREAKPAD_DIR) gnome-breakpad src docs data
-
-DIST_SUBDIRS = $(SUBDIRS) $(GOOGLE_BREAKPAD_DIST_DIR) 
+DIST_SUBDIRS = $(SUBDIRS) 
 
 EXTRA_DIST = \
 	ChangeLog.pre-git	\
diff --git a/configure.in b/configure.in
index 758b9e3..ec9a508 100644
--- a/configure.in
+++ b/configure.in
@@ -73,53 +73,13 @@ AC_CHECK_LIB(elf, elf_version)
 AC_CHECK_HEADERS([libelf.h],[],[AC_MSG_ERROR([libelf.h not found.])])
 AC_CHECK_HEADERS([gelf.h],[],[AC_MSG_ERROR([gelf.h not found.])])
 
-AC_ARG_ENABLE([google-breakpad],
-	[AC_HELP_STRING([--enable-google-breakpad],
-			[Enable support for retrieving minidumps with Google \
-			 Breakpad [default=yes]])],
-	enable_google_breakpad="$enableval", enable_google_breakpad=yes)
-
-if test "x$enable_google_breakpad" = "xyes"; then
-	AC_CONFIG_SUBDIRS(google-breakpad)
-
-	GOOGLE_BREAKPAD_SUPPORTED_OS="no"
-	case $target_os in
-		solaris*)
-			solaris=yes
-			GOOGLE_BREAKPAD_SUPPORTED_OS="yes"
-		;;
-		linux*)
-			linux=yes
-			GOOGLE_BREAKPAD_SUPPORTED_OS="yes"
-		;;
-	esac
-
-	GOOGLE_BREAKPAD_SUPPORTED_ARCH="no"
-	case $target_cpu in
-		*86)
-	GOOGLE_BREAKPAD_SUPPORTED_ARCH="yes" ;;
-	esac
-
-	if test x$GOOGLE_BREAKPAD_SUPPORTED_OS = xyes ; then
-		if test x$GOOGLE_BREAKPAD_SUPPORTED_ARCH = xyes ; then
-			echo "OS and CPU supported: enabling google-breakpad"
-			AC_DEFINE(ENABLE_GOOGLE_BREAKPAD, 1, [define if google-break is enabled])
-			use_google_breakpad=yes
-		fi
-	fi
-fi
-
-AM_CONDITIONAL(USE_GOOGLE_BREAKPAD, test x$use_google_breakpad = xyes)
-AM_CONDITIONAL(BREAKPAD_SOLARIS, test x$solaris = xyes)
-AM_CONDITIONAL(BREAKPAD_LINUX, test x$linux = xyes)
-
 GDK_REQUIRED="x11 gdk-x11-2.0 >= 2.9"
-PKG_CHECK_MODULES(GNOME_BREAKPAD,
+PKG_CHECK_MODULES(GNOME_SEGV_HANDLER,
 [
 	$GDK_REQUIRED
 ])
-AC_SUBST(GNOME_BREAKPAD_CFLAGS)
-AC_SUBST(GNOME_BREAKPAD_LIBS)
+AC_SUBST(GNOME_SEGV_HANDLER_CFLAGS)
+AC_SUBST(GNOME_SEGV_HANDLER_LIBS)
 
 
 PKG_CHECK_MODULES(GNOME_CRASH, $GTK_REQUIRED)
@@ -151,7 +111,7 @@ data/bug-buddy.schemas
 data/bug-buddy.desktop.in
 docs/Makefile
 po/Makefile.in
-gnome-breakpad/Makefile
+segv_handler/Makefile
 src/Makefile
 ])
 
diff --git a/segv_handler/Makefile.am b/segv_handler/Makefile.am
index 212863e..5e6c8cb 100644
--- a/segv_handler/Makefile.am
+++ b/segv_handler/Makefile.am
@@ -1,41 +1,9 @@
-INCLUDES = -I. -I$(top_srcdir)/google-breakpad/src -DNDEBUG -D_REENTRANT $(GNOME_BREAKPAD_CFLAGS)
+INCLUDES = -I. -DNDEBUG -D_REENTRANT $(GNOME_SEGV_HANDLER_CFLAGS)
 
-
-if USE_GOOGLE_BREAKPAD
-
-if BREAKPAD_SOLARIS
-dir = solaris
-GOOGLE_BREAKPAD_CC_EXTRA = \
-	$(top_srcdir)/google-breakpad/src/client/solaris/handler/solaris_lwp.cc
-endif 
-
-if BREAKPAD_LINUX
-dir = linux
-GOOGLE_BREAKPAD_CC_EXTRA = \
-	$(top_srcdir)/google-breakpad/src/client/linux/handler/linux_thread.cc
-endif
-
-
-GOOGLE_BREAKPAD_CC = 	\
-	$(top_srcdir)/google-breakpad/src/client/$(dir)/handler/exception_handler.cc \
-	$(top_srcdir)/google-breakpad/src/client/$(dir)/handler/minidump_generator.cc \
-	$(top_srcdir)/google-breakpad/src/common/$(dir)/file_id.cc \
-	$(top_srcdir)/google-breakpad/src/common/$(dir)/guid_creator.cc \
-	$(top_srcdir)/google-breakpad/src/client/minidump_file_writer.cc  \
-	$(top_srcdir)/google-breakpad/src/common/string_conversion.cc \
-	$(top_srcdir)/google-breakpad/src/common/convert_UTF.c \
-	$(top_srcdir)/google-breakpad/src/common/md5.c \
-	$(GOOGLE_BREAKPAD_CC_EXTRA)
-
-GOOGLE_BREAKPAD_LIBS = $(top_builddir)/google-breakpad/src/libbreakpad.la -lpthread
-endif
-
-
-
-module_LTLIBRARIES = libgnomebreakpad.la
+module_LTLIBRARIES = libgnomesegvhandler.la
 
 moduledir = $(libdir)/gtk-2.0/modules
 
-libgnomebreakpad_la_SOURCES = gnome-breakpad.cc $(GOOGLE_BREAKPAD_CC)
-libgnomebreakpad_la_LIBADD = $(GOOGLE_BREAKPAD_LIBS) $(GNOME_BREAKPAD_LIBS)
-libgnomebreakpad_la_LDFLAGS = -rpath $(moduledir) -module -avoid-version @LDFLAGS@
+libgnomesegvhandler_la_SOURCES = gnome-segvhanlder.c
+libgnomesegvhandler_la_LIBADD = $(GNOME_SEGV_HANDLER_LIBS)
+libgnomesegvhandler_la_LDFLAGS = -rpath $(moduledir) -module -avoid-version @LDFLAGS@
diff --git a/segv_handler/gnome-breakpad.cc b/segv_handler/gnome-segvhanlder.c
similarity index 82%
rename from segv_handler/gnome-breakpad.cc
rename to segv_handler/gnome-segvhanlder.c
index d0add88..eac1d12 100644
--- a/segv_handler/gnome-breakpad.cc
+++ b/segv_handler/gnome-segvhanlder.c
@@ -19,12 +19,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include <unistd.h>
-#include <cstdio>
-#include <cstdlib>
-#include <cassert>
-#include <cstring>
-
 #include <libelf.h>
 #include <gelf.h>
 
@@ -43,17 +37,13 @@
 
 #include <config.h>
 
-#ifdef ENABLE_GOOGLE_BREAKPAD
-#include "client/linux/handler/exception_handler.h"
-
-using namespace google_breakpad;
-#else
 #include <string.h>
-#endif
 
-extern "C" const char *g_module_check_init (GModule *module);
-extern "C" int gtk_module_init (int *argc, char** argv[]);
-static bool    run_bug_buddy   (const gchar *appname, pid_t pid, const gchar *minidump_path);
+const char *g_module_check_init (GModule *module);
+
+int gtk_module_init (int *argc, char** argv[]);
+
+static gboolean    run_bug_buddy   (const gchar *appname, pid_t pid);
 static void    check_if_gdb    ();
 
 static gchar *bugbuddy;
@@ -69,29 +59,6 @@ typedef struct {
 static CircBuff * log_buff = NULL;
 #define LOG_BUFFER_SIZE 15
 
-#ifdef ENABLE_GOOGLE_BREAKPAD
-static ExceptionHandler * handler;
-
-/* Callback when minidump written. */
-static bool MinidumpCallback(const char *dump_path,
-                             const char *minidump_id,
-                             void *context,
-                             bool succeeded) {
-  gchar *appname;
-  gchar *minidump_file;
-
-	
-  printf("%s is dumped\n", minidump_id);
-  appname = g_get_prgname ();
-  minidump_file = g_strdup_printf ("/tmp/%s.dmp", minidump_id);
-  run_bug_buddy (appname, 0, minidump_file);
-
-  g_unlink (minidump_file);
-  g_free (minidump_file);
-  _exit(0);
-}
-#endif
-
 static void
 circ_buff_free (CircBuff *buff)
 {
@@ -222,14 +189,6 @@ bugbuddy_segv_handle(int signum)
 
 	check_if_gdb ();
 
-#ifdef ENABLE_GOOGLE_BREAKPAD
-	/* If we are here is because there are no debug symbols or gdb couldn't be run.
-	 * Write the minidump anyway.
-	 */
-
-	handler->WriteMinidump ("/tmp", MinidumpCallback, NULL);
-#endif
-
         _exit(1);
 }
 
@@ -240,7 +199,7 @@ find_in_debug_path (const char *filename, const char *debug_filename)
 {
 	char *dir;
 	char *tries[N_TRIES];
-	gboolean result = false;
+	gboolean result = FALSE;
 	int i;
 
 	dir = g_path_get_dirname (filename);
@@ -252,7 +211,7 @@ find_in_debug_path (const char *filename, const char *debug_filename)
 
 	for (i = 0; i < N_TRIES; ++i) {
 		if (g_file_test (tries[i], G_FILE_TEST_EXISTS)) {
-			result = true;
+			result = TRUE;
 			break;
 		}
 	}
@@ -275,14 +234,14 @@ elf_has_debug_symbols (const char *filename)
 
        if (elf_version(EV_CURRENT) == EV_NONE ) {
                fprintf(stderr, "Elf library out of date!n");
-                return false;
+                return FALSE;
        }
 
        fd = open(filename, O_RDONLY);
 
        if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL){
                close (fd);
-               return false;
+               return FALSE;
        }
        gelf_getehdr (elf, &elf_header);
        while ((section = elf_nextscn(elf, section)) != 0) {
@@ -293,7 +252,7 @@ elf_has_debug_symbols (const char *filename)
                if (gelf_getshdr (section, &shdr) != 0) {
                        if (shdr.sh_type == SHT_SYMTAB) {
                                elf_end (elf);
-                               return true;
+                               return TRUE;
                        }
                }
 
@@ -306,7 +265,7 @@ elf_has_debug_symbols (const char *filename)
 			edata = elf_getdata(section, NULL);
 			if (edata != NULL && find_in_debug_path (filename, (const char*) edata->d_buf)) {
 				elf_end (elf);
-				return true;
+				return TRUE;
 			}
 		}
               }
@@ -314,13 +273,13 @@ elf_has_debug_symbols (const char *filename)
 
        /* no symtab neither debug file present */
        elf_end (elf);
-       return false;
+       return FALSE;
 }
 
 
 
 
-static bool
+static gboolean
 release_grabs (void)
 {
         /* Make sure we release grabs */
@@ -334,19 +293,19 @@ release_grabs (void)
 
         gdk_flush();
 
-	return true;
+	return TRUE;
 }
 
-static bool
-run_bug_buddy (const gchar *appname, pid_t pid, const gchar *minidump_path)
+static gboolean
+run_bug_buddy (const gchar *appname, pid_t pid)
 {
 	gboolean res;
 	char *warning_file, *exec_str;
 	GString *args_str;
 	GError *error = NULL;
 
-	if (pid == 0 && minidump_path == NULL)
-		return false;
+	if (pid == 0)
+		return FALSE;
 
 	warning_file = circ_buff_to_file (log_buff);
 	circ_buff_free (log_buff);
@@ -359,10 +318,7 @@ run_bug_buddy (const gchar *appname, pid_t pid, const gchar *minidump_path)
 		g_free (warning_file);
 	}
 
-	if (pid != 0)
-		g_string_append_printf (args_str,  "--pid=%d",(int) pid);
-	else if (minidump_path != NULL)
-		g_string_append_printf (args_str, "--minidump=%s", minidump_path);
+	g_string_append_printf (args_str,  "--pid=%d",(int) pid);
 
 	exec_str = g_string_free (args_str, FALSE);
 	res = g_spawn_command_line_sync (exec_str, NULL, NULL,
@@ -370,13 +326,13 @@ run_bug_buddy (const gchar *appname, pid_t pid, const gchar *minidump_path)
 	g_free (exec_str);
 	if (!res) {
 		g_warning ("Couldn't run bug-buddy\n");
-		return false;
+		return FALSE;
 	}
 
-	return true;
+	return TRUE;
 }
 
-static bool
+static gboolean
 run_gdb (const gchar *appname, pid_t pid)
 {
 	gchar *exec_str;
@@ -397,10 +353,10 @@ run_gdb (const gchar *appname, pid_t pid)
 	g_free(exec_str);
 	if (!res) {
 		g_warning("Couldn't run debugger\n");
-		return false;
+		return FALSE;
 	}
 
-	return true;
+	return TRUE;
 }
 
 static void
@@ -408,7 +364,7 @@ check_if_gdb ()
 {
 	char *mypath;
 	gchar *gdb;
-	bool has_debug_symbols = false;
+	gboolean has_debug_symbols = FALSE;
 	char *filename;
 	gchar *appname;
 	pid_t pid;
@@ -437,7 +393,7 @@ check_if_gdb ()
 	g_free (mypath);
 
 	if (bugbuddy && gdb && has_debug_symbols) {
-		res = run_bug_buddy (appname, pid, NULL);
+		res = run_bug_buddy (appname, pid);
 		if (!res)
 			_exit (1);
 		_exit(0);
@@ -450,11 +406,6 @@ gtk_module_init (int *argc, char** argv[])
 	bugbuddy = g_find_program_in_path ("bug-buddy");
 	
 	if (bugbuddy && !g_getenv ("GNOME_DISABLE_CRASH_DIALOG")) {
-#ifdef ENABLE_GOOGLE_BREAKPAD
-		/* create the handler for minidumps */
-  		handler = new ExceptionHandler ("/tmp", NULL,
-						NULL, NULL, false);
-#endif
 
         	static struct sigaction *setptr;
         	static struct sigaction old_action;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]