|
|
f41043 |
From fa978bdd2c3a576df357ce7905b11b73810dc100 Mon Sep 17 00:00:00 2001
|
|
|
f41043 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
f41043 |
Date: Fri, 20 Jun 2014 20:42:00 +0200
|
|
|
f41043 |
Subject: [SATYR PATCH 2/6] Fix the compat version of duphash generation
|
|
|
f41043 |
|
|
|
f41043 |
sr_thread_get_duphash() must return NULL for oopses having no reliable
|
|
|
f41043 |
frame.
|
|
|
f41043 |
|
|
|
f41043 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
f41043 |
---
|
|
|
f41043 |
lib/generic_thread.c | 7 +++-
|
|
|
f41043 |
tests/koops_frame.at | 1 -
|
|
|
f41043 |
tests/koops_stacktrace.at | 83 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
f41043 |
tests/python/koops.py | 1 +
|
|
|
f41043 |
4 files changed, 90 insertions(+), 2 deletions(-)
|
|
|
f41043 |
|
|
|
f41043 |
diff --git a/lib/generic_thread.c b/lib/generic_thread.c
|
|
|
f41043 |
index b219f26..59fff1b 100644
|
|
|
f41043 |
--- a/lib/generic_thread.c
|
|
|
f41043 |
+++ b/lib/generic_thread.c
|
|
|
f41043 |
@@ -262,7 +262,12 @@ sr_thread_get_duphash(struct sr_thread *thread, int nframes, char *prefix,
|
|
|
f41043 |
nframes--;
|
|
|
f41043 |
}
|
|
|
f41043 |
|
|
|
f41043 |
- if (flags & SR_DUPHASH_NOHASH)
|
|
|
f41043 |
+ if ((flags & SR_DUPHASH_KOOPS_COMPAT) && strbuf->len == 0)
|
|
|
f41043 |
+ {
|
|
|
f41043 |
+ sr_strbuf_free(strbuf);
|
|
|
f41043 |
+ ret = NULL;
|
|
|
f41043 |
+ }
|
|
|
f41043 |
+ else if (flags & SR_DUPHASH_NOHASH)
|
|
|
f41043 |
ret = sr_strbuf_free_nobuf(strbuf);
|
|
|
f41043 |
else
|
|
|
f41043 |
{
|
|
|
f41043 |
diff --git a/tests/koops_frame.at b/tests/koops_frame.at
|
|
|
f41043 |
index be2cb11..4abc32a 100644
|
|
|
f41043 |
--- a/tests/koops_frame.at
|
|
|
f41043 |
+++ b/tests/koops_frame.at
|
|
|
f41043 |
@@ -288,4 +288,3 @@ main(void)
|
|
|
f41043 |
return 0;
|
|
|
f41043 |
}
|
|
|
f41043 |
]])
|
|
|
f41043 |
-
|
|
|
f41043 |
diff --git a/tests/koops_stacktrace.at b/tests/koops_stacktrace.at
|
|
|
f41043 |
index 404d53c..5e17ca7 100644
|
|
|
f41043 |
--- a/tests/koops_stacktrace.at
|
|
|
f41043 |
+++ b/tests/koops_stacktrace.at
|
|
|
f41043 |
@@ -730,3 +730,86 @@ main(void)
|
|
|
f41043 |
return 0;
|
|
|
f41043 |
}
|
|
|
f41043 |
]])
|
|
|
f41043 |
+
|
|
|
f41043 |
+## --------------------- ##
|
|
|
f41043 |
+## sr_thread_get_duphash ##
|
|
|
f41043 |
+## --------------------- ##
|
|
|
f41043 |
+
|
|
|
f41043 |
+AT_TESTFUN([sr_thread_get_duphash],
|
|
|
f41043 |
+[[
|
|
|
f41043 |
+#include "koops/stacktrace.h"
|
|
|
f41043 |
+#include "koops/frame.h"
|
|
|
f41043 |
+#include "thread.h"
|
|
|
f41043 |
+#include "utils.h"
|
|
|
f41043 |
+#include <assert.h>
|
|
|
f41043 |
+#include <stdlib.h>
|
|
|
f41043 |
+#include <stdio.h>
|
|
|
f41043 |
+
|
|
|
f41043 |
+void generate_and_test(struct sr_thread *thread, int flags, const char *expected)
|
|
|
f41043 |
+{
|
|
|
f41043 |
+ char *hash = sr_thread_get_duphash(thread, 1, NULL, flags);
|
|
|
f41043 |
+
|
|
|
f41043 |
+ if (NULL == hash && NULL != expected)
|
|
|
f41043 |
+ {
|
|
|
f41043 |
+ fprintf(stderr, "'%s' != NULL\n", expected);
|
|
|
f41043 |
+ assert(!"NULL was NOT expected");
|
|
|
f41043 |
+ }
|
|
|
f41043 |
+
|
|
|
f41043 |
+ if (NULL != hash && NULL == expected)
|
|
|
f41043 |
+ {
|
|
|
f41043 |
+ fprintf(stderr, "NULL != '%s'\n", hash);
|
|
|
f41043 |
+ assert(!"NULL was expected");
|
|
|
f41043 |
+ }
|
|
|
f41043 |
+
|
|
|
f41043 |
+ if (NULL == hash && NULL == expected)
|
|
|
f41043 |
+ return;
|
|
|
f41043 |
+
|
|
|
f41043 |
+ if (strcmp(hash, expected) != 0)
|
|
|
f41043 |
+ {
|
|
|
f41043 |
+ fprintf(stderr, "'%s' != '%s'\n", expected, hash);
|
|
|
f41043 |
+ //assert(!"Expected and hash are not equal");
|
|
|
f41043 |
+ }
|
|
|
f41043 |
+
|
|
|
f41043 |
+ free(hash);
|
|
|
f41043 |
+}
|
|
|
f41043 |
+
|
|
|
f41043 |
+void test(struct sr_thread *thread, const char *expected, const char *expected_compat)
|
|
|
f41043 |
+{
|
|
|
f41043 |
+ generate_and_test(thread, SR_DUPHASH_NOHASH, expected);
|
|
|
f41043 |
+ fprintf(stderr, "COMPAT\n");
|
|
|
f41043 |
+ generate_and_test(thread, SR_DUPHASH_NOHASH|SR_DUPHASH_KOOPS_COMPAT, expected_compat);
|
|
|
f41043 |
+}
|
|
|
f41043 |
+
|
|
|
f41043 |
+int main(void)
|
|
|
f41043 |
+{
|
|
|
f41043 |
+ struct sr_koops_stacktrace *stacktrace = sr_koops_stacktrace_new();
|
|
|
f41043 |
+ struct sr_thread *thread = (struct sr_thread *)stacktrace;
|
|
|
f41043 |
+
|
|
|
f41043 |
+ struct sr_koops_frame *frame = sr_koops_frame_new();
|
|
|
f41043 |
+ stacktrace->frames = frame;
|
|
|
f41043 |
+
|
|
|
f41043 |
+ frame->address = 0xDEADBEAF;
|
|
|
f41043 |
+
|
|
|
f41043 |
+ fprintf(stderr, "Checkpoint 1\n");
|
|
|
f41043 |
+ frame->reliable = 1;
|
|
|
f41043 |
+ test(thread, "Thread\n0xdeadbeaf\n", "0xdeadbeaf\n");
|
|
|
f41043 |
+
|
|
|
f41043 |
+ fprintf(stderr, "Checkpoint 2\n");
|
|
|
f41043 |
+ frame->reliable = 0;
|
|
|
f41043 |
+ test(thread, "Thread\n0xdeadbeaf\n", NULL);
|
|
|
f41043 |
+
|
|
|
f41043 |
+ frame->address = 0xDEADBEAF;
|
|
|
f41043 |
+ frame->function_name = sr_strdup("omg_warn_slowpath_common");
|
|
|
f41043 |
+ stacktrace->frames = frame;
|
|
|
f41043 |
+
|
|
|
f41043 |
+ fprintf(stderr, "Checkpoint 3\n");
|
|
|
f41043 |
+ frame->reliable = 1;
|
|
|
f41043 |
+ test(thread, "Thread\nomg_warn_slowpath_common\n", "omg_warn_slowpath_common\n");
|
|
|
f41043 |
+
|
|
|
f41043 |
+ fprintf(stderr, "Checkpoint 4\n");
|
|
|
f41043 |
+ frame->reliable = 0;
|
|
|
f41043 |
+ test(thread, "Thread\nomg_warn_slowpath_common\n", NULL);
|
|
|
f41043 |
+
|
|
|
f41043 |
+ return 0;
|
|
|
f41043 |
+}
|
|
|
f41043 |
+]])
|
|
|
f41043 |
diff --git a/tests/python/koops.py b/tests/python/koops.py
|
|
|
f41043 |
index 3f8fe57..0686b70 100755
|
|
|
f41043 |
--- a/tests/python/koops.py
|
|
|
f41043 |
+++ b/tests/python/koops.py
|
|
|
f41043 |
@@ -75,6 +75,7 @@ class TestKerneloops(BindingsTestCase):
|
|
|
f41043 |
compat_expected_plain)
|
|
|
f41043 |
self.assertEqual(self.koops.get_duphash(flags=satyr.DUPHASH_KOOPS_COMPAT, frames=6),
|
|
|
f41043 |
'5718b3a86c64e7bed5e8ead08ae3084e447ddbee')
|
|
|
f41043 |
+ self.assertRaises(RuntimeError, self.koops.get_duphash, flags=(satyr.DUPHASH_NOHASH|satyr.DUPHASH_KOOPS_COMPAT), frames=-1)
|
|
|
f41043 |
|
|
|
f41043 |
def test_crash_thread(self):
|
|
|
f41043 |
self.assertTrue(self.koops.crash_thread is self.koops)
|
|
|
f41043 |
--
|
|
|
f41043 |
1.9.3
|
|
|
f41043 |
|