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