summaryrefslogtreecommitdiffstats
path: root/loc2c.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2009-12-09 17:30:52 -0800
committerRoland McGrath <roland@redhat.com>2009-12-09 17:30:52 -0800
commitb25c01a187d636f1bd3c8c414e7dbe3e84c1b266 (patch)
tree0770fab418cc7a18b16436200c58892414233049 /loc2c.c
parent268c22b1917243cf1c02f8e1ca39ee83c7297ccc (diff)
downloadsystemtap-steved-b25c01a187d636f1bd3c8c414e7dbe3e84c1b266.tar.gz
systemtap-steved-b25c01a187d636f1bd3c8c414e7dbe3e84c1b266.tar.xz
systemtap-steved-b25c01a187d636f1bd3c8c414e7dbe3e84c1b266.zip
Begin to parameterize loc2c for proper DWARF target address size.
* loc2c.c (stack_slot_type): New function. (translate): Use it in place of STACK_TYPE and UTYPE macros. (emit_loc_address, emit_loc_value, c_emit_location): Likewise.
Diffstat (limited to 'loc2c.c')
-rw-r--r--loc2c.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/loc2c.c b/loc2c.c
index 008d5a42..d3ec55fa 100644
--- a/loc2c.c
+++ b/loc2c.c
@@ -76,6 +76,15 @@ struct location
};
};
+/* Select the C type to use in the emitted code to represent slots in the
+ DWARF expression stack. For really proper semantics this should be the
+ target address size. */
+static const char *
+stack_slot_type (struct location *context __attribute__ ((unused)), bool sign)
+{
+ return sign ? STACK_TYPE : UTYPE;
+}
+
static struct location *
alloc_location (struct obstack *pool, struct location *origin)
{
@@ -491,7 +500,8 @@ translate (struct obstack *pool, int indent, Dwarf_Addr addrbias,
POP (b);
POP (a);
push ("(%s) " STACKFMT " >> (%s)" STACKFMT,
- UTYPE, a, UTYPE, b);
+ stack_slot_type (loc, true), a,
+ stack_slot_type (loc, true), b);
break;
}
@@ -2187,7 +2197,8 @@ emit_loc_address (FILE *out, struct location *loc, unsigned int indent,
else
{
emit ("%*s{\n", indent * 2, "");
- emit ("%*s%s " STACKFMT, (indent + 1) * 2, "", STACK_TYPE, 0);
+ emit ("%*s%s " STACKFMT, (indent + 1) * 2, "",
+ stack_slot_type (loc, false), 0);
unsigned i;
for (i = 1; i < loc->address.stack_depth; ++i)
emit (", " STACKFMT, i);
@@ -2207,7 +2218,7 @@ emit_loc_value (FILE *out, struct location *loc, unsigned int indent,
bool *used_deref, unsigned int *max_stack)
{
if (declare)
- emit ("%*s%s %s;\n", indent * 2, "", STACK_TYPE, target);
+ emit ("%*s%s %s;\n", indent * 2, "", stack_slot_type (loc, false), target);
emit_header (out, loc, indent++);
@@ -2260,7 +2271,7 @@ c_emit_location (FILE *out, struct location *loc, int indent,
{
if (l->byte_size == 0 || l->byte_size == (Dwarf_Word) -1)
emit ("%*s%s %s;\n", (indent + 1) * 2, "",
- STACK_TYPE, l->address.declare);
+ stack_slot_type (l, false), l->address.declare);
else
emit ("%*suint%" PRIu64 "_t %s;\n", (indent + 1) * 2, "",
l->byte_size * 8, l->address.declare);