aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-03-25 10:20:34 +0100
committermarha <marha@users.sourceforge.net>2013-03-25 10:20:34 +0100
commit176eab9e8277db1549bfc6c9ae805c4e1858f0b0 (patch)
treea4c8d2d939aa500304d979377e39316b115a8128 /xorg-server/os
parent9c17f511266fff48a936633de280f271f0ce0c11 (diff)
downloadvcxsrv-176eab9e8277db1549bfc6c9ae805c4e1858f0b0.tar.gz
vcxsrv-176eab9e8277db1549bfc6c9ae805c4e1858f0b0.tar.bz2
vcxsrv-176eab9e8277db1549bfc6c9ae805c4e1858f0b0.zip
fontconfig mesa pixman xserver git update 25 Mar 2013
xserver commit 2967391c6d35f03121afa8003e0fb94b62495129 pixman commit d8ac35af1208a4fa4d67f03fee10b5449fb8495a fontconfig commit b561ff2016ce84eef3c81f16dfb0481be6a13f9b mesa commit 92b8a37fdfff9e83f39b8885f51ed2f60326ab6a
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/Makefile.am5
-rw-r--r--xorg-server/os/backtrace.c75
-rw-r--r--xorg-server/os/log.c4
3 files changed, 84 insertions, 0 deletions
diff --git a/xorg-server/os/Makefile.am b/xorg-server/os/Makefile.am
index 88914852f..364b6da2d 100644
--- a/xorg-server/os/Makefile.am
+++ b/xorg-server/os/Makefile.am
@@ -34,6 +34,11 @@ if XDMCP
libos_la_SOURCES += $(XDMCP_SRCS)
endif
+if HAVE_LIBUNWIND
+AM_CFLAGS += $(LIBUNWIND_CFLAGS)
+libos_la_LIBADD += $(LIBUNWIND_LIBS)
+endif
+
EXTRA_DIST = $(SECURERPC_SRCS) $(XDMCP_SRCS)
if SPECIAL_DTRACE_OBJECTS
diff --git a/xorg-server/os/backtrace.c b/xorg-server/os/backtrace.c
index daac60cf6..426f9b15b 100644
--- a/xorg-server/os/backtrace.c
+++ b/xorg-server/os/backtrace.c
@@ -30,6 +30,80 @@
#include <errno.h>
#include <string.h>
+#ifdef HAVE_LIBUNWIND
+
+#define UNW_LOCAL_ONLY
+#include <libunwind.h>
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <dlfcn.h>
+
+void
+xorg_backtrace(void)
+{
+ unw_cursor_t cursor;
+ unw_context_t context;
+ unw_word_t off;
+ unw_proc_info_t pip;
+ int ret, i = 0;
+ char procname[256];
+ const char *filename;
+ Dl_info dlinfo;
+
+ pip.unwind_info = NULL;
+ ret = unw_getcontext(&context);
+ if (ret) {
+ ErrorFSigSafe("unw_getcontext failed: %s [%d]\n", unw_strerror(ret),
+ ret);
+ return;
+ }
+
+ ret = unw_init_local(&cursor, &context);
+ if (ret) {
+ ErrorFSigSafe("unw_init_local failed: %s [%d]\n", unw_strerror(ret),
+ ret);
+ return;
+ }
+
+ ErrorFSigSafe("\n");
+ ErrorFSigSafe("Backtrace:\n");
+ ret = unw_step(&cursor);
+ while (ret > 0) {
+ ret = unw_get_proc_info(&cursor, &pip);
+ if (ret) {
+ ErrorFSigSafe("unw_get_proc_info failed: %s [%d]\n",
+ unw_strerror(ret), ret);
+ break;
+ }
+
+ ret = unw_get_proc_name(&cursor, procname, 256, &off);
+ if (ret && ret != -UNW_ENOMEM) {
+ if (ret != -UNW_EUNSPEC)
+ ErrorFSigSafe("unw_get_proc_name failed: %s [%d]\n",
+ unw_strerror(ret), ret);
+ procname[0] = '?';
+ procname[1] = 0;
+ }
+
+ if (dladdr((void *)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname &&
+ *dlinfo.dli_fname)
+ filename = dlinfo.dli_fname;
+ else
+ filename = "?";
+
+ ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname,
+ ret == -UNW_ENOMEM ? "..." : "", (int)off,
+ (void *)(pip.start_ip + off));
+
+ ret = unw_step(&cursor);
+ if (ret < 0)
+ ErrorFSigSafe("unw_step failed: %s [%d]\n", unw_strerror(ret), ret);
+ }
+ ErrorFSigSafe("\n");
+}
+#else /* HAVE_LIBUNWIND */
#ifdef HAVE_BACKTRACE
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@@ -246,3 +320,4 @@ xorg_backtrace(void)
#endif
#endif
+#endif
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 95bd8cca9..dc6e2888b 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -279,6 +279,10 @@ LogSetParameter(LogParameter param, int value)
}
}
+/**
+ * Signal-safe snprintf, with some limitations over snprintf. Be careful
+ * which directives you use.
+ */
static int
pnprintf(char *string, size_t size, const char *f, va_list args)
{