labels in dwarf

Jim Keniston jkenisto@us.ibm.com
Thu Mar 10 15:18:00 GMT 2005


I took an AR from this morning's meeting to see whether C labels are
recorded in the dwarf debug info.  It appears that they are, even if
they're not referenced.  For example, when the following code is
compiled with
	cc -g -S tossme.c
all three labels (with their corresponding instruction addresses) show
up in the debug info (even though 'done' isn't referenced).

int
sum(int a, int b)
{
        if (a < 0)
                goto nega;
        if (b < 0)
                goto negb;
done:
        return a + b;
nega:
        return -1;
negb:
        return -2;
}

However, if you throw in -O, the nega and negb labels both map to the
leave instruction; the return value is stored in %eax even before the "<
0" test is executed.  So, as was suggested this morning, the
label-to-instruction mapping may be surprising when you optimize.

Jim Keniston
IBM LTC-RAS




More information about the Systemtap mailing list