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

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