summaryrefslogtreecommitdiffstats
path: root/loc2c.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-10-05 09:05:29 +0200
committerMark Wielaard <mjw@redhat.com>2009-10-05 09:05:29 +0200
commit73b5e9064aeb9d5b4862e8cf688f8048f9fce86a (patch)
tree7b53b2274e71e71a76b43f67b4a16bdd0fd8b592 /loc2c.c
parentee89e81c3f87c4eef2b677ed7e38092e3d2c5af9 (diff)
downloadsystemtap-steved-73b5e9064aeb9d5b4862e8cf688f8048f9fce86a.tar.gz
systemtap-steved-73b5e9064aeb9d5b4862e8cf688f8048f9fce86a.tar.xz
systemtap-steved-73b5e9064aeb9d5b4862e8cf688f8048f9fce86a.zip
Make sure loc2c declare_noncontig_union for different locs don't overlap.
* loc2c.c (declare_noncontig_union): Name union u_pieces for loc_noncontiguous or u_const for loc_constant. (translate_base_store): Use u_pieces for loc_noncontiguous. (translate_base_fetch): Likewise or u_const for loc_constant.
Diffstat (limited to 'loc2c.c')
-rw-r--r--loc2c.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/loc2c.c b/loc2c.c
index 9a2e475f..2a1d16e0 100644
--- a/loc2c.c
+++ b/loc2c.c
@@ -1528,7 +1528,17 @@ declare_noncontig_union (struct obstack *pool, int indent,
obstack_printf (pool, "%*suint%" PRIu64 "_t whole;\n",
indent * 2, "", loc->byte_size * 8);
- obstack_printf (pool, "%*s} u;\n", --indent * 2, "");
+ // Different loc types could be in the same syntactical scope, so
+ // should be named differently.
+ const char *uname;
+ if (loc->type == loc_noncontiguous)
+ uname = "u_pieces";
+ else if (loc->type == loc_constant)
+ uname = "u_const";
+ else
+ abort();
+
+ obstack_printf (pool, "%*s} %s;\n", --indent * 2, "", uname);
loc = new_synthetic_loc (pool, *input, false);
loc->type = loc_decl;
@@ -1610,7 +1620,7 @@ translate_base_fetch (struct obstack *pool, int indent,
declare_noncontig_union (pool, indent, input, *input);
Dwarf_Word offset = 0;
- char piece[sizeof "u.pieces.p" + 20] = "u.pieces.p";
+ char piece[sizeof "u_pieces.pieces.p" + 20] = "u_pieces.pieces.p";
while (p != NULL)
{
struct location *newp = obstack_alloc (pool, sizeof *newp);
@@ -1619,7 +1629,8 @@ translate_base_fetch (struct obstack *pool, int indent,
(*input)->next = newp;
*input = newp;
- snprintf (&piece[sizeof "u.pieces.p" - 1], 20, "%" PRIu64, offset);
+ snprintf (&piece[sizeof "u_pieces.pieces.p" - 1], 20,
+ "%" PRIu64, offset);
translate_base_fetch (pool, indent, p->byte_size, signed_p /* ? */,
input, piece);
(*input)->type = loc_fragment;
@@ -1628,7 +1639,8 @@ translate_base_fetch (struct obstack *pool, int indent,
p = p->next;
}
- obstack_printf (pool, "%*s%s = u.whole;\n", indent * 2, "", target);
+ obstack_printf (pool, "%*s%s = u_pieces.whole;\n", indent * 2,
+ "", target);
}
else if ((*input)->type == loc_constant)
{
@@ -1639,10 +1651,11 @@ translate_base_fetch (struct obstack *pool, int indent,
declare_noncontig_union (pool, indent, input, *input);
for (i = 0; i < byte_size; ++i)
- obstack_printf (pool, "%*su.bytes[%zu] = %#x;\n", indent * 2, "",
- i, constant_block[i]);
+ obstack_printf (pool, "%*su_const.bytes[%zu] = %#x;\n", indent * 2,
+ "", i, constant_block[i]);
- obstack_printf (pool, "%*s%s = u.whole;\n", indent * 2, "", target);
+ obstack_printf (pool, "%*s%s = u_const.whole;\n", indent * 2,
+ "", target);
}
else
switch (byte_size)
@@ -1748,14 +1761,15 @@ translate_base_store (struct obstack *pool, int indent, Dwarf_Word byte_size,
{
declare_noncontig_union (pool, indent, input, store_loc);
- obstack_printf (pool, "%*su.whole = %s;\n", indent * 2, "", rvalue);
+ obstack_printf (pool, "%*su_pieces.whole = %s;\n", indent * 2,
+ "", rvalue);
struct location *loc = new_synthetic_loc (pool, *input, deref);
loc->type = loc_fragment;
(*input)->next = loc;
*input = loc;
Dwarf_Word offset = 0;
- char piece[sizeof "u.pieces.p" + 20] = "u.pieces.p";
+ char piece[sizeof "u_pieces.pieces.p" + 20] = "u_pieces.pieces.p";
struct location *p;
for (p = store_loc->pieces; p != NULL; p = p->next)
{
@@ -1765,7 +1779,8 @@ translate_base_store (struct obstack *pool, int indent, Dwarf_Word byte_size,
(*input)->next = newp;
*input = newp;
- snprintf (&piece[sizeof "u.pieces.p" - 1], 20, "%" PRIu64, offset);
+ snprintf (&piece[sizeof "u_pieces.pieces.p" - 1], 20, "%" PRIu64,
+ offset);
translate_base_store (pool, indent,
p->byte_size, input, *input, piece);
(*input)->type = loc_fragment;