1 Index: ./gdb/testsuite/gdb.threads/threadcrash.c
2 ===================================================================
3 RCS file: gdb/testsuite/gdb.threads/threadcrash.c
4 diff -N gdb/testsuite/gdb.threads/threadcrash.c
5 --- /dev/null 1 Jan 1970 00:00:00 -0000
6 +++ ./gdb/testsuite/gdb.threads/threadcrash.c 31 Oct 2006 17:54:38 -0000
9 + * The point of this program is to crash in a multi-threaded app.
10 + * There are seven threads, doing the following things:
12 + * * Spinning inside a signal handler
13 + * * Spinning inside a signal handler executing on the altstack
15 + * * In a syscall inside a signal handler
16 + * * In a syscall inside a signal handler executing on the altstack
17 + * * Finally, the main thread crashes in main, with no frills.
19 + * These are the things threads in JRockit tend to be doing. If gdb
20 + * can handle those things, both in core files and during live
21 + * debugging, that will help (at least) JRockit development.
23 + * Let the program create a core file, then load the core file into
24 + * gdb. Inside gdb, you should be able to do something like this:
28 + * Thread 7 (process 4352):
29 + * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6
30 + * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6
31 + * #2 0x080488a2 in makeSyscall (ignored=0x0) at threadcrash.c:118
32 + * #3 0x006aadec in start_thread () from /lib/tls/libpthread.so.0
33 + * #4 0x001ed19a in clone () from /lib/tls/libc.so.6
35 + * Thread 6 (process 4353):
36 + * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6
37 + * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6
38 + * #2 0x0804898f in syscallingSighandler (signo=10, info=0xb6be76f0, context=0xb6be7770)
39 + * at threadcrash.c:168
40 + * #3 <signal handler called>
41 + * #4 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
42 + * #5 0x08048a51 in makeSyscallFromSighandler (ignored=0x0) at threadcrash.c:204
43 + * #6 0x006aadec in start_thread () from /lib/tls/libpthread.so.0
44 + * #7 0x001ed19a in clone () from /lib/tls/libc.so.6
46 + * Thread 5 (process 4354):
47 + * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6
48 + * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6
49 + * #2 0x08048936 in syscallingAltSighandler (signo=3, info=0x959cd70, context=0x959cdf0)
50 + * at threadcrash.c:144
51 + * #3 <signal handler called>
52 + * #4 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
53 + * #5 0x080489e2 in makeSyscallFromAltSighandler (ignored=0x0) at threadcrash.c:190
54 + * #6 0x006aadec in start_thread () from /lib/tls/libpthread.so.0
55 + * #7 0x001ed19a in clone () from /lib/tls/libc.so.6
57 + * Thread 4 (process 4355):
58 + * #0 spin (ignored=0x0) at threadcrash.c:242
59 + * #1 0x006aadec in start_thread () from /lib/tls/libpthread.so.0
60 + * #2 0x001ed19a in clone () from /lib/tls/libc.so.6
62 + * Thread 3 (process 4356):
63 + * #0 spinningSighandler (signo=12, info=0xb4de46f0, context=0xb4de4770) at threadcrash.c:180
64 + * #1 <signal handler called>
65 + * #2 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
66 + * #3 0x08048b2f in spinFromSighandler (ignored=0x0) at threadcrash.c:232
67 + * #4 0x006aadec in start_thread () from /lib/tls/libpthread.so.0
68 + * #5 0x001ed19a in clone () from /lib/tls/libc.so.6
70 + * Thread 2 (process 4357):
71 + * #0 spinningAltSighandler (signo=14, info=0x959ee50, context=0x959eed0) at threadcrash.c:156
72 + * #1 <signal handler called>
73 + * #2 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
74 + * #3 0x08048ac0 in spinFromAltSighandler (ignored=0x0) at threadcrash.c:218
75 + * #4 0x006aadec in start_thread () from /lib/tls/libpthread.so.0
76 + * #5 0x001ed19a in clone () from /lib/tls/libc.so.6
78 + * Thread 1 (process 4351):
79 + * #0 0x08048cf3 in main (argc=1, argv=0xbfff9d74) at threadcrash.c:273
91 +#define SIGSYSCALL_ALT SIGQUIT
92 +#define SIGSYSCALL SIGUSR1
93 +#define SIGSPIN_ALT SIGALRM
94 +#define SIGSPIN SIGUSR2
96 +typedef void (*sigaction_t)(int, siginfo_t *, void *);
98 +static void installHandler(int signo, sigaction_t handler, int onAltstack) {
99 + struct sigaction action;
103 + stack_t oldaltstack;
105 + memset(&action, 0, sizeof(action));
106 + memset(&altstack, 0, sizeof(altstack));
107 + memset(&oldaltstack, 0, sizeof(oldaltstack));
110 + altstack.ss_sp = malloc(SIGSTKSZ);
111 + assert(altstack.ss_sp != NULL);
112 + altstack.ss_size = SIGSTKSZ;
113 + altstack.ss_flags = 0;
114 + result = sigaltstack(&altstack, &oldaltstack);
115 + assert(result == 0);
116 + assert(oldaltstack.ss_flags == SS_DISABLE);
119 + sigemptyset(&sigset);
121 + action.sa_handler = NULL;
122 + action.sa_sigaction = handler;
123 + action.sa_mask = sigset;
124 + action.sa_flags = SA_SIGINFO;
126 + action.sa_flags |= SA_ONSTACK;
129 + result = sigaction(signo, &action, NULL);
130 + assert(result == 0);
133 +static void installNormalHandler(int signo, sigaction_t handler) {
134 + installHandler(signo, handler, 0);
137 +static void installAlthandler(int signo, sigaction_t handler) {
138 + installHandler(signo, handler, 1);
141 +static void *makeSyscall(void *ignored) {
146 + fprintf(stderr, "%s: returning\n", __FUNCTION__);
150 +/* Return true if we're currently executing on the altstack */
151 +static int onAltstack(void) {
155 + result = sigaltstack(NULL, &stack);
156 + assert(result == 0);
158 + return stack.ss_flags & SS_ONSTACK;
161 +static void syscallingAltSighandler(int signo, siginfo_t *info, void *context) {
166 + if (!onAltstack()) {
167 + printf("%s() not running on altstack!\n", __FUNCTION__);
173 +static void spinningAltSighandler(int signo, siginfo_t *info, void *context) {
178 + if (!onAltstack()) {
179 + printf("%s() not running on altstack!\n", __FUNCTION__);
185 +static void syscallingSighandler(int signo, siginfo_t *info, void *context) {
190 + if (onAltstack()) {
191 + printf("%s() running on altstack!\n", __FUNCTION__);
197 +static void spinningSighandler(int signo, siginfo_t *info, void *context) {
202 + if (onAltstack()) {
203 + printf("%s() running on altstack!\n", __FUNCTION__);
209 +static void *makeSyscallFromAltSighandler(void *ignored) {
214 + installAlthandler(SIGSYSCALL_ALT, syscallingAltSighandler);
216 + result = pthread_kill(pthread_self(), SIGSYSCALL_ALT);
217 + assert(result == 0);
219 + fprintf(stderr, "%s: returning\n", __FUNCTION__);
223 +static void *makeSyscallFromSighandler(void *ignored) {
228 + installNormalHandler(SIGSYSCALL, syscallingSighandler);
230 + result = pthread_kill(pthread_self(), SIGSYSCALL);
231 + assert(result == 0);
233 + fprintf(stderr, "%s: returning\n", __FUNCTION__);
237 +static void *spinFromAltSighandler(void *ignored) {
242 + installAlthandler(SIGSPIN_ALT, spinningAltSighandler);
244 + result = pthread_kill(pthread_self(), SIGSPIN_ALT);
245 + assert(result == 0);
247 + fprintf(stderr, "%s: returning\n", __FUNCTION__);
251 +static void *spinFromSighandler(void *ignored) {
256 + installNormalHandler(SIGSPIN, spinningSighandler);
258 + result = pthread_kill(pthread_self(), SIGSPIN);
259 + assert(result == 0);
261 + fprintf(stderr, "%s: returning\n", __FUNCTION__);
265 +static void *spin(void *ignored) {
270 + fprintf(stderr, "%s: returning\n", __FUNCTION__);
274 +int main(int argc, char *argv[]) {
279 + result = pthread_create(&thread, NULL, makeSyscall, NULL);
280 + assert(result == 0);
281 + result = pthread_create(&thread, NULL, makeSyscallFromSighandler, NULL);
282 + assert(result == 0);
283 + result = pthread_create(&thread, NULL, makeSyscallFromAltSighandler, NULL);
284 + assert(result == 0);
285 + result = pthread_create(&thread, NULL, spin, NULL);
286 + assert(result == 0);
287 + result = pthread_create(&thread, NULL, spinFromSighandler, NULL);
288 + assert(result == 0);
289 + result = pthread_create(&thread, NULL, spinFromAltSighandler, NULL);
290 + assert(result == 0);
292 + // Give threads some time to get going
298 + /* Workaround: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29628
299 + Simulate use to ensure `DW_AT_location' for them:
300 + readelf -a --debug threadcrash|grep -A5 -w argc
301 + --> DW_AT_location : 2 byte block: 71 0 (DW_OP_breg1: 0)
302 + This case verified on: gcc-4.1.1-30.i386
303 + Keep it late to ensure persistency in the registers. */
305 + bad = (unsigned long) argv;
309 Index: ./gdb/testsuite/gdb.threads/threadcrash.exp
310 ===================================================================
311 RCS file: gdb/testsuite/gdb.threads/threadcrash.exp
312 diff -N gdb/testsuite/gdb.threads/threadcrash.exp
313 --- /dev/null 1 Jan 1970 00:00:00 -0000
314 +++ ./gdb/testsuite/gdb.threads/threadcrash.exp 31 Oct 2006 17:54:38 -0000
316 +# threadcrash.exp - The point of this program is to crash in a multi-threaded app.
319 +set testfile threadcrash
320 +set srcfile ${testfile}.c
321 +set shellfile ${srcdir}/${subdir}/${testfile}.sh
322 +set binfile ${objdir}/${subdir}/${testfile}
325 +if [regexp "^\[^/\]" ${GDB_abs}] {
326 + set GDB_abs $env(PWD)/${GDB_abs}
329 +if [istarget "*-*-linux"] then {
330 + set target_cflags "-D_MIT_POSIX_THREADS"
332 + set target_cflags ""
335 +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
339 +# ${shellfile} argument must not contain any directories.
340 +set fd [open "|bash ${shellfile} ${binfile} $GDB -nw $GDBFLAGS" r]
341 +while { [gets $fd line] >= 0 } {
342 + if [regexp " PASS: (.*)$" $line trash message] {
344 + } elseif [regexp " FAIL: (.*)$" $line trash message] {
353 Index: ./gdb/testsuite/gdb.threads/threadcrash.sh
354 ===================================================================
355 RCS file: gdb/testsuite/gdb.threads/threadcrash.sh
356 diff -N gdb/testsuite/gdb.threads/threadcrash.sh
357 --- /dev/null 1 Jan 1970 00:00:00 -0000
358 +++ ./gdb/testsuite/gdb.threads/threadcrash.sh 31 Oct 2006 17:54:38 -0000
362 +# NOTE: threadcrash.c *must* be built with debugging symbols
364 +# The point of this shell script is to crash treadcrash.c, load the
365 +# resulting core file into gdb and verify that gdb can extract enough
366 +# information from the core file.
368 +# The return code from this script is the number of failed tests.
372 +if [ $# = 0 ] ; then
373 + echo >&2 Syntax: $0 \<name of threadcrash binary\> [\<gdb binary\> \<args...\>]
382 +function pf_prefix() {
387 +function set_test() {
388 + if [ -n "$set_test" ] ; then
389 + echo >&2 "DEJAGNU-BASH ERROR: set_test already set"
393 + if [ -n "$pf_prefix" ] ; then
394 + set_test="$pf_prefix: $set_test"
399 +function record_test {
400 + if [ -z "$set_test" ] ; then
401 + echo >&2 "DEJAGNU-BASH ERROR: set_test not set"
404 + # Provide the leading whitespace delimiter:
405 + echo " $1: $set_test"
417 +# Verify that the gdb output doesn't contain $1.
418 +function mustNotHave() {
420 + set_test gdb output contains "$BADWORD"
421 + if grep -q "$BADWORD" $LOG ; then
429 +# Verify that the gdb output contains exactly $1 $2s.
430 +function mustHaveCorrectAmount() {
431 + local WANTEDNUMBER=$1
433 + local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l)
434 + set_test gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected
435 + if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then
443 +# Verify that the gdb output contains seven threads
444 +function mustHaveSevenThreads() {
445 + NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l)
446 + set_test gdb output contains $NTHREADS threads, not 7 as expected
447 + if [ $NTHREADS != 7 ] ; then
455 +# Verify that the gdb output has all parameters on consecutive lines
456 +function mustHaveSequence() {
459 + grep "$1" -A$((NPARTS - 1)) $LOG > matches.log
461 + while [ $# -gt 1 ] ; do
464 + grep "$1" -A$((NPARTS - 1)) matches.log > temp.log
465 + mv temp.log matches.log
469 + set_test gdb output does not contain the sequence: $SEQUENCE
470 + if ! grep -q "$LASTPART" matches.log ; then
478 +# Verify that $LOG contains all information we want
479 +function verifyLog() {
482 + mustNotHave '??' || ((FAILURES++))
483 + mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++))
485 + mustHaveSevenThreads || ((FAILURES++))
486 + mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++))
488 + mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
489 + mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++))
491 + mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
492 + mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++))
494 + mustHaveSequence Thread "spin (ignored=" || ((FAILURES++))
496 + mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
497 + mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++))
499 + mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
500 + mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++))
502 + mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++))
507 +# Put result of debugging a core file in $LOG
508 +function getLogFromCore() {
509 + # Make sure we get a core file
510 + set_test Make sure we get a core file
511 + if ! ulimit -c unlimited ; then
518 + ./$(basename "$RUNME")
521 + # Verify that we actually crashed
522 + set_test $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE
523 + if [ $EXITCODE -lt 128 ] ; then
529 + # Verify that we got a core file
530 + set_test $RUNME did not create a core file
531 + if [ ! -r core* ] ; then
538 + cat > gdbscript.gdb <<EOF
543 + cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" core* > $LOG
546 + set_test gdb exited with error code
547 + if [ $EXITCODE != 0 ] ; then
549 + echo >&2 gdb exited with error code $EXITCODE
555 +# Put result of debugging a gcore file in $LOG
556 +function getLogFromGcore() {
557 + # Create the core file
559 + cat > gdbscript.gdb <<EOF
560 +handle SIGQUIT pass noprint nostop
561 +handle SIGUSR1 pass noprint nostop
562 +handle SIGUSR2 pass noprint nostop
563 +handle SIGALRM pass noprint nostop
568 + cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" > /dev/null
571 + set_test gdb exited with error code when creating gcore file
572 + if [ $EXITCODE != 0 ] ; then
574 + echo >&2 gdb exited with error code $EXITCODE when creating gcore file
579 + # Verify that we got a core file from gcore
580 + set_test gdb gcore did not create a core file
581 + if [ ! -r core* ] ; then
587 + # Run gdb on the gcore file
588 + cat > gdbscript.gdb <<EOF
593 + cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" core* > $LOG
596 + set_test gdb exited with error code when examining gcore file
597 + if [ $EXITCODE != 0 ] ; then
599 + echo >&2 gdb exited with error code $EXITCODE when examining gcore file
605 +# Put result of debugging a core file in $LOG
606 +function getLogFromLiveProcess() {
608 + cat > gdbscript.gdb <<EOF
609 +handle SIGQUIT pass noprint nostop
610 +handle SIGUSR1 pass noprint nostop
611 +handle SIGUSR2 pass noprint nostop
612 +handle SIGALRM pass noprint nostop
618 + cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" > $LOG
621 + set_test gdb exited with error code
622 + if [ $EXITCODE != 0 ] ; then
624 + echo >&2 gdb exited with error code $EXITCODE
630 +####### Main program follows #####################
632 +# Make sure we don't clobber anybody else's (core) file(s)
635 +cp "$RUNME" $WORKDIR
641 +echo === Testing gdb vs core file...
647 +echo === Core file tests done.
651 +echo === Testing gdb vs gcore file...
652 +pf_prefix gcore file
657 +echo === Gcore file tests done.
661 +echo === Testing gdb vs live process...
662 +pf_prefix live process
663 +getLogFromLiveProcess
667 +echo === Live process tests done.
671 +if [ $FAILURES == 0 ] ; then
672 + echo All tests passed!
674 + echo $FAILURES tests failed!
676 + echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\).
684 Index: ./gdb/testsuite/gdb.threads/threadcrash.sh-orig
685 ===================================================================
686 RCS file: gdb/testsuite/gdb.threads/threadcrash.sh-orig
687 diff -N gdb/testsuite/gdb.threads/threadcrash.sh-orig
688 --- /dev/null 1 Jan 1970 00:00:00 -0000
689 +++ ./gdb/testsuite/gdb.threads/threadcrash.sh-orig 31 Oct 2006 17:54:38 -0000
693 +# NOTE: threadcrash.c *must* be built with debugging symbols
695 +# The point of this shell script is to crash treadcrash.c, load the
696 +# resulting core file into gdb and verify that gdb can extract enough
697 +# information from the core file.
699 +# The return code from this script is the number of failed tests.
703 +if [ $# != 1 ] ; then
704 + echo > /dev/stderr Syntax: $0 \<name of threadcrash binary\>
709 +# Verify that the gdb output doesn't contain $1.
710 +function mustNotHave() {
712 + if grep -q "$BADWORD" $LOG ; then
713 + echo >> /dev/stderr WARNING: gdb output contains "$BADWORD"
719 +# Verify that the gdb output contains exactly $1 $2s.
720 +function mustHaveCorrectAmount() {
721 + local WANTEDNUMBER=$1
723 + local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l)
724 + if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then
725 + echo >> /dev/stderr WARNING: gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected
731 +# Verify that the gdb output contains seven threads
732 +function mustHaveSevenThreads() {
733 + NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l)
734 + if [ $NTHREADS != 7 ] ; then
735 + echo >> /dev/stderr WARNING: gdb output contains $NTHREADS threads, not 7 as expected
741 +# Verify that the gdb output has all parameters on consecutive lines
742 +function mustHaveSequence() {
745 + grep "$1" -A$((NPARTS - 1)) $LOG > matches.log
747 + while [ $# -gt 1 ] ; do
750 + grep "$1" -A$((NPARTS - 1)) matches.log > temp.log
751 + mv temp.log matches.log
755 + if ! grep -q "$LASTPART" matches.log ; then
756 + echo >> /dev/stderr WARNING: gdb output does not contain the sequence: $SEQUENCE
762 +# Verify that $LOG contains all information we want
763 +function verifyLog() {
766 + mustNotHave '??' || ((FAILURES++))
767 + mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++))
769 + mustHaveSevenThreads || ((FAILURES++))
770 + mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++))
772 + mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
773 + mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++))
775 + mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
776 + mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++))
778 + mustHaveSequence Thread "spin (ignored=" || ((FAILURES++))
780 + mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
781 + mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++))
783 + mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
784 + mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++))
786 + mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++))
791 +# Put result of debugging a core file in $LOG
792 +function getLogFromCore() {
793 + # Make sure we get a core file
794 + ulimit -c unlimited || exit 1
797 + ./$(basename "$RUNME")
800 + # Verify that we actually crashed
801 + if [ $EXITCODE -lt 128 ] ; then
802 + echo >> /dev/stderr ERROR: $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE
806 + # Verify that we got a core file
807 + if [ ! -r core* ] ; then
808 + echo >> /dev/stderr ERROR: $RUNME did not create a core file
813 + cat > gdbscript.gdb <<EOF
818 + cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" core* > $LOG
821 + if [ $EXITCODE != 0 ] ; then
823 + echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE
827 +# Put result of debugging a gcore file in $LOG
828 +function getLogFromGcore() {
829 + # Create the core file
831 + cat > gdbscript.gdb <<EOF
832 +handle SIGQUIT pass noprint nostop
833 +handle SIGUSR1 pass noprint nostop
834 +handle SIGUSR2 pass noprint nostop
835 +handle SIGALRM pass noprint nostop
840 + cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > /dev/null
843 + if [ $EXITCODE != 0 ] ; then
845 + echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when creating gcore file
848 + # Verify that we got a core file from gcore
849 + if [ ! -r core* ] ; then
850 + echo >> /dev/stderr ERROR: gdb gcore did not create a core file
854 + # Run gdb on the gcore file
855 + cat > gdbscript.gdb <<EOF
860 + cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" core* > $LOG
863 + if [ $EXITCODE != 0 ] ; then
865 + echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when examining gcore file
869 +# Put result of debugging a core file in $LOG
870 +function getLogFromLiveProcess() {
872 + cat > gdbscript.gdb <<EOF
873 +handle SIGQUIT pass noprint nostop
874 +handle SIGUSR1 pass noprint nostop
875 +handle SIGUSR2 pass noprint nostop
876 +handle SIGALRM pass noprint nostop
882 + cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > $LOG
885 + if [ $EXITCODE != 0 ] ; then
887 + echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE
891 +####### Main program follows #####################
893 +# Make sure we don't clobber anybody else's (core) file(s)
896 +cp "$RUNME" $WORKDIR
902 +echo === Testing gdb vs core file...
906 +echo === Core file tests done.
910 +echo === Testing gdb vs gcore file...
914 +echo === Gcore file tests done.
918 +echo === Testing gdb vs live process...
919 +getLogFromLiveProcess
922 +echo === Live process tests done.
926 +if [ $FAILURES == 0 ] ; then
927 + echo All tests passed!
929 + echo $FAILURES tests failed!
931 + echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\).