Blob Blame History Raw
From 0fcd63190deeb0afa2ad04826da99e5632f9d517 Mon Sep 17 00:00:00 2001
From: Martin Milata <mmilata@redhat.com>
Date: Mon, 14 Jul 2014 16:53:12 +0200
Subject: [SATYR PATCH 4/6] gdb: fix parsing of ppc64 stacktraces

Fixes rhbz#1119072.

Signed-off-by: Martin Milata <mmilata@redhat.com>
---
 lib/gdb_frame.c                    |  3 +-
 tests/gdb_stacktrace.at            | 35 ++++++++++++++++++++
 tests/gdb_stacktraces/rhbz-1119072 | 67 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 tests/gdb_stacktraces/rhbz-1119072

diff --git a/lib/gdb_frame.c b/lib/gdb_frame.c
index 57e9479..e449b30 100644
--- a/lib/gdb_frame.c
+++ b/lib/gdb_frame.c
@@ -559,12 +559,13 @@ sr_gdb_frame_parse_function_name(const char **input,
     /* First character:
        '~' for destructor
        '*' for ????
+       '.' on ppc64
        '_a-zA-Z' for mangled/nonmangled function name
        '(' to start "(anonymous namespace)::" or something
      */
     char first;
     char *namechunk;
-    if (sr_parse_char_limited(&local_input, "~*_" SR_alpha, &first))
+    if (sr_parse_char_limited(&local_input, "~*._" SR_alnum, &first))
     {
         /* If it's a start of 'o'perator, put the 'o' back! */
         if (first == 'o')
diff --git a/tests/gdb_stacktrace.at b/tests/gdb_stacktrace.at
index 8832cb8..f626417 100644
--- a/tests/gdb_stacktrace.at
+++ b/tests/gdb_stacktrace.at
@@ -247,3 +247,38 @@ main(void)
   return 0;
 }
 ]])
