[SATYR PATCH] Fix broken sr_stacktrace_parse

Richard Marko rmarko at redhat.com
Wed Jun 26 11:28:24 UTC 2013


Pushed, thanks.

On 06/26/2013 11:54 AM, Martin Milata wrote:
> Did not work for any other crash types than "core" due to the wrong
> function being called.
>
> Signed-off-by: Martin Milata <mmilata at redhat.com>
> ---
>  lib/gdb_stacktrace.c      |  3 ++-
>  lib/generic_stacktrace.h  | 12 ++++++++----
>  lib/java_stacktrace.c     |  3 ++-
>  lib/koops_stacktrace.c    |  3 ++-
>  lib/python_stacktrace.c   |  3 ++-
>  tests/java_stacktrace.at  | 14 ++++++++++++++
>  tests/koops_stacktrace.at | 17 +++++++++++++++++
>  7 files changed, 47 insertions(+), 8 deletions(-)
>
> diff --git a/lib/gdb_stacktrace.c b/lib/gdb_stacktrace.c
> index 6e4dc29..b77898b 100644
> --- a/lib/gdb_stacktrace.c
> +++ b/lib/gdb_stacktrace.c
> @@ -43,10 +43,11 @@ gdb_return_null(struct sr_stacktrace *stacktrace)
>  
>  DEFINE_THREADS_FUNC(gdb_threads, struct sr_gdb_stacktrace)
>  DEFINE_SET_THREADS_FUNC(gdb_set_threads, struct sr_gdb_stacktrace)
> +DEFINE_PARSE_WRAPPER_FUNC(gdb_parse, SR_REPORT_GDB)
>  
>  struct stacktrace_methods gdb_stacktrace_methods =
>  {
> -    .parse = (parse_fn_t) stacktrace_parse_wrapper,
> +    .parse = (parse_fn_t) gdb_parse,
>      .parse_location = (parse_location_fn_t) sr_gdb_stacktrace_parse,
>      .to_short_text = (to_short_text_fn_t) sr_gdb_stacktrace_to_short_text,
>      .to_json = (to_json_fn_t) gdb_return_null,
> diff --git a/lib/generic_stacktrace.h b/lib/generic_stacktrace.h
> index 2c1f56d..bb6ba9f 100644
> --- a/lib/generic_stacktrace.h
> +++ b/lib/generic_stacktrace.h
> @@ -54,7 +54,14 @@ extern struct stacktrace_methods core_stacktrace_methods, python_stacktrace_meth
>  #define DEFINE_SET_THREADS_FUNC(name, concrete_t) \
>      DEFINE_SETTER(name, threads, struct sr_stacktrace, concrete_t, struct sr_thread)
>  
> -/* XXX generic functions */
> +#define DEFINE_PARSE_WRAPPER_FUNC(name, type)                        \
> +    static struct sr_stacktrace *                                    \
> +    name(const char **input, char **error_message)                   \
> +    {                                                                \
> +        return stacktrace_parse_wrapper(type, input, error_message); \
> +    }
> +
> +/* generic functions */
>  struct sr_stacktrace *
>  stacktrace_parse_wrapper(enum sr_report_type type, const char **input, char **error_message);
>  
> @@ -63,6 +70,3 @@ stacktrace_to_short_text(struct sr_stacktrace *stacktrace, int max_frames);
>  
>  struct sr_thread *
>  stacktrace_one_thread_only(struct sr_stacktrace *stacktrace);
> -
> -struct sr_stacktrace *
> -stacktrace_parse_wrapper(enum sr_report_type type, const char **input, char **error_message);
> diff --git a/lib/java_stacktrace.c b/lib/java_stacktrace.c
> index 0a7b583..b3231e7 100644
> --- a/lib/java_stacktrace.c
> +++ b/lib/java_stacktrace.c
> @@ -33,10 +33,11 @@
>  
>  DEFINE_THREADS_FUNC(java_threads, struct sr_java_stacktrace)
>  DEFINE_SET_THREADS_FUNC(java_set_threads, struct sr_java_stacktrace)
> +DEFINE_PARSE_WRAPPER_FUNC(java_parse, SR_REPORT_JAVA)
>  
>  struct stacktrace_methods java_stacktrace_methods =
>  {
> -    .parse = (parse_fn_t) stacktrace_parse_wrapper,
> +    .parse = (parse_fn_t) java_parse,
>      .parse_location = (parse_location_fn_t) sr_java_stacktrace_parse,
>      .to_short_text = (to_short_text_fn_t) stacktrace_to_short_text,
>      .to_json = (to_json_fn_t) sr_java_stacktrace_to_json,
> diff --git a/lib/koops_stacktrace.c b/lib/koops_stacktrace.c
> index 121c330..5ac3fdf 100644
> --- a/lib/koops_stacktrace.c
> +++ b/lib/koops_stacktrace.c
> @@ -58,6 +58,7 @@ struct sr_taint_flag sr_flags[] = {
>  
>  DEFINE_FRAMES_FUNC(koops_frames, struct sr_koops_stacktrace)
>  DEFINE_SET_FRAMES_FUNC(koops_set_frames, struct sr_koops_stacktrace)
> +DEFINE_PARSE_WRAPPER_FUNC(koops_parse, SR_REPORT_KERNELOOPS)
>  
>  struct thread_methods koops_thread_methods =
>  {
> @@ -71,7 +72,7 @@ struct thread_methods koops_thread_methods =
>  
>  struct stacktrace_methods koops_stacktrace_methods =
>  {
> -    .parse = (parse_fn_t) stacktrace_parse_wrapper,
> +    .parse = (parse_fn_t) koops_parse,
>      .parse_location = (parse_location_fn_t) sr_koops_stacktrace_parse,
>      .to_short_text = (to_short_text_fn_t) stacktrace_to_short_text,
>      .to_json = (to_json_fn_t) sr_koops_stacktrace_to_json,
> diff --git a/lib/python_stacktrace.c b/lib/python_stacktrace.c
> index 89a090c..3c1d030 100644
> --- a/lib/python_stacktrace.c
> +++ b/lib/python_stacktrace.c
> @@ -36,6 +36,7 @@
>  
>  DEFINE_FRAMES_FUNC(python_frames, struct sr_python_stacktrace)
>  DEFINE_SET_FRAMES_FUNC(python_set_frames, struct sr_python_stacktrace)
> +DEFINE_PARSE_WRAPPER_FUNC(python_parse, SR_REPORT_PYTHON)
>  
>  struct thread_methods python_thread_methods =
>  {
> @@ -49,7 +50,7 @@ struct thread_methods python_thread_methods =
>  
>  struct stacktrace_methods python_stacktrace_methods =
>  {
> -    .parse = (parse_fn_t) stacktrace_parse_wrapper,
> +    .parse = (parse_fn_t) python_parse,
>      .parse_location = (parse_location_fn_t) sr_python_stacktrace_parse,
>      .to_short_text = (to_short_text_fn_t) stacktrace_to_short_text,
>      .to_json = (to_json_fn_t) sr_python_stacktrace_to_json,
> diff --git a/tests/java_stacktrace.at b/tests/java_stacktrace.at
> index d38074c..be55703 100644
> --- a/tests/java_stacktrace.at
> +++ b/tests/java_stacktrace.at
> @@ -80,6 +80,7 @@ AT_TESTFUN([sr_java_stacktrace_parse],
>  #include "java/thread.h"
>  #include "java/frame.h"
>  #include "location.h"
> +#include "stacktrace.h"
>  #include <assert.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -102,6 +103,19 @@ check(char *input,
>    {
>      assert(*input == '\0');
>      assert(0 == sr_java_stacktrace_cmp(stacktrace, expected_stacktrace));
> +
> +    /* check sr_stacktrace_parse */
> +    char *error;
> +    input = old_input;
> +    struct sr_stacktrace *stacktrace2 = sr_stacktrace_parse(SR_REPORT_JAVA, &input, &error);
> +    assert(stacktrace2);
> +    char *json1 = sr_stacktrace_to_json(stacktrace);
> +    char *json2 = sr_stacktrace_to_json(stacktrace2);
> +    assert(json1 && json2 && 0 == strcmp(json1, json2));
> +    free(json1);
> +    free(json2);
> +    sr_stacktrace_free(stacktrace2);
> +
>      sr_java_stacktrace_free(stacktrace);
>    }
>    else
> diff --git a/tests/koops_stacktrace.at b/tests/koops_stacktrace.at
> index 86e694f..291b004 100644
> --- a/tests/koops_stacktrace.at
> +++ b/tests/koops_stacktrace.at
> @@ -101,6 +101,7 @@ AT_TESTFUN([sr_koops_stacktrace_parse],
>  #include "location.h"
>  #include "utils.h"
>  #include "thread.h"
> +#include "stacktrace.h"
>  #include <assert.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -177,6 +178,22 @@ check(const char *path,
>    }
>    assert(actual_module_count == module_count);
>  
> +  /* test parsing via sr_stacktrace_parse */
> +  input = full_input;
> +  char *error;
> +  struct sr_stacktrace *stacktrace2 = sr_stacktrace_parse(SR_REPORT_KERNELOOPS, &input, &error);
> +
> +  assert(stacktrace2);
> +  reason = sr_stacktrace_get_reason(stacktrace);
> +  reason2 = sr_stacktrace_get_reason(stacktrace2);
> +
> +  assert(reason && reason2);
> +  assert(0 == strcmp(reason, reason2));
> +
> +  free(reason);
> +  free(reason2);
> +  sr_stacktrace_free(stacktrace2);
> +
>    sr_koops_stacktrace_free(stacktrace);
>    free(full_input);
>  }


-- 
Richard Marko

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/crash-catcher/attachments/20130626/92c5444a/attachment-0001.html>


More information about the Crash-catcher mailing list