Replies: 3 comments
-
Here's my bpftrace info
|
Beta Was this translation helpful? Give feedback.
-
Compile with
$ gcc uprobe.c -o uprobe
$ objdump -d uprobe In assembly code, 00000000000011c9 <test>:
11c9: f3 0f 1e fa endbr64
11cd: 55 push %rbp
11ce: 48 89 e5 mov %rsp,%rbp
11d1: 48 83 ec 10 sub $0x10,%rsp
11d5: 89 7d fc mov %edi,-0x4(%rbp)
11d8: e8 e3 fe ff ff call 10c0 <rand@plt>
11dd: 48 63 d0 movslq %eax,%rdx
11e0: 48 69 d2 d3 4d 62 10 imul $0x10624dd3,%rdx,%rdx
11e7: 48 c1 ea 20 shr $0x20,%rdx
11eb: c1 fa 06 sar $0x6,%edx
11ee: 89 c1 mov %eax,%ecx
11f0: c1 f9 1f sar $0x1f,%ecx
11f3: 29 ca sub %ecx,%edx
11f5: 69 ca e8 03 00 00 imul $0x3e8,%edx,%ecx
11fb: 29 c8 sub %ecx,%eax
11fd: 89 c2 mov %eax,%edx
11ff: 89 d0 mov %edx,%eax
1201: 89 c7 mov %eax,%edi
1203: e8 c8 fe ff ff call 10d0 <usleep@plt>
1208: e8 b3 fe ff ff call 10c0 <rand@plt>
120d: 89 c2 mov %eax,%edx
120f: 48 63 c2 movslq %edx,%rax
1212: 48 69 c0 67 66 66 66 imul $0x66666667,%rax,%rax
1219: 48 c1 e8 20 shr $0x20,%rax
121d: c1 f8 02 sar $0x2,%eax
1220: 89 d6 mov %edx,%esi
1222: c1 fe 1f sar $0x1f,%esi
1225: 29 f0 sub %esi,%eax
1227: 89 c1 mov %eax,%ecx
1229: 89 c8 mov %ecx,%eax
122b: c1 e0 02 shl $0x2,%eax
122e: 01 c8 add %ecx,%eax
1230: 01 c0 add %eax,%eax
1232: 89 d1 mov %edx,%ecx
1234: 29 c1 sub %eax,%ecx
1236: 8b 45 fc mov -0x4(%rbp),%eax
1239: 01 c8 add %ecx,%eax
123b: c9 leave
123c: c3 ret
000000000000123d <t1>:
123d: f3 0f 1e fa endbr64
1241: 55 push %rbp
1242: 48 89 e5 mov %rsp,%rbp
1245: 48 83 ec 10 sub $0x10,%rsp
1249: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%rbp)
1250: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
1257: eb 11 jmp 126a <t1+0x2d>
1259: 8b 45 fc mov -0x4(%rbp),%eax
125c: 89 c7 mov %eax,%edi
125e: e8 66 ff ff ff call 11c9 <test>
1263: 01 45 f8 add %eax,-0x8(%rbp)
1266: 83 45 fc 01 addl $0x1,-0x4(%rbp)
126a: 83 7d fc 09 cmpl $0x9,-0x4(%rbp)
126e: 7e e9 jle 1259 <t1+0x1c>
1270: 8b 45 f8 mov -0x8(%rbp),%eax
1273: 89 c6 mov %eax,%esi
1275: 48 8d 05 88 0d 00 00 lea 0xd88(%rip),%rax # 2004 <_IO_stdin_used+0x4>
127c: 48 89 c7 mov %rax,%rdi
127f: b8 00 00 00 00 mov $0x0,%eax
1284: e8 07 fe ff ff call 1090 <printf@plt>
1289: 90 nop
128a: c9 leave
128b: c3 ret
$ gcc -O2 uprobe.c -o uprobe.o2
$ objdump -d uprobe.o2 In assembly code, 0000000000001200 <test>:
1200: f3 0f 1e fa endbr64
1204: 53 push %rbx
1205: 89 fb mov %edi,%ebx
1207: e8 b4 fe ff ff call 10c0 <rand@plt>
120c: 48 63 d0 movslq %eax,%rdx
120f: 89 c1 mov %eax,%ecx
1211: 48 69 d2 d3 4d 62 10 imul $0x10624dd3,%rdx,%rdx
1218: c1 f9 1f sar $0x1f,%ecx
121b: 48 c1 fa 26 sar $0x26,%rdx
121f: 29 ca sub %ecx,%edx
1221: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
1227: 29 d0 sub %edx,%eax
1229: 89 c7 mov %eax,%edi
122b: e8 a0 fe ff ff call 10d0 <usleep@plt>
1230: e8 8b fe ff ff call 10c0 <rand@plt>
1235: 48 63 d0 movslq %eax,%rdx
1238: 89 c1 mov %eax,%ecx
123a: 48 69 d2 67 66 66 66 imul $0x66666667,%rdx,%rdx
1241: c1 f9 1f sar $0x1f,%ecx
1244: 48 c1 fa 22 sar $0x22,%rdx
1248: 29 ca sub %ecx,%edx
124a: 8d 14 92 lea (%rdx,%rdx,4),%edx
124d: 01 d2 add %edx,%edx
124f: 29 d0 sub %edx,%eax
1251: 01 d8 add %ebx,%eax
1253: 5b pop %rbx
1254: c3 ret
1255: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
125c: 00 00 00 00
0000000000001260 <t1>:
1260: f3 0f 1e fa endbr64
1264: 41 54 push %r12
1266: 45 31 e4 xor %r12d,%r12d
1269: 53 push %rbx
126a: 31 db xor %ebx,%ebx
126c: 48 83 ec 08 sub $0x8,%rsp
1270: e8 4b fe ff ff call 10c0 <rand@plt>
1275: 48 63 d0 movslq %eax,%rdx
1278: 89 c1 mov %eax,%ecx
127a: 48 69 d2 d3 4d 62 10 imul $0x10624dd3,%rdx,%rdx
1281: c1 f9 1f sar $0x1f,%ecx
1284: 48 c1 fa 26 sar $0x26,%rdx
1288: 29 ca sub %ecx,%edx
128a: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
1290: 29 d0 sub %edx,%eax
1292: 89 c7 mov %eax,%edi
1294: e8 37 fe ff ff call 10d0 <usleep@plt>
1299: e8 22 fe ff ff call 10c0 <rand@plt>
129e: 48 63 d0 movslq %eax,%rdx
12a1: 89 c1 mov %eax,%ecx
12a3: 48 69 d2 67 66 66 66 imul $0x66666667,%rdx,%rdx
12aa: c1 f9 1f sar $0x1f,%ecx
12ad: 48 c1 fa 22 sar $0x22,%rdx
12b1: 29 ca sub %ecx,%edx
12b3: 8d 14 92 lea (%rdx,%rdx,4),%edx
12b6: 01 d2 add %edx,%edx
12b8: 29 d0 sub %edx,%eax
12ba: 01 d8 add %ebx,%eax
12bc: 83 c3 01 add $0x1,%ebx
12bf: 41 01 c4 add %eax,%r12d
12c2: 83 fb 0a cmp $0xa,%ebx
12c5: 75 a9 jne 1270 <t1+0x10>
12c7: 48 83 c4 08 add $0x8,%rsp
12cb: 44 89 e2 mov %r12d,%edx
12ce: 48 8d 35 2f 0d 00 00 lea 0xd2f(%rip),%rsi # 2004 <_IO_stdin_used+0x4>
12d5: 31 c0 xor %eax,%eax
12d7: 5b pop %rbx
12d8: bf 01 00 00 00 mov $0x1,%edi
12dd: 41 5c pop %r12
12df: e9 cc fd ff ff jmp 10b0 <__printf_chk@plt>
Change source code $ gcc -O2 uprobe.c
$ objdump -d a.out In assembly code, 0000000000001200 <test>:
1200: f3 0f 1e fa endbr64
1204: 53 push %rbx
1205: 89 fb mov %edi,%ebx
1207: e8 b4 fe ff ff call 10c0 <rand@plt>
120c: 48 63 d0 movslq %eax,%rdx
120f: 89 c1 mov %eax,%ecx
1211: 48 69 d2 d3 4d 62 10 imul $0x10624dd3,%rdx,%rdx
1218: c1 f9 1f sar $0x1f,%ecx
121b: 48 c1 fa 26 sar $0x26,%rdx
121f: 29 ca sub %ecx,%edx
1221: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
1227: 29 d0 sub %edx,%eax
1229: 89 c7 mov %eax,%edi
122b: e8 a0 fe ff ff call 10d0 <usleep@plt>
1230: e8 8b fe ff ff call 10c0 <rand@plt>
1235: 48 63 d0 movslq %eax,%rdx
1238: 89 c1 mov %eax,%ecx
123a: 48 69 d2 67 66 66 66 imul $0x66666667,%rdx,%rdx
1241: c1 f9 1f sar $0x1f,%ecx
1244: 48 c1 fa 22 sar $0x22,%rdx
1248: 29 ca sub %ecx,%edx
124a: 8d 14 92 lea (%rdx,%rdx,4),%edx
124d: 01 d2 add %edx,%edx
124f: 29 d0 sub %edx,%eax
1251: 01 d8 add %ebx,%eax
1253: 5b pop %rbx
1254: c3 ret
1255: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
125c: 00 00 00 00
0000000000001260 <t1>:
1260: f3 0f 1e fa endbr64
1264: 41 54 push %r12
1266: 45 31 e4 xor %r12d,%r12d
1269: 53 push %rbx
126a: 31 db xor %ebx,%ebx
126c: 48 83 ec 08 sub $0x8,%rsp
1270: 89 df mov %ebx,%edi
1272: 83 c3 01 add $0x1,%ebx
1275: e8 86 ff ff ff call 1200 <test>
127a: 41 01 c4 add %eax,%r12d
127d: 83 fb 0a cmp $0xa,%ebx
1280: 75 ee jne 1270 <t1+0x10>
1282: 48 83 c4 08 add $0x8,%rsp
1286: 44 89 e2 mov %r12d,%edx
1289: 48 8d 35 74 0d 00 00 lea 0xd74(%rip),%rsi # 2004 <_IO_stdin_used+0x4>
1290: 31 c0 xor %eax,%eax
1292: 5b pop %rbx
1293: bf 01 00 00 00 mov $0x1,%edi
1298: 41 5c pop %r12
129a: e9 11 fe ff ff jmp 10b0 <__printf_chk@plt> and triggers $ sudo bpftrace uprobe.bt
Attaching 3 probes...
stacktrace:
test+0
input=0,output=5, time: 1126 us
... |
Beta Was this translation helpful? Give feedback.
-
The good news is that we're just about to get support for tracing inlined functions! #3095
This is a longstanding bug (#646) - because we attach our uprobe at the first instruction of the |
Beta Was this translation helpful? Give feedback.
-
Hello. Here's my simple c program.
And bpftrace scripts:
When I compile without optimization, it can output almost normally(why is
t1
missing in ustack ?):But when compiled with optimization, it shows no output:
Why is that ? I don't think the symobl
test
is optimized out, it's still there innm
output.Beta Was this translation helpful? Give feedback.
All reactions