Skip to content

Commit

Permalink
Normalize both gdb stacktrace and the crash frame
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
msrb committed Feb 20, 2023
1 parent 26aa206 commit cac2815
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
30 changes: 19 additions & 11 deletions lib/normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions python/py_gdb_stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cac2815

Please sign in to comment.