[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1751-gd6746f0
[email protected] (Robin Watts) Thu, 24 Oct 2019 15:34:48 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via d6746f08c592057dfd3abe1b957c8b23971508cc (commit)
from de22d4d177a5911310d4af0777e87a8809a1622c (commit)
----------------------------------------------------------------------
commit d6746f08c592057dfd3abe1b957c8b23971508cc
Author: Robin Watts <[email protected]>
Date: Thu Oct 24 08:31:38 2019 -0700
Memento tweaks: libbacktrace warning/instructions.
If we can't load libbacktrace.so, give a warning that backtraces
will be cryptic.
Add info to memento.h about where people can get libbacktrace
from, how to build it, and where to install it.
Also add some code from Julian Smith to call gdb to extract
backtrace data; this doesn't work for me, so it's disabled
by default for now.
diff --git a/base/memento.c b/base/memento.c
index f1b938f..252b482 100644
--- a/base/memento.c
+++ b/base/memento.c
@@ -45,6 +45,7 @@ int atexit(void (*)(void));
#ifndef _MSC_VER
#include <stdint.h>
#include <limits.h>
+#include <unistd.h>
#endif
#include <stdlib.h>
@@ -535,7 +536,30 @@ static void print_stack_libbt(void *addr)
static void print_stack_libbt_failed(void *addr)
{
- char **strings = backtrace_symbols(&addr, 1);
+ char **strings;
+#if 0
+ /* Let's use a hack from Julian Smith to call gdb to extract the information */
+ /* Disabled for now, as I can't make this work. */
+ static char command[1024];
+ int e;
+ static int gdb_invocation_failed = 0;
+
+ if (gdb_invocation_failed == 0)
+ {
+ snprintf(command, sizeof(command),
+ //"gdb -q --batch -p=%i -ex 'info line *%p' -ex quit 2>/dev/null",
+ "gdb -q --batch -p=%i -ex 'info line *%p' -ex quit 2>/dev/null| egrep -v '(Thread debugging using)|(Using host libthread_db library)|(A debugging session is active)|(will be detached)|(Quit anyway)|(No such file or directory)|(^0x)|(^$)'",
+ getpid(), addr);
+ printf("%s\n", command);
+ e = system(command);
+ if (e == 0)
+ return; /* That'll do! */
+ gdb_invocation_failed = 1; /* If it's failed once, it'll probably keep failing. */
+ }
+#endif
+
+ /* We couldn't even get gdb! Make do. */
+ strings = backtrace_symbols(&addr, 1);
if (strings == NULL || strings[0] == NULL)
{
@@ -553,6 +577,12 @@ static void print_stack_libbt_failed(void *addr)
static int init_libbt(void)
{
+ static int libbt_inited = 0;
+
+ if (libbt_inited)
+ return 0;
+ libbt_inited = 1;
+
libbt = dlopen("libbacktrace.so", RTLD_LAZY);
if (libbt == NULL)
libbt = dlopen("/opt/lib/libbacktrace.so", RTLD_LAZY);
@@ -588,6 +618,9 @@ static int init_libbt(void)
return 1;
fail:
+ fprintf(stderr,
+ "MEMENTO: libbacktrace.so failed to load; backtraces will be sparse.\n"
+ "MEMENTO: See memento.h for how to rectify this.\n");
libbt = NULL;
backtrace_create_state = NULL;
backtrace_syminfo = NULL;
@@ -614,8 +647,8 @@ static void print_stack_default(void *addr)
{
memcpy(backtrace_exe, strings[0], s - strings[0]);
backtrace_exe[s-strings[0]] = 0;
- if (init_libbt())
- print_stack_value(addr);
+ init_libbt();
+ print_stack_value(addr);
}
}
#endif
diff --git a/base/memento.h b/base/memento.h
index 2a24162..e81db07 100644
--- a/base/memento.h
+++ b/base/memento.h
@@ -156,6 +156,30 @@
* Both Windows and GCC provide separate new[] and delete[] operators
* for arrays. Apparently some systems do not. If this is the case for
* your system, define MEMENTO_CPP_NO_ARRAY_CONSTRUCTORS.
+ *
+ * "libbacktrace.so failed to load"
+ *
+ * In order to give nice backtraces on unix, Memento will try to use
+ * a libbacktrace dynamic library. If it can't find it, you'll see
+ * that warning, and your backtraces won't include file/line information.
+ *
+ * To fix this you'll need to build your own libbacktrace. Don't worry
+ * it's really easy:
+ * git clone git://github.com/ianlancetaylor/libbacktrace
+ * cd libbacktrace
+ * ./configure
+ * make
+ *
+ * This leaves the build .so as .libs/libbacktrace.so
+ *
+ * Memento will look for this on LD_LIBRARY_PATH, or in /opt/lib/,
+ * or in /lib/, or in /usr/lib/, or in /usr/local/lib/. I recommend
+ * using /opt/lib/ as this won't conflict with anything that you
+ * get via a package manager like apt.
+ *
+ * sudo mkdir /opt
+ * sudo mkdir /opt/lib
+ * sudo cp .libs/libbacktrace.so /opt/lib/
*/
#ifndef MEMENTO_H
Summary of changes:
base/memento.c | 39 ++++++++++++++++++++++++++++++++++++---
base/memento.h | 24 ++++++++++++++++++++++++
2 files changed, 60 insertions(+), 3 deletions(-)