public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* possible loc2c problem, DW_OP_rot
@ 2013-01-05  2:47 Frank Ch. Eigler
  2013-01-05 10:18 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Ch. Eigler @ 2013-01-05  2:47 UTC (permalink / raw)
  To: mjw; +Cc: systemtap

Hi, Mark -

A particularly wildcardy stap script generates this little ditty:

static void function__dwarf_tvar_get_num_155657 (struct context* __restrict__ c) {
[...]
  {
    uintptr_t addr;
    { // DWARF expression: 0x70 0x38 0x14 0x14 0x24 0xa(65535) 0x1a 0x17 0x16 0xa(65535) 0x1a 0x16 0x1f 0x23(16) 0x25 0x21 0xa(65535) 0x1a 0x9f
      {
        uintptr_t s0, s1, s2, s3;
        s0 = fetch_register (0) + 0L;
        s1 = 8L;
        s2 = s0;
        s3 = s1;
        s2 = s2 << s3;
        s3 = 65535L;
        s2 = s2 & s3;
        s3 = s2, s2 = s1, s1 = s0, s4294967295 = s3;
        s3 = s2, s2 = s1, s1 = s3;
        s3 = 65535L;
        s2 = s2 & s3;
        s3 = s2, s2 = s1, s1 = s3;
        s2 = - (s2);
        s2 = s2 + 16UL;
        s1 = s1 >> s2;
        s0 = s0 | s1;
        s1 = 65535L;
        s0 = s0 & s1;
        addr = s0;
      }
    }

Note the DW_OP_rot ditty, 0x17, where a nonexistent variable
s4294967295 is used.  gcc (via stap -p4) barfs at that point.

Looking at loc2c.c:551,

    551         case DW_OP_rot:
    552           if (stack_depth < 3)
    553             goto underflow;
    554           deepen ();            /* Use a temporary slot.  */
    555           emit ("%*s"
    556                 STACKFMT " = " STACKFMT ", "
    557                 STACKFMT " = " STACKFMT ", "
    558                 STACKFMT " = " STACKFMT ", "
    559                 STACKFMT " = " STACKFMT ";\n",
    560                 indent * 2, "",
    561                 STACK (-1), STACK (0),
    562                 STACK (0), STACK (1),
    563                 STACK (1), STACK (2),
    564                 STACK (3), STACK (-1));
    565           break;

that pattern of STACK(...) numbers looks wrong.  Should that last line have
STACK (2) instead of STACK (3)?

- FChE

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: possible loc2c problem, DW_OP_rot
  2013-01-05  2:47 possible loc2c problem, DW_OP_rot Frank Ch. Eigler
@ 2013-01-05 10:18 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2013-01-05 10:18 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: systemtap

On Fri, Jan 04, 2013 at 09:47:06PM -0500, Frank Ch. Eigler wrote:
> A particularly wildcardy stap script generates this little ditty:
> 
> static void function__dwarf_tvar_get_num_155657 (struct context* __restrict__ c) {
> [...]
>   {
>     uintptr_t addr;
>     { // DWARF expression: 0x70 0x38 0x14 0x14 0x24 0xa(65535) 0x1a 0x17 0x16 0xa(65535) 0x1a 0x16 0x1f 0x23(16) 0x25 0x21 0xa(65535) 0x1a 0x9f

Nice DWARF expression :)
I really should push my elfutils libdw dwarfstrings patch again,
the above is somewhat hard to translate by hand.

> Note the DW_OP_rot ditty, 0x17, where a nonexistent variable
> s4294967295 is used.  gcc (via stap -p4) barfs at that point.
> 
> Looking at loc2c.c:551,
> 
>     551         case DW_OP_rot:
>     552           if (stack_depth < 3)
>     553             goto underflow;
>     554           deepen ();            /* Use a temporary slot.  */
>     555           emit ("%*s"
>     556                 STACKFMT " = " STACKFMT ", "
>     557                 STACKFMT " = " STACKFMT ", "
>     558                 STACKFMT " = " STACKFMT ", "
>     559                 STACKFMT " = " STACKFMT ";\n",
>     560                 indent * 2, "",
>     561                 STACK (-1), STACK (0),
>     562                 STACK (0), STACK (1),
>     563                 STACK (1), STACK (2),
>     564                 STACK (3), STACK (-1));
>     565           break;
> 
> that pattern of STACK(...) numbers looks wrong.  Should that last line have
> STACK (2) instead of STACK (3)?

Certainly looks so. Do you happen to have the test binary/script.
Would be good to turn that into a testcase. Apparently we never
saw a DW_OP_rot before. I see the runtime unwinder doesn't even
support it. So if it can also happen in CFI then we should also
add support there.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-05 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-05  2:47 possible loc2c problem, DW_OP_rot Frank Ch. Eigler
2013-01-05 10:18 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).