svn commit: r244692 - head/lib/libproc/test/t1-bkpt
Sergey Kandaurov
pluknet at freebsd.org
Wed Dec 26 05:20:16 UTC 2012
On 26 December 2012 09:11, Sergey Kandaurov <pluknet at freebsd.org> wrote:
> Author: pluknet
> Date: Wed Dec 26 05:11:48 2012
> New Revision: 244692
> URL: http://svnweb.freebsd.org/changeset/base/244692
>
> Log:
> Fix libproc test case to work with clang premature optimization
> observed with -O2 (used by default).
> Avoid function inlining for t1_bkpt_t on which we set a breakpoint.
> Otherwise the address of the function is never called thus the
> breakpoint never triggers.
>
> Reported by: zont
> Reviewed by: rpaulo
>
> Modified:
> head/lib/libproc/test/t1-bkpt/t1-bkpt.c
>
> Modified: head/lib/libproc/test/t1-bkpt/t1-bkpt.c
> ==============================================================================
> --- head/lib/libproc/test/t1-bkpt/t1-bkpt.c Tue Dec 25 23:34:20 2012 (r244691)
> +++ head/lib/libproc/test/t1-bkpt/t1-bkpt.c Wed Dec 26 05:11:48 2012 (r244692)
> @@ -36,7 +36,7 @@
> #include <string.h>
> #include <libproc.h>
>
> -int
> +int __noinline
> t1_bkpt_t()
> {
> printf("TEST OK\n");
This can be demonstrated with the generated code diff:
0000000000400b20 <main>:
400b20: 55 push %rbp
400b21: 48 89 e5 mov %rsp,%rbp
400b24: 48 8b 3e mov (%rsi),%rdi
- 400b27: be a9 0b 40 00 mov $0x400ba9,%esi
+ 400b27: be a0 0b 40 00 mov $0x400ba0,%esi
400b2c: e8 bb fc ff ff callq 4007ec <strcmp at plt>
400b31: 85 c0 test %eax,%eax
400b33: 74 07 je 400b3c <main+0x1c>
400b35: e8 f6 fe ff ff callq 400a30 <t1_bkpt_d>
- 400b3a: eb 05 jmp 400b41 <main+0x21>
- 400b3c: e8 df fe ff ff callq 400a20 <t1_bkpt_t>
- 400b41: 31 c0 xor %eax,%eax
- 400b43: 5d pop %rbp
- 400b44: c3 retq
- 400b45: 90 nop
- 400b46: 90 nop
- 400b47: 90 nop
- 400b48: 90 nop
- 400b49: 90 nop
+ 400b3a: eb 0a jmp 400b46 <main+0x26>
+ 400b3c: bf c3 0b 40 00 mov $0x400bc3,%edi
+ 400b41: e8 b6 fc ff ff callq 4007fc <puts at plt>
+ 400b46: 31 c0 xor %eax,%eax
+ 400b48: 5d pop %rbp
+ 400b49: c3 retq
400b4a: 90 nop
400b4b: 90 nop
400b4c: 90 nop
400b4d: 90 nop
400b4e: 90 nop
400b4f: 90 nop
--
wbr,
pluknet
More information about the svn-src-head
mailing list