summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroland <roland>2005-08-18 08:51:30 +0000
committerroland <roland>2005-08-18 08:51:30 +0000
commit4b1ad75ead48645adb7f8e6115aff95b76c2f32a (patch)
tree2f019f41fcd767cc373eafb902a8b1492c4f4f6f
parent52e9954ec3b3944aa489f514f434cdab64330979 (diff)
downloadsystemtap-steved-4b1ad75ead48645adb7f8e6115aff95b76c2f32a.tar.gz
systemtap-steved-4b1ad75ead48645adb7f8e6115aff95b76c2f32a.tar.xz
systemtap-steved-4b1ad75ead48645adb7f8e6115aff95b76c2f32a.zip
2005-08-18 Roland McGrath <roland@redhat.com>
* loc2c.c (struct location): New member `emit_address'. (alloc_location): Initialize new member from ORIGIN. (location_from_address): New argument EMIT_ADDRESS. Initialize new member. (translate): Use LOC->emit_address hook to format DW_OP_addr constant. (location_relative): Die if DW_OP_addr is used. (default_emit_address): New function. (c_translate_location): New argument EMIT_ADDRESS, pass it down. Use default_emit_address if argument is null. * loc2c.h: Update decl. * loc2c-test.c (handle_variable): Update caller. * tapsets.cxx (dwflpp::literal_stmt_for_local): Update caller. (dwflpp::loc2c_emit_address): New static method.
-rw-r--r--loc2c-test.c6
-rw-r--r--loc2c.c31
-rw-r--r--loc2c.h3
-rw-r--r--tapsets.cxx15
4 files changed, 46 insertions, 9 deletions
diff --git a/loc2c-test.c b/loc2c-test.c
index aab92144..26734096 100644
--- a/loc2c-test.c
+++ b/loc2c-test.c
@@ -85,7 +85,8 @@ 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, &fail, NULL, 1, cubias, &attr_mem, pc,
+ head = c_translate_location (&pool, &fail, NULL, NULL,
+ 1, cubias, &attr_mem, pc,
&tail, fb_attr);
if (dwarf_attr_integrate (vardie, DW_AT_type, &attr_mem) == NULL)
@@ -176,7 +177,8 @@ handle_variable (Dwarf_Die *scopes, int nscopes, int out,
*fields, dwarf_errmsg (-1));
}
else
- c_translate_location (&pool, NULL, NULL, 1, cubias, &attr_mem, pc,
+ c_translate_location (&pool, NULL, NULL, NULL,
+ 1, cubias, &attr_mem, pc,
&tail, NULL);
++fields;
break;
diff --git a/loc2c.c b/loc2c.c
index 2a3c3a61..45c965aa 100644
--- a/loc2c.c
+++ b/loc2c.c
@@ -26,6 +26,7 @@ struct location
void (*fail) (void *arg, const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 2, 3)));
void *fail_arg;
+ void (*emit_address) (void *fail_arg, struct obstack *, Dwarf_Addr);
const Dwarf_Loc *ops;
size_t nops;
@@ -53,11 +54,19 @@ alloc_location (struct obstack *pool, struct location *origin)
struct location *loc = obstack_alloc (pool, sizeof *loc);
loc->fail = origin->fail;
loc->fail_arg = origin->fail_arg;
+ loc->emit_address = origin->emit_address;
return loc;
}
#define FAIL(loc, fmt, ...) \
(*(loc)->fail) ((loc)->fail_arg, fmt, ## __VA_ARGS__)
+
+static void
+default_emit_address (void *fail_arg __attribute__ ((unused)),
+ struct obstack *pool, Dwarf_Addr address)
+{
+ obstack_printf (pool, AFORMAT, address);
+}
static const char *
dwarf_diename_integrate (Dwarf_Die *die)
@@ -338,7 +347,10 @@ translate (struct obstack *pool, int indent, Dwarf_Addr addrbias,
/* Constant-value operations. */
case DW_OP_addr:
- push (AFORMAT, addrbias + expr[i].number);
+ emit ("%*s" STACKFMT " = ", indent * 2, "", PUSH);
+ (*loc->emit_address) (loc->fail_arg, pool,
+ addrbias + expr[i].number);
+ emit (";\n");
break;
case DW_OP_lit0 ... DW_OP_lit31:
@@ -510,8 +522,10 @@ translate (struct obstack *pool, int indent, Dwarf_Addr addrbias,
static struct location *
location_from_address (struct obstack *pool,
void (*fail) (void *arg, const char *fmt, ...)
- __attribute__ ((noreturn, format (printf, 2, 3))),
+ __attribute__ ((noreturn, format (printf, 2, 3))),
void *fail_arg,
+ void (*emit_address) (void *fail_arg,
+ struct obstack *, Dwarf_Addr),
int indent, Dwarf_Addr dwbias,
const Dwarf_Loc *expr, size_t len, Dwarf_Addr address,
struct location **input, Dwarf_Attribute *fb_attr)
@@ -519,6 +533,7 @@ location_from_address (struct obstack *pool,
struct location *loc = obstack_alloc (pool, sizeof *loc);
loc->fail = *input == NULL ? fail : (*input)->fail;
loc->fail_arg = *input == NULL ? fail_arg : (*input)->fail_arg;
+ loc->emit_address = *input == NULL ? emit_address : (*input)->emit_address;
bool need_fb = false;
size_t loser;
@@ -707,12 +722,13 @@ location_relative (struct obstack *pool,
/* This started from a register, but now it's following a pointer.
So we can do the translation starting from address here. */
- return location_from_address (pool, NULL, NULL, indent, dwbias,
+ return location_from_address (pool, NULL, NULL, NULL, indent, dwbias,
expr, len, address, input, fb_attr);
/* Constant-value operations. */
case DW_OP_addr:
+ DIE ("static calculation depends on load-time address");
push (dwbias + expr[i].number);
break;
@@ -863,7 +879,7 @@ location_relative (struct obstack *pool,
/* This expression keeps going, but further
computations now have an address to start with.
So we can punt to the address computation generator. */
- loc = location_from_address (pool, NULL, NULL,
+ loc = location_from_address (pool, NULL, NULL, NULL,
indent, dwbias,
&expr[i + 1], len - i - 1,
address, input, fb_attr);
@@ -943,6 +959,8 @@ c_translate_location (struct obstack *pool,
void (*fail) (void *arg, const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 2, 3))),
void *fail_arg,
+ void (*emit_address) (void *fail_arg,
+ struct obstack *, Dwarf_Addr),
int indent, Dwarf_Addr dwbias,
Dwarf_Attribute *loc_attr, Dwarf_Addr address,
struct location **input, Dwarf_Attribute *fb_attr)
@@ -976,8 +994,9 @@ c_translate_location (struct obstack *pool,
case loc_address:
/* We have a previous address computation.
This expression will compute starting with that on the stack. */
- return location_from_address (pool, fail, fail_arg, indent,
- dwbias, expr, len, address,
+ return location_from_address (pool, fail, fail_arg,
+ emit_address ?: &default_emit_address,
+ indent, dwbias, expr, len, address,
input, fb_attr);
case loc_noncontiguous:
diff --git a/loc2c.h b/loc2c.h
index c8cfb935..a92e7bfd 100644
--- a/loc2c.h
+++ b/loc2c.h
@@ -22,6 +22,9 @@ struct location *c_translate_location (struct obstack *,
__attribute__ ((noreturn,
format (printf, 2, 3))),
void *fail_arg,
+ void (*emit_address) (void *fail_arg,
+ struct obstack *,
+ Dwarf_Addr),
int indent,
Dwarf_Addr bias,
Dwarf_Attribute *loc_attr,
diff --git a/tapsets.cxx b/tapsets.cxx
index da16750a..88369d55 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -28,6 +28,9 @@ extern "C" {
#include <elf.h>
#include <obstack.h>
#include "loc2c.h"
+
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
}
#include <fnmatch.h>
@@ -639,6 +642,15 @@ dwflpp
throw semantic_error (msg);
}
+ static void loc2c_emit_address (void *arg, struct obstack *pool,
+ Dwarf_Addr address)
+ {
+ dwflpp *dwfl = (dwflpp *) arg;
+ obstack_printf (pool, "%#" PRIx64 "UL /* hard-coded %s address */",
+ address, dwfl_module_info (dwfl->module, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL));
+ }
+
string literal_stmt_for_local(Dwarf_Addr pc,
string const & local,
vector<pair<target_symbol::component_type,
@@ -703,6 +715,7 @@ dwflpp
obstack_init (&pool);
struct location *tail = NULL;
struct location *head = c_translate_location (&pool, &loc2c_error, this,
+ &loc2c_emit_address,
1, module_bias,
&attr_mem, pc,
&tail, fb_attr);
@@ -780,7 +793,7 @@ dwflpp
+ " :" + string(dwarf_errmsg (-1)));
}
else
- c_translate_location (&pool, NULL, NULL, 1,
+ c_translate_location (&pool, NULL, NULL, NULL, 1,
module_bias, &attr_mem, pc,
&tail, NULL);
++i;