llvm-project/lldb/utils/test/main.c

15 lines
346 B
C
Raw Normal View History

#include <stdio.h>
Make 'run-until-faulted.py' script more interesting by modifying the example main.c program to seg fault randomly instead of deterministically. Example: [15:10:43] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ clang -g main.c [15:10:46] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ ./run-until-faulted.py -l $PWD/../../build/Debug/lldb -e a.out lldb command: /Volumes/data/lldb/svn/trunk/utils/test/../../build/Debug/lldb executable: a.out executable options: (lldb) sending 'file a.out' command... file a.out Current executable set to 'a.out' (x86_64). (lldb) sending 'process launch -- ' command... (iteration: 0) process launch -- Process 63630 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=9 Better luck next time! Process 63630 exited with status = 0 (0x00000000) (lldb) sending 'process launch -- ' command... (iteration: 1) process launch -- Process 63633 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Process 63633 exited with status = 0 (0x00000000) sending 'process launch -- ' command... (iteration: 2) Hello, fault! val=0 Better luck next time! (lldb) process launch -- Process 63637 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=15 Better luck next time! Process 63637 exited with status = 0 (0x00000000) (lldb) sending 'process launch -- ' command... (iteration: 3) process launch -- Process 63640 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=2 Better luck next time! Process 63640 exited with status = 0 (0x00000000) sending 'process launch -- ' command... (iteration: 4) (lldb) process launch -- Process 63643 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Process 63643 stopped * thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11 8 u_int32_t val = (arc4random() & 0x0f); 9 printf("val=%u\n", val); 10 if (val == 0x07) // Lucky 7 :-) -> 11 printf("Now segfault %d\n", *null_ptr); 12 else 13 printf("Better luck next time!\n"); 14 } (lldb) * thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11 8 u_int32_t val = (arc4random() & 0x0f); 9 printf("val=%u\n", val); 10 if (val == 0x07) // Lucky 7 :-) -> 11 printf("Now segfault %d\n", *null_ptr); 12 else 13 printf("Better luck next time!\n"); 14 } Hello, fault! val=7 (lldb) llvm-svn: 132430
2011-06-02 06:12:27 +08:00
#include <stdlib.h>
int main(int argc, const char* argv[])
{
int *null_ptr = 0;
printf("Hello, fault!\n");
Make 'run-until-faulted.py' script more interesting by modifying the example main.c program to seg fault randomly instead of deterministically. Example: [15:10:43] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ clang -g main.c [15:10:46] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ ./run-until-faulted.py -l $PWD/../../build/Debug/lldb -e a.out lldb command: /Volumes/data/lldb/svn/trunk/utils/test/../../build/Debug/lldb executable: a.out executable options: (lldb) sending 'file a.out' command... file a.out Current executable set to 'a.out' (x86_64). (lldb) sending 'process launch -- ' command... (iteration: 0) process launch -- Process 63630 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=9 Better luck next time! Process 63630 exited with status = 0 (0x00000000) (lldb) sending 'process launch -- ' command... (iteration: 1) process launch -- Process 63633 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Process 63633 exited with status = 0 (0x00000000) sending 'process launch -- ' command... (iteration: 2) Hello, fault! val=0 Better luck next time! (lldb) process launch -- Process 63637 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=15 Better luck next time! Process 63637 exited with status = 0 (0x00000000) (lldb) sending 'process launch -- ' command... (iteration: 3) process launch -- Process 63640 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=2 Better luck next time! Process 63640 exited with status = 0 (0x00000000) sending 'process launch -- ' command... (iteration: 4) (lldb) process launch -- Process 63643 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Process 63643 stopped * thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11 8 u_int32_t val = (arc4random() & 0x0f); 9 printf("val=%u\n", val); 10 if (val == 0x07) // Lucky 7 :-) -> 11 printf("Now segfault %d\n", *null_ptr); 12 else 13 printf("Better luck next time!\n"); 14 } (lldb) * thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11 8 u_int32_t val = (arc4random() & 0x0f); 9 printf("val=%u\n", val); 10 if (val == 0x07) // Lucky 7 :-) -> 11 printf("Now segfault %d\n", *null_ptr); 12 else 13 printf("Better luck next time!\n"); 14 } Hello, fault! val=7 (lldb) llvm-svn: 132430
2011-06-02 06:12:27 +08:00
u_int32_t val = (arc4random() & 0x0f);
printf("val=%u\n", val);
if (val == 0x07) // Lucky 7 :-)
printf("Now segfault %d\n", *null_ptr);
else
printf("Better luck next time!\n");
}