Files
third_party_elfutils/tests/testfile_parameter_ref.c
Mark Wielaard 6e6e54e12a tests: Add new varlocs test for dwarf_getlocation* functions.
This tests the new dwarf_getlocations, dwarf_getlocation_attr and
dwarf_getlocation_die functions. But it is also an example of how
to handle location expressions and which libdw functions can be
used to access all information required to interpret each DW_OP.

It might make sense to extend this test/example into a program
that verifies various properties of DWARF expressions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-09-06 12:17:14 +02:00

21 lines
379 B
C

// gcc -g -O2 -o parameter_ref parameter_ref.c
volatile int vv;
/* Don't inline, but do allow clone to create specialized versions. */
static __attribute__((noinline)) int
foo (int x, int y, int z)
{
int a = x * 2;
int b = y * 2;
int c = z * 2;
vv++;
return x + z;
}
int
main (int x, char **argv)
{
return foo (x, 2, 3) + foo (x, 4, 3) + foo (x + 6, x, 3) + x;
}