Frank Ch Eigler writes:

> Hi, Lluís -
>> I've attached both. BTW, I'm using debian's gcc 6.1.1-1.

> Thank you.  Those both look just fine, argh.  Could you try using
> gdb's "static probe points" facility to break at the same point, to
> see if the arguments are accessible?

> https://sourceware.org/gdb/onlinedocs/gdb/Static-Probe-Points.html

> Maybe provide a disassembly of the two functions of that binary, just
> to confirm that the numeric parameters are being passed?

Everything seems correct (gdb 7.11.1-2), so either the kernel or systemtap are
garbling up the arguments when retrieving them, or systemtap gets confused and
gets them from the wrong place.

$ gdb ./test
(gdb) break main
(gdb) run
Starting program: /home/lluis/tmp/systemtap/test 

Breakpoint 3, main (argc=1, argv=0x7fffffffe168) at test.c:12
12          f(1, 1);

# just in case, I made sure the program is loaded

(gdb) disassemble main
Dump of assembler code for function main:
   0x000000000040050f <+0>:     push   %rbp
   0x0000000000400510 <+1>:     mov    %rsp,%rbp
   0x0000000000400513 <+4>:     sub    $0x10,%rsp
   0x0000000000400517 <+8>:     mov    %edi,-0x4(%rbp)
   0x000000000040051a <+11>:    mov    %rsi,-0x10(%rbp)
=> 0x000000000040051e <+15>:    mov    $0x1,%esi
   0x0000000000400523 <+20>:    mov    $0x1,%edi
   0x0000000000400528 <+25>:    callq  0x4004e6 <f>
   0x000000000040052d <+30>:    mov    $0x2,%esi
   0x0000000000400532 <+35>:    mov    $0x2,%edi
   0x0000000000400537 <+40>:    callq  0x4004e6 <f>
   0x000000000040053c <+45>:    mov    $0x0,%eax
   0x0000000000400541 <+50>:    leaveq 
   0x0000000000400542 <+51>:    retq   
(gdb) disassemble f
Dump of assembler code for function f:
   0x00000000004004e6 <+0>:     push   %rbp
   0x00000000004004e7 <+1>:     mov    %rsp,%rbp
   0x00000000004004ea <+4>:     sub    $0x10,%rsp
   0x00000000004004ee <+8>:     mov    %edi,-0x4(%rbp)
   0x00000000004004f1 <+11>:    mov    %esi,-0x8(%rbp)
   0x00000000004004f4 <+14>:    nop
   0x00000000004004f5 <+15>:    mov    -0x8(%rbp),%edx
   0x00000000004004f8 <+18>:    mov    -0x4(%rbp),%eax
   0x00000000004004fb <+21>:    mov    %eax,%esi
   0x00000000004004fd <+23>:    mov    $0x4005d4,%edi
   0x0000000000400502 <+28>:    mov    $0x0,%eax
   0x0000000000400507 <+33>:    callq  0x4003c0 <printf@plt>
   0x000000000040050c <+38>:    nop
   0x000000000040050d <+39>:    leaveq 
   0x000000000040050e <+40>:    retq   
(gdb) info probes
Type Provider Name Where              Semaphore          Object                 
        
stap test     f    0x00000000004004f4 0x0000000000600988 
/home/lluis/tmp/systemtap/test 
(gdb) enable probes test
Probe test:f cannot be enabled.
(gdb) b -probe test:f
Breakpoint 1 at 0x4004f4
(gdb) info b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004004f4 -probe test:f
(gdb) c
Continuing.

Breakpoint 1, f (a1=1, a2=1) at test.c:6
6           TEST_F(a1, a2);
(gdb) p $rsi
$1 = 1
(gdb) p $rdi
$2 = 1
(gdb) c
Continuing.
a1=1 a2=1

Breakpoint 1, f (a1=2, a2=2) at test.c:6
6           TEST_F(a1, a2);
(gdb) p $rsi
$3 = 2
(gdb) p $rdi
$4 = 2
(gdb) c
Continuing.
a1=2 a2=2
[Inferior 1 (process 30372) exited normally]


Thanks,
  Lluis

Reply via email to