Blame SOURCES/satyr-0.13-abrt-refactorize-unwinding-from-core-hook.patch

01add4
From 89e0a7d0a195605585b80157ce23be1fb03f04a2 Mon Sep 17 00:00:00 2001
01add4
From: Jakub Filak <jfilak@redhat.com>
01add4
Date: Wed, 13 May 2015 10:45:32 +0200
01add4
Subject: [PATCH] abrt: refactorize unwinding from core hook
01add4
01add4
ABRT needs to save files from its core hook with O_EXCL and with right
01add4
mode and owner and there might be more constraints ABRT needs to
01add4
respect in future.
01add4
01add4
This patch breaks granularity of the abrt functions to allow ABRT to save the
01add4
core backtrace data in the way it need by providing a function returning
01add4
the data instead of directly saving the data to a file.
01add4
01add4
Signed-off-by: Jakub Filak <jfilak@redhat.com>
01add4
---
01add4
 include/abrt.h |  6 ++++++
01add4
 lib/abrt.c     | 29 ++++++++++++++++++++++-------
01add4
 2 files changed, 28 insertions(+), 7 deletions(-)
01add4
01add4
diff --git a/include/abrt.h b/include/abrt.h
01add4
index 5116446..ca0748c 100644
01add4
--- a/include/abrt.h
01add4
+++ b/include/abrt.h
01add4
@@ -44,6 +44,12 @@ sr_abrt_create_core_stacktrace_from_gdb(const char *directory,
01add4
                                         bool hash_fingerprints,
01add4
                                         char **error_message);
01add4
 
01add4
+char *
01add4
+sr_abrt_get_core_stacktrace_from_core_hook(pid_t thread_id,
01add4
+                                           const char *executable,
01add4
+                                           int signum,
01add4
+                                           char **error_message);
01add4
+
01add4
 bool
01add4
 sr_abrt_create_core_stacktrace_from_core_hook(const char *directory,
01add4
                                               pid_t thread_id,
01add4
diff --git a/lib/abrt.c b/lib/abrt.c
01add4
index 86e9082..4599e2c 100644
01add4
--- a/lib/abrt.c
01add4
+++ b/lib/abrt.c
01add4
@@ -162,12 +162,11 @@ sr_abrt_create_core_stacktrace(const char *directory,
01add4
                                   error_message);
01add4
 }
01add4
 
01add4
-bool
01add4
-sr_abrt_create_core_stacktrace_from_core_hook(const char *directory,
01add4
-                                              pid_t thread_id,
01add4
-                                              const char *executable,
01add4
-                                              int signum,
01add4
-                                              char **error_message)
01add4
+char *
01add4
+sr_abrt_get_core_stacktrace_from_core_hook(pid_t thread_id,
01add4
+                                           const char *executable,
01add4
+                                           int signum,
01add4
+                                           char **error_message)
01add4
 {
01add4
 
01add4
     struct sr_core_stacktrace *core_stacktrace;
01add4
@@ -180,12 +179,29 @@ sr_abrt_create_core_stacktrace_from_core_hook(const char *directory,
01add4
     fulfill_missing_values(core_stacktrace);
01add4
 
01add4
     char *json = sr_core_stacktrace_to_json(core_stacktrace);
01add4
+    sr_core_stacktrace_free(core_stacktrace);
01add4
 
01add4
     // Add newline to the end of core stacktrace file to make text
01add4
     // editors happy.
01add4
     json = sr_realloc(json, strlen(json) + 2);
01add4
     strcat(json, "\n");
01add4
 
01add4
+    return json;
01add4
+;
01add4
+}
01add4
+
01add4
+bool
01add4
+sr_abrt_create_core_stacktrace_from_core_hook(const char *directory,
01add4
+                                              pid_t thread_id,
01add4
+                                              const char *executable,
01add4
+                                              int signum,
01add4
+                                              char **error_message)
01add4
+{
01add4
+    char *json = sr_abrt_get_core_stacktrace_from_core_hook(thread_id,
01add4
+                                                            executable,
01add4
+                                                            signum,
01add4
+                                                            error_message);
01add4
+
01add4
     char *core_backtrace_filename = sr_build_path(directory, "core_backtrace", NULL);
01add4
     bool success = sr_string_to_file(core_backtrace_filename,
01add4
                                     json,
01add4
@@ -193,7 +209,6 @@ sr_abrt_create_core_stacktrace_from_core_hook(const char *directory,
01add4
 
01add4
     free(core_backtrace_filename);
01add4
     free(json);
01add4
-    sr_core_stacktrace_free(core_stacktrace);
01add4
     return success;
01add4
 }
01add4
 
01add4
-- 
01add4
2.4.3
01add4