From e36387d7f8597e307927a8d7e1bd5d216d52e3db Mon Sep 17 00:00:00 2001 From: roland Date: Thu, 18 Aug 2005 03:41:29 +0000 Subject: 2005-08-17 Roland McGrath PR systemtap/1197 * loc2c.c (struct location): New members `fail', `fail_arg'. (alloc_location): New function. Initialize those members. (new_synthetic_loc, translate): Use that instead of obstack_alloc. (location_from_address, location_relative): Likewise. (FAIL): New macro. Use it everywhere in place of `error'. * loc2c-test.c (fail): New function. (handle_variable): Pass it to c_translate_location. * tapsets.cxx (dwflpp::loc2c_error): New static method. (dwflpp::literal_stmt_for_local): Pass it to to c_translate_location. --- loc2c-test.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'loc2c-test.c') diff --git a/loc2c-test.c b/loc2c-test.c index 05f51c25..aab92144 100644 --- a/loc2c-test.c +++ b/loc2c-test.c @@ -14,7 +14,8 @@ #include #include #include - +#include +#include #include "loc2c.h" #define _(msg) msg @@ -27,6 +28,19 @@ dwarf_diename_integrate (Dwarf_Die *die) } +static void __attribute__ ((noreturn)) +fail (void *arg __attribute__ ((unused)), const char *fmt, ...) +{ + va_list ap; + + fprintf (stderr, "%s: ", program_invocation_short_name); + + va_start (ap, fmt); + vfprintf (stderr, _(fmt), ap); + va_end (ap); + + exit (2); +} static void handle_variable (Dwarf_Die *scopes, int nscopes, int out, @@ -71,7 +85,7 @@ handle_variable (Dwarf_Die *scopes, int nscopes, int out, #define emit(fmt, ...) printf (" addr = " fmt "\n", ## __VA_ARGS__) struct location *head, *tail = NULL; - head = c_translate_location (&pool, 1, cubias, &attr_mem, pc, + head = c_translate_location (&pool, &fail, NULL, 1, cubias, &attr_mem, pc, &tail, fb_attr); if (dwarf_attr_integrate (vardie, DW_AT_type, &attr_mem) == NULL) @@ -162,7 +176,7 @@ handle_variable (Dwarf_Die *scopes, int nscopes, int out, *fields, dwarf_errmsg (-1)); } else - c_translate_location (&pool, 1, cubias, &attr_mem, pc, + c_translate_location (&pool, NULL, NULL, 1, cubias, &attr_mem, pc, &tail, NULL); ++fields; break; -- cgit