[SATYR PATCH 4/9] Move kerneloops normalization to koops_stacktrace.c

Martin Milata mmilata at redhat.com
Wed Jun 26 20:14:08 UTC 2013


The gdb normalization is left in normalize.c as some of the code/data
may be shared with core normalization when it is implemented.

Signed-off-by: Martin Milata <mmilata at redhat.com>
---
 include/koops/stacktrace.h |  3 +++
 include/normalize.h        |  7 ------
 lib/koops_stacktrace.c     | 60 ++++++++++++++++++++++++++++++++++++++++++++
 lib/normalize.c            | 62 ----------------------------------------------
 4 files changed, 63 insertions(+), 69 deletions(-)

diff --git a/include/koops/stacktrace.h b/include/koops/stacktrace.h
index 4aa545e..9d76cab 100644
--- a/include/koops/stacktrace.h
+++ b/include/koops/stacktrace.h
@@ -159,6 +159,9 @@ sr_koops_stacktrace_get_reason(struct sr_koops_stacktrace *stacktrace);
 char *
 sr_koops_stacktrace_to_json(struct sr_koops_stacktrace *stacktrace);
 
+void
+sr_normalize_koops_stacktrace(struct sr_koops_stacktrace *stacktrace);
+
 
 #ifdef __cplusplus
 }
diff --git a/include/normalize.h b/include/normalize.h
index c93595f..a595cb9 100644
--- a/include/normalize.h
+++ b/include/normalize.h
@@ -36,10 +36,6 @@ extern "C" {
 struct sr_gdb_frame;
 struct sr_gdb_thread;
 struct sr_gdb_stacktrace;
-struct sr_core_frame;
-struct sr_core_thread;
-struct sr_core_stacktrace;
-struct sr_koops_stacktrace;
 
 void
 sr_normalize_gdb_thread(struct sr_gdb_thread *thread);
@@ -47,9 +43,6 @@ sr_normalize_gdb_thread(struct sr_gdb_thread *thread);
 void
 sr_normalize_gdb_stacktrace(struct sr_gdb_stacktrace *stacktrace);
 
-void
-sr_normalize_koops_stacktrace(struct sr_koops_stacktrace *stacktrace);
-
 // TODO: move to gdb_stacktrace.h
 /**
  * Checks whether the thread it contains some function used to exit
diff --git a/lib/koops_stacktrace.c b/lib/koops_stacktrace.c
index 95ae344..0533034 100644
--- a/lib/koops_stacktrace.c
+++ b/lib/koops_stacktrace.c
@@ -559,3 +559,63 @@ koops_append_bthash_text(struct sr_koops_stacktrace *stacktrace,
 
     sr_strbuf_append_char(strbuf, '\n');
 }
+
+void
+sr_normalize_koops_stacktrace(struct sr_koops_stacktrace *stacktrace)
+{
+    /* Normalize function names by removing the suffixes identified by
+     * the dot character.
+     */
+    struct sr_koops_frame *frame = stacktrace->frames;
+    while (frame)
+    {
+        if (frame->function_name)
+        {
+            char *dot = strchr(frame->function_name, '.');
+            if (dot)
+                *dot = '\0';
+        }
+
+        frame = frame->next;
+    }
+
+    /* Remove blacklisted frames. */
+    /* !!! MUST BE SORTED !!! */
+    const char *blacklist[] = {
+        "do_softirq",
+        "do_vfs_ioctl",
+        "flush_kthread_worker",
+        "gs_change",
+        "irq_exit",
+        "kernel_thread_helper",
+        "kthread",
+        "process_one_work",
+        "system_call_fastpath",
+        "warn_slowpath_common",
+        "warn_slowpath_fmt",
+        "warn_slowpath_fmt_taint",
+        "warn_slowpath_null",
+        "worker_thread"
+    };
+
+    frame = stacktrace->frames;
+    while (frame)
+    {
+        struct sr_koops_frame *next_frame = frame->next;
+
+        bool in_blacklist = bsearch(&frame->function_name,
+                                    blacklist,
+                                    sizeof(blacklist) / sizeof(blacklist[0]),
+                                    sizeof(blacklist[0]),
+                                    sr_ptrstrcmp);
+
+        /* do not drop frames belonging to a module */
+        if (!frame->module_name && in_blacklist)
+        {
+            bool success = sr_koops_stacktrace_remove_frame(stacktrace, frame);
+            assert(success || !"failed to remove frame");
+        }
+
+        frame = next_frame;
+    }
+}
diff --git a/lib/normalize.c b/lib/normalize.c
index 7cd8144..6a8c351 100644
--- a/lib/normalize.c
+++ b/lib/normalize.c
@@ -21,8 +21,6 @@
 #include "gdb/frame.h"
 #include "gdb/thread.h"
 #include "gdb/stacktrace.h"
-#include "koops/frame.h"
-#include "koops/stacktrace.h"
 #include "utils.h"
 #include <string.h>
 #include <assert.h>
@@ -380,66 +378,6 @@ sr_normalize_gdb_stacktrace(struct sr_gdb_stacktrace *stacktrace)
     }
 }
 
-void
-sr_normalize_koops_stacktrace(struct sr_koops_stacktrace *stacktrace)
-{
-    /* Normalize function names by removing the suffixes identified by
-     * the dot character.
-     */
-    struct sr_koops_frame *frame = stacktrace->frames;
-    while (frame)
-    {
-        if (frame->function_name)
-        {
-            char *dot = strchr(frame->function_name, '.');
-            if (dot)
-                *dot = '\0';
-        }
-
-        frame = frame->next;
-    }
-
-    /* Remove blacklisted frames. */
-    /* !!! MUST BE SORTED !!! */
-    const char *blacklist[] = {
-        "do_softirq",
-        "do_vfs_ioctl",
-        "flush_kthread_worker",
-        "gs_change",
-        "irq_exit",
-        "kernel_thread_helper",
-        "kthread",
-        "process_one_work",
-        "system_call_fastpath",
-        "warn_slowpath_common",
-        "warn_slowpath_fmt",
-        "warn_slowpath_fmt_taint",
-        "warn_slowpath_null",
-        "worker_thread"
-    };
-
-    frame = stacktrace->frames;
-    while (frame)
-    {
-        struct sr_koops_frame *next_frame = frame->next;
-
-        bool in_blacklist = bsearch(&frame->function_name,
-                                    blacklist,
-                                    sizeof(blacklist) / sizeof(blacklist[0]),
-                                    sizeof(blacklist[0]),
-                                    sr_ptrstrcmp);
-
-        /* do not drop frames belonging to a module */
-        if (!frame->module_name && in_blacklist)
-        {
-            bool success = sr_koops_stacktrace_remove_frame(stacktrace, frame);
-            assert(success || !"failed to remove frame");
-        }
-
-        frame = next_frame;
-    }
-}
-
 static bool
 next_functions_similar(struct sr_gdb_frame *frame1,
                        struct sr_gdb_frame *frame2)
-- 
1.7.11.7



More information about the Crash-catcher mailing list