From 1fc0e782d56af4df3f21560929176a09103923ad Mon Sep 17 00:00:00 2001
From: Martin Milata <mmilata@redhat.com>
Date: Tue, 4 Nov 2014 16:51:24 +0100
Subject: [PATCH] koops: improve 'reason' text for page faults

Current : 'general protection fault: 4000 [#1] SMP'
Improved: 'general protection fault in i915_gem_do_execbuffer'

Resolves rhbz#998887.

Signed-off-by: Martin Milata <mmilata@redhat.com>
---
 src/plugins/oops-utils.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/plugins/oops-utils.c b/src/plugins/oops-utils.c
index 9e2355e..ea6c639 100644
--- a/src/plugins/oops-utils.c
+++ b/src/plugins/oops-utils.c
@@ -12,6 +12,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
+#include <satyr/stacktrace.h>
+
 #include "oops-utils.h"
 #include "libabrt.h"
 
@@ -242,8 +244,24 @@ void abrt_oops_save_data_in_dump_dir(struct dump_dir *dd, char *oops, const char
 
     // TODO: add "Kernel oops: " prefix, so that all oopses have recognizable FILENAME_REASON?
     // kernel oops 1st line may look quite puzzling otherwise...
-    strchrnul(second_line, '\n')[0] = '\0';
-    dd_save_text(dd, FILENAME_REASON, second_line);
+    char *reason_pretty = NULL;
+    char *error = NULL;
+    struct sr_stacktrace *trace = sr_stacktrace_parse(SR_REPORT_KERNELOOPS, second_line, &error);
+    if (trace)
+    {
+        reason_pretty = sr_stacktrace_get_reason(trace);
+        sr_stacktrace_free(trace);
+    }
+    else
+        free(error);
+
+    if (reason_pretty)
+    {
+        dd_save_text(dd, FILENAME_REASON, reason_pretty);
+        free(reason_pretty);
+    }
+    else
+        dd_save_text(dd, FILENAME_REASON, second_line);
 }
 
 int abrt_oops_signaled_sleep(int seconds)
-- 
2.1.0

