[SATYR PATCH 2/6] Add fingerprint_hashed to core frame json

Martin Milata mmilata at redhat.com
Wed Aug 7 15:53:21 UTC 2013


Assume that fingerprints are hashed by default, unhashed are mainly
useful for debugging anyway.

Fingerprint hashing was introduced in commit
6de14b079f3022c2012cbc64ea75bcf918051430.

Signed-off-by: Martin Milata <mmilata at redhat.com>
---
 lib/core_fingerprint.c |  1 +
 lib/core_frame.c       | 22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/core_fingerprint.c b/lib/core_fingerprint.c
index af33a93..a3e580b 100644
--- a/lib/core_fingerprint.c
+++ b/lib/core_fingerprint.c
@@ -477,6 +477,7 @@ compute_fingerprint(struct sr_core_frame *frame,
     }
 
     frame->fingerprint = sr_strbuf_free_nobuf(fingerprint);
+    frame->fingerprint_hashed = false;
     sr_disasm_instructions_free(instructions);
     return true;
 }
diff --git a/lib/core_frame.c b/lib/core_frame.c
index bb4f576..f8c201d 100644
--- a/lib/core_frame.c
+++ b/lib/core_frame.c
@@ -72,7 +72,7 @@ sr_core_frame_init(struct sr_core_frame *frame)
     frame->function_name = NULL;
     frame->file_name = NULL;
     frame->fingerprint = NULL;
-    frame->fingerprint_hashed = false;
+    frame->fingerprint_hashed = true;
     frame->next = NULL;
     frame->type = SR_REPORT_CORE;
 }
@@ -352,6 +352,23 @@ sr_core_frame_from_json(struct sr_json_value *root,
         break;
     }
 
+    /* Read fingerprint_hashed. */
+    for (unsigned i = 0; i < root->u.object.length; ++i)
+    {
+        if (0 != strcmp("fingerprint_hashed", root->u.object.values[i].name))
+            continue;
+
+        if (root->u.object.values[i].value->type != SR_JSON_BOOLEAN)
+        {
+            *error_message = sr_strdup("Invalid type of \"fingerprint_hashed\"; bool expected.");
+            sr_core_frame_free(result);
+            return NULL;
+        }
+
+        result->fingerprint_hashed = root->u.object.values[i].value->u.boolean;
+        break;
+    }
+
     return result;
 }
 
@@ -400,6 +417,9 @@ sr_core_frame_to_json(struct sr_core_frame *frame)
         sr_strbuf_append_str(strbuf, ",   \"fingerprint\": ");
         sr_json_append_escaped(strbuf, frame->fingerprint);
         sr_strbuf_append_str(strbuf, "\n");
+
+        if (frame->fingerprint_hashed == false)
+            sr_strbuf_append_str(strbuf, ",   \"fingerprint_hashed\": false\n");
     }
 
     if (strbuf->len > 0)
-- 
1.8.3.1



More information about the Crash-catcher mailing list