GDB for poking at libc to test random things
Posted Mon, 21 Sep 2009
I wanted to test something quickly out in C, but didn't want to write the 5 line of code to do it. Having done some fun ruby debugging with gdb recently, I decided to go with that.
% gdb -q `which sleep` --args `which sleep` 60000 (gdb) break nanosleep (gdb) run Starting program: /bin/sleep 60000 [Thread debugging using libthread_db enabled] [New Thread 0x7f8c40bc46f0 (LWP 6504)] [Switching to Thread 0x7f8c40bc46f0 (LWP 6504)] Breakpoint 1, 0x00007f8c404f7ce0 in nanosleep () from /lib/libc.so.6 (gdb) call strcspn("hello world", "w") $1 = 6I don't know why I didn't think about this before. This is nicely useful, allowing me to easily test any simple function call unrelated.