summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/config/i386/tm-vxworks.h28
-rw-r--r--gdb/config/i386/vxworks.mt3
-rw-r--r--gdb/config/pa/hppa64.mt4
-rw-r--r--gdb/config/pa/tm-hppa64.h320
-rw-r--r--gdb/config/powerpc/tm-vxworks.h28
-rw-r--r--gdb/config/powerpc/vxworks.mt3
-rw-r--r--gdb/testsuite/gdb.base/selftest.exp430
7 files changed, 816 insertions, 0 deletions
diff --git a/gdb/config/i386/tm-vxworks.h b/gdb/config/i386/tm-vxworks.h
new file mode 100644
index 00000000000..efd2665d359
--- /dev/null
+++ b/gdb/config/i386/tm-vxworks.h
@@ -0,0 +1,28 @@
+/* Target machine description for VxWorks on the 80[3456]86,
+ for GDB, the GNU debugger.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef TM_VXWORKS_H
+#define TM_VXWORKS_H
+
+#include "i386/tm-i386v.h"
+#include "tm-vxworks.h"
+
+#endif /* ifndef TM_VXWORKS_H */
diff --git a/gdb/config/i386/vxworks.mt b/gdb/config/i386/vxworks.mt
new file mode 100644
index 00000000000..a14aacc8cd0
--- /dev/null
+++ b/gdb/config/i386/vxworks.mt
@@ -0,0 +1,3 @@
+# Target: i386 running VxWorks
+TDEPFILES= i386-tdep.o i387-tdep.o
+TM_FILE= tm-vxworks.h
diff --git a/gdb/config/pa/hppa64.mt b/gdb/config/pa/hppa64.mt
new file mode 100644
index 00000000000..ea7559fd56f
--- /dev/null
+++ b/gdb/config/pa/hppa64.mt
@@ -0,0 +1,4 @@
+# Target: HP PA-RISC 2.0 running HPUX 11.00 in wide mode
+TDEPFILES= hppa-tdep.o # pa64-solib.o
+TM_FILE= tm-hppa64.h
+TM_CLIBS= # $(srcdir)/libxpdl.a
diff --git a/gdb/config/pa/tm-hppa64.h b/gdb/config/pa/tm-hppa64.h
new file mode 100644
index 00000000000..3aaeaeedb7f
--- /dev/null
+++ b/gdb/config/pa/tm-hppa64.h
@@ -0,0 +1,320 @@
+/* Parameters for execution on any Hewlett-Packard PA-RISC machine.
+ Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1995
+ Free Software Foundation, Inc.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* PA 64-bit specific definitions. Override those which are in
+ tm-hppa.h */
+
+#include "pa/tm-hppah.h"
+
+#define HPUX_1100 1
+
+/* jimb: this must go. I'm just using it to disable code I haven't
+ gotten working yet. */
+#define GDB_TARGET_IS_HPPA_20W
+
+/* The low two bits of the IA are the privilege level of the instruction. */
+#define ADDR_BITS_REMOVE(addr) ((CORE_ADDR)addr & (CORE_ADDR)~3)
+
+/* Say how long (ordinary) registers are. This is used in
+ push_word and a few other places, but REGISTER_RAW_SIZE is
+ the real way to know how big a register is. */
+
+#undef REGISTER_SIZE
+#define REGISTER_SIZE 8
+
+/* Number of bytes of storage in the actual machine representation
+ for register N. On the PA-RISC 2.0, all regs are 8 bytes, including
+ the FP registers (they're accessed as two 4 byte halves). */
+
+#undef REGISTER_RAW_SIZE
+#define REGISTER_RAW_SIZE(N) 8
+
+/* Largest value REGISTER_RAW_SIZE can have. */
+
+#undef MAX_REGISTER_RAW_SIZE
+#define MAX_REGISTER_RAW_SIZE 8
+
+/* Total amount of space needed to store our copies of the machine's
+ register state, the array `registers'. */
+
+#undef REGISTER_BYTES
+#define REGISTER_BYTES (NUM_REGS * 8)
+
+/* Index within `registers' of the first byte of the space for
+ register N. */
+
+#undef REGISTER_BYTE
+#define REGISTER_BYTE(N) ((N) * 8)
+
+#undef REGISTER_VIRTUAL_TYPE
+#define REGISTER_VIRTUAL_TYPE(N) \
+ ((N) < FP4_REGNUM ? builtin_type_unsigned_long_long : builtin_type_double)
+
+
+/* Number of machine registers */
+#undef NUM_REGS
+#define NUM_REGS 96
+
+/* Initializer for an array of names of registers.
+ There should be NUM_REGS strings in this initializer.
+ They are in rows of eight entries */
+#undef REGISTER_NAMES
+#define REGISTER_NAMES \
+ {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", \
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
+ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
+ "r24", "r25", "r26", "dp", "ret0", "ret1", "sp", "r31", \
+ "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", "eiem", "iir", "isr", \
+ "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", "sr3", \
+ "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", \
+ "cr13", "cr24", "cr25", "cr26", "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",\
+ "fpsr", "fpe1", "fpe2", "fpe3", "fr4", "fr5", "fr6", "fr7", \
+ "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
+ "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
+ "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"}
+
+#undef FP0_REGNUM
+#undef FP4_REGNUM
+#define FP0_REGNUM 64 /* floating point reg. 0 (fspr)*/
+#define FP4_REGNUM 68
+
+/* Redefine some target bit sizes from the default. */
+
+/* Number of bits in a long or unsigned long for the target machine. */
+
+#define TARGET_LONG_BIT 64
+
+/* Number of bits in a long long or unsigned long long for the
+ target machine. */
+
+#define TARGET_LONG_LONG_BIT 64
+
+/* Number of bits in a pointer for the target machine */
+
+#define TARGET_PTR_BIT 64
+
+/* Argument Pointer Register */
+#define AP_REGNUM 29
+
+#define DP_REGNUM 27
+
+#define FP5_REGNUM 70
+
+#define SR5_REGNUM 48
+
+#undef FRAME_ARGS_ADDRESS
+#define FRAME_ARGS_ADDRESS(fi) ((fi)->ap)
+
+/* We access locals from SP. This may not work for frames which call
+ alloca; for those, we may need to consult unwind tables.
+ jimb: FIXME. */
+#undef FRAME_LOCALS_ADDRESS
+#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
+
+#define INIT_FRAME_AP init_frame_ap
+
+#define EXTRA_FRAME_INFO \
+ CORE_ADDR ap;
+
+/* For a number of horrible reasons we may have to adjust the location
+ of variables on the stack. Ugh. jimb: why? */
+#define HPREAD_ADJUST_STACK_ADDRESS(ADDR) hpread_adjust_stack_address(ADDR)
+
+extern int hpread_adjust_stack_address PARAMS ((CORE_ADDR));
+
+
+/* jimb: omitted dynamic linking stuff here */
+
+/* This sequence of words is the instructions
+
+; Call stack frame has already been built by gdb. Since we could be calling
+; a varargs function, and we do not have the benefit of a stub to put things in
+; the right place, we load the first 8 word of arguments into both the general
+; and fp registers.
+call_dummy
+ copy %r4,%r29
+ copy %r5,%r22
+ copy %r6,%r27
+ fldd -64(0,%r29),%fr4
+ fldd -56(0,%r29),%fr5
+ fldd -48(0,%r29),%fr6
+ fldd -40(0,%r29),%fr7
+ fldd -32(0,%r29),%fr8
+ fldd -24(0,%r29),%fr9
+ fldd -16(0,%r29),%fr10
+ fldd -8(0,%r29),%fr11
+ copy %r22,%r1
+ ldd -64(%r29), %r26
+ ldd -56(%r29), %r25
+ ldd -48(%r29), %r24
+ ldd -40(%r29), %r23
+ ldd -32(%r29), %r22
+ ldd -24(%r29), %r21
+ ldd -16(%r29), %r20
+ bve,l (%r1),%r2
+ ldd -8(%r29), %r19
+ break 4, 8
+ mtsp %r21, %sr0
+ ble 0(%sr0, %r22)
+ nop
+*/
+
+#undef CALL_DUMMY
+#define CALL_DUMMY {0x349d0000, 0x34b60000, 0x34db0000, \
+ 0x53a43f83, 0x53a53f93, 0x53a63fa3, 0x53a73fb3,\
+ 0x53a83fc3, 0x53a93fd3, 0x2fa1100a, 0x2fb1100b,\
+ 0x36c10000, 0x53ba3f81, 0x53b93f91, 0x53b83fa1,\
+ 0x53b73fb1, 0x53b63fc1, 0x53b53fd1, 0x0fa110d4,\
+ 0xe820f000, 0x0fb110d3, 0x00010004, 0x00151820,\
+ 0xe6c00000, 0x08000240}
+
+#undef CALL_DUMMY_LENGTH
+#define CALL_DUMMY_LENGTH (INSTRUCTION_SIZE * 25)
+
+#undef FUNC_LDIL_OFFSET
+#undef FUNC_LDO_OFFSET
+#undef SR4EXPORT_LDIL_OFFSET
+#undef SR4EXPORT_LDO_OFFSET
+#undef CALL_DUMMY_LOCATION
+/* jimb: need to find out what AT_WDB_CALL_DUMMY is about */
+#if 0
+#define CALL_DUMMY_LOCATION AFTER_TEXT_END
+extern CORE_ADDR wdb_call_dummy_addr;
+#undef PC_IN_CALL_DUMMY
+#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
+ ((pc) >= wdb_call_dummy_addr && \
+ (pc) <= wdb_call_dummy_addr + CALL_DUMMY_LENGTH)
+#endif
+
+#undef REG_STRUCT_HAS_ADDR
+
+#undef EXTRACT_RETURN_VALUE
+/* RM: floats are returned in FR4R, doubles in FR4
+ * integral values are in r28, padded on the left
+ * aggregates less that 65 bits are in r28, right padded
+ * aggregates upto 128 bits are in r28 and r29, right padded
+ */
+#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
+ { \
+ if (TYPE_CODE (TYPE) == TYPE_CODE_FLT && !SOFT_FLOAT) \
+ memcpy ((VALBUF), \
+ ((char *)(REGBUF)) + REGISTER_BYTE (FP4_REGNUM) + \
+ (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
+ TYPE_LENGTH (TYPE)); \
+ else if (is_integral_type(TYPE) || SOFT_FLOAT) \
+ memcpy ((VALBUF), \
+ (char *)(REGBUF) + REGISTER_BYTE (28) + \
+ (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
+ TYPE_LENGTH (TYPE)); \
+ else if (TYPE_LENGTH (TYPE) <= 8) \
+ memcpy ((VALBUF), \
+ (char *)(REGBUF) + REGISTER_BYTE (28), \
+ TYPE_LENGTH (TYPE)); \
+ else if (TYPE_LENGTH (TYPE) <= 16) \
+ { \
+ memcpy ((VALBUF), \
+ (char *)(REGBUF) + REGISTER_BYTE (28), \
+ 8); \
+ memcpy (((char *) VALBUF + 8), \
+ (char *)(REGBUF) + REGISTER_BYTE (29), \
+ TYPE_LENGTH (TYPE) - 8); \
+ } \
+ }
+
+/* RM: struct upto 128 bits are returned in registers */
+#undef USE_STRUCT_CONVENTION
+#define USE_STRUCT_CONVENTION(gcc_p, value_type)\
+ (TYPE_LENGTH (value_type) > 16)
+
+/* RM: for return command */
+#undef STORE_RETURN_VALUE
+#define STORE_RETURN_VALUE(TYPE,VALBUF) \
+ { \
+ if (TYPE_CODE (TYPE) == TYPE_CODE_FLT && !SOFT_FLOAT) \
+ write_register_bytes \
+ (REGISTER_BYTE (FP4_REGNUM) + \
+ (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
+ (VALBUF), \
+ TYPE_LENGTH (TYPE)); \
+ else if (is_integral_type(TYPE) || SOFT_FLOAT) \
+ write_register_bytes \
+ (REGISTER_BYTE (28) + \
+ (REGISTER_SIZE - TYPE_LENGTH (TYPE)), \
+ (VALBUF), \
+ TYPE_LENGTH (TYPE)); \
+ else if (TYPE_LENGTH (TYPE) <= 8) \
+ write_register_bytes \
+ ( REGISTER_BYTE (28), \
+ (VALBUF), \
+ TYPE_LENGTH (TYPE)); \
+ else if (TYPE_LENGTH (TYPE) <= 16) \
+ { \
+ write_register_bytes \
+ (REGISTER_BYTE (28), \
+ (VALBUF), \
+ 8); \
+ write_register_bytes \
+ (REGISTER_BYTE (29), \
+ ((char *) VALBUF + 8), \
+ TYPE_LENGTH (TYPE) - 8); \
+ } \
+ }
+
+/* RM: these are the PA64 equivalents of the macros in tm-hppah.h --
+ * see comments there. For PA64, the save_state structure is at an
+ * offset of 24 32-bit words from the sigcontext structure. The 64 bit
+ * general registers are at an offset of 640 bytes from the beginning of the
+ * save_state structure, and the floating pointer register are at an offset
+ * of 256 bytes from the beginning of the save_state structure.
+ */
+#undef FRAME_SAVED_PC_IN_SIGTRAMP
+#define FRAME_SAVED_PC_IN_SIGTRAMP(FRAME, TMP) \
+{ \
+ *(TMP) = read_memory_integer ((FRAME)->frame + (24 * 4) + 640 + (33 * 8), 8); \
+}
+
+#undef FRAME_BASE_BEFORE_SIGTRAMP
+#define FRAME_BASE_BEFORE_SIGTRAMP(FRAME, TMP) \
+{ \
+ *(TMP) = read_memory_integer ((FRAME)->frame + (24 * 4) + 640 + (30 * 8), 8); \
+}
+
+#undef FRAME_FIND_SAVED_REGS_IN_SIGTRAMP
+#define FRAME_FIND_SAVED_REGS_IN_SIGTRAMP(FRAME, FSR) \
+{ \
+ int i; \
+ CORE_ADDR TMP1, TMP2; \
+ TMP1 = (FRAME)->frame + (24 * 4) + 640; \
+ TMP2 = (FRAME)->frame + (24 * 4) + 256; \
+ for (i = 0; i < NUM_REGS; i++) \
+ { \
+ if (i == SP_REGNUM) \
+ (FSR)->regs[SP_REGNUM] = read_memory_integer (TMP1 + SP_REGNUM * 8, 8); \
+ else if (i >= FP0_REGNUM) \
+ (FSR)->regs[i] = TMP2 + (i - FP0_REGNUM) * 8; \
+ else \
+ (FSR)->regs[i] = TMP1 + i * 8; \
+ } \
+}
+
+/* jimb: omitted purify call support */
diff --git a/gdb/config/powerpc/tm-vxworks.h b/gdb/config/powerpc/tm-vxworks.h
new file mode 100644
index 00000000000..a31846a802f
--- /dev/null
+++ b/gdb/config/powerpc/tm-vxworks.h
@@ -0,0 +1,28 @@
+/* Target machine description for VxWorks on the PowerPC,
+ for GDB, the GNU debugger.
+ Copyright 1999 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef TM_VXWORKS_H
+#define TM_VXWORKS_H
+
+#include "powerpc/tm-ppc-eabi.h"
+#include "tm-vxworks.h"
+
+#endif /* ifndef TM_VXWORKS_H */
diff --git a/gdb/config/powerpc/vxworks.mt b/gdb/config/powerpc/vxworks.mt
new file mode 100644
index 00000000000..1c71413bb07
--- /dev/null
+++ b/gdb/config/powerpc/vxworks.mt
@@ -0,0 +1,3 @@
+# Target: Powerpc running VxWorks
+TDEPFILES= rs6000-tdep.o
+TM_FILE= tm-vxworks.h
diff --git a/gdb/testsuite/gdb.base/selftest.exp b/gdb/testsuite/gdb.base/selftest.exp
new file mode 100644
index 00000000000..c0d17c815ec
--- /dev/null
+++ b/gdb/testsuite/gdb.base/selftest.exp
@@ -0,0 +1,430 @@
+# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Rob Savoye. (rob@cygnus.com)
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+# are we on a target board
+if [is_remote target] {
+ return
+}
+
+if [istarget "m68k*-*-hpux*"] then {
+ # The top-level makefile passes CFLAGS= (no -g) for hp300. This probably
+ # should be fixed (it is only needed for gcc bootstrapping, not gdb),
+ # but until then.....
+ setup_xfail "*-*-*"
+ fail "cannot test self if compiled without debug info"
+ return -1
+}
+
+# Not all of the lines of code near the start of main are executed for
+# every machine. Also, optimization may reorder some of the lines.
+# So all we do is try to step or next over everything until we get
+# to a line that we know is always executed.
+
+proc do_steps_and_nexts {} {
+ global gdb_prompt
+ global srcdir
+
+ gdb_reinitialize_dir $srcdir/..
+
+ for {set count 0} {$count < 20} {incr count} {
+ send_gdb "list\n"
+ gdb_expect {
+ -re ".*symarg = NULL.*$gdb_prompt $" {
+ set description "step over symarg initialization"
+ set command "step"
+ }
+ -re ".*execarg = NULL.*$gdb_prompt $" {
+ set description "step over execarg initialization"
+ set command "step"
+ }
+ -re ".*corearg = NULL.*$gdb_prompt $" {
+ set description "step over corearg initialization"
+ set command "step"
+ }
+ -re ".*cdarg = NULL.*$gdb_prompt $" {
+ set description "step over cdarg initialization"
+ set command "step"
+ }
+ -re ".*ttyarg = NULL.*$gdb_prompt $" {
+ set description "step over ttyarg initialization"
+ set command "step"
+ }
+ -re ".*interparg = NULL.*$gdb_prompt $" {
+ set description "step over interparg initialization"
+ set command "step"
+ }
+ -re ".*time_at_startup = get_run_time.*$gdb_prompt $" {
+ set description "next over get_run_time and everything it calls"
+ set command "next"
+ }
+ -re ".*START_PROGRESS.*$gdb_prompt $" {
+ set description "next over START_PROGRESS and everything it calls"
+ set command "next"
+ }
+ -re ".*mac_init.*$gdb_prompt $" {
+ set description "next over mac_init and everything it calls"
+ set command "next"
+ }
+ -re ".*init_malloc.*$gdb_prompt $" {
+ set description "next over init_malloc and everything it calls"
+ set command "next"
+ }
+ -re ".*count . 0x3.*$gdb_prompt $" {
+ set description "next over conditional stack alignment code 1"
+ set command "next"
+ }
+ -re ".*if .i != 0.*$gdb_prompt $" {
+ set description "next over conditional stack alignment code 2"
+ set command "next"
+ }
+ -re ".*alloca .i - 4.*$gdb_prompt $" {
+ set description "next over conditional stack alignment alloca"
+ set command "next"
+ }
+ -re ".*SET_TOP_LEVEL.*$gdb_prompt $" {
+ set description "next over SET_TOP_LEVEL call"
+ set command "next"
+ }
+ -re ".*cmdsize = 1.*$gdb_prompt $" {
+ set description "step over cmdsize initialization"
+ set command "next"
+ }
+ -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" {
+ set description "next over cmdarg initialization via xmalloc"
+ set command "next"
+ }
+ -re ".*ncmd = 0.*$gdb_prompt $" {
+ set description "next over ncmd initialization"
+ set command "next"
+ }
+ -re ".*dirsize = 1.*$gdb_prompt $" {
+ set description "next over dirsize initialization"
+ set command "next"
+ }
+ -re ".*dirarg = .* xmalloc.*$gdb_prompt $" {
+ return
+ }
+ -re "\[ \t\]+\{\r\n$gdb_prompt $" {
+ setup_xfail "mips-*-irix5*"
+ fail "$description ended up at odd location"
+ }
+ -re ".*main.c.*No such file or directory.*$gdb_prompt $" {
+ setup_xfail "rs6000-*-aix3*"
+ fail "must be able to list source lines"
+ return
+ }
+ -re ".*$gdb_prompt $" {
+ fail "unknown source line after $description"
+ return
+ }
+ default {
+ fail "unknown source line near main"
+ return
+ }
+ }
+ send_gdb "$command\n"
+ gdb_expect {
+ -re ".*No such file or directory.\r\n$gdb_prompt $" {
+ fail "$description (no source available)"
+ }
+ -re ".*A file or directory .* does not exist..\r\n$gdb_prompt $" {
+ fail "$description (no source available)"
+ }
+ -re ".*$gdb_prompt $" {
+ pass "$description"
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+ }
+}
+
+proc test_with_self { executable } {
+ global gdb_prompt
+ global tool
+ global det_file
+ global decimal
+ global timeout
+
+ # load yourself into the debugger
+ # This can take a relatively long time, particularly for testing where
+ # the executable is being accessed over a network, or where gdb does not
+ # support partial symbols for a particular target and has to load the
+ # entire symbol table. Set the timeout to 10 minutes, which should be
+ # adequate for most environments (it *has* timed out with 5 min on a
+ # SPARCstation SLC under moderate load, so this isn't unreasonable).
+ # After gdb is started, set the timeout to 30 seconds for the duration
+ # of this test, and then back to the original value.
+
+ set oldtimeout $timeout
+ set timeout 600
+ verbose "Timeout is now $timeout seconds" 2
+ if {[gdb_load $executable] <0} then {
+ set timeout $oldtimeout
+ verbose "Timeout is now $timeout seconds" 2
+ return -1
+ }
+ set timeout $oldtimeout
+ verbose "Timeout is now $timeout seconds" 2
+
+ # disassemble yourself
+ gdb_test "x/10i main" \
+ "x/10i.*main.*main.$decimal.*main.$decimal.*" \
+ "Disassemble main"
+
+ # Set a breakpoint at main
+ gdb_test "break main" \
+ "Breakpoint.*at.* file.*, line.*" \
+ "breakpoint in main"
+
+ # We'll need this when we send a ^C to GDB. Need to do it before we
+ # run the program and gdb starts saving and restoring tty states.
+ # On Ultrix, we don't need it and it is really slow (because shell_escape
+ # doesn't use vfork).
+ if ![istarget "*-*-ultrix*"] then {
+ gdb_test "shell stty intr '^C'" "" \
+ "set interrupt character in test_with_self"
+ }
+
+ # FIXME: If we put this after the run to main, the first list
+ # command doesn't print the same line as the current line where
+ # gdb is stopped.
+ gdb_test "set listsize 1" "" "set listsize to 1"
+
+ # run yourself
+ # It may take a very long time for the inferior gdb to start (lynx),
+ # so we bump it back up for the duration of this command.
+ set timeout 600
+
+ set description "run until breakpoint at main"
+ send_gdb "run -nw\n"
+ gdb_expect {
+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .argc.*argv.* at .*main.c:.*$gdb_prompt $" {
+ pass "$description"
+ }
+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .argc.*argv.*$gdb_prompt $" {
+ xfail "$description (line numbers scrambled?)"
+ }
+ -re "vfork: No more processes.*$gdb_prompt $" {
+ fail "$description (out of virtual memory)"
+ set timeout $oldtimeout
+ verbose "Timeout is now $timeout seconds" 2
+ return -1
+ }
+ -re ".*$gdb_prompt $" {
+ fail "$description"
+ set timeout $oldtimeout
+ verbose "Timeout is now $timeout seconds" 2
+ return -1
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+
+ set timeout $oldtimeout
+ verbose "Timeout is now $timeout seconds" 2
+
+ # do we have a version number ?
+ send_gdb "print version\n"
+ gdb_expect {
+ -re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" {
+ pass "printed version"
+ }
+ -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" {
+ pass "printed version with cast"
+ }
+ -re ".*$gdb_prompt $" { fail "printed version" }
+ timeout { fail "(timeout) printed version" }
+ }
+
+ do_steps_and_nexts
+
+ gdb_test "print \"foo\"" ".\[0-9\]+ = \"foo\"" "print a string"
+
+ # do_steps_and_nexts left us ready to execute an xmalloc call,
+ # so give that a try.
+ # If we don't actually enter the xmalloc call when we give a
+ # step command that seems like a genuine bug. It seems to happen
+ # on most RISC processors.
+ setup_xfail "alpha-*-*" "mips-*-*"
+ set description "step into xmalloc call"
+ send_gdb "step\n"
+ gdb_expect {
+ -re "xmalloc.*size=.*at.*utils.c.*$gdb_prompt $" {
+ pass "$description"
+ }
+ -re ".*No such file or directory.\r\n$gdb_prompt $" {
+ pass "$description (no source available)"
+ }
+ -re "A file or directory .* does not exist..\r\n$gdb_prompt $" {
+ pass "$description (no source available)"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "$description"
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+
+ # start the "xgdb" process
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "GNU gdb \[0-9\.\]*.*
+Copyright \[0-9\]* Free Software Foundation, Inc.*
+GDB is free software, covered by the GNU General Public License, and you are.*
+welcome to change it and/or distribute copies of it under certain conditions.*
+Type \"show copying\" to see the conditions.*
+There is absolutely no warranty for GDB. Type \"show warranty\" for details.*
+This GDB was configured as .*$gdb_prompt $"\
+ { pass "xgdb is at prompt" }
+ -re "GDB is free software and you are welcome to distribute copies of it.*
+ under certain conditions; type \"show copying\" to see the conditions..*
+There is absolutely no warranty for GDB; type \"show warranty\" for details..*
+GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\
+ { pass "xgdb is at prompt (obsolescent gdb)" }
+ -re ".*$gdb_prompt $" { fail "xgdb is at prompt" }
+ timeout { fail "(timeout) xgdb is at prompt" }
+ }
+
+ # set xgdb prompt so we can tell which is which
+ send_gdb "set prompt (xgdb) \n"
+ gdb_expect {
+ -re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" { pass "Set xgdb prompt" }
+ -re ".*$gdb_prompt $" { fail "Set xgdb prompt" }
+ default { fail "(timeout) Set xgdb prompt" }
+ }
+
+ # kill the xgdb process
+ set description "send ^C to child process"
+ send_gdb "\003"
+ gdb_expect {
+ -re "Program received signal SIGINT.*$gdb_prompt $" {
+ pass "$description"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "$description"
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+
+ set description "send SIGINT signal to child process"
+ send_gdb "signal SIGINT\n"
+ gdb_expect {
+ -re "Continuing with signal SIGINT.*$gdb_prompt $" {
+ pass "$description"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "$description"
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+
+ # get a stack trace
+ #
+ # This fails on some linux systems for unknown reasons. On the
+ # systems where it fails, sometimes it works fine when run manually.
+ # The testsuite failures may not be limited to just aout systems.
+ setup_xfail "i*86-pc-linuxaout-gnu" "hppa*-*-hpux*"
+ set description "backtrace through signal handler"
+ send_gdb "backtrace\n"
+ gdb_expect {
+ -re "#0.*read.*in main \\(.*\\) at .*main\\.c.*$gdb_prompt $" {
+ pass "$description"
+ }
+ -re ".*$gdb_prompt $" {
+ # On the alpha, we hit the infamous problem about gdb
+ # being unable to get the frame pointer (mentioned in
+ # gdb/README). As it is intermittent, there is no way to
+ # XFAIL it which will give us an XPASS if the problem goes
+ # away.
+ setup_xfail "alpha*-*-osf*"
+ fail "$description"
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+
+
+ # Set the timeout back to the value it had when we were called.
+ set timeout $oldtimeout
+ verbose "Timeout is now $timeout seconds" 2
+
+ # Restart gdb in case next test expects it to be started already.
+ return 0
+}
+
+# Find a pathname to a file that we would execute if the shell was asked
+# to run $arg using the current PATH.
+
+proc find_gdb { arg } {
+
+ # If the arg directly specifies an existing executable file, then
+ # simply use it.
+
+ if [file executable $arg] then {
+ return $arg
+ }
+
+ set result [which $arg]
+ if [string match "/" [ string range $result 0 0 ]] then {
+ return $result
+ }
+
+ # If everything fails, just return the unqualified pathname as default
+ # and hope for best.
+
+ return $arg
+}
+
+# Run the test with self.
+# Copy the file executable file in case this OS doesn't like to edit its own
+# text space.
+
+set GDB_FULLPATH [find_gdb $GDB]
+
+# Remove any old copy lying around.
+remote_file host delete x$tool
+
+gdb_start
+set file [remote_download host $GDB_FULLPATH x$tool]
+set result [test_with_self $file];
+gdb_exit;
+catch "remote_file host delete $file";
+
+if {$result <0} then {
+ warning "Couldn't test self"
+ return -1
+}