[SATYR PATCH 7/9] Add normalize method to thread

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


Signed-off-by: Martin Milata <mmilata at redhat.com>
---
 include/thread.h        |  7 +++++++
 lib/core_thread.c       |  2 ++
 lib/gdb_thread.c        |  1 +
 lib/generic_thread.c    | 12 ++++++++++++
 lib/generic_thread.h    |  5 +++++
 lib/java_thread.c       |  1 +
 lib/koops_stacktrace.c  |  1 +
 lib/python_stacktrace.c |  1 +
 8 files changed, 30 insertions(+)

diff --git a/include/thread.h b/include/thread.h
index 56bf1b5..c62c08f 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -118,6 +118,13 @@ sr_thread_remove_frames_above(struct sr_thread *thread, struct sr_frame *frame);
 struct sr_thread *
 sr_thread_dup(struct sr_thread *thread);
 
+/**
+ * Normalizes thread for deduplication/clustering. The normalization consists
+ * of removing useless frames and changing names of others.
+ */
+void
+sr_thread_normalize(struct sr_thread *thread);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/core_thread.c b/lib/core_thread.c
index d6e62b2..fc5f9e7 100644
--- a/lib/core_thread.c
+++ b/lib/core_thread.c
@@ -25,6 +25,7 @@
 #include "generic_thread.h"
 #include "stacktrace.h"
 #include "internal_utils.h"
+#include "normalize.h"
 #include <string.h>
 
 /* Method table */
@@ -50,6 +51,7 @@ struct thread_methods core_thread_methods =
     .remove_frames_above =
         (remove_frames_above_fn_t) thread_remove_frames_above,
     .thread_dup = (thread_dup_fn_t) core_dup,
+    .normalize = (normalize_fn_t) sr_normalize_core_thread,
 };
 
 /* Public functions */
diff --git a/lib/gdb_thread.c b/lib/gdb_thread.c
index dc34320..ec08609 100644
--- a/lib/gdb_thread.c
+++ b/lib/gdb_thread.c
@@ -58,6 +58,7 @@ struct thread_methods gdb_thread_methods =
     .remove_frames_above =
         (remove_frames_above_fn_t) thread_remove_frames_above,
     .thread_dup = (thread_dup_fn_t) gdb_dup,
+    .normalize = (normalize_fn_t) sr_normalize_gdb_thread,
 };
 
 /* Public functions */
diff --git a/lib/generic_thread.c b/lib/generic_thread.c
index c9ff98a..4b17a63 100644
--- a/lib/generic_thread.c
+++ b/lib/generic_thread.c
@@ -111,6 +111,12 @@ thread_no_bthash_text(struct sr_thread *thread, enum sr_bthash_flags flags,
     /* nop */
 }
 
+void
+thread_no_normalization(struct sr_thread *thread)
+{
+    /* nop */
+}
+
 /* Initialize dispatch table. */
 
 /* Table that maps type-specific functions to the corresponding report types.
@@ -201,3 +207,9 @@ sr_thread_dup(struct sr_thread *thread)
 {
     return DISPATCH(dtable, thread->type, thread_dup)(thread);
 }
+
+void
+sr_thread_normalize(struct sr_thread *thread)
+{
+    DISPATCH(dtable, thread->type, normalize)(thread);
+}
diff --git a/lib/generic_thread.h b/lib/generic_thread.h
index 3914212..005e5ac 100644
--- a/lib/generic_thread.h
+++ b/lib/generic_thread.h
@@ -34,6 +34,7 @@ typedef void (*set_next_thread_fn_t)(struct sr_thread*, struct sr_thread*);
 typedef void (*thread_append_bthash_text_fn_t)(struct sr_thread*, enum sr_bthash_flags,
                                                struct sr_strbuf*);
 typedef void (*thread_free_fn_t)(struct sr_thread*);
+typedef void (*normalize_fn_t)(struct sr_thread*);
 typedef bool (*remove_frame_fn_t)(struct sr_thread*, struct sr_frame*);
 typedef bool (*remove_frames_above_fn_t)(struct sr_thread*, struct sr_frame*);
 typedef struct sr_thread* (*thread_dup_fn_t)(struct sr_thread*);
@@ -48,6 +49,7 @@ struct thread_methods
     set_next_thread_fn_t set_next;
     thread_append_bthash_text_fn_t thread_append_bthash_text;
     thread_free_fn_t thread_free;
+    normalize_fn_t normalize;
     remove_frame_fn_t remove_frame;
     remove_frames_above_fn_t remove_frames_above;
     thread_dup_fn_t thread_dup;
@@ -87,6 +89,9 @@ void
 thread_no_bthash_text(struct sr_thread *thread, enum sr_bthash_flags flags,
                       struct sr_strbuf *strbuf);
 
+void
+thread_no_normalization(struct sr_thread *thread);
+
 /* Uses dispatch table but not intended for public use. */
 void
 thread_append_bthash_text(struct sr_thread *thread, enum sr_bthash_flags flags,
diff --git a/lib/java_thread.c b/lib/java_thread.c
index 644ac34..9f6145d 100644
--- a/lib/java_thread.c
+++ b/lib/java_thread.c
@@ -58,6 +58,7 @@ struct thread_methods java_thread_methods =
     .remove_frames_above =
         (remove_frames_above_fn_t) thread_remove_frames_above,
     .thread_dup = (thread_dup_fn_t) java_dup,
+    .normalize = (normalize_fn_t) thread_no_normalization,
 };
 
 /* Public functions */
diff --git a/lib/koops_stacktrace.c b/lib/koops_stacktrace.c
index ab62598..4ba74db 100644
--- a/lib/koops_stacktrace.c
+++ b/lib/koops_stacktrace.c
@@ -78,6 +78,7 @@ struct thread_methods koops_thread_methods =
     .remove_frames_above =
         (remove_frames_above_fn_t) thread_remove_frames_above,
     .thread_dup = (thread_dup_fn_t) sr_koops_stacktrace_dup,
+    .normalize = (normalize_fn_t) sr_normalize_koops_stacktrace,
 };
 
 struct stacktrace_methods koops_stacktrace_methods =
diff --git a/lib/python_stacktrace.c b/lib/python_stacktrace.c
index 15bb41c..b7c69cf 100644
--- a/lib/python_stacktrace.c
+++ b/lib/python_stacktrace.c
@@ -57,6 +57,7 @@ struct thread_methods python_thread_methods =
     .remove_frames_above =
         (remove_frames_above_fn_t) thread_remove_frames_above,
     .thread_dup = (thread_dup_fn_t) sr_python_stacktrace_dup,
+    .normalize = (normalize_fn_t) thread_no_normalization,
 };
 
 struct stacktrace_methods python_stacktrace_methods =
-- 
1.7.11.7



More information about the Crash-catcher mailing list