Martin Milata
2013-08-20 16:40:33 UTC
Related to #94.
Signed-off-by: Martin Milata <mmilata-H+wXaHxf7aLQT0dZR+***@public.gmane.org>
---
lib/core_stacktrace.c | 10 +++-------
lib/core_unwind.c | 16 +---------------
lib/core_unwind_libunwind.c | 1 +
lib/gdb_frame.c | 9 +++------
lib/internal_unwind.h | 3 ---
lib/internal_utils.h | 4 ++++
lib/utils.c | 15 +++++++++++++++
7 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/lib/core_stacktrace.c b/lib/core_stacktrace.c
index 6534ce1..2b94d58 100644
--- a/lib/core_stacktrace.c
+++ b/lib/core_stacktrace.c
@@ -336,11 +336,8 @@ sr_core_stacktrace_create(const char *gdb_stacktrace_text,
if (!gdb_stacktrace)
{
- if (sr_debug_parser)
- {
- fprintf(stderr, "Unable to parse stacktrace: %d:%d: %s\n",
- location.line, location.column, location.message);
- }
+ warn("Unable to parse stacktrace: %d:%d: %s\n",
+ location.line, location.column, location.message);
return NULL;
}
@@ -349,8 +346,7 @@ sr_core_stacktrace_create(const char *gdb_stacktrace_text,
struct sr_unstrip_entry *unstrip = sr_unstrip_parse(unstrip_text);
if (!unstrip)
{
- if (sr_debug_parser)
- fprintf(stderr, "Unable to parse unstrip output.");
+ warn("Unable to parse unstrip output.");
return NULL;
}
diff --git a/lib/core_unwind.c b/lib/core_unwind.c
index 1268bfc..9597c75 100644
--- a/lib/core_unwind.c
+++ b/lib/core_unwind.c
@@ -29,6 +29,7 @@
#include "utils.h"
#include "core/unwind.h"
#include "internal_unwind.h"
+#include "internal_utils.h"
#include "location.h"
#include "gdb/frame.h"
@@ -69,21 +70,6 @@ _set_error(char **error_msg, const char *fmt, ...)
}
void
-warn(const char *fmt, ...)
-{
- va_list ap;
-
- if (!sr_debug_parser)
- return;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-
-}
-
-void
core_handle_free(struct core_handle *ch)
{
if (ch)
diff --git a/lib/core_unwind_libunwind.c b/lib/core_unwind_libunwind.c
index 221e968..966a5b9 100644
--- a/lib/core_unwind_libunwind.c
+++ b/lib/core_unwind_libunwind.c
@@ -22,6 +22,7 @@
#include "core/thread.h"
#include "core/stacktrace.h"
#include "internal_unwind.h"
+#include "internal_utils.h"
#ifdef WITH_LIBUNWIND
diff --git a/lib/gdb_frame.c b/lib/gdb_frame.c
index 7cf0287..57e9479 100644
--- a/lib/gdb_frame.c
+++ b/lib/gdb_frame.c
@@ -338,12 +338,9 @@ sr_gdb_frame_parse(const char **input,
++local_input;
}
- if (sr_debug_parser)
- {
- printf("frame #%u %s\n",
- header->number,
- header->function_name ? header->function_name : "signal handler called");
- }
+ warn("frame #%u %s\n",
+ header->number,
+ header->function_name ? header->function_name : "signal handler called");
*input = local_input;
return header;
diff --git a/lib/internal_unwind.h b/lib/internal_unwind.h
index 3aa2b63..d537f86 100644
--- a/lib/internal_unwind.h
+++ b/lib/internal_unwind.h
@@ -52,9 +52,6 @@
void
_set_error(char **error_msg, const char *fmt, ...) __sr_printf(2, 3);
-void
-warn(const char *fmt, ...) __sr_printf(1, 2);
-
/* internal linked list manipulation */
#define list_append(head,tail,item) \
do{ \
diff --git a/lib/internal_utils.h b/lib/internal_utils.h
index faa42be..e69fb97 100644
--- a/lib/internal_utils.h
+++ b/lib/internal_utils.h
@@ -20,9 +20,13 @@
#ifndef SATYR_INTERNAL_UTILS_H
#define SATYR_INTERNAL_UTILS_H
+#include "utils.h"
#include <stddef.h>
#include <assert.h>
+void
+warn(const char *fmt, ...) __sr_printf(1, 2);
+
#define DISPATCH(table, type, method) \
(assert((type > SR_REPORT_INVALID) && (type) < SR_REPORT_NUM && table[type]->method), \
table[type]->method)
diff --git a/lib/utils.c b/lib/utils.c
index ac56c7e..206c1fa 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -37,6 +37,21 @@ sr_debug_parser = false;
static const char
hexdigits_locase[] = "0123456789abcdef";
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (!sr_debug_parser)
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+
+}
+
void *
sr_malloc(size_t size)
{
Signed-off-by: Martin Milata <mmilata-H+wXaHxf7aLQT0dZR+***@public.gmane.org>
---
lib/core_stacktrace.c | 10 +++-------
lib/core_unwind.c | 16 +---------------
lib/core_unwind_libunwind.c | 1 +
lib/gdb_frame.c | 9 +++------
lib/internal_unwind.h | 3 ---
lib/internal_utils.h | 4 ++++
lib/utils.c | 15 +++++++++++++++
7 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/lib/core_stacktrace.c b/lib/core_stacktrace.c
index 6534ce1..2b94d58 100644
--- a/lib/core_stacktrace.c
+++ b/lib/core_stacktrace.c
@@ -336,11 +336,8 @@ sr_core_stacktrace_create(const char *gdb_stacktrace_text,
if (!gdb_stacktrace)
{
- if (sr_debug_parser)
- {
- fprintf(stderr, "Unable to parse stacktrace: %d:%d: %s\n",
- location.line, location.column, location.message);
- }
+ warn("Unable to parse stacktrace: %d:%d: %s\n",
+ location.line, location.column, location.message);
return NULL;
}
@@ -349,8 +346,7 @@ sr_core_stacktrace_create(const char *gdb_stacktrace_text,
struct sr_unstrip_entry *unstrip = sr_unstrip_parse(unstrip_text);
if (!unstrip)
{
- if (sr_debug_parser)
- fprintf(stderr, "Unable to parse unstrip output.");
+ warn("Unable to parse unstrip output.");
return NULL;
}
diff --git a/lib/core_unwind.c b/lib/core_unwind.c
index 1268bfc..9597c75 100644
--- a/lib/core_unwind.c
+++ b/lib/core_unwind.c
@@ -29,6 +29,7 @@
#include "utils.h"
#include "core/unwind.h"
#include "internal_unwind.h"
+#include "internal_utils.h"
#include "location.h"
#include "gdb/frame.h"
@@ -69,21 +70,6 @@ _set_error(char **error_msg, const char *fmt, ...)
}
void
-warn(const char *fmt, ...)
-{
- va_list ap;
-
- if (!sr_debug_parser)
- return;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-
-}
-
-void
core_handle_free(struct core_handle *ch)
{
if (ch)
diff --git a/lib/core_unwind_libunwind.c b/lib/core_unwind_libunwind.c
index 221e968..966a5b9 100644
--- a/lib/core_unwind_libunwind.c
+++ b/lib/core_unwind_libunwind.c
@@ -22,6 +22,7 @@
#include "core/thread.h"
#include "core/stacktrace.h"
#include "internal_unwind.h"
+#include "internal_utils.h"
#ifdef WITH_LIBUNWIND
diff --git a/lib/gdb_frame.c b/lib/gdb_frame.c
index 7cf0287..57e9479 100644
--- a/lib/gdb_frame.c
+++ b/lib/gdb_frame.c
@@ -338,12 +338,9 @@ sr_gdb_frame_parse(const char **input,
++local_input;
}
- if (sr_debug_parser)
- {
- printf("frame #%u %s\n",
- header->number,
- header->function_name ? header->function_name : "signal handler called");
- }
+ warn("frame #%u %s\n",
+ header->number,
+ header->function_name ? header->function_name : "signal handler called");
*input = local_input;
return header;
diff --git a/lib/internal_unwind.h b/lib/internal_unwind.h
index 3aa2b63..d537f86 100644
--- a/lib/internal_unwind.h
+++ b/lib/internal_unwind.h
@@ -52,9 +52,6 @@
void
_set_error(char **error_msg, const char *fmt, ...) __sr_printf(2, 3);
-void
-warn(const char *fmt, ...) __sr_printf(1, 2);
-
/* internal linked list manipulation */
#define list_append(head,tail,item) \
do{ \
diff --git a/lib/internal_utils.h b/lib/internal_utils.h
index faa42be..e69fb97 100644
--- a/lib/internal_utils.h
+++ b/lib/internal_utils.h
@@ -20,9 +20,13 @@
#ifndef SATYR_INTERNAL_UTILS_H
#define SATYR_INTERNAL_UTILS_H
+#include "utils.h"
#include <stddef.h>
#include <assert.h>
+void
+warn(const char *fmt, ...) __sr_printf(1, 2);
+
#define DISPATCH(table, type, method) \
(assert((type > SR_REPORT_INVALID) && (type) < SR_REPORT_NUM && table[type]->method), \
table[type]->method)
diff --git a/lib/utils.c b/lib/utils.c
index ac56c7e..206c1fa 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -37,6 +37,21 @@ sr_debug_parser = false;
static const char
hexdigits_locase[] = "0123456789abcdef";
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (!sr_debug_parser)
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+
+}
+
void *
sr_malloc(size_t size)
{
--
1.8.3.1
1.8.3.1