From cac2815beacb22b011a4c23ab61fa20d101b61a8 Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Sat, 18 Feb 2023 10:52:46 +0100 Subject: [PATCH] Normalize both gdb stacktrace and the crash frame If we normalize the stacktrace, then we should also normalize the crash frame. Otherwise the normalized function name from the top thread frame doesn't have to match with the same function name in the crash frame. Example: Normalized thread frame function name: __poll Raw crash frame function name: __GI___poll Resolves: rhbz#2168223 Signed-off-by: Michal Srb --- lib/normalize.c | 30 +++++++++++++++++++----------- python/py_gdb_stacktrace.c | 2 ++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/normalize.c b/lib/normalize.c index 5aea713..6cdf5e6 100644 --- a/lib/normalize.c +++ b/lib/normalize.c @@ -215,6 +215,20 @@ sr_gdb_frame_is_removable(const char *function_name, return false; } +void sr_normalize_gdb_frame(struct sr_gdb_frame *frame) +{ + if (frame && frame->source_file) + { + /* Remove IA__ prefix used in GLib, GTK and GDK. */ + remove_func_prefix(frame->function_name, "IA__gdk", strlen("IA__")); + remove_func_prefix(frame->function_name, "IA__g_", strlen("IA__")); + remove_func_prefix(frame->function_name, "IA__gtk", strlen("IA__")); + + /* Remove __GI_ (glibc internal) prefix. */ + remove_func_prefix(frame->function_name, "__GI_", strlen("__GI_")); + } +} + void sr_normalize_gdb_thread(struct sr_gdb_thread *thread) { @@ -234,17 +248,7 @@ sr_normalize_gdb_thread(struct sr_gdb_thread *thread) struct sr_gdb_frame *frame = thread->frames; while (frame) { - if (frame->source_file) - { - /* Remove IA__ prefix used in GLib, GTK and GDK. */ - remove_func_prefix(frame->function_name, "IA__gdk", strlen("IA__")); - remove_func_prefix(frame->function_name, "IA__g_", strlen("IA__")); - remove_func_prefix(frame->function_name, "IA__gtk", strlen("IA__")); - - /* Remove __GI_ (glibc internal) prefix. */ - remove_func_prefix(frame->function_name, "__GI_", strlen("__GI_")); - } - + sr_normalize_gdb_frame(frame); frame = frame->next; } @@ -507,6 +511,10 @@ sr_normalize_gdb_stacktrace(struct sr_gdb_stacktrace *stacktrace) sr_normalize_gdb_thread(thread); thread = thread->next; } + + if (stacktrace->crash) { + sr_normalize_gdb_frame(stacktrace->crash); + } } static bool diff --git a/python/py_gdb_stacktrace.c b/python/py_gdb_stacktrace.c index 4ca50c3..73a1958 100644 --- a/python/py_gdb_stacktrace.c +++ b/python/py_gdb_stacktrace.c @@ -532,7 +532,9 @@ sr_py_gdb_stacktrace_normalize(PyObject *self, PyObject *args) Py_DECREF(this->threads); this->stacktrace->threads = tmp->threads; + this->stacktrace->crash = tmp->crash; tmp->threads = NULL; + tmp->crash = NULL; sr_gdb_stacktrace_free(tmp); this->threads = thread_linked_list_to_python_list(this->stacktrace);