]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.3-test-pie-20050107.patch
- update to 6.8.91.20090930-1 from fedora
[packages/gdb.git] / gdb-6.3-test-pie-20050107.patch
CommitLineData
7566401a 1Index: gdb-6.8.50.20090909/gdb/testsuite/configure.ac
3a58abaf 2===================================================================
7566401a
ER
3--- gdb-6.8.50.20090909.orig/gdb/testsuite/configure.ac 2009-07-31 17:38:16.000000000 +0200
4+++ gdb-6.8.50.20090909/gdb/testsuite/configure.ac 2009-09-09 19:06:01.000000000 +0200
5@@ -144,6 +144,6 @@ AC_OUTPUT([Makefile \
3a58abaf
AM
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 \
7566401a 11 gdb.python/Makefile gdb.reverse/Makefile \
3a58abaf 12 gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
7566401a 13Index: gdb-6.8.50.20090909/gdb/testsuite/configure
3a58abaf 14===================================================================
7566401a
ER
15--- gdb-6.8.50.20090909.orig/gdb/testsuite/configure 2009-08-22 18:56:43.000000000 +0200
16+++ gdb-6.8.50.20090909/gdb/testsuite/configure 2009-09-09 19:06:27.000000000 +0200
17@@ -3515,7 +3515,7 @@ done
3a58abaf
AM
18
19
20
7566401a
ER
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.reverse/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.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
23
3a58abaf
AM
24 cat >confcache <<\_ACEOF
25 # This file is a shell script that caches the results of configure
7566401a
ER
26@@ -4231,6 +4231,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.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;;
33 "gdb.threads/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.threads/Makefile" ;;
34Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c
3a58abaf
AM
35===================================================================
36--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 37+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
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+}
7566401a 59Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c
3a58abaf
AM
60===================================================================
61--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 62+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
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+}
7566401a 88Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c
3a58abaf
AM
89===================================================================
90--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 91+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
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+}
7566401a 239Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c
3a58abaf
AM
240===================================================================
241--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 242+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
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
7566401a 288Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c
3a58abaf
AM
289===================================================================
290--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 291+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
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+
7566401a 435Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp
3a58abaf
AM
436===================================================================
437--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 438+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
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
7566401a 872Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp
3a58abaf
AM
873===================================================================
874--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a
ER
875+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp 2009-09-09 19:06:01.000000000 +0200
876@@ -0,0 +1,977 @@
3a58abaf
AM
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+
7566401a
ER
1058+# Test a pending breakpoint in PIE executable does not crash later GDB.
1059+gdb_breakpoint "non_existent_function" allow-pending
1060+
3a58abaf
AM
1061+gdb_test "info break" \
1062+ "Num\[ \]+Type\[ \]+Disp Enb Address\[ \]+What.*
1063+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
1064+\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).*
1065+\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.*
1066+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
1067+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
1068+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
1069+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
7566401a
ER
1070+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4.*
1071+\[0-9\]+\[\t \]+breakpoint keep y.* <PENDING> *non_existent_function" \
3a58abaf
AM
1072+ "breakpoint info"
1073+
1074+# FIXME: The rest of this test doesn't work with anything that can't
1075+# handle arguments.
1076+# Huh? There doesn't *appear* to be anything that passes arguments
1077+# below.
1078+if [istarget "mips-idt-*"] then {
1079+ return
1080+}
1081+
1082+#
1083+# run until the breakpoint at main is hit. For non-stubs-using targets.
1084+#
1085+if ![target_info exists use_gdb_stub] {
1086+ if [istarget "*-*-vxworks*"] then {
1087+ send_gdb "run vxmain \"2\"\n"
1088+ set timeout 120
1089+ verbose "Timeout is now $timeout seconds" 2
1090+ } else {
1091+ send_gdb "run\n"
1092+ }
1093+ gdb_expect {
1094+ -re "The program .* has been started already.*y or n. $" {
1095+ send_gdb "y\n"
1096+ exp_continue
1097+ }
1098+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
1099+ { pass "run until function breakpoint" }
1100+ -re ".*$gdb_prompt $" { fail "run until function breakpoint" }
1101+ timeout { fail "run until function breakpoint (timeout)" }
1102+ }
1103+} else {
1104+ if ![target_info exists gdb_stub] {
1105+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
1106+ }
1107+}
1108+
1109+#
1110+# run until the breakpoint at a line number
1111+#
1112+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
1113+ "run until breakpoint set at a line number"
1114+
1115+#
1116+# Run until the breakpoint set in a function in a file
1117+#
1118+for {set i 6} {$i >= 1} {incr i -1} {
1119+ gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
1120+ "run until file:function($i) breakpoint"
1121+}
1122+
1123+#
1124+# Run until the breakpoint set at a quoted function
1125+#
1126+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \
1127+ "run until quoted breakpoint"
1128+#
1129+# run until the file:function breakpoint at a line number in a file
1130+#
1131+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
1132+ "run until file:linenum breakpoint"
1133+
1134+# Test break at offset +1
1135+set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
1136+
1137+gdb_test "break +1" \
1138+ "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
1139+ "breakpoint offset +1"
1140+
1141+# Check to see if breakpoint is hit when stepped onto
1142+
1143+gdb_test "step" \
1144+ ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
1145+ "step onto breakpoint"
1146+
1147+#
1148+# delete all breakpoints so we can start over, course this can be a test too
1149+#
1150+delete_breakpoints
1151+
1152+#
1153+# test temporary breakpoint at function
1154+#
1155+
1156+gdb_test "tbreak main" "reakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
1157+
1158+#
1159+# test break at function in file
1160+#
1161+
1162+gdb_test "tbreak $srcfile:factorial" "reakpoint.*at.* file .*$srcfile, line.*" \
1163+ "Temporary breakpoint function in file"
1164+
1165+#
1166+# test break at line number
1167+#
1168+send_gdb "tbreak $bp_location1\n"
1169+gdb_expect {
1170+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
1171+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
1172+ timeout { fail "breakpoint line number #1 (timeout)" }
1173+}
1174+
1175+gdb_test "tbreak $bp_location6" "reakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2"
1176+
1177+#
1178+# test break at line number in file
1179+#
1180+send_gdb "tbreak $srcfile:$bp_location2\n"
1181+gdb_expect {
1182+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
1183+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
1184+ timeout { fail "Temporary breakpoint line number in file #1 (timeout)" }
1185+}
1186+
1187+set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
1188+gdb_test "tbreak $srcfile:$bp_location11" "reakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2"
1189+
1190+#
1191+# check to see what breakpoints are set (temporary this time)
1192+#
1193+gdb_test "info break" "Num.*Type.*Disp Enb Address.*What.*\[\r\n\]
1194+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
1195+\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\]
1196+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
1197+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
1198+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
1199+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
1200+ "Temporary breakpoint info"
1201+
1202+
1203+#***********
1204+
1205+# Verify that catchpoints for fork, vfork and exec don't trigger
1206+# inappropriately. (There are no calls to those system functions
1207+# in this test program.)
1208+#
1209+if ![runto_main] then { fail "break tests suppressed" }
1210+
1211+send_gdb "catch\n"
1212+gdb_expect {
1213+ -re "Catch requires an event name.*$gdb_prompt $"\
1214+ {pass "catch requires an event name"}
1215+ -re "$gdb_prompt $"\
1216+ {fail "catch requires an event name"}
1217+ timeout {fail "(timeout) catch requires an event name"}
1218+}
1219+
1220+
1221+set name "set catch fork, never expected to trigger"
1222+send_gdb "catch fork\n"
1223+gdb_expect {
1224+ -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
1225+ {pass $name}
1226+ -re "Catch of fork not yet implemented.*$gdb_prompt $"
1227+ {pass $name}
1228+ -re "$gdb_prompt $"
1229+ {fail $name}
1230+ timeout {fail "(timeout) $name"}
1231+}
1232+
1233+
1234+set name "set catch vfork, never expected to trigger"
1235+send_gdb "catch vfork\n"
1236+
1237+# If we are on HP-UX 10.20, we expect an error message to be
1238+# printed if we type "catch vfork" at the gdb gdb_prompt. This is
1239+# because on HP-UX 10.20, we cannot catch vfork events.
1240+
1241+if [istarget "hppa*-hp-hpux10.20"] then {
1242+ gdb_expect {
1243+ -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
1244+ {pass $name}
1245+ -re "$gdb_prompt $"
1246+ {fail $name}
1247+ timeout {fail "(timeout) $name"}
1248+ }
1249+} else {
1250+ gdb_expect {
1251+ -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
1252+ {pass $name}
1253+ -re "Catch of vfork not yet implemented.*$gdb_prompt $"
1254+ {pass $name}
1255+ -re "$gdb_prompt $"
1256+ {fail $name}
1257+ timeout {fail "(timeout) $name"}
1258+ }
1259+}
1260+
1261+set name "set catch exec, never expected to trigger"
1262+send_gdb "catch exec\n"
1263+gdb_expect {
1264+ -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
1265+ {pass $name}
1266+ -re "Catch of exec not yet implemented.*$gdb_prompt $"
1267+ {pass $name}
1268+ -re "$gdb_prompt $" {fail $name}
1269+ timeout {fail "(timeout) $name"}
1270+}
1271+
1272+# Verify that GDB responds gracefully when asked to set a breakpoint
1273+# on a nonexistent source line.
1274+#
1275+send_gdb "break 999\n"
1276+gdb_expect {
1277+ -re "No line 999 in file .*$gdb_prompt $"\
1278+ {pass "break on non-existent source line"}
1279+ -re "$gdb_prompt $"\
1280+ {fail "break on non-existent source line"}
1281+ timeout {fail "(timeout) break on non-existent source line"}
1282+}
1283+
1284+# Run to the desired default location. If not positioned here, the
1285+# tests below don't work.
1286+#
1287+gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1"
1288+
1289+
1290+# Verify that GDB allows one to just say "break", which is treated
1291+# as the "default" breakpoint. Note that GDB gets cute when printing
1292+# the informational message about other breakpoints at the same
1293+# location. We'll hit that bird with this stone too.
1294+#
1295+send_gdb "break\n"
1296+gdb_expect {
1297+ -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
1298+ {pass "break on default location, 1st time"}
1299+ -re "$gdb_prompt $"\
1300+ {fail "break on default location, 1st time"}
1301+ timeout {fail "(timeout) break on default location, 1st time"}
1302+}
1303+
1304+send_gdb "break\n"
1305+gdb_expect {
1306+ -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1307+ {pass "break on default location, 2nd time"}
1308+ -re "$gdb_prompt $"\
1309+ {fail "break on default location, 2nd time"}
1310+ timeout {fail "(timeout) break on default location, 2nd time"}
1311+}
1312+
1313+send_gdb "break\n"
1314+gdb_expect {
1315+ -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1316+ {pass "break on default location, 3rd time"}
1317+ -re "$gdb_prompt $"\
1318+ {fail "break on default location, 3rd time"}
1319+ timeout {fail "(timeout) break on default location, 3rd time"}
1320+}
1321+
1322+send_gdb "break\n"
1323+gdb_expect {
1324+ -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
1325+ {pass "break on default location, 4th time"}
1326+ -re "$gdb_prompt $"\
1327+ {fail "break on default location, 4th time"}
1328+ timeout {fail "(timeout) break on default location, 4th time"}
1329+}
1330+
1331+# Verify that a "silent" breakpoint can be set, and that GDB is indeed
1332+# "silent" about its triggering.
1333+#
1334+if ![runto_main] then { fail "break tests suppressed" }
1335+
1336+send_gdb "break $bp_location1\n"
1337+gdb_expect {
1338+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\
1339+ {pass "set to-be-silent break bp_location1"}
1340+ -re "$gdb_prompt $"\
1341+ {fail "set to-be-silent break bp_location1"}
1342+ timeout {fail "(timeout) set to-be-silent break bp_location1"}
1343+}
1344+
1345+send_gdb "commands $expect_out(1,string)\n"
1346+send_gdb "silent\n"
1347+send_gdb "end\n"
1348+gdb_expect {
1349+ -re ".*$gdb_prompt $"\
1350+ {pass "set silent break bp_location1"}
1351+ timeout {fail "(timeout) set silent break bp_location1"}
1352+}
1353+
1354+send_gdb "info break $expect_out(1,string)\n"
1355+gdb_expect {
1356+ -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\
1357+ {pass "info silent break bp_location1"}
1358+ -re "$gdb_prompt $"\
1359+ {fail "info silent break bp_location1"}
1360+ timeout {fail "(timeout) info silent break bp_location1"}
1361+}
1362+send_gdb "continue\n"
1363+gdb_expect {
1364+ -re "Continuing.\r\n$gdb_prompt $"\
1365+ {pass "hit silent break bp_location1"}
1366+ -re "$gdb_prompt $"\
1367+ {fail "hit silent break bp_location1"}
1368+ timeout {fail "(timeout) hit silent break bp_location1"}
1369+}
1370+send_gdb "bt\n"
1371+gdb_expect {
1372+ -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\
1373+ {pass "stopped for silent break bp_location1"}
1374+ -re "$gdb_prompt $"\
1375+ {fail "stopped for silent break bp_location1"}
1376+ timeout {fail "(timeout) stopped for silent break bp_location1"}
1377+}
1378+
1379+# Verify that GDB can at least parse a breakpoint with the
1380+# "thread" keyword. (We won't attempt to test here that a
1381+# thread-specific breakpoint really triggers appropriately.
1382+# The gdb.threads subdirectory contains tests for that.)
1383+#
1384+set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
1385+send_gdb "break $bp_location12 thread 999\n"
1386+gdb_expect {
1387+ -re "Unknown thread 999.*$gdb_prompt $"\
1388+ {pass "thread-specific breakpoint on non-existent thread disallowed"}
1389+ -re "$gdb_prompt $"\
1390+ {fail "thread-specific breakpoint on non-existent thread disallowed"}
1391+ timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
1392+}
1393+send_gdb "break $bp_location12 thread foo\n"
1394+gdb_expect {
1395+ -re "Junk after thread keyword..*$gdb_prompt $"\
1396+ {pass "thread-specific breakpoint on bogus thread ID disallowed"}
1397+ -re "$gdb_prompt $"\
1398+ {fail "thread-specific breakpoint on bogus thread ID disallowed"}
1399+ timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
1400+}
1401+
1402+# Verify that GDB responds gracefully to a breakpoint command with
1403+# trailing garbage.
1404+#
1405+send_gdb "break $bp_location12 foo\n"
1406+gdb_expect {
1407+ -re "Junk at end of arguments..*$gdb_prompt $"\
1408+ {pass "breakpoint with trailing garbage disallowed"}
1409+ -re "$gdb_prompt $"\
1410+ {fail "breakpoint with trailing garbage disallowed"}
1411+ timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
1412+}
1413+
1414+# Verify that GDB responds gracefully to a "clear" command that has
1415+# no matching breakpoint. (First, get us off the current source line,
1416+# which we know has a breakpoint.)
1417+#
1418+send_gdb "next\n"
1419+gdb_expect {
1420+ -re ".*$gdb_prompt $"\
1421+ {pass "step over breakpoint"}
1422+ timeout {fail "(timeout) step over breakpoint"}
1423+}
1424+send_gdb "clear 81\n"
1425+gdb_expect {
1426+ -re "No breakpoint at 81..*$gdb_prompt $"\
1427+ {pass "clear line has no breakpoint disallowed"}
1428+ -re "$gdb_prompt $"\
1429+ {fail "clear line has no breakpoint disallowed"}
1430+ timeout {fail "(timeout) clear line has no breakpoint disallowed"}
1431+}
1432+send_gdb "clear\n"
1433+gdb_expect {
1434+ -re "No breakpoint at this line..*$gdb_prompt $"\
1435+ {pass "clear current line has no breakpoint disallowed"}
1436+ -re "$gdb_prompt $"\
1437+ {fail "clear current line has no breakpoint disallowed"}
1438+ timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
1439+}
1440+
1441+# Verify that we can set and clear multiple breakpoints.
1442+#
1443+# We don't test that it deletes the correct breakpoints. We do at
1444+# least test that it deletes more than one breakpoint.
1445+#
1446+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
1447+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
1448+gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
1449+
1450+# Verify that a breakpoint can be set via a convenience variable.
1451+#
1452+send_gdb "set \$foo=$bp_location11\n"
1453+gdb_expect {
1454+ -re "$gdb_prompt $"\
1455+ {pass "set convenience variable \$foo to bp_location11"}
1456+ timeout {fail "(timeout) set convenience variable \$foo to bp_location11"}
1457+}
1458+send_gdb "break \$foo\n"
1459+gdb_expect {
1460+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\
1461+ {pass "set breakpoint via convenience variable"}
1462+ -re "$gdb_prompt $"\
1463+ {fail "set breakpoint via convenience variable"}
1464+ timeout {fail "(timeout) set breakpoint via convenience variable"}
1465+}
1466+
1467+# Verify that GDB responds gracefully to an attempt to set a
1468+# breakpoint via a convenience variable whose type is not integer.
1469+#
1470+send_gdb "set \$foo=81.5\n"
1471+gdb_expect {
1472+ -re "$gdb_prompt $"\
1473+ {pass "set convenience variable \$foo to 81.5"}
1474+ timeout {fail "(timeout) set convenience variable \$foo to 81.5"}
1475+}
1476+send_gdb "break \$foo\n"
1477+gdb_expect {
1478+ -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
1479+ {pass "set breakpoint via non-integer convenience variable disallowed"}
1480+ -re "$gdb_prompt $"\
1481+ {fail "set breakpoint via non-integer convenience variable disallowed"}
1482+ timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
1483+}
1484+
1485+# Verify that we can set and trigger a breakpoint in a user-called function.
1486+#
1487+send_gdb "break marker2\n"
1488+gdb_expect {
1489+ -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\
1490+ {pass "set breakpoint on to-be-called function"}
1491+ -re "$gdb_prompt $"\
1492+ {fail "set breakpoint on to-be-called function"}
1493+ timeout {fail "(timeout) set breakpoint on to-be-called function"}
1494+}
1495+send_gdb "print marker2(99)\n"
1496+gdb_expect {
7566401a 1497+ -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 $"\
3a58abaf
AM
1498+ {pass "hit breakpoint on called function"}
1499+ -re "$gdb_prompt $"\
1500+ {fail "hit breakpoint on called function"}
1501+ timeout {fail "(timeout) hit breakpoint on called function"}
1502+}
1503+
1504+# As long as we're stopped (breakpointed) in a called function,
1505+# verify that we can successfully backtrace & such from here.
1506+#
1507+# In this and the following test, the _sr4export check apparently is needed
1508+# for hppa*-*-hpux.
1509+#
1510+send_gdb "bt\n"
1511+gdb_expect {
1512+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\
1513+ {pass "backtrace while in called function"}
1514+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\
1515+ {pass "backtrace while in called function"}
1516+ -re "$gdb_prompt $"\
1517+ {fail "backtrace while in called function"}
1518+ timeout {fail "(timeout) backtrace while in called function"}
1519+}
1520+
1521+# Return from the called function. For remote targets, it's important to do
1522+# this before runto_main, which otherwise may silently stop on the dummy
1523+# breakpoint inserted by GDB at the program's entry point.
1524+#
1525+send_gdb "finish\n"
1526+gdb_expect {
1527+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\
1528+ {pass "finish from called function"}
1529+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\
1530+ {pass "finish from called function"}
1531+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\
1532+ {pass "finish from called function"}
1533+ -re "$gdb_prompt $"\
1534+ {fail "finish from called function"}
1535+ timeout {fail "(timeout) finish from called function"}
1536+}
1537+
1538+# Verify that GDB responds gracefully to a "finish" command with
1539+# arguments.
1540+#
1541+if ![runto_main] then { fail "break tests suppressed" }
1542+
1543+send_gdb "finish 123\n"
1544+gdb_expect {
1545+ -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
1546+ {pass "finish with arguments disallowed"}
1547+ -re "$gdb_prompt $"\
1548+ {fail "finish with arguments disallowed"}
1549+ timeout {fail "(timeout) finish with arguments disallowed"}
1550+}
1551+
1552+# Verify that GDB responds gracefully to a request to "finish" from
1553+# the outermost frame. On a stub that never exits, this will just
1554+# run to the stubs routine, so we don't get this error... Thus the
1555+# second condition.
1556+#
1557+
1558+send_gdb "finish\n"
1559+gdb_expect {
1560+ -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
1561+ {pass "finish from outermost frame disallowed"}
1562+ -re "Run till exit from.*\r\n$gdb_prompt $" {
1563+ pass "finish from outermost frame disallowed"
1564+ }
1565+ -re "$gdb_prompt $"\
1566+ {fail "finish from outermost frame disallowed"}
1567+ timeout {fail "(timeout) finish from outermost frame disallowed"}
1568+}
1569+
1570+# Verify that we can explicitly ask GDB to stop on all shared library
1571+# events, and that it does so.
1572+#
1573+if [istarget "hppa*-*-hpux*"] then {
1574+ if ![runto_main] then { fail "break tests suppressed" }
1575+
1576+ send_gdb "set stop-on-solib-events 1\n"
1577+ gdb_expect {
1578+ -re "$gdb_prompt $"\
1579+ {pass "set stop-on-solib-events"}
1580+ timeout {fail "(timeout) set stop-on-solib-events"}
1581+ }
1582+
1583+ send_gdb "run\n"
1584+ gdb_expect {
1585+ -re ".*Start it from the beginning.*y or n. $"\
1586+ {send_gdb "y\n"
1587+ gdb_expect {
1588+ -re ".*Stopped due to shared library event.*$gdb_prompt $"\
1589+ {pass "triggered stop-on-solib-events"}
1590+ -re "$gdb_prompt $"\
1591+ {fail "triggered stop-on-solib-events"}
1592+ timeout {fail "(timeout) triggered stop-on-solib-events"}
1593+ }
1594+ }
1595+ -re "$gdb_prompt $"\
1596+ {fail "rerun for stop-on-solib-events"}
1597+ timeout {fail "(timeout) rerun for stop-on-solib-events"}
1598+ }
1599+
1600+ send_gdb "set stop-on-solib-events 0\n"
1601+ gdb_expect {
1602+ -re "$gdb_prompt $"\
1603+ {pass "reset stop-on-solib-events"}
1604+ timeout {fail "(timeout) reset stop-on-solib-events"}
1605+ }
1606+}
1607+
1608+# Hardware breakpoints are unsupported on HP-UX. Verify that GDB
1609+# gracefully responds to requests to create them.
1610+#
1611+if [istarget "hppa*-*-hpux*"] then {
1612+ if ![runto_main] then { fail "break tests suppressed" }
1613+
1614+ send_gdb "hbreak\n"
1615+ gdb_expect {
1616+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
1617+ {pass "hw breaks disallowed"}
1618+ -re "$gdb_prompt $"\
1619+ {fail "hw breaks disallowed"}
1620+ timeout {fail "(timeout) hw breaks disallowed"}
1621+ }
1622+
1623+ send_gdb "thbreak\n"
1624+ gdb_expect {
1625+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
1626+ {pass "temporary hw breaks disallowed"}
1627+ -re "$gdb_prompt $"\
1628+ {fail "temporary hw breaks disallowed"}
1629+ timeout {fail "(timeout) temporary hw breaks disallowed"}
1630+ }
1631+}
1632+
1633+#********
1634+
1635+
1636+#
1637+# Test "next" over recursive function call.
1638+#
1639+
1640+proc test_next_with_recursion {} {
1641+ global gdb_prompt
1642+ global decimal
1643+ global binfile
1644+
1645+ if [target_info exists use_gdb_stub] {
1646+ # Reload the program.
1647+ delete_breakpoints
1648+ gdb_load ${binfile};
1649+ } else {
1650+ # FIXME: should be using runto
1651+ gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
1652+
1653+ delete_breakpoints
1654+ }
1655+
1656+ gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
1657+
1658+ # Run until we call factorial with 6
1659+
1660+ if [istarget "*-*-vxworks*"] then {
1661+ send_gdb "run vxmain \"6\"\n"
1662+ } else {
1663+ gdb_run_cmd
1664+ }
1665+ gdb_expect {
1666+ -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
1667+ -re ".*$gdb_prompt $" {
1668+ fail "run to factorial(6)";
1669+ gdb_suppress_tests;
1670+ }
1671+ timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
1672+ }
1673+
1674+ # Continue until we call factorial recursively with 5.
1675+
1676+ if [gdb_test "continue" \
1677+ "Continuing.*Break.* factorial .value=5. .*" \
1678+ "continue to factorial(5)"] then { gdb_suppress_tests }
1679+
1680+ # Do a backtrace just to confirm how many levels deep we are.
1681+
1682+ if [gdb_test "backtrace" \
1683+ "#0\[ \t\]+ factorial .value=5..*" \
1684+ "backtrace from factorial(5)"] then { gdb_suppress_tests }
1685+
1686+ # Now a "next" should position us at the recursive call, which
1687+ # we will be performing with 4.
1688+
1689+ if [gdb_test "next" \
1690+ ".* factorial .value - 1.;.*" \
1691+ "next to recursive call"] then { gdb_suppress_tests }
1692+
1693+ # Disable the breakpoint at the entry to factorial by deleting them all.
1694+ # The "next" should run until we return to the next line from this
1695+ # recursive call to factorial with 4.
1696+ # Buggy versions of gdb will stop instead at the innermost frame on
1697+ # the line where we are trying to "next" to.
1698+
1699+ delete_breakpoints
1700+
1701+ if [istarget "mips*tx39-*"] {
1702+ set timeout 60
1703+ }
1704+ # We used to set timeout here for all other targets as well. This
1705+ # is almost certainly wrong. The proper timeout depends on the
1706+ # target system in use, and how we communicate with it, so there
1707+ # is no single value appropriate for all targets. The timeout
1708+ # should be established by the Dejagnu config file(s) for the
1709+ # board, and respected by the test suite.
1710+ #
1711+ # For example, if I'm running GDB over an SSH tunnel talking to a
1712+ # portmaster in California talking to an ancient 68k board running
1713+ # a crummy ROM monitor (a situation I can only wish were
1714+ # hypothetical), then I need a large timeout. But that's not the
1715+ # kind of knowledge that belongs in this file.
1716+
1717+ gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
1718+ "next over recursive call"
1719+
1720+ # OK, we should be back in the same stack frame we started from.
1721+ # Do a backtrace just to confirm.
1722+
1723+ set result [gdb_test "backtrace" \
1724+ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
1725+ "backtrace from factorial(5.1)"]
1726+ if { $result != 0 } { gdb_suppress_tests }
1727+
1728+ if [target_info exists gdb,noresults] { gdb_suppress_tests }
1729+ gdb_continue_to_end "recursive next test"
1730+ gdb_stop_suppressing_tests;
1731+}
1732+
1733+test_next_with_recursion
1734+
1735+
1736+#********
1737+
1738+# build a new file with optimization enabled so that we can try breakpoints
1739+# on targets with optimized prologues
1740+
1741+set binfileo2 ${objdir}/${subdir}/${testfile}o2
1742+
1743+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.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 "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
1748+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1749+}
1750+
1751+if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
1752+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1753+}
1754+
1755+if [get_compiler_info ${binfileo2}] {
1756+ return -1
1757+}
1758+
1759+gdb_exit
1760+gdb_start
1761+gdb_reinitialize_dir $srcdir/$subdir
1762+gdb_load ${binfileo2}
1763+
1764+if [target_info exists gdb_stub] {
1765+ gdb_step_for_stub;
1766+}
1767+
1768+#
1769+# test break at function
1770+#
1771+gdb_test "break main" \
1772+ "Breakpoint.*at.* file .*$srcfile, line.*" \
1773+ "breakpoint function, optimized file"
1774+
1775+#
1776+# test break at function
1777+#
1778+gdb_test "break marker4" \
1779+ "Breakpoint.*at.* file .*$srcfile1, line.*" \
1780+ "breakpoint small function, optimized file"
1781+
1782+#
1783+# run until the breakpoint at main is hit. For non-stubs-using targets.
1784+#
1785+if ![target_info exists use_gdb_stub] {
1786+ if [istarget "*-*-vxworks*"] then {
1787+ send_gdb "run vxmain \"2\"\n"
1788+ set timeout 120
1789+ verbose "Timeout is now $timeout seconds" 2
1790+ } else {
1791+ send_gdb "run\n"
1792+ }
1793+ gdb_expect {
1794+ -re "The program .* has been started already.*y or n. $" {
1795+ send_gdb "y\n"
1796+ exp_continue
1797+ }
1798+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
1799+ { pass "run until function breakpoint, optimized file" }
1800+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
1801+ { pass "run until function breakpoint, optimized file (code motion)" }
1802+ -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" }
1803+ timeout { fail "run until function breakpoint, optimized file (timeout)" }
1804+ }
1805+} else {
1806+ if ![target_info exists gdb_stub] {
1807+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
1808+ }
1809+}
1810+
1811+#
1812+# run until the breakpoint at a small function
1813+#
1814+
1815+#
1816+# Add a second pass pattern. The behavior differs here between stabs
1817+# and dwarf for one-line functions. Stabs preserves two line symbols
1818+# (one before the prologue and one after) with the same line number,
1819+# but dwarf regards these as duplicates and discards one of them.
1820+# Therefore the address after the prologue (where the breakpoint is)
1821+# has no exactly matching line symbol, and GDB reports the breakpoint
1822+# as if it were in the middle of a line rather than at the beginning.
1823+
1824+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
1825+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
1826+send_gdb "continue\n"
1827+gdb_expect {
1828+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
1829+ pass "run until breakpoint set at small function, optimized file"
1830+ }
1831+ -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
1832+ pass "run until breakpoint set at small function, optimized file"
1833+ }
1834+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
1835+ # marker4() is defined at line 46 when compiled with -DPROTOTYPES
1836+ pass "run until breakpoint set at small function, optimized file (line bp_location14)"
1837+ }
1838+ -re ".*$gdb_prompt " {
1839+ fail "run until breakpoint set at small function, optimized file"
1840+ }
1841+ timeout {
1842+ fail "run until breakpoint set at small function, optimized file (timeout)"
1843+ }
1844+}
1845+
1846+
1847+# Reset the default arguments for VxWorks
1848+if [istarget "*-*-vxworks*"] {
1849+ set timeout 10
1850+ verbose "Timeout is now $timeout seconds" 2
1851+ send_gdb "set args main\n"
1852+ gdb_expect -re ".*$gdb_prompt $" {}
1853+}
7566401a 1854Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp
3a58abaf
AM
1855===================================================================
1856--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 1857+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
1858@@ -0,0 +1,243 @@
1859+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
1860+# Free Software Foundation, Inc.
1861+
1862+# This program is free software; you can redistribute it and/or modify
1863+# it under the terms of the GNU General Public License as published by
1864+# the Free Software Foundation; either version 2 of the License, or
1865+# (at your option) any later version.
1866+#
1867+# This program is distributed in the hope that it will be useful,
1868+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1869+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1870+# GNU General Public License for more details.
1871+#
1872+# You should have received a copy of the GNU General Public License
1873+# along with this program; if not, write to the Free Software
1874+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1875+
1876+# Please email any bugs, comments, and/or additions to this file to:
1877+# bug-gdb@prep.ai.mit.edu
1878+
1879+# This file was written by Fred Fish. (fnf@cygnus.com)
1880+
1881+if $tracelevel then {
1882+ strace $tracelevel
1883+}
1884+
1885+set prms_id 0
1886+set bug_id 0
1887+
1888+# are we on a target board
1889+if ![isnative] then {
1890+ return
1891+}
1892+
1893+set testfile "coremaker"
1894+set srcfile ${testfile}.c
1895+set binfile ${objdir}/${subdir}/${testfile}
1896+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } {
1897+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
1898+}
1899+
1900+# Create and source the file that provides information about the compiler
1901+# used to compile the test case.
1902+if [get_compiler_info ${binfile}] {
1903+ return -1;
1904+}
1905+
1906+# Create a core file named "corefile" rather than just "core", to
1907+# avoid problems with sys admin types that like to regularly prune all
1908+# files named "core" from the system.
1909+#
1910+# Arbitrarily try setting the core size limit to "unlimited" since
1911+# this does not hurt on systems where the command does not work and
1912+# allows us to generate a core on systems where it does.
1913+#
1914+# Some systems append "core" to the name of the program; others append
1915+# the name of the program to "core"; still others (like Linux, as of
1916+# May 2003) create cores named "core.PID". In the latter case, we
1917+# could have many core files lying around, and it may be difficult to
1918+# tell which one is ours, so let's run the program in a subdirectory.
1919+set found 0
1920+set coredir "${objdir}/${subdir}/coredir.[getpid]"
1921+file mkdir $coredir
1922+catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
1923+# remote_exec host "${binfile}"
1924+foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
1925+ if [remote_file build exists $i] {
1926+ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
1927+ set found 1
1928+ }
1929+}
1930+# Check for "core.PID".
1931+if { $found == 0 } {
1932+ set names [glob -nocomplain -directory $coredir core.*]
1933+ if {[llength $names] == 1} {
1934+ set corefile [file join $coredir [lindex $names 0]]
1935+ remote_exec build "mv $corefile ${objdir}/${subdir}/corefile"
1936+ set found 1
1937+ }
1938+}
1939+if { $found == 0 } {
1940+ # The braindamaged HPUX shell quits after the ulimit -c above
1941+ # without executing ${binfile}. So we try again without the
1942+ # ulimit here if we didn't find a core file above.
1943+ # Oh, I should mention that any "braindamaged" non-Unix system has
1944+ # the same problem. I like the cd bit too, it's really neat'n stuff.
1945+ catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
1946+ foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
1947+ if [remote_file build exists $i] {
1948+ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
1949+ set found 1
1950+ }
1951+ }
1952+}
1953+
1954+# Try to clean up after ourselves.
1955+remote_file build delete [file join $coredir coremmap.data]
1956+remote_exec build "rmdir $coredir"
1957+
1958+if { $found == 0 } {
1959+ warning "can't generate a core file - core tests suppressed - check ulimit -c"
1960+ return 0
1961+}
1962+
1963+#
1964+# Test that we can simply startup with a "-core=corefile" command line arg
1965+# and recognize that the core file is a valid, usable core file.
1966+# To do this, we must shutdown the currently running gdb and restart
1967+# with the -core args. We can't use gdb_start because it looks for
1968+# the first gdb prompt, and the message we are looking for occurs
1969+# before the first prompt. Also, we can't include GDBFLAGS because
1970+# if it is empty, this confuses gdb with an empty argument that it
1971+# grumbles about (said grumbling currently being ignored in gdb_start).
1972+# **FIXME**
1973+#
1974+# Another problem is that on some systems (solaris for example), there
1975+# is apparently a limit on the length of a fully specified path to
1976+# the coremaker executable, at about 80 chars. For this case, consider
1977+# it a pass, but note that the program name is bad.
1978+
1979+gdb_exit
1980+if $verbose>1 then {
1981+ send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
1982+}
1983+
1984+set oldtimeout $timeout
1985+set timeout [expr "$timeout + 60"]
1986+verbose "Timeout is now $timeout seconds" 2
1987+eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
1988+expect {
1989+ -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
1990+ fail "args: -core=corefile (couldn't find regs)"
1991+ }
1992+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1993+ pass "args: -core=corefile"
1994+ }
1995+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
1996+ pass "args: -core=corefile (with bad program name)"
1997+ }
1998+ -re ".*registers from core file: File in wrong format.* $" {
1999+ fail "args: -core=corefile (could not read registers from core file)"
2000+ }
2001+ -re ".*$gdb_prompt $" { fail "args: -core=corefile" }
2002+ timeout { fail "(timeout) starting with -core" }
2003+}
2004+
2005+
2006+#
2007+# Test that startup with both an executable file and -core argument.
2008+# See previous comments above, they are still applicable.
2009+#
2010+
2011+close;
2012+
2013+if $verbose>1 then {
2014+ send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n"
2015+}
2016+
2017+
2018+eval "spawn $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile";
2019+expect {
2020+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2021+ pass "args: execfile -core=corefile"
2022+ }
2023+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2024+ pass "args: execfile -core=corefile (with bad program name)"
2025+ }
2026+ -re ".*registers from core file: File in wrong format.* $" {
2027+ fail "args: execfile -core=corefile (could not read registers from core file)"
2028+ }
2029+ -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" }
2030+ timeout { fail "(timeout) starting with -core" }
2031+}
2032+set timeout $oldtimeout
2033+verbose "Timeout is now $timeout seconds" 2
2034+
2035+close;
2036+
2037+# Now restart normally.
2038+
2039+gdb_start
2040+gdb_reinitialize_dir $srcdir/$subdir
2041+gdb_load ${binfile}
2042+
2043+# Test basic corefile recognition via core-file command.
2044+
2045+send_gdb "core-file $objdir/$subdir/corefile\n"
2046+gdb_expect {
2047+ -re ".* program is being debugged already.*y or n. $" {
2048+ # gdb_load may connect us to a gdbserver.
2049+ send_gdb "y\n"
2050+ exp_continue;
2051+ }
2052+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2053+ pass "core-file command"
2054+ }
2055+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
2056+ pass "core-file command (with bad program name)"
2057+ }
2058+ -re ".*registers from core file: File in wrong format.* $" {
2059+ fail "core-file command (could not read registers from core file)"
2060+ }
2061+ -re ".*$gdb_prompt $" { fail "core-file command" }
2062+ timeout { fail "(timeout) core-file command" }
2063+}
2064+
2065+# Test correct mapping of corefile sections by printing some variables.
2066+
2067+gdb_test "print coremaker_data" "\\\$$decimal = 202"
2068+gdb_test "print coremaker_bss" "\\\$$decimal = 10"
2069+gdb_test "print coremaker_ro" "\\\$$decimal = 201"
2070+
2071+gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
2072+
2073+# Somehow we better test the ability to read the registers out of the core
2074+# file correctly. I don't think the other tests do this.
2075+
2076+gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
2077+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp"
2078+
2079+# Test ability to read mmap'd data
2080+
2081+gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file"
2082+setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*"
2083+set test "accessing mmapped data in core file"
2084+gdb_test_multiple "x/8bd buf2" "$test" {
2085+ -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" {
2086+ pass "$test"
2087+ }
2088+ -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" {
2089+ fail "$test (mapping failed at runtime)"
2090+ }
2091+ -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" {
2092+ fail "$test (mapping address not found in core file)"
2093+ }
2094+}
2095+
2096+# test reinit_frame_cache
2097+
2098+gdb_load ${binfile}
2099+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\).*" "up in corefile.exp (reinit)"
2100+
2101+gdb_test "core" "No core file now."
7566401a 2102Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/Makefile.in
3a58abaf
AM
2103===================================================================
2104--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7566401a 2105+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/Makefile.in 2009-09-09 19:06:01.000000000 +0200
3a58abaf
AM
2106@@ -0,0 +1,19 @@
2107+VPATH = @srcdir@
2108+srcdir = @srcdir@
2109+
2110+EXECUTABLES =
2111+MISCELLANEOUS = arch.inc
2112+
2113+all info install-info dvi install uninstall installcheck check:
2114+ @echo "Nothing to be done for $@..."
2115+
2116+clean mostlyclean:
2117+ -rm -f *~ *.o a.out *.x *.ci *.tmp
2118+ -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES)
2119+ -rm -f $(MISCELLANEOUS)
2120+
2121+distclean maintainer-clean realclean: clean
2122+ -rm -f *~ core
2123+ -rm -f Makefile config.status config.log
2124+ -rm -f *-init.exp
2125+ -rm -fr *.log summary detail *.plog *.sum *.psum site.*
This page took 0.483757 seconds and 4 git commands to generate.