]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.3-test-pie-20050107.patch
- rel 1.x (so no need for using epoch)
[packages/gdb.git] / gdb-6.3-test-pie-20050107.patch
CommitLineData
3a58abaf
AM
1Index: gdb-6.8.50.20081128/gdb/testsuite/configure.ac
2===================================================================
3--- gdb-6.8.50.20081128.orig/gdb/testsuite/configure.ac 2008-12-09 17:02:39.000000000 +0100
4+++ gdb-6.8.50.20081128/gdb/testsuite/configure.ac 2008-12-09 17:02:55.000000000 +0100
5@@ -116,6 +116,6 @@ AC_OUTPUT([Makefile \
6 gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \
7 gdb.fortran/Makefile gdb.server/Makefile \
8 gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile \
9- gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
10+ gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \
11 gdb.python/Makefile \
12 gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
13Index: gdb-6.8.50.20081128/gdb/testsuite/configure
14===================================================================
15--- gdb-6.8.50.20081128.orig/gdb/testsuite/configure 2008-12-09 17:02:39.000000000 +0100
16+++ gdb-6.8.50.20081128/gdb/testsuite/configure 2008-12-09 17:02:55.000000000 +0100
17@@ -3131,7 +3131,7 @@ done
18
19
20
21- ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/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.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
23 cat >confcache <<\_ACEOF
24 # This file is a shell script that caches the results of configure
25 # tests run on this system so they can be shared between configure
26@@ -3698,6 +3698,7 @@ do
27 "gdb.objc/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.objc/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.threads/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.threads/Makefile" ;;
33 "gdb.trace/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.trace/Makefile" ;;
34Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/attach.c
35===================================================================
36--- /dev/null 1970-01-01 00:00:00.000000000 +0000
37+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/attach.c 2008-12-09 17:02:55.000000000 +0100
38@@ -0,0 +1,20 @@
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.)
44+ */
45+#include <stdio.h>
46+
47+int should_exit = 0;
48+
49+int main ()
50+{
51+ int local_i = 0;
52+
53+ while (! should_exit)
54+ {
55+ local_i++;
56+ }
57+ return 0;
58+}
59Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/attach2.c
60===================================================================
61--- /dev/null 1970-01-01 00:00:00.000000000 +0000
62+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/attach2.c 2008-12-09 17:02:55.000000000 +0100
63@@ -0,0 +1,24 @@
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.)
69+ */
70+#include <stdio.h>
71+#include <stdlib.h>
72+#include <unistd.h>
73+
74+int should_exit = 0;
75+
76+int main ()
77+{
78+ int local_i = 0;
79+
80+ sleep( 10 ); /* System call causes register fetch to fail */
81+ /* This is a known HPUX "feature" */
82+ while (! should_exit)
83+ {
84+ local_i++;
85+ }
86+ return (0);
87+}
88Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/break.c
89===================================================================
90--- /dev/null 1970-01-01 00:00:00.000000000 +0000
91+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/break.c 2008-12-09 17:02:55.000000000 +0100
92@@ -0,0 +1,146 @@
93+/* This testcase is part of GDB, the GNU debugger.
94+
95+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
96+ Foundation, Inc.
97+
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.
102+
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.
107+
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.
111+
112+ Please email any bugs, comments, and/or additions to this file to:
113+ bug-gdb@prep.ai.mit.edu */
114+
115+#ifdef vxworks
116+
117+# include <stdio.h>
118+
119+/* VxWorks does not supply atoi. */
120+static int
121+atoi (z)
122+ char *z;
123+{
124+ int i = 0;
125+
126+ while (*z >= '0' && *z <= '9')
127+ i = i * 10 + (*z++ - '0');
128+ return i;
129+}
130+
131+/* I don't know of any way to pass an array to VxWorks. This function
132+ can be called directly from gdb. */
133+
134+vxmain (arg)
135+char *arg;
136+{
137+ char *argv[2];
138+
139+ argv[0] = "";
140+ argv[1] = arg;
141+ main (2, argv, (char **) 0);
142+}
143+
144+#else /* ! vxworks */
145+# include <stdio.h>
146+# include <stdlib.h>
147+#endif /* ! vxworks */
148+
149+#ifdef PROTOTYPES
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);
154+#else
155+extern int marker1 ();
156+extern int marker2 ();
157+extern void marker3 ();
158+extern void marker4 ();
159+#endif
160+
161+/*
162+ * This simple classical example of recursion is useful for
163+ * testing stack backtraces and such.
164+ */
165+
166+#ifdef PROTOTYPES
167+int factorial(int);
168+
169+int
170+main (int argc, char **argv, char **envp)
171+#else
172+int
173+main (argc, argv, envp)
174+int argc;
175+char *argv[], **envp;
176+#endif
177+{
178+#ifdef usestubs
179+ set_debug_traps(); /* set breakpoint 5 here */
180+ breakpoint();
181+#endif
182+ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
183+ fprintf (stderr, "usage: factorial <number>\n");
184+ return 1;
185+ }
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 */
194+}
195+
196+#ifdef PROTOTYPES
197+int factorial (int value)
198+#else
199+int factorial (value)
200+int value;
201+#endif
202+{
203+ if (value > 1) { /* set breakpoint 7 here */
204+ value *= factorial (value - 1);
205+ }
206+ return (value); /* set breakpoint 19 here */
207+}
208+
209+#ifdef PROTOTYPES
210+int multi_line_if_conditional (int a, int b, int c)
211+#else
212+int multi_line_if_conditional (a, b, c)
213+ int a, b, c;
214+#endif
215+{
216+ if (a /* set breakpoint 3 here */
217+ && b
218+ && c)
219+ return 0;
220+ else
221+ return 1;
222+}
223+
224+#ifdef PROTOTYPES
225+int multi_line_while_conditional (int a, int b, int c)
226+#else
227+int multi_line_while_conditional (a, b, c)
228+ int a, b, c;
229+#endif
230+{
231+ while (a /* set breakpoint 4 here */
232+ && b
233+ && c)
234+ {
235+ a--, b--, c--;
236+ }
237+ return 0;
238+}
239Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/break1.c
240===================================================================
241--- /dev/null 1970-01-01 00:00:00.000000000 +0000
242+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/break1.c 2008-12-09 17:02:55.000000000 +0100
243@@ -0,0 +1,44 @@
244+/* This testcase is part of GDB, the GNU debugger.
245+
246+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
247+ Foundation, Inc.
248+
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.
253+
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.
258+
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.
262+
263+ Please email any bugs, comments, and/or additions to this file to:
264+ bug-gdb@prep.ai.mit.edu */
265+
266+/* The code for this file was extracted from the gdb testsuite
267+ testcase "break.c". */
268+
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).
273+
274+ These functions are in a separate source file to prevent an
275+ optimizing compiler from inlining them and optimizing them away. */
276+
277+#ifdef PROTOTYPES
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 */
282+#else
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 */
287+#endif
288Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/coremaker.c
289===================================================================
290--- /dev/null 1970-01-01 00:00:00.000000000 +0000
291+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/coremaker.c 2008-12-09 17:02:55.000000000 +0100
292@@ -0,0 +1,142 @@
293+/* Copyright 1992, 1993, 1994, 1995, 1996, 1999
294+ Free Software Foundation, Inc.
295+
296+ This file is part of GDB.
297+
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.
302+
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.
307+
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. */
312+
313+/* Simple little program that just generates a core dump from inside some
314+ nested function calls. */
315+
316+#include <stdio.h>
317+#include <sys/types.h>
318+#include <fcntl.h>
319+#include <sys/mman.h>
320+#include <signal.h>
321+#include <stdlib.h>
322+#include <unistd.h>
323+
324+#ifndef __STDC__
325+#define const /**/
326+#endif
327+
328+#define MAPSIZE (8 * 1024)
329+
330+/* Don't make these automatic vars or we will have to walk back up the
331+ stack to access them. */
332+
333+char *buf1;
334+char *buf2;
335+
336+int coremaker_data = 1; /* In Data section */
337+int coremaker_bss; /* In BSS section */
338+
339+const int coremaker_ro = 201; /* In Read-Only Data section */
340+
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. */
345+
346+void
347+mmapdata ()
348+{
349+ int j, fd;
350+
351+ /* Allocate and initialize a buffer that will be used to write
352+ the file that is later mapped in. */
353+
354+ buf1 = (char *) malloc (MAPSIZE);
355+ for (j = 0; j < MAPSIZE; ++j)
356+ {
357+ buf1[j] = j;
358+ }
359+
360+ /* Write the file to map in */
361+
362+ fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666);
363+ if (fd == -1)
364+ {
365+ perror ("coremmap.data open failed");
366+ buf2 = (char *) -1;
367+ return;
368+ }
369+ write (fd, buf1, MAPSIZE);
370+
371+ /* Now map the file into our address space as buf2 */
372+
373+ buf2 = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
374+ if (buf2 == (char *) -1)
375+ {
376+ perror ("mmap failed");
377+ return;
378+ }
379+
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. */
383+
384+ for (j = 0; j < MAPSIZE; ++j)
385+ {
386+ if (buf1[j] != buf2[j])
387+ {
388+ fprintf (stderr, "mapped data is incorrect");
389+ buf2 = (char *) -1;
390+ return;
391+ }
392+ }
393+}
394+
395+void
396+func2 ()
397+{
398+ int coremaker_local[5];
399+ int i;
400+
401+#ifdef SA_FULLDUMP
402+ /* Force a corefile that includes the data section for AIX. */
403+ {
404+ struct sigaction sa;
405+
406+ sigaction (SIGABRT, (struct sigaction *)0, &sa);
407+ sa.sa_flags |= SA_FULLDUMP;
408+ sigaction (SIGABRT, &sa, (struct sigaction *)0);
409+ }
410+#endif
411+
412+ /* Make sure that coremaker_local doesn't get optimized away. */
413+ for (i = 0; i < 5; i++)
414+ coremaker_local[i] = i;
415+ coremaker_bss = 0;
416+ for (i = 0; i < 5; i++)
417+ coremaker_bss += coremaker_local[i];
418+ coremaker_data = coremaker_ro + 1;
419+ abort ();
420+}
421+
422+void
423+func1 ()
424+{
425+ func2 ();
426+}
427+
428+int main ()
429+{
430+ mmapdata ();
431+ func1 ();
432+ return 0;
433+}
434+
435Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/attach.exp
436===================================================================
437--- /dev/null 1970-01-01 00:00:00.000000000 +0000
438+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/attach.exp 2008-12-09 17:02:55.000000000 +0100
439@@ -0,0 +1,432 @@
440+# Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
441+
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.
446+#
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.
451+#
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. */
455+
456+# Please email any bugs, comments, and/or additions to this file to:
457+# bug-gdb@prep.ai.mit.edu
458+
459+if $tracelevel then {
460+ strace $tracelevel
461+ }
462+
463+set prms_id 0
464+set bug_id 0
465+
466+# On HP-UX 11.0, this test is causing a process running the program
467+# "attach" to be left around spinning. Until we figure out why, I am
468+# commenting out the test to avoid polluting tiamat (our 11.0 nightly
469+# test machine) with these processes. RT
470+#
471+# Setting the magic bit in the target app should work. I added a
472+# "kill", and also a test for the R3 register warning. JB
473+if { [istarget "hppa*-*-hpux*"] } {
474+ return 0
475+}
476+
477+# are we on a target board
478+if [is_remote target] then {
479+ return 0
480+}
481+
482+set testfile "attach"
483+set srcfile ${testfile}.c
484+set srcfile2 ${testfile}2.c
485+set binfile ${objdir}/${subdir}/${testfile}
486+set binfile2 ${objdir}/${subdir}/${testfile}2
487+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
488+set cleanupfile ${objdir}/${subdir}/${testfile}.awk
489+
490+#execute_anywhere "rm -f ${binfile} ${binfile2}"
491+remote_exec build "rm -f ${binfile} ${binfile2}"
492+# For debugging this test
493+#
494+#log_user 1
495+
496+# Clean out any old files from past runs.
497+#
498+remote_exec build "${cleanupfile}"
499+
500+# build the first test case
501+#
502+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
503+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
504+}
505+
506+# Build the in-system-call test
507+
508+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
509+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
510+}
511+
512+if [get_compiler_info ${binfile}] {
513+ return -1
514+}
515+
516+proc do_attach_tests {} {
517+ global gdb_prompt
518+ global binfile
519+ global escapedbinfile
520+ global srcfile
521+ global testfile
522+ global objdir
523+ global subdir
524+ global timeout
525+
526+ # Start the program running and then wait for a bit, to be sure
527+ # that it can be attached to.
528+ #
529+ set testpid [eval exec $binfile &]
530+ exec sleep 2
531+
532+ # Verify that we cannot attach to nonsense.
533+ #
534+ send_gdb "attach abc\n"
535+ gdb_expect {
536+ -re ".*Illegal process-id: abc.*$gdb_prompt $"\
537+ {pass "attach to nonsense is prohibited"}
538+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
539+ {
540+ # Response expected from /proc-based systems.
541+ pass "attach to nonsense is prohibited"
542+ }
543+ -re "Attaching to.*$gdb_prompt $"\
544+ {fail "attach to nonsense is prohibited (bogus pid allowed)"}
545+ -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"}
546+ timeout {fail "(timeout) attach to nonsense is prohibited"}
547+ }
548+
549+ # Verify that we cannot attach to what appears to be a valid
550+ # process ID, but is a process that doesn't exist. Traditionally,
551+ # most systems didn't have a process with ID 0, so we take that as
552+ # the default. However, there are a few exceptions.
553+ #
554+ set boguspid 0
555+ if { [istarget "*-*-*bsd*"] } {
556+ # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead
557+ # (which should have the desired effect on any version of
558+ # FreeBSD, and probably other *BSD's too).
559+ set boguspid -1
560+ }
561+ send_gdb "attach $boguspid\n"
562+ gdb_expect {
563+ -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\
564+ {
565+ # Response expected on ptrace-based systems (i.e. HP-UX 10.20).
566+ pass "attach to nonexistent process is prohibited"
567+ }
568+ -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\
569+ {
570+ # Response expected on ttrace-based systems (i.e. HP-UX 11.0).
571+ pass "attach to nonexistent process is prohibited"
572+ }
573+ -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\
574+ {pass "attach to nonexistent process is prohibited"}
575+ -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\
576+ {pass "attach to nonexistent process is prohibited"}
577+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
578+ {
579+ # Response expected from /proc-based systems.
580+ pass "attach to nonexistent process is prohibited"
581+ }
582+ -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"}
583+ timeout {
584+ fail "(timeout) attach to nonexistent process is prohibited"
585+ }
586+ }
587+
588+ # Verify that we can attach to the process by first giving its
589+ # executable name via the file command, and using attach with
590+ # the process ID.
591+ #
592+ # (Actually, the test system appears to do this automatically
593+ # for us. So, we must also be prepared to be asked if we want
594+ # to discard an existing set of symbols.)
595+ #
596+ send_gdb "file $binfile\n"
597+ gdb_expect {
598+ -re "Load new symbol table from.*y or n.*$" {
599+ send_gdb "y\n"
600+ gdb_expect {
601+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
602+ {pass "(re)set file, before attach1"}
603+ -re "$gdb_prompt $" {fail "(re)set file, before attach1"}
604+ timeout {fail "(timeout) (re)set file, before attach1"}
605+ }
606+ }
607+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
608+ {pass "set file, before attach1"}
609+ -re "$gdb_prompt $" {fail "set file, before attach1"}
610+ timeout {fail "(timeout) set file, before attach1"}
611+ }
612+
613+ send_gdb "attach $testpid\n"
614+ gdb_expect {
615+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\
616+ {pass "attach1, after setting file"}
617+ -re "$gdb_prompt $" {fail "attach1, after setting file"}
618+ timeout {fail "(timeout) attach1, after setting file"}
619+ }
620+
621+ # Verify that we can "see" the variable "should_exit" in the
622+ # program, and that it is zero.
623+ #
624+ send_gdb "print should_exit\n"
625+ gdb_expect {
626+ -re ".* = 0.*$gdb_prompt $"\
627+ {pass "after attach1, print should_exit"}
628+ -re "$gdb_prompt $" {fail "after attach1, print should_exit"}
629+ timeout {fail "(timeout) after attach1, print should_exit"}
630+ }
631+
632+ # Detach the process.
633+ #
634+ send_gdb "detach\n"
635+ gdb_expect {
636+ -re "Detaching from program: .*$escapedbinfile.*$gdb_prompt $"\
637+ {pass "attach1 detach"}
638+ -re "$gdb_prompt $" {fail "attach1 detach"}
639+ timeout {fail "(timeout) attach1 detach"}
640+ }
641+
642+ # Wait a bit for gdb to finish detaching
643+ #
644+ exec sleep 5
645+
646+ # Purge the symbols from gdb's brain. (We want to be certain
647+ # the next attach, which won't be preceded by a "file" command,
648+ # is really getting the executable file without our help.)
649+ #
650+ set old_timeout $timeout
651+ set timeout 15
652+ send_gdb "file\n"
653+ gdb_expect {
654+ -re ".*gdb internal error.*$" {
655+ fail "Internal error, prob. Memory corruption"
656+ }
657+ -re "No executable file now.*Discard symbol table.*y or n.*$" {
658+ send_gdb "y\n"
659+ gdb_expect {
660+ -re "No symbol file now.*$gdb_prompt $"\
661+ {pass "attach1, purging symbols after detach"}
662+ -re "$gdb_prompt $" {fail "attach1, purging symbols after detach"}
663+ timeout {fail "(timeout) attach1, purging symbols after detach"}
664+ }
665+ }
666+ -re "$gdb_prompt $" {fail "attach1, purging file after detach"}
667+ timeout {
668+ fail "(timeout) attach1, purging file after detach"
669+ }
670+ }
671+ set timeout $old_timeout
672+
673+ # Verify that we can attach to the process just by giving the
674+ # process ID.
675+ #
676+ send_gdb "attach $testpid\n"
677+ gdb_expect {
678+ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
679+ {pass "attach2"}
680+ -re "$gdb_prompt $" {fail "attach2"}
681+ timeout {fail "(timeout) attach2"}
682+ }
683+
684+ # Verify that we can modify the variable "should_exit" in the
685+ # program.
686+ #
687+ send_gdb "set should_exit=1\n"
688+ gdb_expect {
689+ -re "$gdb_prompt $" {pass "after attach2, set should_exit"}
690+ timeout {fail "(timeout) after attach2, set should_exit"}
691+ }
692+
693+ # Verify that the modification really happened.
694+ #
695+ send_gdb "tbreak 19\n"
696+ gdb_expect {
697+ -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $"\
698+ {pass "after attach2, set tbreak postloop"}
699+ -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"}
700+ timeout {fail "(timeout) after attach2, set tbreak postloop"}
701+ }
702+ send_gdb "continue\n"
703+ gdb_expect {
704+ -re "main.*at.*$srcfile:19.*$gdb_prompt $"\
705+ {pass "after attach2, reach tbreak postloop"}
706+ -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"}
707+ timeout {fail "(timeout) after attach2, reach tbreak postloop"}
708+ }
709+
710+ # Allow the test process to exit, to cleanup after ourselves.
711+ #
712+ send_gdb "continue\n"
713+ gdb_expect {
714+ -re "Program exited normally.*$gdb_prompt $"\
715+ {pass "after attach2, exit"}
716+ -re "$gdb_prompt $" {fail "after attach2, exit"}
717+ timeout {fail "(timeout) after attach2, exit"}
718+ }
719+
720+ # Make sure we don't leave a process around to confuse
721+ # the next test run (and prevent the compile by keeping
722+ # the text file busy), in case the "set should_exit" didn't
723+ # work.
724+ #
725+ remote_exec build "kill -9 ${testpid}"
726+ # Start the program running and then wait for a bit, to be sure
727+ # that it can be attached to.
728+ #
729+ set testpid [eval exec $binfile &]
730+ exec sleep 2
731+
732+ # Verify that we can attach to the process, and find its a.out
733+ # when we're cd'd to some directory that doesn't contain the
734+ # a.out. (We use the source path set by the "dir" command.)
735+ #
736+ send_gdb "dir ${objdir}/${subdir}\n"
737+ gdb_expect {
738+ -re ".*Source directories searched: .*$gdb_prompt $"\
739+ {pass "set source path"}
740+ -re "$gdb_prompt $" {fail "set source path"}
741+ timeout {fail "(timeout) set source path"}
742+ }
743+
744+ send_gdb "cd /tmp\n"
745+ gdb_expect {
746+ -re ".*Working directory /tmp.*$gdb_prompt $"\
747+ {pass "cd away from process' a.out"}
748+ -re "$gdb_prompt $" {fail "cd away from process' a.out"}
749+ timeout {fail "(timeout) cd away from process' a.out"}
750+ }
751+
752+ # Explicitly flush out any knowledge of the previous attachment.
753+ send_gdb "symbol\n"
754+ gdb_expect {
755+ -re ".*Discard symbol table from.*y or n. $"\
756+ {send_gdb "y\n"
757+ gdb_expect {
758+ -re ".*No symbol file now.*$gdb_prompt $"\
759+ {pass "before attach3, flush symbols"}
760+ -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
761+ timeout {fail "(timeout) before attach3, flush symbols"}
762+ }
763+ }
764+ -re ".*No symbol file now.*$gdb_prompt $"\
765+ {pass "before attach3, flush symbols"}
766+ -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
767+ timeout {fail "(timeout) before attach3, flush symbols"}
768+ }
769+ send_gdb "exec\n"
770+ gdb_expect {
771+ -re ".*No executable file now.*$gdb_prompt $"\
772+ {pass "before attach3, flush exec"}
773+ -re "$gdb_prompt $" {fail "before attach3, flush exec"}
774+ timeout {fail "(timeout) before attach3, flush exec"}
775+ }
776+
777+ send_gdb "attach $testpid\n"
778+ gdb_expect {
779+ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
780+ {pass "attach when process' a.out not in cwd"}
781+ -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"}
782+ timeout {fail "(timeout) attach when process' a.out not in cwd"}
783+ }
784+
785+ send_gdb "kill\n"
786+ gdb_expect {
787+ -re ".*Kill the program being debugged.*y or n. $"\
788+ {send_gdb "y\n"
789+ gdb_expect {
790+ -re "$gdb_prompt $" {pass "after attach3, exit"}
791+ timeout {fail "(timeout) after attach3, exit"}
792+ }
793+ }
794+ -re "$gdb_prompt $" {fail "after attach3, exit"}
795+ timeout {fail "(timeout) after attach3, exit"}
796+ }
797+
798+ # Another "don't leave a process around"
799+ remote_exec build "kill -9 ${testpid}"
800+}
801+
802+proc do_call_attach_tests {} {
803+ global gdb_prompt
804+ global binfile2
805+
806+ # Start the program running and then wait for a bit, to be sure
807+ # that it can be attached to.
808+ #
809+ set testpid [eval exec $binfile2 &]
810+ exec sleep 2
811+
812+ # Attach
813+ #
814+ gdb_test "file $binfile2" ".*" "force switch to gdb64, if necessary"
815+ send_gdb "attach $testpid\n"
816+ gdb_expect {
817+ -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" {
818+ fail "attach call, read register 3 error"
819+ }
820+ -re "Attaching to.*process $testpid.*libc.*$gdb_prompt $" {
821+ pass "attach call"
822+ }
823+ -re "$gdb_prompt $" {fail "attach call"}
824+ timeout {fail "(timeout) attach call"}
825+ }
826+
827+ # See if other registers are problems
828+ #
829+ send_gdb "i r r3\n"
830+ gdb_expect {
831+ -re ".*warning: reading register.*$gdb_prompt $" {
832+ pass "CHFts23490: known bug"
833+ }
834+ -re ".*r3.*$gdb_prompt $" {
835+ pass "Bug fixed, Yayyy!"
836+ }
837+ timeout { fail "timeout on info reg" }
838+ }
839+
840+ # Get rid of the process
841+ #
842+ gdb_test "p should_exit = 1" ".*"
843+ gdb_test "c" ".*Program exited normally.*"
844+
845+ # Be paranoid
846+ #
847+ remote_exec build "kill -9 ${testpid}"
848+
849+}
850+
851+
852+# Start with a fresh gdb
853+#
854+gdb_exit
855+gdb_start
856+gdb_reinitialize_dir $srcdir/$subdir
857+gdb_load ${binfile}
858+
859+# This is a test of gdb's ability to attach to a running process.
860+#
861+do_attach_tests
862+
863+# Test attaching when the target is inside a system call
864+#
865+gdb_exit
866+gdb_start
867+
868+gdb_reinitialize_dir $srcdir/$subdir
869+do_call_attach_tests
870+
871+return 0
872Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/break.exp
873===================================================================
874--- /dev/null 1970-01-01 00:00:00.000000000 +0000
875+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/break.exp 2008-12-09 17:24:34.000000000 +0100
876@@ -0,0 +1,973 @@
877+# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
878+# 2000, 2002, 2003, 2004
879+# Free Software Foundation, Inc.
880+
881+# This program is free software; you can redistribute it and/or modify
882+# it under the terms of the GNU General Public License as published by
883+# the Free Software Foundation; either version 2 of the License, or
884+# (at your option) any later version.
885+#
886+# This program is distributed in the hope that it will be useful,
887+# but WITHOUT ANY WARRANTY; without even the implied warranty of
888+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
889+# GNU General Public License for more details.
890+#
891+# You should have received a copy of the GNU General Public License
892+# along with this program; if not, write to the Free Software
893+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
894+
895+# Please email any bugs, comments, and/or additions to this file to:
896+# bug-gdb@prep.ai.mit.edu
897+
898+# This file was written by Rob Savoye. (rob@cygnus.com)
899+
900+# Test the same stuff but with PIE executables
901+
902+if $tracelevel then {
903+ strace $tracelevel
904+}
905+
906+
907+#
908+# test running programs
909+#
910+set prms_id 0
911+set bug_id 0
912+
913+set testfile "break"
914+set srcfile ${testfile}.c
915+set srcfile1 ${testfile}1.c
916+set binfile ${objdir}/${subdir}/${testfile}
917+
918+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
919+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
920+}
921+
922+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
923+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
924+}
925+
926+if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
927+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
928+}
929+
930+if [get_compiler_info ${binfile}] {
931+ return -1
932+}
933+
934+gdb_exit
935+gdb_start
936+gdb_reinitialize_dir $srcdir/$subdir
937+gdb_load ${binfile}
938+
939+if [target_info exists gdb_stub] {
940+ gdb_step_for_stub;
941+}
942+#
943+# test simple breakpoint setting commands
944+#
945+
946+# Test deleting all breakpoints when there are none installed,
947+# GDB should not prompt for confirmation.
948+# Note that gdb-init.exp provides a "delete_breakpoints" proc
949+# for general use elsewhere.
950+
951+send_gdb "delete breakpoints\n"
952+gdb_expect {
953+ -re "Delete all breakpoints.*$" {
954+ send_gdb "y\n"
955+ gdb_expect {
956+ -re "$gdb_prompt $" {
957+ fail "Delete all breakpoints when none (unexpected prompt)"
958+ }
959+ timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" }
960+ }
961+ }
962+ -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" }
963+ timeout { fail "Delete all breakpoints when none (timeout)" }
964+}
965+
966+#
967+# test break at function
968+#
969+gdb_test "break main" \
970+ "Breakpoint.*at.* file .*$srcfile, line.*" \
971+ "breakpoint function"
972+
973+#
974+# test break at quoted function
975+#
976+gdb_test "break \"marker2\"" \
977+ "Breakpoint.*at.* file .*$srcfile1, line.*" \
978+ "breakpoint quoted function"
979+
980+#
981+# test break at function in file
982+#
983+gdb_test "break $srcfile:factorial" \
984+ "Breakpoint.*at.* file .*$srcfile, line.*" \
985+ "breakpoint function in file"
986+
987+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
988+
989+#
990+# test break at line number
991+#
992+# Note that the default source file is the last one whose source text
993+# was printed. For native debugging, before we've executed the
994+# program, this is the file containing main, but for remote debugging,
995+# it's wherever the processor was stopped when we connected to the
996+# board. So, to be sure, we do a list command.
997+#
998+gdb_test "list main" \
999+ ".*main \\(argc, argv, envp\\).*" \
1000+ "use `list' to establish default source file"
1001+gdb_test "break $bp_location1" \
1002+ "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \
1003+ "breakpoint line number"
1004+
1005+#
1006+# test duplicate breakpoint
1007+#
1008+gdb_test "break $bp_location1" \
1009+ "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \
1010+ "breakpoint duplicate"
1011+
1012+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
1013+
1014+#
1015+# test break at line number in file
1016+#
1017+gdb_test "break $srcfile:$bp_location2" \
1018+ "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \
1019+ "breakpoint line number in file"
1020+
1021+set bp_location3 [gdb_get_line_number "set breakpoint 3 here"]
1022+set bp_location4 [gdb_get_line_number "set breakpoint 4 here"]
1023+
1024+#
1025+# Test putting a break at the start of a multi-line if conditional.
1026+# Verify the breakpoint was put at the start of the conditional.
1027+#
1028+gdb_test "break multi_line_if_conditional" \
1029+ "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \
1030+ "breakpoint at start of multi line if conditional"
1031+
1032+gdb_test "break multi_line_while_conditional" \
1033+ "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
1034+ "breakpoint at start of multi line while conditional"
1035+
1036+set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
1037+set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
1038+
1039+#
1040+# check to see what breakpoints are set
1041+#
1042+if [target_info exists gdb_stub] {
1043+ set main_line $bp_location5
1044+} else {
1045+ set main_line $bp_location6
1046+}
1047+
1048+if {$hp_aCC_compiler} {
1049+ set proto "\\(int\\)"
1050+} else {
1051+ set proto ""
1052+}
1053+
1054+set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
1055+set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
1056+set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
1057+
1058+gdb_test "info break" \
1059+ "Num\[ \]+Type\[ \]+Disp Enb Address\[ \]+What.*
1060+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
1061+\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).*
1062+\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.*
1063+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
1064+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
1065+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
1066+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
1067+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \
1068+ "breakpoint info"
1069+
1070+# FIXME: The rest of this test doesn't work with anything that can't
1071+# handle arguments.
1072+# Huh? There doesn't *appear* to be anything that passes arguments
1073+# below.
1074+if [istarget "mips-idt-*"] then {
1075+ return
1076+}
1077+
1078+#
1079+# run until the breakpoint at main is hit. For non-stubs-using targets.
1080+#
1081+if ![target_info exists use_gdb_stub] {
1082+ if [istarget "*-*-vxworks*"] then {
1083+ send_gdb "run vxmain \"2\"\n"
1084+ set timeout 120
1085+ verbose "Timeout is now $timeout seconds" 2
1086+ } else {
1087+ send_gdb "run\n"
1088+ }
1089+ gdb_expect {
1090+ -re "The program .* has been started already.*y or n. $" {
1091+ send_gdb "y\n"
1092+ exp_continue
1093+ }
1094+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
1095+ { pass "run until function breakpoint" }
1096+ -re ".*$gdb_prompt $" { fail "run until function breakpoint" }
1097+ timeout { fail "run until function breakpoint (timeout)" }
1098+ }
1099+} else {
1100+ if ![target_info exists gdb_stub] {
1101+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
1102+ }
1103+}
1104+
1105+#
1106+# run until the breakpoint at a line number
1107+#
1108+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
1109+ "run until breakpoint set at a line number"
1110+
1111+#
1112+# Run until the breakpoint set in a function in a file
1113+#
1114+for {set i 6} {$i >= 1} {incr i -1} {
1115+ gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
1116+ "run until file:function($i) breakpoint"
1117+}
1118+
1119+#
1120+# Run until the breakpoint set at a quoted function
1121+#
1122+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \
1123+ "run until quoted breakpoint"
1124+#
1125+# run until the file:function breakpoint at a line number in a file
1126+#
1127+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
1128+ "run until file:linenum breakpoint"
1129+
1130+# Test break at offset +1
1131+set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
1132+
1133+gdb_test "break +1" \
1134+ "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
1135+ "breakpoint offset +1"
1136+
1137+# Check to see if breakpoint is hit when stepped onto
1138+
1139+gdb_test "step" \
1140+ ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
1141+ "step onto breakpoint"
1142+
1143+#
1144+# delete all breakpoints so we can start over, course this can be a test too
1145+#
1146+delete_breakpoints
1147+
1148+#
1149+# test temporary breakpoint at function
1150+#
1151+
1152+gdb_test "tbreak main" "reakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
1153+
1154+#
1155+# test break at function in file
1156+#
1157+
1158+gdb_test "tbreak $srcfile:factorial" "reakpoint.*at.* file .*$srcfile, line.*" \
1159+ "Temporary breakpoint function in file"
1160+
1161+#
1162+# test break at line number
1163+#
1164+send_gdb "tbreak $bp_location1\n"
1165+gdb_expect {
1166+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
1167+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
1168+ timeout { fail "breakpoint line number #1 (timeout)" }
1169+}
1170+
1171+gdb_test "tbreak $bp_location6" "reakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2"
1172+
1173+#
1174+# test break at line number in file
1175+#
1176+send_gdb "tbreak $srcfile:$bp_location2\n"
1177+gdb_expect {
1178+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
1179+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
1180+ timeout { fail "Temporary breakpoint line number in file #1 (timeout)" }
1181+}
1182+
1183+set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
1184+gdb_test "tbreak $srcfile:$bp_location11" "reakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2"
1185+
1186+#
1187+# check to see what breakpoints are set (temporary this time)
1188+#
1189+gdb_test "info break" "Num.*Type.*Disp Enb Address.*What.*\[\r\n\]
1190+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
1191+\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\]
1192+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
1193+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
1194+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
1195+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
1196+ "Temporary breakpoint info"
1197+
1198+
1199+#***********
1200+
1201+# Verify that catchpoints for fork, vfork and exec don't trigger
1202+# inappropriately. (There are no calls to those system functions
1203+# in this test program.)
1204+#
1205+if ![runto_main] then { fail "break tests suppressed" }
1206+
1207+send_gdb "catch\n"
1208+gdb_expect {
1209+ -re "Catch requires an event name.*$gdb_prompt $"\
1210+ {pass "catch requires an event name"}
1211+ -re "$gdb_prompt $"\
1212+ {fail "catch requires an event name"}
1213+ timeout {fail "(timeout) catch requires an event name"}
1214+}
1215+
1216+
1217+set name "set catch fork, never expected to trigger"
1218+send_gdb "catch fork\n"
1219+gdb_expect {
1220+ -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
1221+ {pass $name}
1222+ -re "Catch of fork not yet implemented.*$gdb_prompt $"
1223+ {pass $name}
1224+ -re "$gdb_prompt $"
1225+ {fail $name}
1226+ timeout {fail "(timeout) $name"}
1227+}
1228+
1229+
1230+set name "set catch vfork, never expected to trigger"
1231+send_gdb "catch vfork\n"
1232+
1233+# If we are on HP-UX 10.20, we expect an error message to be
1234+# printed if we type "catch vfork" at the gdb gdb_prompt. This is
1235+# because on HP-UX 10.20, we cannot catch vfork events.
1236+
1237+if [istarget "hppa*-hp-hpux10.20"] then {
1238+ gdb_expect {
1239+ -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
1240+ {pass $name}
1241+ -re "$gdb_prompt $"
1242+ {fail $name}
1243+ timeout {fail "(timeout) $name"}
1244+ }
1245+} else {
1246+ gdb_expect {
1247+ -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
1248+ {pass $name}
1249+ -re "Catch of vfork not yet implemented.*$gdb_prompt $"
1250+ {pass $name}
1251+ -re "$gdb_prompt $"
1252+ {fail $name}
1253+ timeout {fail "(timeout) $name"}
1254+ }
1255+}
1256+
1257+set name "set catch exec, never expected to trigger"
1258+send_gdb "catch exec\n"
1259+gdb_expect {
1260+ -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
1261+ {pass $name}
1262+ -re "Catch of exec not yet implemented.*$gdb_prompt $"
1263+ {pass $name}
1264+ -re "$gdb_prompt $" {fail $name}
1265+ timeout {fail "(timeout) $name"}
1266+}
1267+
1268+# Verify that GDB responds gracefully when asked to set a breakpoint
1269+# on a nonexistent source line.
1270+#
1271+send_gdb "break 999\n"
1272+gdb_expect {
1273+ -re "No line 999 in file .*$gdb_prompt $"\
1274+ {pass "break on non-existent source line"}
1275+ -re "$gdb_prompt $"\
1276+ {fail "break on non-existent source line"}
1277+ timeout {fail "(timeout) break on non-existent source line"}
1278+}
1279+
1280+# Run to the desired default location. If not positioned here, the
1281+# tests below don't work.
1282+#
1283+gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1"
1284+
1285+
1286+# Verify that GDB allows one to just say "break", which is treated
1287+# as the "default" breakpoint. Note that GDB gets cute when printing
1288+# the informational message about other breakpoints at the same
1289+# location. We'll hit that bird with this stone too.
1290+#
1291+send_gdb "break\n"
1292+gdb_expect {
1293+ -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
1294+ {pass "break on default location, 1st time"}
1295+ -re "$gdb_prompt $"\
1296+ {fail "break on default location, 1st time"}
1297+ timeout {fail "(timeout) break on default location, 1st time"}
1298+}
1299+
1300+send_gdb "break\n"
1301+gdb_expect {
1302+ -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1303+ {pass "break on default location, 2nd time"}
1304+ -re "$gdb_prompt $"\
1305+ {fail "break on default location, 2nd time"}
1306+ timeout {fail "(timeout) break on default location, 2nd time"}
1307+}
1308+
1309+send_gdb "break\n"
1310+gdb_expect {
1311+ -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1312+ {pass "break on default location, 3rd time"}
1313+ -re "$gdb_prompt $"\
1314+ {fail "break on default location, 3rd time"}
1315+ timeout {fail "(timeout) break on default location, 3rd time"}
1316+}
1317+
1318+send_gdb "break\n"
1319+gdb_expect {
1320+ -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1321+ {pass "break on default location, 4th time"}
1322+ -re "$gdb_prompt $"\
1323+ {fail "break on default location, 4th time"}
1324+ timeout {fail "(timeout) break on default location, 4th time"}
1325+}
1326+
1327+# Verify that a "silent" breakpoint can be set, and that GDB is indeed
1328+# "silent" about its triggering.
1329+#
1330+if ![runto_main] then { fail "break tests suppressed" }
1331+
1332+send_gdb "break $bp_location1\n"
1333+gdb_expect {
1334+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\
1335+ {pass "set to-be-silent break bp_location1"}
1336+ -re "$gdb_prompt $"\
1337+ {fail "set to-be-silent break bp_location1"}
1338+ timeout {fail "(timeout) set to-be-silent break bp_location1"}
1339+}
1340+
1341+send_gdb "commands $expect_out(1,string)\n"
1342+send_gdb "silent\n"
1343+send_gdb "end\n"
1344+gdb_expect {
1345+ -re ".*$gdb_prompt $"\
1346+ {pass "set silent break bp_location1"}
1347+ timeout {fail "(timeout) set silent break bp_location1"}
1348+}
1349+
1350+send_gdb "info break $expect_out(1,string)\n"
1351+gdb_expect {
1352+ -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\
1353+ {pass "info silent break bp_location1"}
1354+ -re "$gdb_prompt $"\
1355+ {fail "info silent break bp_location1"}
1356+ timeout {fail "(timeout) info silent break bp_location1"}
1357+}
1358+send_gdb "continue\n"
1359+gdb_expect {
1360+ -re "Continuing.\r\n$gdb_prompt $"\
1361+ {pass "hit silent break bp_location1"}
1362+ -re "$gdb_prompt $"\
1363+ {fail "hit silent break bp_location1"}
1364+ timeout {fail "(timeout) hit silent break bp_location1"}
1365+}
1366+send_gdb "bt\n"
1367+gdb_expect {
1368+ -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\
1369+ {pass "stopped for silent break bp_location1"}
1370+ -re "$gdb_prompt $"\
1371+ {fail "stopped for silent break bp_location1"}
1372+ timeout {fail "(timeout) stopped for silent break bp_location1"}
1373+}
1374+
1375+# Verify that GDB can at least parse a breakpoint with the
1376+# "thread" keyword. (We won't attempt to test here that a
1377+# thread-specific breakpoint really triggers appropriately.
1378+# The gdb.threads subdirectory contains tests for that.)
1379+#
1380+set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
1381+send_gdb "break $bp_location12 thread 999\n"
1382+gdb_expect {
1383+ -re "Unknown thread 999.*$gdb_prompt $"\
1384+ {pass "thread-specific breakpoint on non-existent thread disallowed"}
1385+ -re "$gdb_prompt $"\
1386+ {fail "thread-specific breakpoint on non-existent thread disallowed"}
1387+ timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
1388+}
1389+send_gdb "break $bp_location12 thread foo\n"
1390+gdb_expect {
1391+ -re "Junk after thread keyword..*$gdb_prompt $"\
1392+ {pass "thread-specific breakpoint on bogus thread ID disallowed"}
1393+ -re "$gdb_prompt $"\
1394+ {fail "thread-specific breakpoint on bogus thread ID disallowed"}
1395+ timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
1396+}
1397+
1398+# Verify that GDB responds gracefully to a breakpoint command with
1399+# trailing garbage.
1400+#
1401+send_gdb "break $bp_location12 foo\n"
1402+gdb_expect {
1403+ -re "Junk at end of arguments..*$gdb_prompt $"\
1404+ {pass "breakpoint with trailing garbage disallowed"}
1405+ -re "$gdb_prompt $"\
1406+ {fail "breakpoint with trailing garbage disallowed"}
1407+ timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
1408+}
1409+
1410+# Verify that GDB responds gracefully to a "clear" command that has
1411+# no matching breakpoint. (First, get us off the current source line,
1412+# which we know has a breakpoint.)
1413+#
1414+send_gdb "next\n"
1415+gdb_expect {
1416+ -re ".*$gdb_prompt $"\
1417+ {pass "step over breakpoint"}
1418+ timeout {fail "(timeout) step over breakpoint"}
1419+}
1420+send_gdb "clear 81\n"
1421+gdb_expect {
1422+ -re "No breakpoint at 81..*$gdb_prompt $"\
1423+ {pass "clear line has no breakpoint disallowed"}
1424+ -re "$gdb_prompt $"\
1425+ {fail "clear line has no breakpoint disallowed"}
1426+ timeout {fail "(timeout) clear line has no breakpoint disallowed"}
1427+}
1428+send_gdb "clear\n"
1429+gdb_expect {
1430+ -re "No breakpoint at this line..*$gdb_prompt $"\
1431+ {pass "clear current line has no breakpoint disallowed"}
1432+ -re "$gdb_prompt $"\
1433+ {fail "clear current line has no breakpoint disallowed"}
1434+ timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
1435+}
1436+
1437+# Verify that we can set and clear multiple breakpoints.
1438+#
1439+# We don't test that it deletes the correct breakpoints. We do at
1440+# least test that it deletes more than one breakpoint.
1441+#
1442+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
1443+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
1444+gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
1445+
1446+# Verify that a breakpoint can be set via a convenience variable.
1447+#
1448+send_gdb "set \$foo=$bp_location11\n"
1449+gdb_expect {
1450+ -re "$gdb_prompt $"\
1451+ {pass "set convenience variable \$foo to bp_location11"}
1452+ timeout {fail "(timeout) set convenience variable \$foo to bp_location11"}
1453+}
1454+send_gdb "break \$foo\n"
1455+gdb_expect {
1456+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\
1457+ {pass "set breakpoint via convenience variable"}
1458+ -re "$gdb_prompt $"\
1459+ {fail "set breakpoint via convenience variable"}
1460+ timeout {fail "(timeout) set breakpoint via convenience variable"}
1461+}
1462+
1463+# Verify that GDB responds gracefully to an attempt to set a
1464+# breakpoint via a convenience variable whose type is not integer.
1465+#
1466+send_gdb "set \$foo=81.5\n"
1467+gdb_expect {
1468+ -re "$gdb_prompt $"\
1469+ {pass "set convenience variable \$foo to 81.5"}
1470+ timeout {fail "(timeout) set convenience variable \$foo to 81.5"}
1471+}
1472+send_gdb "break \$foo\n"
1473+gdb_expect {
1474+ -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
1475+ {pass "set breakpoint via non-integer convenience variable disallowed"}
1476+ -re "$gdb_prompt $"\
1477+ {fail "set breakpoint via non-integer convenience variable disallowed"}
1478+ timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
1479+}
1480+
1481+# Verify that we can set and trigger a breakpoint in a user-called function.
1482+#
1483+send_gdb "break marker2\n"
1484+gdb_expect {
1485+ -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\
1486+ {pass "set breakpoint on to-be-called function"}
1487+ -re "$gdb_prompt $"\
1488+ {fail "set breakpoint on to-be-called function"}
1489+ timeout {fail "(timeout) set breakpoint on to-be-called function"}
1490+}
1491+send_gdb "print marker2(99)\n"
1492+gdb_expect {
1493+ -re "The program being debugged stopped while in a function called from GDB.\r\nWhen the function .marker2$proto. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$gdb_prompt $"\
1494+ {pass "hit breakpoint on called function"}
1495+ -re "$gdb_prompt $"\
1496+ {fail "hit breakpoint on called function"}
1497+ timeout {fail "(timeout) hit breakpoint on called function"}
1498+}
1499+
1500+# As long as we're stopped (breakpointed) in a called function,
1501+# verify that we can successfully backtrace & such from here.
1502+#
1503+# In this and the following test, the _sr4export check apparently is needed
1504+# for hppa*-*-hpux.
1505+#
1506+send_gdb "bt\n"
1507+gdb_expect {
1508+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\
1509+ {pass "backtrace while in called function"}
1510+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\
1511+ {pass "backtrace while in called function"}
1512+ -re "$gdb_prompt $"\
1513+ {fail "backtrace while in called function"}
1514+ timeout {fail "(timeout) backtrace while in called function"}
1515+}
1516+
1517+# Return from the called function. For remote targets, it's important to do
1518+# this before runto_main, which otherwise may silently stop on the dummy
1519+# breakpoint inserted by GDB at the program's entry point.
1520+#
1521+send_gdb "finish\n"
1522+gdb_expect {
1523+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\
1524+ {pass "finish from called function"}
1525+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\
1526+ {pass "finish from called function"}
1527+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\
1528+ {pass "finish from called function"}
1529+ -re "$gdb_prompt $"\
1530+ {fail "finish from called function"}
1531+ timeout {fail "(timeout) finish from called function"}
1532+}
1533+
1534+# Verify that GDB responds gracefully to a "finish" command with
1535+# arguments.
1536+#
1537+if ![runto_main] then { fail "break tests suppressed" }
1538+
1539+send_gdb "finish 123\n"
1540+gdb_expect {
1541+ -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
1542+ {pass "finish with arguments disallowed"}
1543+ -re "$gdb_prompt $"\
1544+ {fail "finish with arguments disallowed"}
1545+ timeout {fail "(timeout) finish with arguments disallowed"}
1546+}
1547+
1548+# Verify that GDB responds gracefully to a request to "finish" from
1549+# the outermost frame. On a stub that never exits, this will just
1550+# run to the stubs routine, so we don't get this error... Thus the
1551+# second condition.
1552+#
1553+
1554+send_gdb "finish\n"
1555+gdb_expect {
1556+ -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
1557+ {pass "finish from outermost frame disallowed"}
1558+ -re "Run till exit from.*\r\n$gdb_prompt $" {
1559+ pass "finish from outermost frame disallowed"
1560+ }
1561+ -re "$gdb_prompt $"\
1562+ {fail "finish from outermost frame disallowed"}
1563+ timeout {fail "(timeout) finish from outermost frame disallowed"}
1564+}
1565+
1566+# Verify that we can explicitly ask GDB to stop on all shared library
1567+# events, and that it does so.
1568+#
1569+if [istarget "hppa*-*-hpux*"] then {
1570+ if ![runto_main] then { fail "break tests suppressed" }
1571+
1572+ send_gdb "set stop-on-solib-events 1\n"
1573+ gdb_expect {
1574+ -re "$gdb_prompt $"\
1575+ {pass "set stop-on-solib-events"}
1576+ timeout {fail "(timeout) set stop-on-solib-events"}
1577+ }
1578+
1579+ send_gdb "run\n"
1580+ gdb_expect {
1581+ -re ".*Start it from the beginning.*y or n. $"\
1582+ {send_gdb "y\n"
1583+ gdb_expect {
1584+ -re ".*Stopped due to shared library event.*$gdb_prompt $"\
1585+ {pass "triggered stop-on-solib-events"}
1586+ -re "$gdb_prompt $"\
1587+ {fail "triggered stop-on-solib-events"}
1588+ timeout {fail "(timeout) triggered stop-on-solib-events"}
1589+ }
1590+ }
1591+ -re "$gdb_prompt $"\
1592+ {fail "rerun for stop-on-solib-events"}
1593+ timeout {fail "(timeout) rerun for stop-on-solib-events"}
1594+ }
1595+
1596+ send_gdb "set stop-on-solib-events 0\n"
1597+ gdb_expect {
1598+ -re "$gdb_prompt $"\
1599+ {pass "reset stop-on-solib-events"}
1600+ timeout {fail "(timeout) reset stop-on-solib-events"}
1601+ }
1602+}
1603+
1604+# Hardware breakpoints are unsupported on HP-UX. Verify that GDB
1605+# gracefully responds to requests to create them.
1606+#
1607+if [istarget "hppa*-*-hpux*"] then {
1608+ if ![runto_main] then { fail "break tests suppressed" }
1609+
1610+ send_gdb "hbreak\n"
1611+ gdb_expect {
1612+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
1613+ {pass "hw breaks disallowed"}
1614+ -re "$gdb_prompt $"\
1615+ {fail "hw breaks disallowed"}
1616+ timeout {fail "(timeout) hw breaks disallowed"}
1617+ }
1618+
1619+ send_gdb "thbreak\n"
1620+ gdb_expect {
1621+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
1622+ {pass "temporary hw breaks disallowed"}
1623+ -re "$gdb_prompt $"\
1624+ {fail "temporary hw breaks disallowed"}
1625+ timeout {fail "(timeout) temporary hw breaks disallowed"}
1626+ }
1627+}
1628+
1629+#********
1630+
1631+
1632+#
1633+# Test "next" over recursive function call.
1634+#
1635+
1636+proc test_next_with_recursion {} {
1637+ global gdb_prompt
1638+ global decimal
1639+ global binfile
1640+
1641+ if [target_info exists use_gdb_stub] {
1642+ # Reload the program.
1643+ delete_breakpoints
1644+ gdb_load ${binfile};
1645+ } else {
1646+ # FIXME: should be using runto
1647+ gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
1648+
1649+ delete_breakpoints
1650+ }
1651+
1652+ gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
1653+
1654+ # Run until we call factorial with 6
1655+
1656+ if [istarget "*-*-vxworks*"] then {
1657+ send_gdb "run vxmain \"6\"\n"
1658+ } else {
1659+ gdb_run_cmd
1660+ }
1661+ gdb_expect {
1662+ -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
1663+ -re ".*$gdb_prompt $" {
1664+ fail "run to factorial(6)";
1665+ gdb_suppress_tests;
1666+ }
1667+ timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
1668+ }
1669+
1670+ # Continue until we call factorial recursively with 5.
1671+
1672+ if [gdb_test "continue" \
1673+ "Continuing.*Break.* factorial .value=5. .*" \
1674+ "continue to factorial(5)"] then { gdb_suppress_tests }
1675+
1676+ # Do a backtrace just to confirm how many levels deep we are.
1677+
1678+ if [gdb_test "backtrace" \
1679+ "#0\[ \t\]+ factorial .value=5..*" \
1680+ "backtrace from factorial(5)"] then { gdb_suppress_tests }
1681+
1682+ # Now a "next" should position us at the recursive call, which
1683+ # we will be performing with 4.
1684+
1685+ if [gdb_test "next" \
1686+ ".* factorial .value - 1.;.*" \
1687+ "next to recursive call"] then { gdb_suppress_tests }
1688+
1689+ # Disable the breakpoint at the entry to factorial by deleting them all.
1690+ # The "next" should run until we return to the next line from this
1691+ # recursive call to factorial with 4.
1692+ # Buggy versions of gdb will stop instead at the innermost frame on
1693+ # the line where we are trying to "next" to.
1694+
1695+ delete_breakpoints
1696+
1697+ if [istarget "mips*tx39-*"] {
1698+ set timeout 60
1699+ }
1700+ # We used to set timeout here for all other targets as well. This
1701+ # is almost certainly wrong. The proper timeout depends on the
1702+ # target system in use, and how we communicate with it, so there
1703+ # is no single value appropriate for all targets. The timeout
1704+ # should be established by the Dejagnu config file(s) for the
1705+ # board, and respected by the test suite.
1706+ #
1707+ # For example, if I'm running GDB over an SSH tunnel talking to a
1708+ # portmaster in California talking to an ancient 68k board running
1709+ # a crummy ROM monitor (a situation I can only wish were
1710+ # hypothetical), then I need a large timeout. But that's not the
1711+ # kind of knowledge that belongs in this file.
1712+
1713+ gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
1714+ "next over recursive call"
1715+
1716+ # OK, we should be back in the same stack frame we started from.
1717+ # Do a backtrace just to confirm.
1718+
1719+ set result [gdb_test "backtrace" \
1720+ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
1721+ "backtrace from factorial(5.1)"]
1722+ if { $result != 0 } { gdb_suppress_tests }
1723+
1724+ if [target_info exists gdb,noresults] { gdb_suppress_tests }
1725+ gdb_continue_to_end "recursive next test"
1726+ gdb_stop_suppressing_tests;
1727+}
1728+
1729+test_next_with_recursion
1730+
1731+
1732+#********
1733+
1734+# build a new file with optimization enabled so that we can try breakpoints
1735+# on targets with optimized prologues
1736+
1737+set binfileo2 ${objdir}/${subdir}/${testfile}o2
1738+
1739+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
1740+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1741+}
1742+
1743+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
1744+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1745+}
1746+
1747+if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
1748+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1749+}
1750+
1751+if [get_compiler_info ${binfileo2}] {
1752+ return -1
1753+}
1754+
1755+gdb_exit
1756+gdb_start
1757+gdb_reinitialize_dir $srcdir/$subdir
1758+gdb_load ${binfileo2}
1759+
1760+if [target_info exists gdb_stub] {
1761+ gdb_step_for_stub;
1762+}
1763+
1764+#
1765+# test break at function
1766+#
1767+gdb_test "break main" \
1768+ "Breakpoint.*at.* file .*$srcfile, line.*" \
1769+ "breakpoint function, optimized file"
1770+
1771+#
1772+# test break at function
1773+#
1774+gdb_test "break marker4" \
1775+ "Breakpoint.*at.* file .*$srcfile1, line.*" \
1776+ "breakpoint small function, optimized file"
1777+
1778+#
1779+# run until the breakpoint at main is hit. For non-stubs-using targets.
1780+#
1781+if ![target_info exists use_gdb_stub] {
1782+ if [istarget "*-*-vxworks*"] then {
1783+ send_gdb "run vxmain \"2\"\n"
1784+ set timeout 120
1785+ verbose "Timeout is now $timeout seconds" 2
1786+ } else {
1787+ send_gdb "run\n"
1788+ }
1789+ gdb_expect {
1790+ -re "The program .* has been started already.*y or n. $" {
1791+ send_gdb "y\n"
1792+ exp_continue
1793+ }
1794+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
1795+ { pass "run until function breakpoint, optimized file" }
1796+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
1797+ { pass "run until function breakpoint, optimized file (code motion)" }
1798+ -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" }
1799+ timeout { fail "run until function breakpoint, optimized file (timeout)" }
1800+ }
1801+} else {
1802+ if ![target_info exists gdb_stub] {
1803+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
1804+ }
1805+}
1806+
1807+#
1808+# run until the breakpoint at a small function
1809+#
1810+
1811+#
1812+# Add a second pass pattern. The behavior differs here between stabs
1813+# and dwarf for one-line functions. Stabs preserves two line symbols
1814+# (one before the prologue and one after) with the same line number,
1815+# but dwarf regards these as duplicates and discards one of them.
1816+# Therefore the address after the prologue (where the breakpoint is)
1817+# has no exactly matching line symbol, and GDB reports the breakpoint
1818+# as if it were in the middle of a line rather than at the beginning.
1819+
1820+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
1821+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
1822+send_gdb "continue\n"
1823+gdb_expect {
1824+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
1825+ pass "run until breakpoint set at small function, optimized file"
1826+ }
1827+ -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
1828+ pass "run until breakpoint set at small function, optimized file"
1829+ }
1830+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
1831+ # marker4() is defined at line 46 when compiled with -DPROTOTYPES
1832+ pass "run until breakpoint set at small function, optimized file (line bp_location14)"
1833+ }
1834+ -re ".*$gdb_prompt " {
1835+ fail "run until breakpoint set at small function, optimized file"
1836+ }
1837+ timeout {
1838+ fail "run until breakpoint set at small function, optimized file (timeout)"
1839+ }
1840+}
1841+
1842+
1843+# Reset the default arguments for VxWorks
1844+if [istarget "*-*-vxworks*"] {
1845+ set timeout 10
1846+ verbose "Timeout is now $timeout seconds" 2
1847+ send_gdb "set args main\n"
1848+ gdb_expect -re ".*$gdb_prompt $" {}
1849+}
1850Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/corefile.exp
1851===================================================================
1852--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1853+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/corefile.exp 2008-12-09 17:02:55.000000000 +0100
1854@@ -0,0 +1,243 @@
1855+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
1856+# Free Software Foundation, Inc.
1857+
1858+# This program is free software; you can redistribute it and/or modify
1859+# it under the terms of the GNU General Public License as published by
1860+# the Free Software Foundation; either version 2 of the License, or
1861+# (at your option) any later version.
1862+#
1863+# This program is distributed in the hope that it will be useful,
1864+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1865+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1866+# GNU General Public License for more details.
1867+#
1868+# You should have received a copy of the GNU General Public License
1869+# along with this program; if not, write to the Free Software
1870+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1871+
1872+# Please email any bugs, comments, and/or additions to this file to:
1873+# bug-gdb@prep.ai.mit.edu
1874+
1875+# This file was written by Fred Fish. (fnf@cygnus.com)
1876+
1877+if $tracelevel then {
1878+ strace $tracelevel
1879+}
1880+
1881+set prms_id 0
1882+set bug_id 0
1883+
1884+# are we on a target board
1885+if ![isnative] then {
1886+ return
1887+}
1888+
1889+set testfile "coremaker"
1890+set srcfile ${testfile}.c
1891+set binfile ${objdir}/${subdir}/${testfile}
1892+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } {
1893+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1894+}
1895+
1896+# Create and source the file that provides information about the compiler
1897+# used to compile the test case.
1898+if [get_compiler_info ${binfile}] {
1899+ return -1;
1900+}
1901+
1902+# Create a core file named "corefile" rather than just "core", to
1903+# avoid problems with sys admin types that like to regularly prune all
1904+# files named "core" from the system.
1905+#
1906+# Arbitrarily try setting the core size limit to "unlimited" since
1907+# this does not hurt on systems where the command does not work and
1908+# allows us to generate a core on systems where it does.
1909+#
1910+# Some systems append "core" to the name of the program; others append
1911+# the name of the program to "core"; still others (like Linux, as of
1912+# May 2003) create cores named "core.PID". In the latter case, we
1913+# could have many core files lying around, and it may be difficult to
1914+# tell which one is ours, so let's run the program in a subdirectory.
1915+set found 0
1916+set coredir "${objdir}/${subdir}/coredir.[getpid]"
1917+file mkdir $coredir
1918+catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
1919+# remote_exec host "${binfile}"
1920+foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
1921+ if [remote_file build exists $i] {
1922+ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
1923+ set found 1
1924+ }
1925+}
1926+# Check for "core.PID".
1927+if { $found == 0 } {
1928+ set names [glob -nocomplain -directory $coredir core.*]
1929+ if {[llength $names] == 1} {
1930+ set corefile [file join $coredir [lindex $names 0]]
1931+ remote_exec build "mv $corefile ${objdir}/${subdir}/corefile"
1932+ set found 1
1933+ }
1934+}
1935+if { $found == 0 } {
1936+ # The braindamaged HPUX shell quits after the ulimit -c above
1937+ # without executing ${binfile}. So we try again without the
1938+ # ulimit here if we didn't find a core file above.
1939+ # Oh, I should mention that any "braindamaged" non-Unix system has
1940+ # the same problem. I like the cd bit too, it's really neat'n stuff.
1941+ catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
1942+ foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
1943+ if [remote_file build exists $i] {
1944+ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
1945+ set found 1
1946+ }
1947+ }
1948+}
1949+
1950+# Try to clean up after ourselves.
1951+remote_file build delete [file join $coredir coremmap.data]
1952+remote_exec build "rmdir $coredir"
1953+
1954+if { $found == 0 } {
1955+ warning "can't generate a core file - core tests suppressed - check ulimit -c"
1956+ return 0
1957+}
1958+
1959+#
1960+# Test that we can simply startup with a "-core=corefile" command line arg
1961+# and recognize that the core file is a valid, usable core file.
1962+# To do this, we must shutdown the currently running gdb and restart
1963+# with the -core args. We can't use gdb_start because it looks for
1964+# the first gdb prompt, and the message we are looking for occurs
1965+# before the first prompt. Also, we can't include GDBFLAGS because
1966+# if it is empty, this confuses gdb with an empty argument that it
1967+# grumbles about (said grumbling currently being ignored in gdb_start).
1968+# **FIXME**
1969+#
1970+# Another problem is that on some systems (solaris for example), there
1971+# is apparently a limit on the length of a fully specified path to
1972+# the coremaker executable, at about 80 chars. For this case, consider
1973+# it a pass, but note that the program name is bad.
1974+
1975+gdb_exit
1976+if $verbose>1 then {
1977+ send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
1978+}
1979+
1980+set oldtimeout $timeout
1981+set timeout [expr "$timeout + 60"]
1982+verbose "Timeout is now $timeout seconds" 2
1983+eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
1984+expect {
1985+ -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
1986+ fail "args: -core=corefile (couldn't find regs)"
1987+ }
1988+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1989+ pass "args: -core=corefile"
1990+ }
1991+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1992+ pass "args: -core=corefile (with bad program name)"
1993+ }
1994+ -re ".*registers from core file: File in wrong format.* $" {
1995+ fail "args: -core=corefile (could not read registers from core file)"
1996+ }
1997+ -re ".*$gdb_prompt $" { fail "args: -core=corefile" }
1998+ timeout { fail "(timeout) starting with -core" }
1999+}
2000+
2001+
2002+#
2003+# Test that startup with both an executable file and -core argument.
2004+# See previous comments above, they are still applicable.
2005+#
2006+
2007+close;
2008+
2009+if $verbose>1 then {
2010+ send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n"
2011+}
2012+
2013+
2014+eval "spawn $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile";
2015+expect {
2016+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2017+ pass "args: execfile -core=corefile"
2018+ }
2019+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2020+ pass "args: execfile -core=corefile (with bad program name)"
2021+ }
2022+ -re ".*registers from core file: File in wrong format.* $" {
2023+ fail "args: execfile -core=corefile (could not read registers from core file)"
2024+ }
2025+ -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" }
2026+ timeout { fail "(timeout) starting with -core" }
2027+}
2028+set timeout $oldtimeout
2029+verbose "Timeout is now $timeout seconds" 2
2030+
2031+close;
2032+
2033+# Now restart normally.
2034+
2035+gdb_start
2036+gdb_reinitialize_dir $srcdir/$subdir
2037+gdb_load ${binfile}
2038+
2039+# Test basic corefile recognition via core-file command.
2040+
2041+send_gdb "core-file $objdir/$subdir/corefile\n"
2042+gdb_expect {
2043+ -re ".* program is being debugged already.*y or n. $" {
2044+ # gdb_load may connect us to a gdbserver.
2045+ send_gdb "y\n"
2046+ exp_continue;
2047+ }
2048+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2049+ pass "core-file command"
2050+ }
2051+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2052+ pass "core-file command (with bad program name)"
2053+ }
2054+ -re ".*registers from core file: File in wrong format.* $" {
2055+ fail "core-file command (could not read registers from core file)"
2056+ }
2057+ -re ".*$gdb_prompt $" { fail "core-file command" }
2058+ timeout { fail "(timeout) core-file command" }
2059+}
2060+
2061+# Test correct mapping of corefile sections by printing some variables.
2062+
2063+gdb_test "print coremaker_data" "\\\$$decimal = 202"
2064+gdb_test "print coremaker_bss" "\\\$$decimal = 10"
2065+gdb_test "print coremaker_ro" "\\\$$decimal = 201"
2066+
2067+gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
2068+
2069+# Somehow we better test the ability to read the registers out of the core
2070+# file correctly. I don't think the other tests do this.
2071+
2072+gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
2073+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp"
2074+
2075+# Test ability to read mmap'd data
2076+
2077+gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file"
2078+setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*"
2079+set test "accessing mmapped data in core file"
2080+gdb_test_multiple "x/8bd buf2" "$test" {
2081+ -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" {
2082+ pass "$test"
2083+ }
2084+ -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" {
2085+ fail "$test (mapping failed at runtime)"
2086+ }
2087+ -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" {
2088+ fail "$test (mapping address not found in core file)"
2089+ }
2090+}
2091+
2092+# test reinit_frame_cache
2093+
2094+gdb_load ${binfile}
2095+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\).*" "up in corefile.exp (reinit)"
2096+
2097+gdb_test "core" "No core file now."
2098Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/Makefile.in
2099===================================================================
2100--- /dev/null 1970-01-01 00:00:00.000000000 +0000
2101+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.pie/Makefile.in 2008-12-09 17:02:55.000000000 +0100
2102@@ -0,0 +1,19 @@
2103+VPATH = @srcdir@
2104+srcdir = @srcdir@
2105+
2106+EXECUTABLES =
2107+MISCELLANEOUS = arch.inc
2108+
2109+all info install-info dvi install uninstall installcheck check:
2110+ @echo "Nothing to be done for $@..."
2111+
2112+clean mostlyclean:
2113+ -rm -f *~ *.o a.out *.x *.ci *.tmp
2114+ -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES)
2115+ -rm -f $(MISCELLANEOUS)
2116+
2117+distclean maintainer-clean realclean: clean
2118+ -rm -f *~ core
2119+ -rm -f Makefile config.status config.log
2120+ -rm -f *-init.exp
2121+ -rm -fr *.log summary detail *.plog *.sum *.psum site.*
This page took 0.285509 seconds and 4 git commands to generate.