1 Index: gdb-7.4.50.20120602/gdb/testsuite/configure.ac
2 ===================================================================
3 --- gdb-7.4.50.20120602.orig/gdb/testsuite/configure.ac 2012-04-25 16:07:22.000000000 +0200
4 +++ gdb-7.4.50.20120602/gdb/testsuite/configure.ac 2012-06-02 18:24:38.456266545 +0200
5 @@ -96,6 +96,6 @@ AC_OUTPUT([Makefile \
6 gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile \
7 gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile \
8 gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \
9 - gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
10 + gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \
11 gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile \
12 gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
13 Index: gdb-7.4.50.20120602/gdb/testsuite/configure
14 ===================================================================
15 --- gdb-7.4.50.20120602.orig/gdb/testsuite/configure 2012-04-25 16:07:21.000000000 +0200
16 +++ gdb-7.4.50.20120602/gdb/testsuite/configure 2012-06-02 18:25:06.200258240 +0200
17 @@ -3448,7 +3448,7 @@ done
21 -ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
22 +ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
24 cat >confcache <<\_ACEOF
25 # This file is a shell script that caches the results of configure
26 @@ -4175,6 +4175,7 @@ do
27 "gdb.opencl/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opencl/Makefile" ;;
28 "gdb.opt/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opt/Makefile" ;;
29 "gdb.pascal/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pascal/Makefile" ;;
30 + "gdb.pie/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pie/Makefile" ;;
31 "gdb.python/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.python/Makefile" ;;
32 "gdb.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;;
33 "gdb.stabs/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.stabs/Makefile" ;;
34 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.c
35 ===================================================================
36 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
37 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.c 2012-06-02 18:24:38.497266532 +0200
39 +/* This program is intended to be started outside of gdb, and then
40 + attached to by gdb. Thus, it simply spins in a loop. The loop
41 + is exited when & if the variable 'should_exit' is non-zero. (It
42 + is initialized to zero in this program, so the loop will never
43 + exit unless/until gdb sets the variable to non-zero.)
53 + while (! should_exit)
59 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach2.c
60 ===================================================================
61 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
62 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach2.c 2012-06-02 18:24:38.504266529 +0200
64 +/* This program is intended to be started outside of gdb, and then
65 + attached to by gdb. Thus, it simply spins in a loop. The loop
66 + is exited when & if the variable 'should_exit' is non-zero. (It
67 + is initialized to zero in this program, so the loop will never
68 + exit unless/until gdb sets the variable to non-zero.)
80 + sleep( 10 ); /* System call causes register fetch to fail */
81 + /* This is a known HPUX "feature" */
82 + while (! should_exit)
88 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.c
89 ===================================================================
90 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
91 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.c 2012-06-02 18:24:38.505266529 +0200
93 +/* This testcase is part of GDB, the GNU debugger.
95 + Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
98 + This program is free software; you can redistribute it and/or modify
99 + it under the terms of the GNU General Public License as published by
100 + the Free Software Foundation; either version 2 of the License, or
101 + (at your option) any later version.
103 + This program is distributed in the hope that it will be useful,
104 + but WITHOUT ANY WARRANTY; without even the implied warranty of
105 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106 + GNU General Public License for more details.
108 + You should have received a copy of the GNU General Public License
109 + along with this program; if not, write to the Free Software
110 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
112 + Please email any bugs, comments, and/or additions to this file to:
113 + bug-gdb@prep.ai.mit.edu */
119 +/* VxWorks does not supply atoi. */
126 + while (*z >= '0' && *z <= '9')
127 + i = i * 10 + (*z++ - '0');
131 +/* I don't know of any way to pass an array to VxWorks. This function
132 + can be called directly from gdb. */
141 + main (2, argv, (char **) 0);
144 +#else /* ! vxworks */
146 +# include <stdlib.h>
147 +#endif /* ! vxworks */
150 +extern int marker1 (void);
151 +extern int marker2 (int a);
152 +extern void marker3 (char *a, char *b);
153 +extern void marker4 (long d);
155 +extern int marker1 ();
156 +extern int marker2 ();
157 +extern void marker3 ();
158 +extern void marker4 ();
162 + * This simple classical example of recursion is useful for
163 + * testing stack backtraces and such.
170 +main (int argc, char **argv, char **envp)
173 +main (argc, argv, envp)
175 +char *argv[], **envp;
179 + set_debug_traps(); /* set breakpoint 5 here */
182 + if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
183 + fprintf (stderr, "usage: factorial <number>\n");
186 + printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
187 + /* set breakpoint 12 here */
188 + marker1 (); /* set breakpoint 11 here */
189 + marker2 (43); /* set breakpoint 20 here */
190 + marker3 ("stack", "trace"); /* set breakpoint 21 here */
191 + marker4 (177601976L);
192 + argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
193 + return argc; /* set breakpoint 10 here */
197 +int factorial (int value)
199 +int factorial (value)
203 + if (value > 1) { /* set breakpoint 7 here */
204 + value *= factorial (value - 1);
206 + return (value); /* set breakpoint 19 here */
210 +int multi_line_if_conditional (int a, int b, int c)
212 +int multi_line_if_conditional (a, b, c)
216 + if (a /* set breakpoint 3 here */
225 +int multi_line_while_conditional (int a, int b, int c)
227 +int multi_line_while_conditional (a, b, c)
231 + while (a /* set breakpoint 4 here */
239 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break1.c
240 ===================================================================
241 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
242 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break1.c 2012-06-02 18:24:38.506266530 +0200
244 +/* This testcase is part of GDB, the GNU debugger.
246 + Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
249 + This program is free software; you can redistribute it and/or modify
250 + it under the terms of the GNU General Public License as published by
251 + the Free Software Foundation; either version 2 of the License, or
252 + (at your option) any later version.
254 + This program is distributed in the hope that it will be useful,
255 + but WITHOUT ANY WARRANTY; without even the implied warranty of
256 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
257 + GNU General Public License for more details.
259 + You should have received a copy of the GNU General Public License
260 + along with this program; if not, write to the Free Software
261 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
263 + Please email any bugs, comments, and/or additions to this file to:
264 + bug-gdb@prep.ai.mit.edu */
266 +/* The code for this file was extracted from the gdb testsuite
267 + testcase "break.c". */
269 +/* The following functions do nothing useful. They are included
270 + simply as places to try setting breakpoints at. They are
271 + explicitly "one-line functions" to verify that this case works
272 + (some versions of gcc have or have had problems with this).
274 + These functions are in a separate source file to prevent an
275 + optimizing compiler from inlining them and optimizing them away. */
278 +int marker1 (void) { return (0); } /* set breakpoint 15 here */
279 +int marker2 (int a) { return (1); } /* set breakpoint 8 here */
280 +void marker3 (char *a, char *b) {} /* set breakpoint 17 here */
281 +void marker4 (long d) {} /* set breakpoint 14 here */
283 +int marker1 () { return (0); } /* set breakpoint 16 here */
284 +int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */
285 +void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */
286 +void marker4 (d) long d; {} /* set breakpoint 13 here */
288 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/coremaker.c
289 ===================================================================
290 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
291 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/coremaker.c 2012-06-02 18:24:38.506266530 +0200
293 +/* Copyright 1992, 1993, 1994, 1995, 1996, 1999
294 + Free Software Foundation, Inc.
296 + This file is part of GDB.
298 + This program is free software; you can redistribute it and/or modify
299 + it under the terms of the GNU General Public License as published by
300 + the Free Software Foundation; either version 2 of the License, or (at
301 + your option) any later version.
303 + This program is distributed in the hope that it will be useful, but
304 + WITHOUT ANY WARRANTY; without even the implied warranty of
305 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
306 + General Public License for more details.
308 + You should have received a copy of the GNU General Public License
309 + along with this program; if not, write to the Free Software
310 + Foundation, Inc., 59 Temple Place - Suite 330,
311 + Boston, MA 02111-1307, USA. */
313 +/* Simple little program that just generates a core dump from inside some
314 + nested function calls. */
317 +#include <sys/types.h>
319 +#include <sys/mman.h>
328 +#define MAPSIZE (8 * 1024)
330 +/* Don't make these automatic vars or we will have to walk back up the
331 + stack to access them. */
336 +int coremaker_data = 1; /* In Data section */
337 +int coremaker_bss; /* In BSS section */
339 +const int coremaker_ro = 201; /* In Read-Only Data section */
341 +/* Note that if the mapping fails for any reason, we set buf2
342 + to -1 and the testsuite notices this and reports it as
343 + a failure due to a mapping error. This way we don't have
344 + to test for specific errors when running the core maker. */
351 + /* Allocate and initialize a buffer that will be used to write
352 + the file that is later mapped in. */
354 + buf1 = (char *) malloc (MAPSIZE);
355 + for (j = 0; j < MAPSIZE; ++j)
360 + /* Write the file to map in */
362 + fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666);
365 + perror ("coremmap.data open failed");
366 + buf2 = (char *) -1;
369 + write (fd, buf1, MAPSIZE);
371 + /* Now map the file into our address space as buf2 */
373 + buf2 = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
374 + if (buf2 == (char *) -1)
376 + perror ("mmap failed");
380 + /* Verify that the original data and the mapped data are identical.
381 + If not, we'd rather fail now than when trying to access the mapped
382 + data from the core file. */
384 + for (j = 0; j < MAPSIZE; ++j)
386 + if (buf1[j] != buf2[j])
388 + fprintf (stderr, "mapped data is incorrect");
389 + buf2 = (char *) -1;
398 + int coremaker_local[5];
402 + /* Force a corefile that includes the data section for AIX. */
404 + struct sigaction sa;
406 + sigaction (SIGABRT, (struct sigaction *)0, &sa);
407 + sa.sa_flags |= SA_FULLDUMP;
408 + sigaction (SIGABRT, &sa, (struct sigaction *)0);
412 + /* Make sure that coremaker_local doesn't get optimized away. */
413 + for (i = 0; i < 5; i++)
414 + coremaker_local[i] = i;
416 + for (i = 0; i < 5; i++)
417 + coremaker_bss += coremaker_local[i];
418 + coremaker_data = coremaker_ro + 1;
435 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.exp
436 ===================================================================
437 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
438 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.exp 2012-06-02 18:24:38.508266531 +0200
440 +# Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
442 +# This program is free software; you can redistribute it and/or modify
443 +# it under the terms of the GNU General Public License as published by
444 +# the Free Software Foundation; either version 2 of the License, or
445 +# (at your option) any later version.
447 +# This program is distributed in the hope that it will be useful,
448 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
449 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
450 +# GNU General Public License for more details.
452 +# You should have received a copy of the GNU General Public License
453 +# along with this program; if not, write to the Free Software
454 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
456 +# On HP-UX 11.0, this test is causing a process running the program
457 +# "attach" to be left around spinning. Until we figure out why, I am
458 +# commenting out the test to avoid polluting tiamat (our 11.0 nightly
459 +# test machine) with these processes. RT
461 +# Setting the magic bit in the target app should work. I added a
462 +# "kill", and also a test for the R3 register warning. JB
463 +if { [istarget "hppa*-*-hpux*"] } {
467 +# are we on a target board
468 +if [is_remote target] then {
472 +set testfile "attach"
473 +set srcfile ${testfile}.c
474 +set srcfile2 ${testfile}2.c
475 +set binfile ${objdir}/${subdir}/${testfile}
476 +set binfile2 ${objdir}/${subdir}/${testfile}2
477 +set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
478 +set cleanupfile ${objdir}/${subdir}/${testfile}.awk
480 +#execute_anywhere "rm -f ${binfile} ${binfile2}"
481 +remote_exec build "rm -f ${binfile} ${binfile2}"
482 +# For debugging this test
486 +# Clean out any old files from past runs.
488 +remote_exec build "${cleanupfile}"
490 +# build the first test case
492 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
493 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
496 +# Build the in-system-call test
498 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
499 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
502 +if [get_compiler_info ${binfile}] {
506 +proc do_attach_tests {} {
509 + global escapedbinfile
516 + # Start the program running and then wait for a bit, to be sure
517 + # that it can be attached to.
519 + set testpid [eval exec $binfile &]
522 + # Verify that we cannot attach to nonsense.
524 + send_gdb "attach abc\n"
526 + -re ".*Illegal process-id: abc.*$gdb_prompt $"\
527 + {pass "attach to nonsense is prohibited"}
528 + -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
530 + # Response expected from /proc-based systems.
531 + pass "attach to nonsense is prohibited"
533 + -re "Attaching to.*$gdb_prompt $"\
534 + {fail "attach to nonsense is prohibited (bogus pid allowed)"}
535 + -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"}
536 + timeout {fail "(timeout) attach to nonsense is prohibited"}
539 + # Verify that we cannot attach to what appears to be a valid
540 + # process ID, but is a process that doesn't exist. Traditionally,
541 + # most systems didn't have a process with ID 0, so we take that as
542 + # the default. However, there are a few exceptions.
545 + if { [istarget "*-*-*bsd*"] } {
546 + # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead
547 + # (which should have the desired effect on any version of
548 + # FreeBSD, and probably other *BSD's too).
551 + send_gdb "attach $boguspid\n"
553 + -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\
555 + # Response expected on ptrace-based systems (i.e. HP-UX 10.20).
556 + pass "attach to nonexistent process is prohibited"
558 + -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\
560 + # Response expected on ttrace-based systems (i.e. HP-UX 11.0).
561 + pass "attach to nonexistent process is prohibited"
563 + -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\
564 + {pass "attach to nonexistent process is prohibited"}
565 + -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\
566 + {pass "attach to nonexistent process is prohibited"}
567 + -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
569 + # Response expected from /proc-based systems.
570 + pass "attach to nonexistent process is prohibited"
572 + -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"}
574 + fail "(timeout) attach to nonexistent process is prohibited"
578 + # Verify that we can attach to the process by first giving its
579 + # executable name via the file command, and using attach with
582 + # (Actually, the test system appears to do this automatically
583 + # for us. So, we must also be prepared to be asked if we want
584 + # to discard an existing set of symbols.)
586 + send_gdb "file $binfile\n"
588 + -re "Load new symbol table from.*y or n.*$" {
591 + -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
592 + {pass "(re)set file, before attach1"}
593 + -re "$gdb_prompt $" {fail "(re)set file, before attach1"}
594 + timeout {fail "(timeout) (re)set file, before attach1"}
597 + -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
598 + {pass "set file, before attach1"}
599 + -re "$gdb_prompt $" {fail "set file, before attach1"}
600 + timeout {fail "(timeout) set file, before attach1"}
603 + send_gdb "attach $testpid\n"
605 + -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\
606 + {pass "attach1, after setting file"}
607 + -re "$gdb_prompt $" {fail "attach1, after setting file"}
608 + timeout {fail "(timeout) attach1, after setting file"}
611 + # Verify that we can "see" the variable "should_exit" in the
612 + # program, and that it is zero.
614 + send_gdb "print should_exit\n"
616 + -re ".* = 0.*$gdb_prompt $"\
617 + {pass "after attach1, print should_exit"}
618 + -re "$gdb_prompt $" {fail "after attach1, print should_exit"}
619 + timeout {fail "(timeout) after attach1, print should_exit"}
622 + # Detach the process.
624 + send_gdb "detach\n"
626 + -re "Detaching from program: .*$escapedbinfile.*$gdb_prompt $"\
627 + {pass "attach1 detach"}
628 + -re "$gdb_prompt $" {fail "attach1 detach"}
629 + timeout {fail "(timeout) attach1 detach"}
632 + # Wait a bit for gdb to finish detaching
636 + # Purge the symbols from gdb's brain. (We want to be certain
637 + # the next attach, which won't be preceded by a "file" command,
638 + # is really getting the executable file without our help.)
640 + set old_timeout $timeout
644 + -re ".*gdb internal error.*$" {
645 + fail "Internal error, prob. Memory corruption"
647 + -re "No executable file now.*Discard symbol table.*y or n.*$" {
650 + -re "No symbol file now.*$gdb_prompt $"\
651 + {pass "attach1, purging symbols after detach"}
652 + -re "$gdb_prompt $" {fail "attach1, purging symbols after detach"}
653 + timeout {fail "(timeout) attach1, purging symbols after detach"}
656 + -re "$gdb_prompt $" {fail "attach1, purging file after detach"}
658 + fail "(timeout) attach1, purging file after detach"
661 + set timeout $old_timeout
663 + # Verify that we can attach to the process just by giving the
666 + send_gdb "attach $testpid\n"
668 + -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
670 + -re "$gdb_prompt $" {fail "attach2"}
671 + timeout {fail "(timeout) attach2"}
674 + # Verify that we can modify the variable "should_exit" in the
677 + send_gdb "set should_exit=1\n"
679 + -re "$gdb_prompt $" {pass "after attach2, set should_exit"}
680 + timeout {fail "(timeout) after attach2, set should_exit"}
683 + # Verify that the modification really happened.
685 + send_gdb "tbreak 19\n"
687 + -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $"\
688 + {pass "after attach2, set tbreak postloop"}
689 + -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"}
690 + timeout {fail "(timeout) after attach2, set tbreak postloop"}
692 + send_gdb "continue\n"
694 + -re "main.*at.*$srcfile:19.*$gdb_prompt $"\
695 + {pass "after attach2, reach tbreak postloop"}
696 + -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"}
697 + timeout {fail "(timeout) after attach2, reach tbreak postloop"}
700 + # Allow the test process to exit, to cleanup after ourselves.
702 + gdb_test "continue" {\[Inferior .* exited normally\]} "after attach2, exit"
704 + # Make sure we don't leave a process around to confuse
705 + # the next test run (and prevent the compile by keeping
706 + # the text file busy), in case the "set should_exit" didn't
709 + remote_exec build "kill -9 ${testpid}"
710 + # Start the program running and then wait for a bit, to be sure
711 + # that it can be attached to.
713 + set testpid [eval exec $binfile &]
716 + # Verify that we can attach to the process, and find its a.out
717 + # when we're cd'd to some directory that doesn't contain the
718 + # a.out. (We use the source path set by the "dir" command.)
720 + send_gdb "dir ${objdir}/${subdir}\n"
722 + -re ".*Source directories searched: .*$gdb_prompt $"\
723 + {pass "set source path"}
724 + -re "$gdb_prompt $" {fail "set source path"}
725 + timeout {fail "(timeout) set source path"}
728 + send_gdb "cd /tmp\n"
730 + -re ".*Working directory /tmp.*$gdb_prompt $"\
731 + {pass "cd away from process' a.out"}
732 + -re "$gdb_prompt $" {fail "cd away from process' a.out"}
733 + timeout {fail "(timeout) cd away from process' a.out"}
736 + # Explicitly flush out any knowledge of the previous attachment.
737 + send_gdb "symbol\n"
739 + -re ".*Discard symbol table from.*y or n. $"\
742 + -re ".*No symbol file now.*$gdb_prompt $"\
743 + {pass "before attach3, flush symbols"}
744 + -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
745 + timeout {fail "(timeout) before attach3, flush symbols"}
748 + -re ".*No symbol file now.*$gdb_prompt $"\
749 + {pass "before attach3, flush symbols"}
750 + -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
751 + timeout {fail "(timeout) before attach3, flush symbols"}
755 + -re ".*No executable file now.*$gdb_prompt $"\
756 + {pass "before attach3, flush exec"}
757 + -re "$gdb_prompt $" {fail "before attach3, flush exec"}
758 + timeout {fail "(timeout) before attach3, flush exec"}
761 + send_gdb "attach $testpid\n"
763 + -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
764 + {pass "attach when process' a.out not in cwd"}
765 + -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"}
766 + timeout {fail "(timeout) attach when process' a.out not in cwd"}
771 + -re ".*Kill the program being debugged.*y or n. $"\
774 + -re "$gdb_prompt $" {pass "after attach3, exit"}
775 + timeout {fail "(timeout) after attach3, exit"}
778 + -re "$gdb_prompt $" {fail "after attach3, exit"}
779 + timeout {fail "(timeout) after attach3, exit"}
782 + # Another "don't leave a process around"
783 + remote_exec build "kill -9 ${testpid}"
786 +proc do_call_attach_tests {} {
790 + # Start the program running and then wait for a bit, to be sure
791 + # that it can be attached to.
793 + set testpid [eval exec $binfile2 &]
798 + gdb_test "file $binfile2" ".*" "force switch to gdb64, if necessary"
799 + send_gdb "attach $testpid\n"
801 + -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" {
802 + fail "attach call, read register 3 error"
804 + -re "Attaching to.*process $testpid.*$gdb_prompt $" {
805 + # libc is relocated, not relocated, therefore not printed.
808 + -re "$gdb_prompt $" {fail "attach call"}
809 + timeout {fail "(timeout) attach call"}
812 + # See if other registers are problems
814 + send_gdb "i r r3\n"
816 + -re ".*warning: reading register.*$gdb_prompt $" {
817 + pass "CHFts23490: known bug"
819 + -re ".*r3.*$gdb_prompt $" {
820 + pass "Bug fixed, Yayyy!"
822 + timeout { fail "timeout on info reg" }
825 + # Get rid of the process
827 + gdb_test "p should_exit = 1" ".*"
828 + gdb_test "c" {\[Inferior .* exited normally\]}
832 + remote_exec build "kill -9 ${testpid}"
837 +# Start with a fresh gdb
841 +gdb_reinitialize_dir $srcdir/$subdir
844 +# This is a test of gdb's ability to attach to a running process.
848 +# Test attaching when the target is inside a system call
853 +gdb_reinitialize_dir $srcdir/$subdir
854 +do_call_attach_tests
857 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.exp
858 ===================================================================
859 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
860 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.exp 2012-06-02 18:24:38.510266529 +0200
862 +# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
863 +# 2000, 2002, 2003, 2004
864 +# Free Software Foundation, Inc.
866 +# This program is free software; you can redistribute it and/or modify
867 +# it under the terms of the GNU General Public License as published by
868 +# the Free Software Foundation; either version 2 of the License, or
869 +# (at your option) any later version.
871 +# This program is distributed in the hope that it will be useful,
872 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
873 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
874 +# GNU General Public License for more details.
876 +# You should have received a copy of the GNU General Public License
877 +# along with this program; if not, write to the Free Software
878 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
880 +# Please email any bugs, comments, and/or additions to this file to:
881 +# bug-gdb@prep.ai.mit.edu
883 +# This file was written by Rob Savoye. (rob@cygnus.com)
885 +# Test the same stuff but with PIE executables
887 +set testfile "break"
888 +set srcfile ${testfile}.c
889 +set srcfile1 ${testfile}1.c
890 +set binfile ${objdir}/${subdir}/${testfile}
892 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
893 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
896 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
897 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
900 +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
901 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
904 +if [get_compiler_info ${binfile}] {
910 +gdb_reinitialize_dir $srcdir/$subdir
913 +if [target_info exists gdb_stub] {
917 +# test simple breakpoint setting commands
920 +# Test deleting all breakpoints when there are none installed,
921 +# GDB should not prompt for confirmation.
922 +# Note that gdb-init.exp provides a "delete_breakpoints" proc
923 +# for general use elsewhere.
925 +send_gdb "delete breakpoints\n"
927 + -re "Delete all breakpoints.*$" {
930 + -re "$gdb_prompt $" {
931 + fail "Delete all breakpoints when none (unexpected prompt)"
933 + timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" }
936 + -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" }
937 + timeout { fail "Delete all breakpoints when none (timeout)" }
941 +# test break at function
943 +gdb_test "break main" \
944 + "Breakpoint.*at.* file .*$srcfile, line.*" \
945 + "breakpoint function"
948 +# test break at quoted function
950 +gdb_test "break \"marker2\"" \
951 + "Breakpoint.*at.* file .*$srcfile1, line.*" \
952 + "breakpoint quoted function"
955 +# test break at function in file
957 +gdb_test "break $srcfile:factorial" \
958 + "Breakpoint.*at.* file .*$srcfile, line.*" \
959 + "breakpoint function in file"
961 +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
964 +# test break at line number
966 +# Note that the default source file is the last one whose source text
967 +# was printed. For native debugging, before we've executed the
968 +# program, this is the file containing main, but for remote debugging,
969 +# it's wherever the processor was stopped when we connected to the
970 +# board. So, to be sure, we do a list command.
972 +gdb_test "list main" \
973 + ".*main \\(argc, argv, envp\\).*" \
974 + "use `list' to establish default source file"
975 +gdb_test "break $bp_location1" \
976 + "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \
977 + "breakpoint line number"
980 +# test duplicate breakpoint
982 +gdb_test "break $bp_location1" \
983 + "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \
984 + "breakpoint duplicate"
986 +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
989 +# test break at line number in file
991 +gdb_test "break $srcfile:$bp_location2" \
992 + "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \
993 + "breakpoint line number in file"
995 +set bp_location3 [gdb_get_line_number "set breakpoint 3 here"]
996 +set bp_location4 [gdb_get_line_number "set breakpoint 4 here"]
999 +# Test putting a break at the start of a multi-line if conditional.
1000 +# Verify the breakpoint was put at the start of the conditional.
1002 +gdb_test "break multi_line_if_conditional" \
1003 + "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \
1004 + "breakpoint at start of multi line if conditional"
1006 +gdb_test "break multi_line_while_conditional" \
1007 + "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
1008 + "breakpoint at start of multi line while conditional"
1010 +set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
1011 +set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
1014 +# check to see what breakpoints are set
1016 +if [target_info exists gdb_stub] {
1017 + set main_line $bp_location5
1019 + set main_line $bp_location6
1022 +if {$hp_aCC_compiler} {
1023 + set proto "\\(int\\)"
1028 +set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
1029 +set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
1030 +set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
1032 +# Test a pending breakpoint in PIE executable does not crash later GDB.
1033 +gdb_breakpoint "non_existent_function" allow-pending
1035 +gdb_test "info break" \
1036 + "Num\[ \]+Type\[ \]+Disp Enb Address\[ \]+What.*
1037 +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
1038 +\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).*
1039 +\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.*
1040 +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
1041 +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
1042 +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
1043 +\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
1044 +\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4.*
1045 +\[0-9\]+\[\t \]+breakpoint keep y.* <PENDING> *non_existent_function" \
1048 +# FIXME: The rest of this test doesn't work with anything that can't
1049 +# handle arguments.
1050 +# Huh? There doesn't *appear* to be anything that passes arguments
1052 +if [istarget "mips-idt-*"] then {
1057 +# run until the breakpoint at main is hit. For non-stubs-using targets.
1059 +if ![target_info exists use_gdb_stub] {
1060 + if [istarget "*-*-vxworks*"] then {
1061 + send_gdb "run vxmain \"2\"\n"
1063 + verbose "Timeout is now $timeout seconds" 2
1068 + -re "The program .* has been started already.*y or n. $" {
1072 + -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
1073 + { pass "run until function breakpoint" }
1074 + -re ".*$gdb_prompt $" { fail "run until function breakpoint" }
1075 + timeout { fail "run until function breakpoint (timeout)" }
1078 + if ![target_info exists gdb_stub] {
1079 + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
1084 +# run until the breakpoint at a line number
1086 +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
1087 + "run until breakpoint set at a line number"
1090 +# Run until the breakpoint set in a function in a file
1092 +for {set i 6} {$i >= 1} {incr i -1} {
1093 + gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
1094 + "run until file:function($i) breakpoint"
1098 +# Run until the breakpoint set at a quoted function
1100 +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \
1101 + "run until quoted breakpoint"
1103 +# run until the file:function breakpoint at a line number in a file
1105 +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
1106 + "run until file:linenum breakpoint"
1108 +# Test break at offset +1
1109 +set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
1111 +gdb_test "break +1" \
1112 + "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
1113 + "breakpoint offset +1"
1115 +# Check to see if breakpoint is hit when stepped onto
1118 + ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
1119 + "step onto breakpoint"
1122 +# delete all breakpoints so we can start over, course this can be a test too
1127 +# test temporary breakpoint at function
1130 +gdb_test "tbreak main" "reakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
1133 +# test break at function in file
1136 +gdb_test "tbreak $srcfile:factorial" "reakpoint.*at.* file .*$srcfile, line.*" \
1137 + "Temporary breakpoint function in file"
1140 +# test break at line number
1142 +send_gdb "tbreak $bp_location1\n"
1144 + -re "reakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
1145 + -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
1146 + timeout { fail "breakpoint line number #1 (timeout)" }
1149 +gdb_test "tbreak $bp_location6" "reakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2"
1152 +# test break at line number in file
1154 +send_gdb "tbreak $srcfile:$bp_location2\n"
1156 + -re "reakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
1157 + -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
1158 + timeout { fail "Temporary breakpoint line number in file #1 (timeout)" }
1161 +set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
1162 +gdb_test "tbreak $srcfile:$bp_location11" "reakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2"
1165 +# check to see what breakpoints are set (temporary this time)
1167 +gdb_test "info break" "Num.*Type.*Disp Enb Address.*What.*\[\r\n\]
1168 +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
1169 +\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\]
1170 +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
1171 +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
1172 +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
1173 +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
1174 + "Temporary breakpoint info"
1179 +# Verify that catchpoints for fork, vfork and exec don't trigger
1180 +# inappropriately. (There are no calls to those system functions
1181 +# in this test program.)
1183 +if ![runto_main] then { fail "break tests suppressed" }
1187 + -re "Catch requires an event name.*$gdb_prompt $"\
1188 + {pass "catch requires an event name"}
1189 + -re "$gdb_prompt $"\
1190 + {fail "catch requires an event name"}
1191 + timeout {fail "(timeout) catch requires an event name"}
1195 +set name "set catch fork, never expected to trigger"
1196 +send_gdb "catch fork\n"
1198 + -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
1200 + -re "Catch of fork not yet implemented.*$gdb_prompt $"
1202 + -re "$gdb_prompt $"
1204 + timeout {fail "(timeout) $name"}
1208 +set name "set catch vfork, never expected to trigger"
1209 +send_gdb "catch vfork\n"
1211 +# If we are on HP-UX 10.20, we expect an error message to be
1212 +# printed if we type "catch vfork" at the gdb gdb_prompt. This is
1213 +# because on HP-UX 10.20, we cannot catch vfork events.
1215 +if [istarget "hppa*-hp-hpux10.20"] then {
1217 + -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
1219 + -re "$gdb_prompt $"
1221 + timeout {fail "(timeout) $name"}
1225 + -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
1227 + -re "Catch of vfork not yet implemented.*$gdb_prompt $"
1229 + -re "$gdb_prompt $"
1231 + timeout {fail "(timeout) $name"}
1235 +set name "set catch exec, never expected to trigger"
1236 +send_gdb "catch exec\n"
1238 + -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
1240 + -re "Catch of exec not yet implemented.*$gdb_prompt $"
1242 + -re "$gdb_prompt $" {fail $name}
1243 + timeout {fail "(timeout) $name"}
1246 +# Verify that GDB responds gracefully when asked to set a breakpoint
1247 +# on a nonexistent source line.
1249 +gdb_test_no_output "set breakpoint pending off"
1250 +gdb_test "break 999" \
1251 + "No line 999 in the current file." \
1252 + "break on non-existent source line"
1254 +# Run to the desired default location. If not positioned here, the
1255 +# tests below don't work.
1257 +gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1"
1260 +# Verify that GDB allows one to just say "break", which is treated
1261 +# as the "default" breakpoint. Note that GDB gets cute when printing
1262 +# the informational message about other breakpoints at the same
1263 +# location. We'll hit that bird with this stone too.
1267 + -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
1268 + {pass "break on default location, 1st time"}
1269 + -re "$gdb_prompt $"\
1270 + {fail "break on default location, 1st time"}
1271 + timeout {fail "(timeout) break on default location, 1st time"}
1276 + -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1277 + {pass "break on default location, 2nd time"}
1278 + -re "$gdb_prompt $"\
1279 + {fail "break on default location, 2nd time"}
1280 + timeout {fail "(timeout) break on default location, 2nd time"}
1285 + -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1286 + {pass "break on default location, 3rd time"}
1287 + -re "$gdb_prompt $"\
1288 + {fail "break on default location, 3rd time"}
1289 + timeout {fail "(timeout) break on default location, 3rd time"}
1294 + -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1295 + {pass "break on default location, 4th time"}
1296 + -re "$gdb_prompt $"\
1297 + {fail "break on default location, 4th time"}
1298 + timeout {fail "(timeout) break on default location, 4th time"}
1301 +# Verify that a "silent" breakpoint can be set, and that GDB is indeed
1302 +# "silent" about its triggering.
1304 +if ![runto_main] then { fail "break tests suppressed" }
1306 +send_gdb "break $bp_location1\n"
1308 + -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\
1309 + {pass "set to-be-silent break bp_location1"}
1310 + -re "$gdb_prompt $"\
1311 + {fail "set to-be-silent break bp_location1"}
1312 + timeout {fail "(timeout) set to-be-silent break bp_location1"}
1315 +send_gdb "commands $expect_out(1,string)\n"
1316 +send_gdb "silent\n"
1319 + -re ".*$gdb_prompt $"\
1320 + {pass "set silent break bp_location1"}
1321 + timeout {fail "(timeout) set silent break bp_location1"}
1324 +send_gdb "info break $expect_out(1,string)\n"
1326 + -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\
1327 + {pass "info silent break bp_location1"}
1328 + -re "$gdb_prompt $"\
1329 + {fail "info silent break bp_location1"}
1330 + timeout {fail "(timeout) info silent break bp_location1"}
1332 +send_gdb "continue\n"
1334 + -re "Continuing.\r\n$gdb_prompt $"\
1335 + {pass "hit silent break bp_location1"}
1336 + -re "$gdb_prompt $"\
1337 + {fail "hit silent break bp_location1"}
1338 + timeout {fail "(timeout) hit silent break bp_location1"}
1342 + -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\
1343 + {pass "stopped for silent break bp_location1"}
1344 + -re "$gdb_prompt $"\
1345 + {fail "stopped for silent break bp_location1"}
1346 + timeout {fail "(timeout) stopped for silent break bp_location1"}
1349 +# Verify that GDB can at least parse a breakpoint with the
1350 +# "thread" keyword. (We won't attempt to test here that a
1351 +# thread-specific breakpoint really triggers appropriately.
1352 +# The gdb.threads subdirectory contains tests for that.)
1354 +set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
1355 +send_gdb "break $bp_location12 thread 999\n"
1357 + -re "Unknown thread 999.*$gdb_prompt $"\
1358 + {pass "thread-specific breakpoint on non-existent thread disallowed"}
1359 + -re "$gdb_prompt $"\
1360 + {fail "thread-specific breakpoint on non-existent thread disallowed"}
1361 + timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
1363 +send_gdb "break $bp_location12 thread foo\n"
1365 + -re "Junk after thread keyword..*$gdb_prompt $"\
1366 + {pass "thread-specific breakpoint on bogus thread ID disallowed"}
1367 + -re "$gdb_prompt $"\
1368 + {fail "thread-specific breakpoint on bogus thread ID disallowed"}
1369 + timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
1372 +# Verify that GDB responds gracefully to a breakpoint command with
1373 +# trailing garbage.
1375 +send_gdb "break $bp_location12 foo\n"
1377 + -re "malformed linespec error: unexpected string, \"foo\"\r\n$gdb_prompt $"\
1378 + {pass "breakpoint with trailing garbage disallowed"}
1379 + -re "$gdb_prompt $"\
1380 + {fail "breakpoint with trailing garbage disallowed"}
1381 + timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
1384 +# Verify that GDB responds gracefully to a "clear" command that has
1385 +# no matching breakpoint. (First, get us off the current source line,
1386 +# which we know has a breakpoint.)
1390 + -re ".*$gdb_prompt $"\
1391 + {pass "step over breakpoint"}
1392 + timeout {fail "(timeout) step over breakpoint"}
1394 +send_gdb "clear 81\n"
1396 + -re "No breakpoint at 81..*$gdb_prompt $"\
1397 + {pass "clear line has no breakpoint disallowed"}
1398 + -re "$gdb_prompt $"\
1399 + {fail "clear line has no breakpoint disallowed"}
1400 + timeout {fail "(timeout) clear line has no breakpoint disallowed"}
1404 + -re "No breakpoint at this line..*$gdb_prompt $"\
1405 + {pass "clear current line has no breakpoint disallowed"}
1406 + -re "$gdb_prompt $"\
1407 + {fail "clear current line has no breakpoint disallowed"}
1408 + timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
1411 +# Verify that we can set and clear multiple breakpoints.
1413 +# We don't test that it deletes the correct breakpoints. We do at
1414 +# least test that it deletes more than one breakpoint.
1416 +gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
1417 +gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
1418 +gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
1420 +# Verify that a breakpoint can be set via a convenience variable.
1422 +send_gdb "set \$foo=$bp_location11\n"
1424 + -re "$gdb_prompt $"\
1425 + {pass "set convenience variable \$foo to bp_location11"}
1426 + timeout {fail "(timeout) set convenience variable \$foo to bp_location11"}
1428 +send_gdb "break \$foo\n"
1430 + -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\
1431 + {pass "set breakpoint via convenience variable"}
1432 + -re "$gdb_prompt $"\
1433 + {fail "set breakpoint via convenience variable"}
1434 + timeout {fail "(timeout) set breakpoint via convenience variable"}
1437 +# Verify that GDB responds gracefully to an attempt to set a
1438 +# breakpoint via a convenience variable whose type is not integer.
1440 +send_gdb "set \$foo=81.5\n"
1442 + -re "$gdb_prompt $"\
1443 + {pass "set convenience variable \$foo to 81.5"}
1444 + timeout {fail "(timeout) set convenience variable \$foo to 81.5"}
1446 +send_gdb "break \$foo\n"
1448 + -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
1449 + {pass "set breakpoint via non-integer convenience variable disallowed"}
1450 + -re "$gdb_prompt $"\
1451 + {fail "set breakpoint via non-integer convenience variable disallowed"}
1452 + timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
1455 +# Verify that we can set and trigger a breakpoint in a user-called function.
1457 +send_gdb "break marker2\n"
1459 + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\
1460 + {pass "set breakpoint on to-be-called function"}
1461 + -re "$gdb_prompt $"\
1462 + {fail "set breakpoint on to-be-called function"}
1463 + timeout {fail "(timeout) set breakpoint on to-be-called function"}
1465 +send_gdb "print marker2(99)\n"
1467 + -re "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2$proto. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.\r\n$gdb_prompt $"\
1468 + {pass "hit breakpoint on called function"}
1469 + -re "$gdb_prompt $"\
1470 + {fail "hit breakpoint on called function"}
1471 + timeout {fail "(timeout) hit breakpoint on called function"}
1474 +# As long as we're stopped (breakpointed) in a called function,
1475 +# verify that we can successfully backtrace & such from here.
1477 +# In this and the following test, the _sr4export check apparently is needed
1478 +# for hppa*-*-hpux.
1482 + -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\
1483 + {pass "backtrace while in called function"}
1484 + -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\
1485 + {pass "backtrace while in called function"}
1486 + -re "$gdb_prompt $"\
1487 + {fail "backtrace while in called function"}
1488 + timeout {fail "(timeout) backtrace while in called function"}
1491 +# Return from the called function. For remote targets, it's important to do
1492 +# this before runto_main, which otherwise may silently stop on the dummy
1493 +# breakpoint inserted by GDB at the program's entry point.
1495 +send_gdb "finish\n"
1497 + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\
1498 + {pass "finish from called function"}
1499 + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\
1500 + {pass "finish from called function"}
1501 + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\
1502 + {pass "finish from called function"}
1503 + -re "$gdb_prompt $"\
1504 + {fail "finish from called function"}
1505 + timeout {fail "(timeout) finish from called function"}
1508 +# Verify that GDB responds gracefully to a "finish" command with
1511 +if ![runto_main] then { fail "break tests suppressed" }
1513 +send_gdb "finish 123\n"
1515 + -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
1516 + {pass "finish with arguments disallowed"}
1517 + -re "$gdb_prompt $"\
1518 + {fail "finish with arguments disallowed"}
1519 + timeout {fail "(timeout) finish with arguments disallowed"}
1522 +# Verify that GDB responds gracefully to a request to "finish" from
1523 +# the outermost frame. On a stub that never exits, this will just
1524 +# run to the stubs routine, so we don't get this error... Thus the
1525 +# second condition.
1528 +send_gdb "finish\n"
1530 + -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
1531 + {pass "finish from outermost frame disallowed"}
1532 + -re "Run till exit from.*\r\n$gdb_prompt $" {
1533 + pass "finish from outermost frame disallowed"
1535 + -re "$gdb_prompt $"\
1536 + {fail "finish from outermost frame disallowed"}
1537 + timeout {fail "(timeout) finish from outermost frame disallowed"}
1540 +# Verify that we can explicitly ask GDB to stop on all shared library
1541 +# events, and that it does so.
1543 +if [istarget "hppa*-*-hpux*"] then {
1544 + if ![runto_main] then { fail "break tests suppressed" }
1546 + send_gdb "set stop-on-solib-events 1\n"
1548 + -re "$gdb_prompt $"\
1549 + {pass "set stop-on-solib-events"}
1550 + timeout {fail "(timeout) set stop-on-solib-events"}
1555 + -re ".*Start it from the beginning.*y or n. $"\
1558 + -re ".*Stopped due to shared library event.*$gdb_prompt $"\
1559 + {pass "triggered stop-on-solib-events"}
1560 + -re "$gdb_prompt $"\
1561 + {fail "triggered stop-on-solib-events"}
1562 + timeout {fail "(timeout) triggered stop-on-solib-events"}
1565 + -re "$gdb_prompt $"\
1566 + {fail "rerun for stop-on-solib-events"}
1567 + timeout {fail "(timeout) rerun for stop-on-solib-events"}
1570 + send_gdb "set stop-on-solib-events 0\n"
1572 + -re "$gdb_prompt $"\
1573 + {pass "reset stop-on-solib-events"}
1574 + timeout {fail "(timeout) reset stop-on-solib-events"}
1578 +# Hardware breakpoints are unsupported on HP-UX. Verify that GDB
1579 +# gracefully responds to requests to create them.
1581 +if [istarget "hppa*-*-hpux*"] then {
1582 + if ![runto_main] then { fail "break tests suppressed" }
1584 + send_gdb "hbreak\n"
1586 + -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
1587 + {pass "hw breaks disallowed"}
1588 + -re "$gdb_prompt $"\
1589 + {fail "hw breaks disallowed"}
1590 + timeout {fail "(timeout) hw breaks disallowed"}
1593 + send_gdb "thbreak\n"
1595 + -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
1596 + {pass "temporary hw breaks disallowed"}
1597 + -re "$gdb_prompt $"\
1598 + {fail "temporary hw breaks disallowed"}
1599 + timeout {fail "(timeout) temporary hw breaks disallowed"}
1607 +# Test "next" over recursive function call.
1610 +proc test_next_with_recursion {} {
1615 + if [target_info exists use_gdb_stub] {
1616 + # Reload the program.
1617 + delete_breakpoints
1618 + gdb_load ${binfile};
1620 + # FIXME: should be using runto
1621 + gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
1623 + delete_breakpoints
1626 + gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
1628 + # Run until we call factorial with 6
1630 + if [istarget "*-*-vxworks*"] then {
1631 + send_gdb "run vxmain \"6\"\n"
1636 + -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
1637 + -re ".*$gdb_prompt $" {
1638 + fail "run to factorial(6)";
1639 + gdb_suppress_tests;
1641 + timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
1644 + # Continue until we call factorial recursively with 5.
1646 + if [gdb_test "continue" \
1647 + "Continuing.*Break.* factorial .value=5. .*" \
1648 + "continue to factorial(5)"] then { gdb_suppress_tests }
1650 + # Do a backtrace just to confirm how many levels deep we are.
1652 + if [gdb_test "backtrace" \
1653 + "#0\[ \t\]+ factorial .value=5..*" \
1654 + "backtrace from factorial(5)"] then { gdb_suppress_tests }
1656 + # Now a "next" should position us at the recursive call, which
1657 + # we will be performing with 4.
1659 + if [gdb_test "next" \
1660 + ".* factorial .value - 1.;.*" \
1661 + "next to recursive call"] then { gdb_suppress_tests }
1663 + # Disable the breakpoint at the entry to factorial by deleting them all.
1664 + # The "next" should run until we return to the next line from this
1665 + # recursive call to factorial with 4.
1666 + # Buggy versions of gdb will stop instead at the innermost frame on
1667 + # the line where we are trying to "next" to.
1669 + delete_breakpoints
1671 + if [istarget "mips*tx39-*"] {
1674 + # We used to set timeout here for all other targets as well. This
1675 + # is almost certainly wrong. The proper timeout depends on the
1676 + # target system in use, and how we communicate with it, so there
1677 + # is no single value appropriate for all targets. The timeout
1678 + # should be established by the Dejagnu config file(s) for the
1679 + # board, and respected by the test suite.
1681 + # For example, if I'm running GDB over an SSH tunnel talking to a
1682 + # portmaster in California talking to an ancient 68k board running
1683 + # a crummy ROM monitor (a situation I can only wish were
1684 + # hypothetical), then I need a large timeout. But that's not the
1685 + # kind of knowledge that belongs in this file.
1687 + gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
1688 + "next over recursive call"
1690 + # OK, we should be back in the same stack frame we started from.
1691 + # Do a backtrace just to confirm.
1693 + set result [gdb_test "backtrace" \
1694 + "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
1695 + "backtrace from factorial(5.1)"]
1696 + if { $result != 0 } { gdb_suppress_tests }
1698 + if [target_info exists gdb,noresults] { gdb_suppress_tests }
1699 + gdb_continue_to_end "recursive next test"
1700 + gdb_stop_suppressing_tests;
1703 +test_next_with_recursion
1708 +# build a new file with optimization enabled so that we can try breakpoints
1709 +# on targets with optimized prologues
1711 +set binfileo2 ${objdir}/${subdir}/${testfile}o2
1713 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
1714 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1717 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
1718 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1721 +if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
1722 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1725 +if [get_compiler_info ${binfileo2}] {
1731 +gdb_reinitialize_dir $srcdir/$subdir
1732 +gdb_load ${binfileo2}
1734 +if [target_info exists gdb_stub] {
1735 + gdb_step_for_stub;
1739 +# test break at function
1741 +gdb_test "break main" \
1742 + "Breakpoint.*at.* file .*$srcfile, line.*" \
1743 + "breakpoint function, optimized file"
1746 +# test break at function
1748 +gdb_test "break marker4" \
1749 + "Breakpoint.*at.* file .*$srcfile1, line.*" \
1750 + "breakpoint small function, optimized file"
1753 +# run until the breakpoint at main is hit. For non-stubs-using targets.
1755 +if ![target_info exists use_gdb_stub] {
1756 + if [istarget "*-*-vxworks*"] then {
1757 + send_gdb "run vxmain \"2\"\n"
1759 + verbose "Timeout is now $timeout seconds" 2
1764 + -re "The program .* has been started already.*y or n. $" {
1768 + -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
1769 + { pass "run until function breakpoint, optimized file" }
1770 + -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
1771 + { pass "run until function breakpoint, optimized file (code motion)" }
1772 + -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" }
1773 + timeout { fail "run until function breakpoint, optimized file (timeout)" }
1776 + if ![target_info exists gdb_stub] {
1777 + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
1782 +# run until the breakpoint at a small function
1786 +# Add a second pass pattern. The behavior differs here between stabs
1787 +# and dwarf for one-line functions. Stabs preserves two line symbols
1788 +# (one before the prologue and one after) with the same line number,
1789 +# but dwarf regards these as duplicates and discards one of them.
1790 +# Therefore the address after the prologue (where the breakpoint is)
1791 +# has no exactly matching line symbol, and GDB reports the breakpoint
1792 +# as if it were in the middle of a line rather than at the beginning.
1794 +set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
1795 +set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
1796 +send_gdb "continue\n"
1798 + -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
1799 + pass "run until breakpoint set at small function, optimized file"
1801 + -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
1802 + pass "run until breakpoint set at small function, optimized file"
1804 + -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
1805 + # marker4() is defined at line 46 when compiled with -DPROTOTYPES
1806 + pass "run until breakpoint set at small function, optimized file (line bp_location14)"
1808 + -re ".*$gdb_prompt " {
1809 + fail "run until breakpoint set at small function, optimized file"
1812 + fail "run until breakpoint set at small function, optimized file (timeout)"
1817 +# Reset the default arguments for VxWorks
1818 +if [istarget "*-*-vxworks*"] {
1820 + verbose "Timeout is now $timeout seconds" 2
1821 + send_gdb "set args main\n"
1822 + gdb_expect -re ".*$gdb_prompt $" {}
1824 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/corefile.exp
1825 ===================================================================
1826 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1827 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/corefile.exp 2012-06-02 18:24:38.511266528 +0200
1829 +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
1830 +# Free Software Foundation, Inc.
1832 +# This program is free software; you can redistribute it and/or modify
1833 +# it under the terms of the GNU General Public License as published by
1834 +# the Free Software Foundation; either version 2 of the License, or
1835 +# (at your option) any later version.
1837 +# This program is distributed in the hope that it will be useful,
1838 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1839 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1840 +# GNU General Public License for more details.
1842 +# You should have received a copy of the GNU General Public License
1843 +# along with this program; if not, write to the Free Software
1844 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1846 +# This file was written by Fred Fish. (fnf@cygnus.com)
1848 +# are we on a target board
1849 +if ![isnative] then {
1853 +set testfile "coremaker"
1854 +set srcfile ${testfile}.c
1855 +set binfile ${objdir}/${subdir}/${testfile}
1856 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } {
1857 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1860 +# Create and source the file that provides information about the compiler
1861 +# used to compile the test case.
1862 +if [get_compiler_info ${binfile}] {
1866 +# Create a core file named "corefile" rather than just "core", to
1867 +# avoid problems with sys admin types that like to regularly prune all
1868 +# files named "core" from the system.
1870 +# Arbitrarily try setting the core size limit to "unlimited" since
1871 +# this does not hurt on systems where the command does not work and
1872 +# allows us to generate a core on systems where it does.
1874 +# Some systems append "core" to the name of the program; others append
1875 +# the name of the program to "core"; still others (like Linux, as of
1876 +# May 2003) create cores named "core.PID". In the latter case, we
1877 +# could have many core files lying around, and it may be difficult to
1878 +# tell which one is ours, so let's run the program in a subdirectory.
1880 +set coredir "${objdir}/${subdir}/coredir.[getpid]"
1881 +file mkdir $coredir
1882 +catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
1883 +# remote_exec host "${binfile}"
1884 +foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
1885 + if [remote_file build exists $i] {
1886 + remote_exec build "mv $i ${objdir}/${subdir}/corefile"
1890 +# Check for "core.PID".
1891 +if { $found == 0 } {
1892 + set names [glob -nocomplain -directory $coredir core.*]
1893 + if {[llength $names] == 1} {
1894 + set corefile [file join $coredir [lindex $names 0]]
1895 + remote_exec build "mv $corefile ${objdir}/${subdir}/corefile"
1899 +if { $found == 0 } {
1900 + # The braindamaged HPUX shell quits after the ulimit -c above
1901 + # without executing ${binfile}. So we try again without the
1902 + # ulimit here if we didn't find a core file above.
1903 + # Oh, I should mention that any "braindamaged" non-Unix system has
1904 + # the same problem. I like the cd bit too, it's really neat'n stuff.
1905 + catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
1906 + foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
1907 + if [remote_file build exists $i] {
1908 + remote_exec build "mv $i ${objdir}/${subdir}/corefile"
1914 +# Try to clean up after ourselves.
1915 +remote_file build delete [file join $coredir coremmap.data]
1916 +remote_exec build "rmdir $coredir"
1918 +if { $found == 0 } {
1919 + warning "can't generate a core file - core tests suppressed - check ulimit -c"
1924 +# Test that we can simply startup with a "-core=corefile" command line arg
1925 +# and recognize that the core file is a valid, usable core file.
1926 +# To do this, we must shutdown the currently running gdb and restart
1927 +# with the -core args. We can't use gdb_start because it looks for
1928 +# the first gdb prompt, and the message we are looking for occurs
1929 +# before the first prompt. Also, we can't include GDBFLAGS because
1930 +# if it is empty, this confuses gdb with an empty argument that it
1931 +# grumbles about (said grumbling currently being ignored in gdb_start).
1934 +# Another problem is that on some systems (solaris for example), there
1935 +# is apparently a limit on the length of a fully specified path to
1936 +# the coremaker executable, at about 80 chars. For this case, consider
1937 +# it a pass, but note that the program name is bad.
1940 +if $verbose>1 then {
1941 + send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
1944 +set oldtimeout $timeout
1945 +set timeout [expr "$timeout + 60"]
1946 +verbose "Timeout is now $timeout seconds" 2
1947 +eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
1949 + -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
1950 + fail "args: -core=corefile (couldn't find regs)"
1952 + -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1953 + pass "args: -core=corefile"
1955 + -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1956 + pass "args: -core=corefile (with bad program name)"
1958 + -re ".*registers from core file: File in wrong format.* $" {
1959 + fail "args: -core=corefile (could not read registers from core file)"
1961 + -re ".*$gdb_prompt $" { fail "args: -core=corefile" }
1962 + timeout { fail "(timeout) starting with -core" }
1967 +# Test that startup with both an executable file and -core argument.
1968 +# See previous comments above, they are still applicable.
1973 +if $verbose>1 then {
1974 + send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n"
1978 +eval "spawn $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile";
1980 + -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1981 + pass "args: execfile -core=corefile"
1983 + -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1984 + pass "args: execfile -core=corefile (with bad program name)"
1986 + -re ".*registers from core file: File in wrong format.* $" {
1987 + fail "args: execfile -core=corefile (could not read registers from core file)"
1989 + -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" }
1990 + timeout { fail "(timeout) starting with -core" }
1992 +set timeout $oldtimeout
1993 +verbose "Timeout is now $timeout seconds" 2
1997 +# Now restart normally.
2000 +gdb_reinitialize_dir $srcdir/$subdir
2001 +gdb_load ${binfile}
2003 +# Test basic corefile recognition via core-file command.
2005 +send_gdb "core-file $objdir/$subdir/corefile\n"
2007 + -re ".* program is being debugged already.*y or n. $" {
2008 + # gdb_load may connect us to a gdbserver.
2012 + -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2013 + pass "core-file command"
2015 + -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2016 + pass "core-file command (with bad program name)"
2018 + -re ".*registers from core file: File in wrong format.* $" {
2019 + fail "core-file command (could not read registers from core file)"
2021 + -re ".*$gdb_prompt $" { fail "core-file command" }
2022 + timeout { fail "(timeout) core-file command" }
2025 +# Test correct mapping of corefile sections by printing some variables.
2027 +gdb_test "print coremaker_data" "\\\$$decimal = 202"
2028 +gdb_test "print coremaker_bss" "\\\$$decimal = 10"
2029 +gdb_test "print coremaker_ro" "\\\$$decimal = 201"
2031 +gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
2033 +# Somehow we better test the ability to read the registers out of the core
2034 +# file correctly. I don't think the other tests do this.
2036 +gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
2037 +gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp"
2039 +# Test ability to read mmap'd data
2041 +gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file"
2042 +setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*"
2043 +set test "accessing mmapped data in core file"
2044 +gdb_test_multiple "x/8bd buf2" "$test" {
2045 + -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" {
2048 + -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" {
2049 + fail "$test (mapping failed at runtime)"
2051 + -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" {
2052 + fail "$test (mapping address not found in core file)"
2056 +# test reinit_frame_cache
2058 +gdb_load ${binfile}
2059 +gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
2061 +gdb_test "core" "No core file now."
2062 Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/Makefile.in
2063 ===================================================================
2064 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2065 +++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/Makefile.in 2012-06-02 18:24:38.512266527 +0200
2071 +MISCELLANEOUS = arch.inc
2073 +all info install-info dvi install uninstall installcheck check:
2074 + @echo "Nothing to be done for $@..."
2077 + -rm -f *~ *.o a.out *.x *.ci *.tmp
2078 + -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES)
2079 + -rm -f $(MISCELLANEOUS)
2081 +distclean maintainer-clean realclean: clean
2083 + -rm -f Makefile config.status config.log
2085 + -rm -fr *.log summary detail *.plog *.sum *.psum site.*