+
+## ----------------------------- ##
+## sr_gdb_stacktrace_parse_ppc64 ##
+## ----------------------------- ##
+AT_TESTFUN([sr_gdb_stacktrace_parse_ppc64],
+[[
+#include "gdb/stacktrace.h"
+#include "gdb/thread.h"
+#include "gdb/frame.h"
+#include "location.h"
+#include "utils.h"
+#include <assert.h>
+#include <stdio.h>
+
+int
+main(void)
+{
+  /* Check that satyr is able to parse backtrace with missing Thread header */
+  struct sr_location location;
+  sr_location_init(&location);
+  char *error_message;
+  char *full_input = sr_file_to_string("../../gdb_stacktraces/rhbz-1119072", &error_message);
+  assert(full_input);
+  char *input = full_input;
+  struct sr_gdb_stacktrace *stacktrace = sr_gdb_stacktrace_parse(&input, &location);
+  assert(stacktrace);
+  assert(5 == sr_gdb_stacktrace_get_thread_count(stacktrace));
+  struct sr_gdb_thread *thread = stacktrace->threads;
+  assert(7 == sr_thread_frame_count(thread));
+  struct sr_gdb_frame *frame = thread->frames;
+  assert(0 == strcmp(frame->function_name, ".pthread_cond_timedwait"));
+  sr_gdb_stacktrace_free(stacktrace);
+  return 0;
+}
+]])
diff --git a/tests/gdb_stacktraces/rhbz-1119072 b/tests/gdb_stacktraces/rhbz-1119072
new file mode 100644
index 0000000..2aca936
--- /dev/null
+++ b/tests/gdb_stacktraces/rhbz-1119072
@@ -0,0 +1,67 @@
+[New LWP 2271]
+[New LWP 2374]
+[New LWP 2325]
+[New LWP 2360]
+[New LWP 2375]
+[Thread debugging using libthread_db enabled]
+Using host libthread_db library "/lib64/libthread_db.so.1".
+Core was generated by `caja '.
+Program terminated with signal SIGTRAP, Trace/breakpoint trap.
+#0  0x000000803a327a54 in .raise () from /usr/lib64/libpthread.so.0
+
+Thread 5 (Thread 0x3fffa0ebeed0 (LWP 2375)):
+#0  0x000000803a321f24 in .pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
+#1  0x000000803a748054 in .g_cond_wait_until () from /usr/lib64/libglib-2.0.so.0
+#2  0x000000803a6ac2c8 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#3  0x000000803a720530 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#4  0x000000803a71f3f8 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#5  0x000000803a31c31c in .start_thread () from /usr/lib64/libpthread.so.0
+#6  0x000000803a20c150 in .__clone () from /usr/lib64/libc.so.6
+
+Thread 4 (Thread 0x3fffa208eed0 (LWP 2360)):
+#0  0x000000803a1fd130 in .__GI___poll () from /usr/lib64/libc.so.6
+#1  0x000000803a6fe0b0 in .g_poll () from /usr/lib64/libglib-2.0.so.0
+#2  0x000000803a6e9ef4 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#3  0x000000803a6ea610 in .g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
+#4  0x000000803ae658c8 in 0000090f.plt_call.g_io_channel_flush+0 () from /usr/lib64/libgio-2.0.so.0
+#5  0x000000803a71f3f8 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#6  0x000000803a31c31c in .start_thread () from /usr/lib64/libpthread.so.0
+#7  0x000000803a20c150 in .__clone () from /usr/lib64/libc.so.6
+
+Thread 3 (Thread 0x3fffa288eed0 (LWP 2325)):
+#0  0x000000803a1fd130 in .__GI___poll () from /usr/lib64/libc.so.6
+#1  0x000000803a6fe0b0 in .g_poll () from /usr/lib64/libglib-2.0.so.0
+#2  0x000000803a6e9ef4 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#3  0x000000803a6ea0a4 in .g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
+#4  0x00003fffa28ba8dc in 00000010.plt_call.g_hash_table_size+0 () from /usr/lib64/gio/modules/libdconfsettings.so
+#5  0x000000803a71f3f8 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#6  0x000000803a31c31c in .start_thread () from /usr/lib64/libpthread.so.0
+#7  0x000000803a20c150 in .__clone () from /usr/lib64/libc.so.6
+
+Thread 2 (Thread 0x3fffa16beed0 (LWP 2374)):
+#0  0x000000803a1fd130 in .__GI___poll () from /usr/lib64/libc.so.6
+#1  0x000000803a6fe0b0 in .g_poll () from /usr/lib64/libglib-2.0.so.0
+#2  0x000000803a6e9ef4 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#3  0x000000803a6ea0a4 in .g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
+#4  0x000000803a6ea15c in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#5  0x000000803a71f3f8 in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#6  0x000000803a31c31c in .start_thread () from /usr/lib64/libpthread.so.0
+#7  0x000000803a20c150 in .__clone () from /usr/lib64/libc.so.6
+
+Thread 1 (Thread 0x3fffa9210490 (LWP 2271)):
+#0  0x000000803a327a54 in .raise () from /usr/lib64/libpthread.so.0
+#1  0x000000803a6f3dd8 in .g_logv () from /usr/lib64/libglib-2.0.so.0
+#2  0x000000803a6f3ef8 in .g_log () from /usr/lib64/libglib-2.0.so.0
+#3  0x000000803cd0c230 in 000002cd.plt_call.XmbTextExtents+0 () from /usr/lib64/libgdk-x11-2.0.so.0
+#4  0x000000803a9e0870 in ._XError () from /usr/lib64/libX11.so.6
+#5  0x000000803a9dc398 in 00000e9e.plt_call._XimXTransGetHostname+0 () from /usr/lib64/libX11.so.6
+#6  0x000000803a9dc514 in 00000e9e.plt_call._XimXTransGetHostname+0 () from /usr/lib64/libX11.so.6
+#7  0x000000803a9dd19c in ._XEventsQueued () from /usr/lib64/libX11.so.6
+#8  0x000000803a9c8d6c in .XPending () from /usr/lib64/libX11.so.6
+#9  0x000000803ccfbd74 in 000002cd.plt_call.XmbTextExtents+0 () from /usr/lib64/libgdk-x11-2.0.so.0
+#10 0x000000803ccfbf58 in 000002cd.plt_call.XmbTextExtents+0 () from /usr/lib64/libgdk-x11-2.0.so.0
+#11 0x000000803a6e9124 in .g_main_context_prepare () from /usr/lib64/libglib-2.0.so.0
+#12 0x000000803a6e9d7c in 000000ca.plt_call.strncasecmp@@GLIBC_2.3+0 () from /usr/lib64/libglib-2.0.so.0
+#13 0x000000803a6ea610 in .g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
+#14 0x000000803c839050 in .gtk_main () from /usr/lib64/libgtk-x11-2.0.so.0
+#15 0x0000000010051054 in .main ()
-- 
1.9.3