summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJason Molenda <jsm@bugshack.cygnus.com>1999-11-17 02:31:06 +0000
committerJason Molenda <jsm@bugshack.cygnus.com>1999-11-17 02:31:06 +0000
commite49ad2d1d5b90c08b47a628a1e68c591029a5a15 (patch)
tree9114b63ccfe6a79e820431e18c8de6f6d8dbc54d /gdb
parent5eae3750b9c334b4674593e17df0ac7a09b53ca0 (diff)
downloadgdb-e49ad2d1d5b90c08b47a628a1e68c591029a5a15.tar.gz
import gdb-1999-11-16 snapshot
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog201
-rw-r--r--gdb/Makefile.in5
-rw-r--r--gdb/breakpoint.c9
-rw-r--r--gdb/config/d10v/tm-d10v.h289
-rw-r--r--gdb/config/i386/tm-go32.h182
-rw-r--r--gdb/config/i386/tm-i386.h10
-rw-r--r--gdb/corefile.c4
-rw-r--r--gdb/d10v-tdep.c427
-rw-r--r--gdb/defs.h32
-rw-r--r--gdb/exec.c2
-rw-r--r--gdb/gdbserver/low-hppabsd.c9
-rw-r--r--gdb/gdbserver/low-linux.c20
-rw-r--r--gdb/gdbserver/low-lynx.c5
-rw-r--r--gdb/gdbserver/low-sim.c11
-rw-r--r--gdb/gdbserver/low-sparc.c9
-rw-r--r--gdb/gdbserver/low-sun3.c9
-rw-r--r--gdb/gdbserver/server.c2
-rw-r--r--gdb/gdbserver/server.h1
-rw-r--r--gdb/go32-nat.c11
-rw-r--r--gdb/hppa-tdep.c2
-rw-r--r--gdb/irix5-nat.c2
-rw-r--r--gdb/monitor.c1
-rw-r--r--gdb/osfsolib.c2
-rw-r--r--gdb/pa64solib.c2
-rw-r--r--gdb/remote-rdi.c64
-rw-r--r--gdb/remote-sim.c15
-rw-r--r--gdb/sol-thread.c25
-rw-r--r--gdb/solib.c2
-rw-r--r--gdb/somsolib.c2
-rw-r--r--gdb/stabsread.c18
-rw-r--r--gdb/testsuite/ChangeLog22
-rw-r--r--gdb/testsuite/gdb.base/commands.exp2
-rw-r--r--gdb/testsuite/gdb.c++/derivation.exp15
-rw-r--r--gdb/testsuite/lib/gdb.exp33
-rw-r--r--gdb/utils.c181
35 files changed, 782 insertions, 844 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f75ce8d9ca0..6881a3ce439 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,199 @@
+1999-11-16 Mark Salter <msalter@cygnus.com>
+
+ * monitor.c (monitor_supply_register): Initialize value to zero.
+
+1999-11-15 Eli Zaretskii <eliz@is.elta.co.il>
+
+ (Patches applied by Jim Blandy <jimb@zwingli.cygnus.com>)
+
+ Change DJGPP target use the common register layout in
+ config/i386/tm-i386.h.
+ * config/i386/tm-go32.h: #include "i386/tm-i386.h", not
+ "i386/tm-i386v.h".
+ (HAVE_I387_REGS): Define.
+ (HAVE_SSE_REGS): Undefine.
+ (NUM_FREGS, NUM_REGS, REGISTER_NAMES, FP_REGNUM, SP_REGNUM,
+ PS_REGNUM, PC_REGNUM, FP0_REGNUM, FPC_REGNUM, FPCWD_REGNUM,
+ FPSWD_REGNUM, FPTWD_REGNUM, FPIPO_REGNUM, FPIPS_REGNUM,
+ FPOOS_REGNUM, FPOPS_REGNUM, REGISTER_BYTES, REGISTER_BYTE,
+ REGBYTE_0, REGBYTE_10 REGBYTE_16, REGBYTE_24, REGBYTE_29,
+ REGISTER_RAW_SIZE, REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
+ MAX_REGISTER_VIRTUAL_SIZE, REGISTER_CONVERTIBLE): Definitions
+ deleted.
+ (i387_to_double, double_to_i387): Declarations deleted.
+ (REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW,
+ REGISTER_VIRTUAL_TYPE): Use definitions from
+ config/i386/tm-i386.h, unless LD_I387 is #defined.
+
+ * go32-nat.c (go32_fetch_registers, store_register)
+ (go32_create_inferior, init_go32_ops): Replace fatal with
+ internal_error.
+ (sig_map): Map exception 7 to TARGET_SIGNAL_EMT.
+
+ * utils.c (notice_quit): Doc fixes.
+
+1999-11-15 Kevin Buettner <kevinb@cygnus.com>
+
+ * gdbserver/server.h (initialize_low): Declare this target
+ specific function.
+ * gdbserver/server.c (main): Call initialize_low.
+ * gdbserver/low-hppabsd.c, gdbserver/low-linux.c,
+ gdbserver/low-sim.c, gdbserver/low-sparc.c, gdbserver/low-sun3.c
+ (initialize_low): Renamed from initialize. Also removed
+ initialization of inferior_pid.
+ (have_inferior_p): Removed.
+ * gdbserver/low-lynx.c (initialize_low): New function.
+
+1999-11-12 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * remote-rdi.c: Fix indentation accordingly to GNU standards.
+
+Thu Oct 28 00:28:51 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * d10v-tdep.c (d10v_gdbarch_init): Make the d10v:ts3 the default.
+
+Tue Oct 26 09:57:29 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * gdbarch.sh: Re-sync with Cagney's earlier const change.
+
+Sun Oct 24 20:07:31 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * d10v-tdep.c (struct gdbarch_tdep): Replace nr_a_regs,
+ imap0_regnum, nr_imap_regs, dmap0_regnum, with dmap_register and
+ imap_register.
+ (R0_REGNUM, LR_REGNUM, PSW_REGNUM, NR_IMAP_REGS, NR_A_REGS):
+ Convert to enums.
+ (TS2_NR_A_REGS, TS2_NR_IMAP_REGS, TS3_NR_IMAP_REGS,
+ TS3_NR_A_REGS): Delete.
+ (d10v_ts2_dmap_register, d10v_ts3_dmap_register,
+ d10v_ts2_imap_register, d10v_ts3_imap_register): New functions.
+ (d10v_dmap_register, d10v_imap_register,
+ d10v_ts2_register_sim_regno, d10v_ts3_register_sim_regno,
+ show_regs): Update.
+ (remote_d10v_translate_xfer_address): Rewrite. Use
+ sim_d10v_translate_addr to translate addresses.
+ (d10v_gdbarch_init): Initialize tdep members dmap_register and
+ imap_register.
+
+Sun Oct 24 00:12:44 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * d10v-tdep.c (struct gdbarch_tdep): Declare.
+ (NR_IMAP_REGS, NR_DMAP_REGS, A0_REGNUM, NR_A_REGS): Redefine using
+ value in gdbarch_tdep.
+ (d10v_dmap_register, d10v_imap_register): Ditto.
+ (d10v_ts2_register_name, d10v_ts2_register_sim_regno): Rename
+ d10v_register_name and d10v_register_sim_regno
+ (enum ts3_regnums, d10v_ts3_register_name,
+ d10v_ts3_register_sim_regno, d10v_register_sim_regno): New.
+ (d10v_gdbarch_init): Configure registers and G packet according to
+ d10v/ts2 and d10v/ts3.
+
+Sat Oct 23 21:28:02 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * config/d10v/tm-d10v.h (IMAP0_REGNUM, IMAP1_REGNUM, DMAP_REGNUM):
+ Delete macro.
+ (R0_REGNUM, LR_REGNUM, PSW_REGNUM, A0_REGNUM): Move from here.
+ * d10v-tdep.c: To here.
+
+ * d10v-tdep.c: (NR_DMAP_REGS, NR_IMAP_REGS, NR_A_REGS): Define.
+ (d10v_dmap_register, d10v_imap_register): New functions.
+ (remote_d10v_translate_xfer_address): Make static.
+ (d10v_register_virtual_size): Use TYPE_LENGTH of
+ REGISTER_VIRTUAL_TYPE.
+ (d10v_register_byte, do_d10v_pop_frame,
+ remote_d10v_translate_xfer_address, show_regs,
+ d10v_register_raw_size): Ditto.
+ (d10v_register_virtual_type): Ditto. Use explicitly sized builtin
+ types.
+
+Sat Oct 23 19:08:39 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * d10v-tdep.c: Include "sim-d10v.h".
+ (enum ts2_regnums): Declare.
+ (d10v_register_sim_regno): New function.
+
+ * config/d10v/tm-d10v.h: Delete pre multi-arch code.
+ (REGISTER_SIM_REGNO): Define.
+ (d10v_register_sim_regno): Declare.
+
+Sat Oct 23 16:39:34 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * gdbarch.c (initialize_current_architecture): Make ``choice''
+ const.
+
+Wed Nov 10 16:10:22 1999 Jeffrey A Law (law@cygnus.com)
+
+ * hppa-tdep.c (hppa_fix_call_dummy): Fix typo in error message.
+
+Wed Nov 10 16:47:06 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * utils.c (error_last_message): Use gdb_file_xstrdup.
+
+ * defs.h (verror, internal_verror): Declare.
+
+ * utils.c (verror, internal_error): New functions.
+ (error, internal_error): Use verror / internal_verror.
+ (error_stream): Use gdb_file_xstrdup. Correctly handle %s in
+ error message body.
+ (error_init): Use mem_fileopen.
+
+ * corefile.c (memory_error): Use mem_fileopen instead of
+ tui_sfileopen. Don't call error_begin.
+ * remote-sim.c (gdb_os_error): Rewrite using verror. Don't call
+ error_begin.
+
+Wed Nov 10 14:21:43 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * defs.h (gdb_file_xstrdup): New function.
+ * utils.c (gdb_file_xstrdup, do_gdb_file_xstrdup): Implement.
+
+1999-11-09 Stan Shebs <shebs@andros.cygnus.com>
+
+ * exec.c (exec_file_attach), irix5-nat.c, osfsolib.c, solib.c
+ (info_sharedlibrary_command), pa64solib.c
+ (pa64_sharedlibrary_info_command), somsolib.c
+ (som_sharedlibrary_info_command): Replace "exec file" with
+ "executable file" in messages.
+
+1999-11-09 Jim Blandy <jimb@zwingli.cygnus.com>
+
+ Finish the job attempted by the previous change.
+ * stabsread.c (read_range_type): Make n2 and n3 LONGEST. Adjust
+ the various tests that check for maximum values, bit counts, etc.
+ In the long run, it might have been simpler just to give GDB bignums.
+
+Tue Nov 9 18:34:13 1999 Andrew Cagney <cagney@amy.cygnus.com>
+
+ * defs.h (gdb_file_put): Add parameter write.
+ (gdb_file_put_method_ftype): New typedef.
+ * utils.c (gdb_file_put, mem_file_put, tui_file_put,
+ null_file_put): Update.
+
+ * utils.c (struct gdb_file): Add field magic.
+ (gdb_file_new): Initialize.
+ (gdb_file_data): Verify.
+
+ * utils.c (mem_file_fputs): Delete. Replaced by.
+ (mem_file_write): New function. Rewrite mem_file.
+ (mem_file_new): Update.
+
+Tue Nov 9 17:51:12 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * remote-sim.c (gdb_os_write_stdout): Use gdb_file_write.
+ (gdb_os_flush_stdout): Flush gdb_stdtarg instead of gdb_stdout.
+
+Tue Nov 9 15:33:43 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * Makefile.in (procfs.o): Don't compile with -Werror for moment.
+ * sol-thread.c (info_cb): Move assignments to outside of if
+ statement.
+ (info_cb): Use paddr when printing addresses.
+
+1999-11-08 Jim Blandy <jimb@zenia.red-bean.com>
+
+ * defs.h (ULONGEST_MAX, LONGEST_MAX): New definitions.
+ * stabsread.c (read_huge_number): Parse and return LONGEST values.
+
1999-11-08 Mark Salter <msalter@cygnus.com>
* utils.c (floatformat_to_doublest): Fix conversion of denormals.
@@ -423,7 +619,10 @@ Thu Nov 4 17:36:27 1999 Andrew Cagney <cagney@b1.cygnus.com>
* gdbtypes.c (init_simd_type): The upper bound to
create_range_type is inclusive, not exclusive.
- * configure.in: Check for PTRACE_GETXFPREGS, and #define
+ Add preliminary support for the Pentium-III's Streaming SIMD
+ Extensions --- specifically, the ability to read the XMM
+ registers.
+ * Configure.in: Check for PTRACE_GETXFPREGS, and #define
HAVE_PTRACE_GETXFPREGS if we have it.
* acconfig.h: Add entry for HAVE_PTRACE_GETXFPREGS.
* configure, config.in: Regenerated.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 8686020c56b..acffdb02f89 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -229,7 +229,7 @@ CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE) \
ADD_FILES = $(REGEX) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
ADD_DEPS = $(REGEX1) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
-VERSION = 19991108
+VERSION = 19991116
DIST=gdb
LINT=/usr/5bin/lint
@@ -1407,8 +1407,11 @@ printcmd.o: printcmd.c $(breakpoint_h) $(defs_h) $(expression_h) \
$(gdbcmd_h) $(gdbcore_h) $(gdbtypes_h) language.h objfiles.h \
symfile.h $(symtab_h) target.h gdb_string.h
+# FIXME: Procfs.o gets -Wformat errors because things like pid_t don't
+# match output format strings.
procfs.o: procfs.c $(command_h) $(defs_h) $(gdbcore_h) $(inferior_h) \
target.h gdb_string.h
+ $(CC) -c $(INTERNAL_WARN_CFLAGS) $(NO_WERROR_CFLAGS) $<
sol-thread.o: sol-thread.c $(defs_h) gdbthread.h target.h $(inferior_h) \
$(gdbcmd_h)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ca7bb08cdf4..62dcb27b0c8 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2066,6 +2066,7 @@ print_it_typical (bs)
printf_filtered ("\n");
return PRINT_UNKNOWN;
break;
+
/* Fall through, we don't deal with these types of breakpoints
here. */
@@ -2271,9 +2272,14 @@ watchpoint_check (p)
So we can't even detect the first assignment to it and
watch after that (since the garbage may or may not equal
the first value assigned). */
+ /* We print all the stop information in print_it_typical(), but
+ in this case, by the time we call print_it_typical() this bp
+ will be deleted already. So we have no choice but print the
+ information here. */
printf_filtered ("\
Watchpoint %d deleted because the program has left the block in\n\
which its expression is valid.\n", bs->breakpoint_at->number);
+
if (b->related_breakpoint)
b->related_breakpoint->disposition = del_at_next_stop;
b->disposition = del_at_next_stop;
@@ -2408,6 +2414,9 @@ bpstat_stop_status (pc, not_a_breakpoint)
{
case WP_DELETED:
/* We've already printed what needs to be printed. */
+ /* Actually this is superfluous, because by the time we
+ call print_it_typical() the wp will be already deleted,
+ and the function will return immediately. */
bs->print_it = print_it_done;
/* Stop. */
break;
diff --git a/gdb/config/d10v/tm-d10v.h b/gdb/config/d10v/tm-d10v.h
index 1983f690ac6..e2fe383d28f 100644
--- a/gdb/config/d10v/tm-d10v.h
+++ b/gdb/config/d10v/tm-d10v.h
@@ -22,290 +22,5 @@
#define GDB_MULTI_ARCH 1
-/* #define GDB_TARGET_IS_D10V - moved to gdbarch.h */
-
-/* Define the bit, byte, and word ordering of the machine. */
-
-#if !GDB_MULTI_ARCH
-
-#define TARGET_BYTE_ORDER BIG_ENDIAN
-
-/* Offset from address of function to start of its code.
- Zero on most machines. */
-
-#define FUNCTION_START_OFFSET 0
-
-/* Advance PC across any function entry prologue instructions
- to reach some "real" code. */
-
-extern CORE_ADDR d10v_skip_prologue ();
-#define SKIP_PROLOGUE(ip) (d10v_skip_prologue (ip))
-
-/* Stack grows downward. */
-#define INNER_THAN(lhs,rhs) (core_addr_lessthan ((lhs), (rhs)))
-
-/* for a breakpoint, use "dbt || nop" */
-extern breakpoint_from_pc_fn d10v_breakpoint_from_pc;
-#define BREAKPOINT_FROM_PC(PCPTR,LENPTR) (d10v_breakpoint_from_pc ((PCPTR), (LENPTR)))
-
-/* If your kernel resets the pc after the trap happens you may need to
- define this before including this file. */
-#define DECR_PC_AFTER_BREAK 4
-
-extern char *d10v_register_name PARAMS ((int reg_nr));
-#define REGISTER_NAME(NR) (d10v_register_name (NR))
-
-#define NUM_REGS 37
-
-#endif /* GDB_MULTI_ARCH */
-
-/* Register numbers of various important registers.
- Note that some of these values are "real" register numbers,
- and correspond to the general registers of the machine,
- and some are "phony" register numbers which are too large
- to be actual register numbers as far as the user is concerned
- but do serve to get the desired values when passed to read_register. */
-
-/* Used by both d10v-tdep.c and remote-d10v.c */
-
-#define R0_REGNUM 0
-#define LR_REGNUM 13
-#if !GDB_MULTI_ARCH
-#define SP_REGNUM 15
-#define FP_REGNUM 11
-#define PC_REGNUM 18
-#endif
-#define PSW_REGNUM 16
-#define IMAP0_REGNUM 32
-#define IMAP1_REGNUM 33
-#define DMAP_REGNUM 34
-#define A0_REGNUM 35
-
-#if !GDB_MULTI_ARCH
-
-/* ??? */
-#define REGISTER_SIZE 2
-
-/* Say how much memory is needed to store a copy of the register set */
-#define REGISTER_BYTES ((37/*NUM_REGS*/-2)*2+16)
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-extern int d10v_register_byte PARAMS ((int reg_nr));
-#define REGISTER_BYTE(N) (d10v_register_byte (N))
-
-/* Number of bytes of storage in the actual machine representation
- for register N. */
-extern int d10v_register_raw_size PARAMS ((int reg_nr));
-#define REGISTER_RAW_SIZE(N) (d10v_register_raw_size (N))
-
-/* Number of bytes of storage in the program's representation
- for register N. */
-extern int d10v_register_virtual_size PARAMS ((int reg_nr));
-#define REGISTER_VIRTUAL_SIZE(N) (d10v_register_virtual_size (N))
-
-/* Largest value REGISTER_RAW_SIZE can have. */
-
-#define MAX_REGISTER_RAW_SIZE 8
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have. */
-
-#define MAX_REGISTER_VIRTUAL_SIZE 8
-
-/* Return the GDB type object for the "standard" data type
- of data in register N. */
-
-extern struct type *d10v_register_virtual_type PARAMS ((int reg_nr));
-#define REGISTER_VIRTUAL_TYPE(N) (d10v_register_virtual_type (N))
-
-/* convert $pc and $sp to/from virtual addresses */
-extern int d10v_register_convertible PARAMS ((int nr));
-extern void d10v_register_convert_to_virtual PARAMS ((int regnum, struct type * type, char *from, char *to));
-extern void d10v_register_convert_to_raw PARAMS ((struct type * type, int regnum, char *from, char *to));
-#define REGISTER_CONVERTIBLE(N) (d10v_register_convertible ((N)))
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
- d10v_register_convert_to_virtual ((REGNUM), (TYPE), (FROM), (TO))
-#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
- d10v_register_convert_to_raw ((TYPE), (REGNUM), (FROM), (TO))
-
-extern CORE_ADDR d10v_make_daddr PARAMS ((CORE_ADDR x));
-#define D10V_MAKE_DADDR(x) (d10v_make_daddr (x))
-extern CORE_ADDR d10v_make_iaddr PARAMS ((CORE_ADDR x));
-#define D10V_MAKE_IADDR(x) (d10v_make_iaddr (x))
-
-extern int d10v_daddr_p PARAMS ((CORE_ADDR x));
-#define D10V_DADDR_P(X) (d10v_daddr_p (X))
-extern int d10v_iaddr_p PARAMS ((CORE_ADDR x));
-#define D10V_IADDR_P(X) (d10v_iaddr_p (X))
-
-extern CORE_ADDR d10v_convert_daddr_to_raw PARAMS ((CORE_ADDR x));
-#define D10V_CONVERT_DADDR_TO_RAW(X) (d10v_convert_daddr_to_raw (X))
-extern CORE_ADDR d10v_convert_iaddr_to_raw PARAMS ((CORE_ADDR x));
-#define D10V_CONVERT_IADDR_TO_RAW(X) (d10v_convert_iaddr_to_raw (X))
-
-/* Store the address of the place in which to copy the structure the
- subroutine will return. This is called from call_function.
-
- We store structs through a pointer passed in the first Argument
- register. */
-
-extern void d10v_store_struct_return PARAMS ((CORE_ADDR addr, CORE_ADDR sp));
-#define STORE_STRUCT_RETURN(ADDR, SP) d10v_store_struct_return ((ADDR), (SP))
-
-
-/* Write into appropriate registers a function return value
- of type TYPE, given in virtual format.
-
- Things always get returned in RET1_REGNUM, RET2_REGNUM, ... */
-
-extern void d10v_store_return_value PARAMS ((struct type * type, char *valbuf));
-#define STORE_RETURN_VALUE(TYPE,VALBUF) d10v_store_return_value ((TYPE), (VALBUF))
-
-
-/* Extract from an array REGBUF containing the (raw) register state
- the address in which a function should return its structure value,
- as a CORE_ADDR (or an expression that can be used as one). */
-
-extern CORE_ADDR d10v_extract_struct_value_address PARAMS ((char *regbuf));
-#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (d10v_extract_struct_value_address ((REGBUF)))
-
-/* Should we use EXTRACT_STRUCT_VALUE_ADDRESS instead of
- EXTRACT_RETURN_VALUE? GCC_P is true if compiled with gcc
- and TYPE is the type (which is known to be struct, union or array).
-
- The d10v returns anything less than 8 bytes in size in
- registers. */
-
-extern use_struct_convention_fn d10v_use_struct_convention;
-#define USE_STRUCT_CONVENTION(gcc_p, type) d10v_use_struct_convention (gcc_p, type)
-
-
-/* Define other aspects of the stack frame.
- we keep a copy of the worked out return pc lying around, since it
- is a useful bit of info */
-
-extern void d10v_init_extra_frame_info PARAMS ((int fromleaf, struct frame_info * fi));
-#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
- d10v_init_extra_frame_info(fromleaf, fi)
-
-/* A macro that tells us whether the function invocation represented
- by FI does not have a frame on the stack associated with it. If it
- does not, FRAMELESS is set to 1, else 0. */
-
-#define FRAMELESS_FUNCTION_INVOCATION(FI) \
- (frameless_look_for_prologue (FI))
-
-extern CORE_ADDR d10v_frame_chain PARAMS ((struct frame_info * frame));
-#define FRAME_CHAIN(FRAME) d10v_frame_chain(FRAME)
-extern int d10v_frame_chain_valid PARAMS ((CORE_ADDR, struct frame_info *));
-#define FRAME_CHAIN_VALID(chain, thisframe) d10v_frame_chain_valid (chain, thisframe)
-extern CORE_ADDR d10v_frame_saved_pc PARAMS ((struct frame_info * fi));
-#define FRAME_SAVED_PC(fi) (d10v_frame_saved_pc ((fi)))
-extern CORE_ADDR d10v_frame_args_address PARAMS ((struct frame_info * fi));
-#define FRAME_ARGS_ADDRESS(fi) (d10v_frame_args_address ((fi)))
-extern CORE_ADDR d10v_frame_locals_address PARAMS ((struct frame_info * fi));
-#define FRAME_LOCALS_ADDRESS(fi) (d10v_frame_locals_address ((fi)))
-
-/* Immediately after a function call, return the saved pc. We can't */
-/* use frame->return_pc beause that is determined by reading R13 off the */
-/*stack and that may not be written yet. */
-
-extern CORE_ADDR d10v_saved_pc_after_call PARAMS ((struct frame_info * frame));
-#define SAVED_PC_AFTER_CALL(frame) (d10v_saved_pc_after_call ((frame)))
-
-/* Set VAL to the number of args passed to frame described by FI.
- Can set VAL to -1, meaning no way to tell. */
-/* We can't tell how many args there are */
-
-#define FRAME_NUM_ARGS(fi) (-1)
-
-/* Return number of bytes at start of arglist that are not really args. */
-
-#define FRAME_ARGS_SKIP 0
-
-/* Put here the code to store, into frame_info->saved_regs, the
- addresses of the saved registers of frame described by FRAME_INFO.
- This includes special registers such as pc and fp saved in special
- ways in the stack frame. sp is even more special: the address we
- return for it IS the sp for the next frame. */
-
-extern void d10v_frame_init_saved_regs PARAMS ((struct frame_info *));
-#define FRAME_INIT_SAVED_REGS(frame_info) \
- d10v_frame_init_saved_regs(frame_info)
-
-/* DUMMY FRAMES. Need these to support inferior function calls. They
- work like this on D10V: First we set a breakpoint at 0 or __start.
- Then we push all the registers onto the stack. Then put the
- function arguments in the proper registers and set r13 to our
- breakpoint address. Finally, the PC is set to the start of the
- function being called (no JSR/BSR insn). When it hits the
- breakpoint, clear the break point and pop the old register contents
- off the stack. */
-
-extern void d10v_pop_frame PARAMS ((void));
-#define POP_FRAME d10v_pop_frame ()
-
-#define USE_GENERIC_DUMMY_FRAMES 1
-#define CALL_DUMMY {0}
-#define CALL_DUMMY_START_OFFSET (0)
-#define CALL_DUMMY_BREAKPOINT_OFFSET (0)
-#define CALL_DUMMY_LOCATION AT_ENTRY_POINT
-#define FIX_CALL_DUMMY(DUMMY, START, FUNADDR, NARGS, ARGS, TYPE, GCCP)
-#define CALL_DUMMY_ADDRESS() entry_point_address ()
-extern CORE_ADDR d10v_push_return_address PARAMS ((CORE_ADDR pc, CORE_ADDR sp));
-#define PUSH_RETURN_ADDRESS(PC, SP) d10v_push_return_address (PC, SP)
-
-#define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP, FP)
-/* #define PC_IN_CALL_DUMMY(pc, sp, frame_address) ( pc == IMEM_START + 4 ) */
-
-#define PUSH_DUMMY_FRAME generic_push_dummy_frame ()
-
-/* override the default get_saved_register function with one that
- takes account of generic CALL_DUMMY frames */
-#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
- generic_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
-
-#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
- (d10v_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
-extern CORE_ADDR d10v_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
-
-
-/* Extract from an array REGBUF containing the (raw) register state
- a function return value of type TYPE, and copy that, in virtual format,
- into VALBUF. */
-
-#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
-d10v_extract_return_value(TYPE, REGBUF, VALBUF)
-extern void d10v_extract_return_value PARAMS ((struct type *, char *, char *));
-
-
-void d10v_write_pc PARAMS ((CORE_ADDR val, int pid));
-CORE_ADDR d10v_read_pc PARAMS ((int pid));
-void d10v_write_sp PARAMS ((CORE_ADDR val));
-CORE_ADDR d10v_read_sp PARAMS ((void));
-void d10v_write_fp PARAMS ((CORE_ADDR val));
-CORE_ADDR d10v_read_fp PARAMS ((void));
-
-#define TARGET_READ_PC(pid) d10v_read_pc (pid)
-#define TARGET_WRITE_PC(val,pid) d10v_write_pc (val, pid)
-#define TARGET_READ_FP() d10v_read_fp ()
-#define TARGET_WRITE_FP(val) d10v_write_fp (val)
-#define TARGET_READ_SP() d10v_read_sp ()
-#define TARGET_WRITE_SP(val) d10v_write_sp (val)
-
-/* Number of bits in the appropriate type */
-#define TARGET_INT_BIT (2 * TARGET_CHAR_BIT)
-#define TARGET_PTR_BIT (4 * TARGET_CHAR_BIT)
-#define TARGET_DOUBLE_BIT (4 * TARGET_CHAR_BIT)
-#define TARGET_LONG_DOUBLE_BIT (8 * TARGET_CHAR_BIT)
-
-
-/* For the d10v when talking to the remote d10v board, GDB addresses
- need to be translated into a format that the d10v rom monitor
- understands. */
-
-extern void remote_d10v_translate_xfer_address PARAMS ((CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR * rem_addr, int *rem_len));
-#define REMOTE_TRANSLATE_XFER_ADDRESS(GDB_ADDR, GDB_LEN, REM_ADDR, REM_LEN) \
- remote_d10v_translate_xfer_address ((GDB_ADDR), (GDB_LEN), (REM_ADDR), (REM_LEN))
-
-#endif
+extern int d10v_register_sim_regno (int reg);
+#define REGISTER_SIM_REGNO(NR) d10v_register_sim_regno((NR))
diff --git a/gdb/config/i386/tm-go32.h b/gdb/config/i386/tm-go32.h
index 579355252ae..3db97f9f0c7 100644
--- a/gdb/config/i386/tm-go32.h
+++ b/gdb/config/i386/tm-go32.h
@@ -18,108 +18,10 @@
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include "i386/tm-i386v.h"
-
-/* Number of machine registers. */
-
-#undef NUM_FREGS
-#define NUM_FREGS 15
-#undef NUM_REGS
-#define NUM_REGS (16+NUM_FREGS)
-
-/* Initializer for an array of names of registers. There should be
- NUM_REGS strings in this initializer. */
-
-/* The order of the first 8 registers must match the compiler's
- numbering scheme (which is the same as the 386 scheme). */
-
-#undef REGISTER_NAMES
-#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
- "esp", "ebp", "esi", "edi", \
- "eip", "eflags","cs", "ss", \
- "ds", "es", "fs", "gs", \
- "st0", "st1", "st2", "st3", \
- "st4", "st5", "st6", "st7", \
- "fctrl","fstat", "ftag", "fcs", \
- "fopsel","fip", "fopoff" }
-
-#undef FP_REGNUM
-#define FP_REGNUM 5 /* (ebp) Contains addr of stack frame */
-#undef SP_REGNUM
-#define SP_REGNUM 4 /* (usp) Contains address of top of stack */
-#undef PS_REGNUM
-#define PS_REGNUM 9 /* (ps) Contains processor status */
-#undef PC_REGNUM
-#define PC_REGNUM 8 /* (eip) Contains program counter */
-#undef FP0_REGNUM
-#define FP0_REGNUM 16 /* Floating point register 0 */
-#undef FPC_REGNUM
-#define FPC_REGNUM 24 /* 80387 control register */
-#undef FPCWD_REGNUM
-#define FPCWD_REGNUM FPC_REGNUM
-#undef FPSWD_REGNUM
-#define FPSWD_REGNUM 25 /* 80387 status register */
-#undef FPTWD_REGNUM
-#define FPTWD_REGNUM 26 /* 80387 tag register */
-#undef FPIPO_REGNUM
-#define FPIPO_REGNUM 29 /* 80387 instruction pointer offset reg */
-#undef FPIPS_REGNUM
-#define FPIPS_REGNUM 27 /* 80387 instruction pointer selector reg */
-#undef FPOOS_REGNUM
-#define FPOOS_REGNUM 30 /* 80387 operand pointer offset reg */
-#undef FPOPS_REGNUM
-#define FPOPS_REGNUM 28 /* 80387 operand pointer selector reg */
-
-/* Total amount of space needed to store our copies of the machine's
- register state, the array `registers'. */
-
-#undef REGISTER_BYTES
-#define REGISTER_BYTES (10*4 + 6*2 + 8*10 + 5*2 + 2*4)
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-
-#undef REGISTER_BYTE
-#define REGBYTE_0 0
-#define REGBYTE_10 (REGBYTE_0+10*4)
-#define REGBYTE_16 (REGBYTE_10+6*2)
-#define REGBYTE_24 (REGBYTE_16+8*10)
-#define REGBYTE_29 (REGBYTE_24+5*2)
-#define REGISTER_BYTE(N) (((N) < 10) ? (N) * 4 : \
- (N) < 16 ? REGBYTE_10 +((N) - 10) * 2 : \
- (N) < 24 ? REGBYTE_16 +((N) - 16) * 10 : \
- (N) < 29 ? REGBYTE_24 +((N) - 24) * 2 : \
- REGBYTE_29 + ((N) - 29) * 4)
-
-/* Number of bytes of storage in the actual machine representation
- for register N. */
-
-#undef REGISTER_RAW_SIZE
-#define REGISTER_RAW_SIZE(N) ((N) < 10 ? 4 : (N) < 16 ? 2 : (N) < 24 ? 10 : \
- (N) < 29 ? 2 : 4)
-
-/* Number of bytes of storage in the program's representation
- for register N. */
-
-#undef REGISTER_VIRTUAL_SIZE
-#define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
-
-/* Largest value REGISTER_RAW_SIZE can have. */
-
-#undef MAX_REGISTER_RAW_SIZE
-#define MAX_REGISTER_RAW_SIZE 10
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have. */
-
-#undef MAX_REGISTER_VIRTUAL_SIZE
-#define MAX_REGISTER_VIRTUAL_SIZE 10
-
-/* Nonzero if register N requires conversion
- from raw format to virtual format. */
-
-#undef REGISTER_CONVERTIBLE
-#define REGISTER_CONVERTIBLE(N) ((N) < FP0_REGNUM ? 0 :\
- (N) < FPC_REGNUM ? 1 : 0)
+#undef HAVE_SSE_REGS /* FIXME! go32-nat.c needs to support XMMi registers */
+#define HAVE_I387_REGS
+
+#include "i386/tm-i386.h"
/* The host and target are i386 machines and the compiler supports
long doubles. Long doubles on the host therefore have the same
@@ -142,70 +44,34 @@
extern int i387_hex_long_double_input (char *p, long double *putithere);
+#ifdef LD_I387 /* otherwise, definitions from tm-i386.h are good enough */
+
#undef REGISTER_CONVERT_TO_VIRTUAL
-#ifdef LD_I387
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
-{ \
- if (TYPE == REGISTER_VIRTUAL_TYPE (REGNUM)) \
- { \
- memcpy (TO, FROM, TYPE_LENGTH (TYPE)); \
- } \
- else \
- { \
- long double val = *((long double *)FROM); \
- store_floating ((TO), TYPE_LENGTH (TYPE), val); \
- } \
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
+{ \
+ long double val = *((long double *)(FROM)); \
+ store_floating ((TO), TYPE_LENGTH (TYPE), val); \
}
-#else
-/* Convert data from raw format for register REGNUM in buffer FROM to
- virtual format with type TYPE in buffer TO. */
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
-{ \
- double val; \
- i387_to_double ((FROM), (char *)&val); \
- store_floating ((TO), TYPE_LENGTH (TYPE), val); \
-}
-#endif
-
-extern void i387_to_double PARAMS ((char *, char *));
#undef REGISTER_CONVERT_TO_RAW
-#ifdef LD_I387
-#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
-{ \
- if (TYPE == REGISTER_VIRTUAL_TYPE (REGNUM)) \
- { \
- memcpy (TO, FROM, TYPE_LENGTH (TYPE)); \
- } \
- else \
- { \
- long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
- *((long double *)TO) = val; \
- } \
-}
-#else
-#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
-{ \
- double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
- double_to_i387((char *)&val, (TO)); \
+#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
+{ \
+ long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
+ *((long double *)(TO)) = val; \
}
-#endif
-extern void double_to_i387 PARAMS ((char *, char *));
+/* Return the GDB type object for the "standard" data type of data in
+ register N. Perhaps si and di should go here, but potentially they
+ could be used for things other than address. */
-/* Return the GDB type object for the "standard" data type of data in
- register N. */
+#define REGISTER_VIRTUAL_TYPE(N) \
+ (((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM) \
+ ? lookup_pointer_type (builtin_type_void) \
+ : IS_FP_REGNUM(N) ? builtin_type_long_double \
+ : IS_SSE_REGNUM(N) ? builtin_type_v4sf \
+ : builtin_type_int)
-#undef REGISTER_VIRTUAL_TYPE
-#ifdef LD_I387
-#define REGISTER_VIRTUAL_TYPE(N) \
- ((N < FP0_REGNUM) ? builtin_type_int : \
- (N < FPC_REGNUM) ? builtin_type_long_double : builtin_type_int)
-#else
-#define REGISTER_VIRTUAL_TYPE(N) \
- ((N < FP0_REGNUM) ? builtin_type_int : \
- (N < FPC_REGNUM) ? builtin_type_double : builtin_type_int)
-#endif
+#endif /* LD_I387 */
#undef TARGET_LONG_DOUBLE_BIT
#define TARGET_LONG_DOUBLE_BIT 96
diff --git a/gdb/config/i386/tm-i386.h b/gdb/config/i386/tm-i386.h
index 9f4aaed621c..efc3f417491 100644
--- a/gdb/config/i386/tm-i386.h
+++ b/gdb/config/i386/tm-i386.h
@@ -148,11 +148,11 @@ extern int i386_skip_prologue PARAMS ((int));
#define FP0_REGNUM 16 /* first FPU floating-point register */
#define FP7_REGNUM 23 /* last FPU floating-point register */
-/* All of these control registers are sixteen bits long (at most) in
- the FPU, but are zero-extended to thirty-two bits in GDB's register
- file. This makes it easier to compute the size of the control
- register file, and somewhat easier to convert to and from the FSAVE
- instruction's 32-bit format. */
+/* All of these control registers (except for FCOFF and FDOFF) are
+ sixteen bits long (at most) in the FPU, but are zero-extended to
+ thirty-two bits in GDB's register file. This makes it easier to
+ compute the size of the control register file, and somewhat easier
+ to convert to and from the FSAVE instruction's 32-bit format. */
#define FIRST_FPU_CTRL_REGNUM 24
#define FCTRL_REGNUM 24 /* FPU control word */
#define FPC_REGNUM 24 /* old name for FCTRL_REGNUM */
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 3a5ef9aa340..f41cc55b66e 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -236,11 +236,9 @@ memory_error (status, memaddr)
int status;
CORE_ADDR memaddr;
{
- GDB_FILE *tmp_stream = tui_sfileopen (130);
+ struct gdb_file *tmp_stream = mem_fileopen ();
make_cleanup_gdb_file_delete (tmp_stream);
- error_begin ();
-
if (status == EIO)
{
/* Actually, address between memaddr and memaddr + len
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index aecbea5edc5..93e3c6e05a3 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -35,6 +35,11 @@
#include "objfiles.h"
#include "language.h"
+#include "sim-d10v.h"
+
+#undef XMALLOC
+#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
+
struct frame_extra_info
{
CORE_ADDR return_pc;
@@ -42,14 +47,36 @@ struct frame_extra_info
int size;
};
-/* these are the addresses the D10V-EVA board maps data */
-/* and instruction memory to. */
+struct gdbarch_tdep
+ {
+ int a0_regnum;
+ int nr_dmap_regs;
+ unsigned long (*dmap_register) (int nr);
+ unsigned long (*imap_register) (int nr);
+ int (*register_sim_regno) (int nr);
+ };
+
+/* These are the addresses the D10V-EVA board maps data and
+ instruction memory to. */
#define DMEM_START 0x2000000
#define IMEM_START 0x1000000
#define STACK_START 0x0007ffe
-/* d10v register naming conventions */
+/* d10v register names. */
+
+enum
+ {
+ R0_REGNUM = 0,
+ LR_REGNUM = 13,
+ PSW_REGNUM = 16,
+ NR_IMAP_REGS = 2,
+ NR_A_REGS = 2
+ };
+#define NR_DMAP_REGS (gdbarch_tdep (current_gdbarch)->nr_dmap_regs)
+#define A0_REGNUM (gdbarch_tdep (current_gdbarch)->a0_regnum)
+
+/* d10v calling convention. */
#define ARG1_REGNUM R0_REGNUM
#define ARGN_REGNUM 3
@@ -69,9 +96,6 @@ extern void d10v_frame_init_saved_regs PARAMS ((struct frame_info *));
static void do_d10v_pop_frame PARAMS ((struct frame_info * fi));
-/* FIXME */
-extern void remote_d10v_translate_xfer_address PARAMS ((CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR * rem_addr, int *rem_len));
-
int
d10v_frame_chain_valid (chain, frame)
CORE_ADDR chain;
@@ -108,9 +132,19 @@ d10v_breakpoint_from_pc (pcptr, lenptr)
return breakpoint;
}
-char *
-d10v_register_name (reg_nr)
- int reg_nr;
+/* Map the REG_NR onto an ascii name. Return NULL or an empty string
+ when the reg_nr isn't valid. */
+
+enum ts2_regnums
+ {
+ TS2_IMAP0_REGNUM = 32,
+ TS2_DMAP_REGNUM = 34,
+ TS2_NR_DMAP_REGS = 1,
+ TS2_A0_REGNUM = 35
+ };
+
+static char *
+d10v_ts2_register_name (int reg_nr)
{
static char *register_names[] =
{
@@ -127,6 +161,120 @@ d10v_register_name (reg_nr)
return register_names[reg_nr];
}
+enum ts3_regnums
+ {
+ TS3_IMAP0_REGNUM = 36,
+ TS3_DMAP0_REGNUM = 38,
+ TS3_NR_DMAP_REGS = 4,
+ TS3_A0_REGNUM = 32
+ };
+
+static char *
+d10v_ts3_register_name (int reg_nr)
+{
+ static char *register_names[] =
+ {
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+ "psw", "bpsw", "pc", "bpc", "cr4", "cr5", "cr6", "rpt_c",
+ "rpt_s", "rpt_e", "mod_s", "mod_e", "cr12", "cr13", "iba", "cr15",
+ "a0", "a1",
+ "spi", "spu",
+ "imap0", "imap1",
+ "dmap0", "dmap1", "dmap2", "dmap3"
+ };
+ if (reg_nr < 0)
+ return NULL;
+ if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ return NULL;
+ return register_names[reg_nr];
+}
+
+/* Access the DMAP/IMAP registers in a target independant way. */
+
+static unsigned long
+d10v_ts2_dmap_register (int reg_nr)
+{
+ switch (reg_nr)
+ {
+ case 0:
+ case 1:
+ return 0x2000;
+ case 2:
+ return read_register (TS2_DMAP_REGNUM);
+ default:
+ return 0;
+ }
+}
+
+static unsigned long
+d10v_ts3_dmap_register (int reg_nr)
+{
+ return read_register (TS3_DMAP0_REGNUM + reg_nr);
+}
+
+static unsigned long
+d10v_dmap_register (int reg_nr)
+{
+ return gdbarch_tdep (current_gdbarch)->dmap_register (reg_nr);
+}
+
+static unsigned long
+d10v_ts2_imap_register (int reg_nr)
+{
+ return read_register (TS2_IMAP0_REGNUM + reg_nr);
+}
+
+static unsigned long
+d10v_ts3_imap_register (int reg_nr)
+{
+ return read_register (TS3_IMAP0_REGNUM + reg_nr);
+}
+
+static unsigned long
+d10v_imap_register (int reg_nr)
+{
+ return gdbarch_tdep (current_gdbarch)->imap_register (reg_nr);
+}
+
+/* MAP GDB's internal register numbering (determined by the layout fo
+ the REGISTER_BYTE array) onto the simulator's register
+ numbering. */
+
+static int
+d10v_ts2_register_sim_regno (int nr)
+{
+ if (nr >= TS2_IMAP0_REGNUM
+ && nr < TS2_IMAP0_REGNUM + NR_IMAP_REGS)
+ return nr - TS2_IMAP0_REGNUM + SIM_D10V_IMAP0_REGNUM;
+ if (nr == TS2_DMAP_REGNUM)
+ return nr - TS2_DMAP_REGNUM + SIM_D10V_TS2_DMAP_REGNUM;
+ if (nr >= TS2_A0_REGNUM
+ && nr < TS2_A0_REGNUM + NR_A_REGS)
+ return nr - TS2_A0_REGNUM + SIM_D10V_A0_REGNUM;
+ return nr;
+}
+
+static int
+d10v_ts3_register_sim_regno (int nr)
+{
+ if (nr >= TS3_IMAP0_REGNUM
+ && nr < TS3_IMAP0_REGNUM + NR_IMAP_REGS)
+ return nr - TS3_IMAP0_REGNUM + SIM_D10V_IMAP0_REGNUM;
+ if (nr >= TS3_DMAP0_REGNUM
+ && nr < TS3_DMAP0_REGNUM + TS3_NR_DMAP_REGS)
+ return nr - TS3_DMAP0_REGNUM + SIM_D10V_DMAP0_REGNUM;
+ if (nr >= TS3_A0_REGNUM
+ && nr < TS3_A0_REGNUM + NR_A_REGS)
+ return nr - TS3_A0_REGNUM + SIM_D10V_A0_REGNUM;
+ return nr;
+}
+
+int
+d10v_register_sim_regno (int nr)
+{
+ return gdbarch_tdep (current_gdbarch)->register_sim_regno (nr);
+}
/* Index within `registers' of the first byte of the space for
register REG_NR. */
@@ -135,10 +283,15 @@ int
d10v_register_byte (reg_nr)
int reg_nr;
{
- if (reg_nr > A0_REGNUM)
- return ((reg_nr - A0_REGNUM) * 8 + (A0_REGNUM * 2));
- else
+ if (reg_nr < A0_REGNUM)
return (reg_nr * 2);
+ else if (reg_nr < (A0_REGNUM + NR_A_REGS))
+ return (A0_REGNUM * 2
+ + (reg_nr - A0_REGNUM) * 8);
+ else
+ return (A0_REGNUM * 2
+ + NR_A_REGS * 8
+ + (reg_nr - A0_REGNUM - NR_A_REGS) * 2);
}
/* Number of bytes of storage in the actual machine representation for
@@ -148,7 +301,9 @@ int
d10v_register_raw_size (reg_nr)
int reg_nr;
{
- if (reg_nr >= A0_REGNUM)
+ if (reg_nr < A0_REGNUM)
+ return 2;
+ else if (reg_nr < (A0_REGNUM + NR_A_REGS))
return 8;
else
return 2;
@@ -161,12 +316,7 @@ int
d10v_register_virtual_size (reg_nr)
int reg_nr;
{
- if (reg_nr >= A0_REGNUM)
- return 8;
- else if (reg_nr == PC_REGNUM || reg_nr == SP_REGNUM)
- return 4;
- else
- return 2;
+ return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (reg_nr));
}
/* Return the GDB type object for the "standard" data type
@@ -176,12 +326,14 @@ struct type *
d10v_register_virtual_type (reg_nr)
int reg_nr;
{
- if (reg_nr >= A0_REGNUM)
- return builtin_type_long_long;
- else if (reg_nr == PC_REGNUM || reg_nr == SP_REGNUM)
- return builtin_type_long;
+ if (reg_nr >= A0_REGNUM
+ && reg_nr < (A0_REGNUM + NR_A_REGS))
+ return builtin_type_int64;
+ else if (reg_nr == PC_REGNUM
+ || reg_nr == SP_REGNUM)
+ return builtin_type_int32;
else
- return builtin_type_short;
+ return builtin_type_int16;
}
/* convert $pc and $sp to/from virtual addresses */
@@ -363,7 +515,7 @@ do_d10v_pop_frame (fi)
d10v_frame_init_saved_regs (fi);
/* now update the current registers with the old values */
- for (regnum = A0_REGNUM; regnum < A0_REGNUM + 2; regnum++)
+ for (regnum = A0_REGNUM; regnum < A0_REGNUM + NR_A_REGS; regnum++)
{
if (fi->saved_regs[regnum])
{
@@ -754,12 +906,24 @@ show_regs (args, from_tty)
(long) read_register (13),
(long) read_register (14),
(long) read_register (15));
- printf_filtered ("IMAP0 %04lx IMAP1 %04lx DMAP %04lx\n",
- (long) read_register (IMAP0_REGNUM),
- (long) read_register (IMAP1_REGNUM),
- (long) read_register (DMAP_REGNUM));
- printf_filtered ("A0-A1");
- for (a = A0_REGNUM; a <= A0_REGNUM + 1; a++)
+ for (a = 0; a < NR_IMAP_REGS; a++)
+ {
+ if (a > 0)
+ printf_filtered (" ");
+ printf_filtered ("IMAP%d %04lx", a, d10v_imap_register (a));
+ }
+ if (NR_DMAP_REGS == 1)
+ printf_filtered (" DMAP %04lx\n", d10v_dmap_register (2));
+ else
+ {
+ for (a = 0; a < NR_DMAP_REGS; a++)
+ {
+ printf_filtered (" DMAP%d %04lx", a, d10v_dmap_register (a));
+ }
+ printf_filtered ("\n");
+ }
+ printf_filtered ("A0-A%d", NR_A_REGS - 1);
+ for (a = A0_REGNUM; a < A0_REGNUM + NR_A_REGS; a++)
{
char num[MAX_REGISTER_RAW_SIZE];
int i;
@@ -1032,163 +1196,25 @@ d10v_extract_return_value (type, regbuf, valbuf)
/* Translate a GDB virtual ADDR/LEN into a format the remote target
understands. Returns number of bytes that can be transfered
- starting at taddr, ZERO if no bytes can be transfered. */
+ starting at TARG_ADDR. Return ZERO if no bytes can be transfered
+ (segmentation fault). Since the simulator knows all about how the
+ VM system works, we just call that to do the translation. */
-void
+static void
remote_d10v_translate_xfer_address (CORE_ADDR memaddr, int nr_bytes,
CORE_ADDR *targ_addr, int *targ_len)
{
- CORE_ADDR phys;
- CORE_ADDR seg;
- CORE_ADDR off;
- char *from = "unknown";
- char *to = "unknown";
-
- /* GDB interprets addresses as:
-
- 0x00xxxxxx: Physical unified memory segment (Unified memory)
- 0x01xxxxxx: Physical instruction memory segment (On-chip insn memory)
- 0x02xxxxxx: Physical data memory segment (On-chip data memory)
- 0x10xxxxxx: Logical data address segment (DMAP translated memory)
- 0x11xxxxxx: Logical instruction address segment (IMAP translated memory)
-
- The remote d10v board interprets addresses as:
-
- 0x00xxxxxx: Physical unified memory segment (Unified memory)
- 0x01xxxxxx: Physical instruction memory segment (On-chip insn memory)
- 0x02xxxxxx: Physical data memory segment (On-chip data memory)
-
- Translate according to current IMAP/dmap registers */
-
- enum
- {
- targ_unified = 0x00000000,
- targ_insn = 0x01000000,
- targ_data = 0x02000000,
- };
-
- seg = (memaddr >> 24);
- off = (memaddr & 0xffffffL);
-
- switch (seg)
- {
- case 0x00: /* Physical unified memory */
- from = "phys-unified";
- phys = targ_unified | off;
- to = "unified";
- break;
-
- case 0x01: /* Physical instruction memory */
- from = "phys-insn";
- phys = targ_insn | off;
- to = "chip-insn";
- break;
-
- case 0x02: /* Physical data memory segment */
- from = "phys-data";
- phys = targ_data | off;
- to = "chip-data";
- break;
-
- case 0x10: /* in logical data address segment */
- {
- from = "logical-data";
- if (off <= 0x7fffL)
- {
- /* On chip data */
- phys = targ_data + off;
- if (off + nr_bytes > 0x7fffL)
- /* don't cross VM boundary */
- nr_bytes = 0x7fffL - off + 1;
- to = "chip-data";
- }
- else if (off <= 0xbfffL)
- {
- unsigned short dmap = read_register (DMAP_REGNUM);
- short map = dmap;
-
- if (map & 0x1000)
- {
- /* Instruction memory */
- phys = targ_insn | ((map & 0xf) << 14) | (off & 0x3fff);
- to = "chip-insn";
- }
- else
- {
- /* Unified memory */
- phys = targ_unified | ((map & 0x3ff) << 14) | (off & 0x3fff);
- to = "unified";
- }
- if (off + nr_bytes > 0xbfffL)
- /* don't cross VM boundary */
- nr_bytes = (0xbfffL - off + 1);
- }
- else
- {
- /* Logical address out side of data segments, not supported */
- *targ_len = 0;
- return;
- }
- break;
- }
-
- case 0x11: /* in logical instruction address segment */
- {
- short map;
- unsigned short imap0 = read_register (IMAP0_REGNUM);
- unsigned short imap1 = read_register (IMAP1_REGNUM);
-
- from = "logical-insn";
- if (off <= 0x1ffffL)
- {
- map = imap0;
- }
- else if (off <= 0x3ffffL)
- {
- map = imap1;
- }
- else
- {
- /* Logical address outside of IMAP[01] segment, not
- supported */
- *targ_len = 0;
- return;
- }
- if ((off & 0x1ffff) + nr_bytes > 0x1ffffL)
- {
- /* don't cross VM boundary */
- nr_bytes = 0x1ffffL - (off & 0x1ffffL) + 1;
- }
- if (map & 0x1000)
- /* Instruction memory */
- {
- phys = targ_insn | off;
- to = "chip-insn";
- }
- else
- {
- phys = ((map & 0x7fL) << 17) + (off & 0x1ffffL);
- if (phys > 0xffffffL)
- {
- /* Address outside of unified address segment */
- *targ_len = 0;
- return;
- }
- phys |= targ_unified;
- to = "unified";
- }
- break;
- }
-
- default:
- *targ_len = 0;
- return;
- }
-
- *targ_addr = phys;
- *targ_len = nr_bytes;
+ long out_addr;
+ long out_len;
+ out_len = sim_d10v_translate_addr (memaddr, nr_bytes,
+ &out_addr,
+ d10v_dmap_register,
+ d10v_imap_register);
+ *targ_addr = out_addr;
+ *targ_len = out_len;
}
+
/* The following code implements access to, and display of, the D10V's
instruction trace buffer. The buffer consists of 64K or more
4-byte words of data, of which each words includes an 8-bit count,
@@ -1490,6 +1516,7 @@ display_trace (low, high)
static gdbarch_init_ftype d10v_gdbarch_init;
+
static struct gdbarch *
d10v_gdbarch_init (info, arches)
struct gdbarch_info info;
@@ -1498,12 +1525,42 @@ d10v_gdbarch_init (info, arches)
static LONGEST d10v_call_dummy_words[] =
{0};
struct gdbarch *gdbarch;
- int d10v_num_regs = 37;
+ int d10v_num_regs;
+ struct gdbarch_tdep *tdep;
+ gdbarch_register_name_ftype *d10v_register_name;
- /* there is only one d10v architecture */
+ /* Find a candidate among the list of pre-declared architectures. */
+ arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return arches->gdbarch;
- gdbarch = gdbarch_alloc (&info, NULL);
+
+ /* None found, create a new architecture from the information
+ provided. */
+ tdep = XMALLOC (struct gdbarch_tdep);
+ gdbarch = gdbarch_alloc (&info, tdep);
+
+ switch (info.bfd_arch_info->mach)
+ {
+ case bfd_mach_d10v_ts2:
+ d10v_num_regs = 37;
+ d10v_register_name = d10v_ts2_register_name;
+ tdep->a0_regnum = TS2_A0_REGNUM;
+ tdep->nr_dmap_regs = TS2_NR_DMAP_REGS;
+ tdep->register_sim_regno = d10v_ts2_register_sim_regno;
+ tdep->dmap_register = d10v_ts2_dmap_register;
+ tdep->imap_register = d10v_ts2_imap_register;
+ break;
+ default:
+ case bfd_mach_d10v_ts3:
+ d10v_num_regs = 42;
+ d10v_register_name = d10v_ts3_register_name;
+ tdep->a0_regnum = TS3_A0_REGNUM;
+ tdep->nr_dmap_regs = TS3_NR_DMAP_REGS;
+ tdep->register_sim_regno = d10v_ts3_register_sim_regno;
+ tdep->dmap_register = d10v_ts3_dmap_register;
+ tdep->imap_register = d10v_ts3_imap_register;
+ break;
+ }
set_gdbarch_read_pc (gdbarch, d10v_read_pc);
set_gdbarch_write_pc (gdbarch, d10v_write_pc);
diff --git a/gdb/defs.h b/gdb/defs.h
index 39142bb463b..3d8f83007b2 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -409,7 +409,8 @@ extern void set_gdb_file_isatty (struct gdb_file *stream, gdb_file_isatty_ftype
typedef void (gdb_file_rewind_ftype) (struct gdb_file * stream);
extern void set_gdb_file_rewind (struct gdb_file *stream, gdb_file_rewind_ftype * rewind);
-typedef void (gdb_file_put_ftype) (struct gdb_file * stream, struct gdb_file * dest);
+typedef void (gdb_file_put_method_ftype) (void *object, const char *buffer, long length_buffer);
+typedef void (gdb_file_put_ftype) (struct gdb_file *stream, gdb_file_put_method_ftype * method, void *context);
extern void set_gdb_file_put (struct gdb_file *stream, gdb_file_put_ftype * put);
typedef void (gdb_file_delete_ftype) (struct gdb_file * stream);
@@ -439,7 +440,13 @@ extern int gdb_file_isatty (GDB_FILE *);
extern void gdb_file_write (struct gdb_file *file, const char *buf, long length_buf);
/* NOTE: copies left to right */
-extern void gdb_file_put (struct gdb_file *src, struct gdb_file *dest);
+extern void gdb_file_put (struct gdb_file *src, gdb_file_put_method_ftype *write, void *dest);
+
+/* Returns a freshly allocated buffer containing the entire contents
+ of FILE (as determined by gdb_file_put()) with a NUL character
+ appended. LENGTH is set to the size of the buffer minus that
+ appended NUL. */
+extern char *gdb_file_xstrdup (struct gdb_file *file, long *length);
/* More generic printf like operations */
@@ -782,6 +789,14 @@ enum val_prettyprint
#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
#endif
+#if !defined (ULONGEST_MAX)
+#define ULONGEST_MAX (~(ULONGEST)0) /* 0xFFFFFFFFFFFFFFFF for 32-bits */
+#endif
+
+#if !defined (LONGEST_MAX) /* 0x7FFFFFFFFFFFFFFF for 32-bits */
+#define LONGEST_MAX ((LONGEST)(ULONGEST_MAX >> 1))
+#endif
+
/* Convert a LONGEST to an int. This is used in contexts (e.g. number of
arguments to a function, number in a value history, register number, etc.)
where the value must not be larger than can fit in an int. */
@@ -823,16 +838,23 @@ extern char *quit_pre_print;
extern char *warning_pre_print;
-extern NORETURN void error (const char *, ...) ATTR_NORETURN;
+extern NORETURN void verror (const char *fmt, va_list ap) ATTR_NORETURN;
-extern void error_begin (void);
+extern NORETURN void error (const char *fmt, ...) ATTR_NORETURN;
-extern NORETURN void internal_error (char *, ...) ATTR_NORETURN;
+/* DEPRECATED: Use error(), verror() or error_stream(). */
+extern NORETURN void error_begin (void);
extern NORETURN void error_stream (GDB_FILE *) ATTR_NORETURN;
+/* Returns a freshly allocate buffer containing the last error
+ message. */
extern char *error_last_message (void);
+extern NORETURN void internal_verror (const char *, va_list ap) ATTR_NORETURN;
+
+extern NORETURN void internal_error (char *, ...) ATTR_NORETURN;
+
extern NORETURN void nomem (long) ATTR_NORETURN;
/* Reasons for calling return_to_top_level. */
diff --git a/gdb/exec.c b/gdb/exec.c
index 2ff76e87eea..8a7da9df88a 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -198,7 +198,7 @@ exec_file_attach (args, from_tty)
{;
}
if (*argv == NULL)
- error ("no exec file name was specified");
+ error ("No executable file name was specified");
filename = tilde_expand (*argv);
make_cleanup (free, filename);
diff --git a/gdb/gdbserver/low-hppabsd.c b/gdb/gdbserver/low-hppabsd.c
index 7c1b6603d69..de78ad51a0a 100644
--- a/gdb/gdbserver/low-hppabsd.c
+++ b/gdb/gdbserver/low-hppabsd.c
@@ -369,13 +369,6 @@ write_inferior_memory (memaddr, myaddr, len)
}
void
-initialize ()
+initialize_low ()
{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
}
diff --git a/gdb/gdbserver/low-linux.c b/gdb/gdbserver/low-linux.c
index b9573b34e14..3b3e2871466 100644
--- a/gdb/gdbserver/low-linux.c
+++ b/gdb/gdbserver/low-linux.c
@@ -451,6 +451,15 @@ static int u_offsets[] =
PT_F125,
PT_F126,
PT_F127,
+ /* predicate registers - we don't fetch these individually */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
/* branch registers */
PT_B0,
PT_B1,
@@ -460,6 +469,8 @@ static int u_offsets[] =
PT_B5,
PT_B6,
PT_B7,
+ /* virtual frame pointer and virtual return address pointer */
+ -1, -1,
/* other registers */
PT_PR,
PT_CR_IIP,
@@ -735,14 +746,7 @@ write_inferior_memory (memaddr, myaddr, len)
}
void
-initialize ()
+initialize_low ()
{
- inferior_pid = 0;
initialize_arch();
}
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
-}
diff --git a/gdb/gdbserver/low-lynx.c b/gdb/gdbserver/low-lynx.c
index 75e11ba050a..666956506cf 100644
--- a/gdb/gdbserver/low-lynx.c
+++ b/gdb/gdbserver/low-lynx.c
@@ -746,3 +746,8 @@ ptrace (PTRACE_POKETEXT): errno=%d, pid=0x%x, addr=0x%x, buffer[i] = 0x%x\n",
return 0;
}
+
+void
+initialize_low ()
+{
+}
diff --git a/gdb/gdbserver/low-sim.c b/gdb/gdbserver/low-sim.c
index 3f9dea26ee9..8d7c2e6c767 100644
--- a/gdb/gdbserver/low-sim.c
+++ b/gdb/gdbserver/low-sim.c
@@ -276,16 +276,7 @@ write_inferior_memory (memaddr, myaddr, len)
return 0;
}
-#if 0
void
-initialize ()
-{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
+initialize_low ()
{
- return inferior_pid != 0;
}
-#endif
diff --git a/gdb/gdbserver/low-sparc.c b/gdb/gdbserver/low-sparc.c
index e0e635e5bd0..178afc79ab0 100644
--- a/gdb/gdbserver/low-sparc.c
+++ b/gdb/gdbserver/low-sparc.c
@@ -324,13 +324,6 @@ write_inferior_memory (memaddr, myaddr, len)
}
void
-initialize ()
+initialize_low ()
{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
}
diff --git a/gdb/gdbserver/low-sun3.c b/gdb/gdbserver/low-sun3.c
index 786770b9a55..71a151e1faf 100644
--- a/gdb/gdbserver/low-sun3.c
+++ b/gdb/gdbserver/low-sun3.c
@@ -303,13 +303,6 @@ write_inferior_memory (memaddr, myaddr, len)
}
void
-initialize ()
+initialize_low ()
{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
-{
- return inferior_pid != 0;
}
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 8b18f533836..48a7e0f597a 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -62,6 +62,8 @@ main (argc, argv)
if (argc < 3)
error ("Usage: gdbserver tty prog [args ...]");
+ initialize_low ();
+
/* Wait till we are at first instruction in program. */
signal = start_inferior (&argv[2], &status);
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index c42a65c6c8f..21e4d68b7b5 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -33,6 +33,7 @@ unsigned char mywait PARAMS ((char *status));
void read_inferior_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
int write_inferior_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
int create_inferior ();
+void initialize_low ();
/* Target-specific variables */
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index b24312411d0..dae43439988 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -345,7 +345,7 @@ sig_map[] =
4, TARGET_SIGNAL_FPE,
5, TARGET_SIGNAL_SEGV,
6, TARGET_SIGNAL_ILL,
- 7, TARGET_SIGNAL_FPE,
+ 7, TARGET_SIGNAL_EMT, /* no-coprocessor exception */
8, TARGET_SIGNAL_SEGV,
9, TARGET_SIGNAL_SEGV,
10, TARGET_SIGNAL_BUS,
@@ -570,7 +570,8 @@ go32_fetch_registers (int regno)
supply_register (regno,
(char *) &npx + regno_mapping[regno].tss_ofs);
else
- fatal ("Invalid register no. %d in go32_fetch_register.", regno);
+ internal_error ("Invalid register no. %d in go32_fetch_register.",
+ regno);
}
}
@@ -587,7 +588,7 @@ store_register (int regno)
else if (regno < 31)
rp = (char *) &npx + regno_mapping[regno].tss_ofs;
else
- fatal ("Invalid register no. %d in store_register.", regno);
+ internal_error ("Invalid register no. %d in store_register.", regno);
memcpy (rp, v, regno_mapping[regno].size);
}
@@ -680,7 +681,7 @@ go32_create_inferior (char *exec_file, char *args, char **env)
resume_is_step = 0;
/* Init command line storage. */
if (redir_debug_init (&child_cmd) == -1)
- fatal ("Cannot allocate redirection storage: not enough memory.\n");
+ internal_error ("Cannot allocate redirection storage: not enough memory.\n");
/* Parse the command line and create redirections. */
if (strpbrk (args, "<>"))
@@ -1311,7 +1312,7 @@ init_go32_ops (void)
/* Initialize child's command line storage. */
if (redir_debug_init (&child_cmd) == -1)
- fatal ("Cannot allocate redirection storage: not enough memory.\n");
+ internal_error ("Cannot allocate redirection storage: not enough memory.\n");
}
void
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 8b1d87fc1c4..1477df2527f 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -2230,7 +2230,7 @@ hppa_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p)
funsymbol = lookup_minimal_symbol_by_pc (fun);
if (!funsymbol)
- error ("Unable to find minimal symbol for target fucntion.\n");
+ error ("Unable to find minimal symbol for target function.\n");
/* Search all the object files for an import symbol with the
right name. */
diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c
index 7ff0c441c85..eb6208cf15f 100644
--- a/gdb/irix5-nat.c
+++ b/gdb/irix5-nat.c
@@ -983,7 +983,7 @@ info_sharedlibrary_command (ignore, from_tty)
if (exec_bfd == NULL)
{
- printf_unfiltered ("No exec file.\n");
+ printf_unfiltered ("No executable file.\n");
return;
}
while ((so = find_solib (so)) != NULL)
diff --git a/gdb/monitor.c b/gdb/monitor.c
index c9c6d5a47cc..3a50c9887aa 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -912,6 +912,7 @@ monitor_supply_register (regno, valstr)
unsigned char regbuf[MAX_REGISTER_RAW_SIZE];
char *p;
+ val = 0;
p = valstr;
while (p && *p != '\0')
{
diff --git a/gdb/osfsolib.c b/gdb/osfsolib.c
index 2c4980455b5..1294072f8ed 100644
--- a/gdb/osfsolib.c
+++ b/gdb/osfsolib.c
@@ -732,7 +732,7 @@ info_sharedlibrary_command (ignore, from_tty)
if (exec_bfd == NULL)
{
- printf_unfiltered ("No exec file.\n");
+ printf_unfiltered ("No executable file.\n");
return;
}
while ((so = find_solib (so)) != NULL)
diff --git a/gdb/pa64solib.c b/gdb/pa64solib.c
index e281e6a7216..271efc2367b 100644
--- a/gdb/pa64solib.c
+++ b/gdb/pa64solib.c
@@ -794,7 +794,7 @@ pa64_sharedlibrary_info_command (ignore, from_tty)
if (exec_bfd == NULL)
{
- printf_unfiltered ("no exec file.\n");
+ printf_unfiltered ("No executable file.\n");
return;
}
diff --git a/gdb/remote-rdi.c b/gdb/remote-rdi.c
index 69addf6ed35..73327628ece 100644
--- a/gdb/remote-rdi.c
+++ b/gdb/remote-rdi.c
@@ -108,13 +108,13 @@ static int max_load_size;
static int execute_status;
/* Send heatbeat packets? */
-static int rdi_heartbeat = 0;
+static int rdi_heartbeat = 0;
/* Target has ROM at address 0. */
static int rom_at_zero = 0;
/* Enable logging? */
-static int log_enable = 0;
+static int log_enable = 0;
/* Name of the log file. Default is "rdi.log". */
static char *log_filename;
@@ -236,8 +236,8 @@ device is attached to the remote system (e.g. /dev/ttya).");
/* split name after whitespace, pass tail as arg to open command */
- devName = strdup(name);
- p = strchr(devName,' ');
+ devName = strdup (name);
+ p = strchr (devName, ' ');
if (p)
{
*p = '\0';
@@ -280,7 +280,7 @@ device is attached to the remote system (e.g. /dev/ttya).");
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
Adp_CloseDevice ();
- error("RID_open failed\n");
+ error ("RID_open failed\n");
}
rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
@@ -999,47 +999,49 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
arm_rdi_ops.to_magic = OPS_MAGIC;
}
-static void rdilogfile_command (char *arg, int from_tty)
+static void
+rdilogfile_command (char *arg, int from_tty)
{
if (!arg || strlen (arg) == 0)
{
printf_filtered ("rdi log file is '%s'\n", log_filename);
return;
}
-
+
if (log_filename)
free (log_filename);
-
+
log_filename = strdup (arg);
Adp_SetLogfile (log_filename);
}
-static void rdilogenable_command (char *args, int from_tty)
+static void
+rdilogenable_command (char *args, int from_tty)
{
if (!args || strlen (args) == 0)
{
printf_filtered ("rdi log is %s\n", log_enable ? "enabled" : "disabled");
return;
}
-
- if (!strcasecmp (args,"1") ||
- !strcasecmp (args,"y") ||
- !strcasecmp (args,"yes") ||
- !strcasecmp (args,"on") ||
- !strcasecmp (args,"t") ||
- !strcasecmp (args,"true"))
- Adp_SetLogEnable (log_enable=1);
- else if (!strcasecmp (args,"0") ||
- !strcasecmp (args,"n") ||
- !strcasecmp (args,"no") ||
- !strcasecmp (args,"off") ||
- !strcasecmp (args,"f") ||
- !strcasecmp (args,"false"))
- Adp_SetLogEnable (log_enable=0);
+
+ if (!strcasecmp (args, "1") ||
+ !strcasecmp (args, "y") ||
+ !strcasecmp (args, "yes") ||
+ !strcasecmp (args, "on") ||
+ !strcasecmp (args, "t") ||
+ !strcasecmp (args, "true"))
+ Adp_SetLogEnable (log_enable = 1);
+ else if (!strcasecmp (args, "0") ||
+ !strcasecmp (args, "n") ||
+ !strcasecmp (args, "no") ||
+ !strcasecmp (args, "off") ||
+ !strcasecmp (args, "f") ||
+ !strcasecmp (args, "false"))
+ Adp_SetLogEnable (log_enable = 0);
else
printf_filtered ("rdilogenable: unrecognized argument '%s'\n"
- " try y or n\n",args);
+ " try y or n\n", args);
}
void
@@ -1048,9 +1050,9 @@ _initialize_remote_rdi ()
init_rdi_ops ();
add_target (&arm_rdi_ops);
- log_filename = strdup("rdi.log");
- Adp_SetLogfile(log_filename);
- Adp_SetLogEnable(log_enable);
+ log_filename = strdup ("rdi.log");
+ Adp_SetLogfile (log_filename);
+ Adp_SetLogEnable (log_enable);
add_cmd ("rdilogfile", class_maintenance,
rdilogfile_command,
@@ -1061,7 +1063,7 @@ Without an argument, shows the current logfile name.\n\
See also: rdilogenable\n",
&maintenancelist);
- add_cmd("rdilogenable", class_maintenance,
+ add_cmd ("rdilogenable", class_maintenance,
rdilogenable_command,
"Set enable logging of ADP packets.\n\
This will log ADP packets exchanged between gdb and the\n\
@@ -1078,7 +1080,7 @@ Withough an argument, it will display current state.\n",
A true value disables vector catching, false enables vector catching.\n\
This is evaluated at the time the 'target rdi' command is executed\n",
&setlist),
- &showlist);
+ &showlist);
add_show_from_set
(add_set_cmd ("rdiheartbeat", no_class,
@@ -1088,7 +1090,7 @@ I don't know why you would want this. If you enable them,\n\
it will confuse ARM and EPI JTAG interface boxes as well\n\
as the Angel Monitor.\n",
&setlist),
- &showlist);
+ &showlist);
}
/* A little dummy to make linking with the library succeed. */
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 0c9d6761f32..74728376dc1 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -194,12 +194,7 @@ gdb_os_write_stdout (p, buf, len)
int i;
char b[2];
- for (i = 0; i < len; i++)
- {
- b[0] = buf[i];
- b[1] = 0;
- fputs_unfiltered (b, gdb_stdtarg);
- }
+ gdb_file_write (gdb_stdtarg, buf, len);
return len;
}
@@ -209,7 +204,7 @@ static void
gdb_os_flush_stdout (p)
host_callback *p;
{
- gdb_flush (gdb_stdout);
+ gdb_flush (gdb_stdtarg);
}
/* GDB version of os_write_stderr callback. */
@@ -281,12 +276,8 @@ gdb_os_error (host_callback * p, const char *format,...)
{
va_list args;
va_start (args, format);
-
- error_begin ();
- vfprintf_filtered (gdb_stderr, format, args);
- fprintf_filtered (gdb_stderr, "\n");
+ verror (format, args);
va_end (args);
- return_to_top_level (RETURN_ERROR);
}
}
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 218ab38f34c..2ab04b3890b 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -1493,7 +1493,6 @@ info_cb (th, s)
{
td_err_e ret;
td_thrinfo_t ti;
- struct minimal_symbol *msym;
if ((ret = p_td_thr_get_info (th, &ti)) == TD_OK)
{
@@ -1527,17 +1526,25 @@ info_cb (th, s)
}
/* Print thr_create start function: */
if (ti.ti_startfunc != 0)
- if (msym = lookup_minimal_symbol_by_pc (ti.ti_startfunc))
- printf_filtered (" startfunc: %s\n", SYMBOL_NAME (msym));
- else
- printf_filtered (" startfunc: 0x%08x\n", ti.ti_startfunc);
+ {
+ struct minimal_symbol *msym;
+ msym = lookup_minimal_symbol_by_pc (ti.ti_startfunc);
+ if (msym)
+ printf_filtered (" startfunc: %s\n", SYMBOL_NAME (msym));
+ else
+ printf_filtered (" startfunc: 0x%s\n", paddr (ti.ti_startfunc));
+ }
/* If thread is asleep, print function that went to sleep: */
if (ti.ti_state == TD_THR_SLEEP)
- if (msym = lookup_minimal_symbol_by_pc (ti.ti_pc))
- printf_filtered (" - Sleep func: %s\n", SYMBOL_NAME (msym));
- else
- printf_filtered (" - Sleep func: 0x%08x\n", ti.ti_startfunc);
+ {
+ struct minimal_symbol *msym;
+ msym = lookup_minimal_symbol_by_pc (ti.ti_pc);
+ if (msym)
+ printf_filtered (" - Sleep func: %s\n", SYMBOL_NAME (msym));
+ else
+ printf_filtered (" - Sleep func: 0x%s\n", paddr (ti.ti_startfunc));
+ }
/* Wrap up line, if necessary */
if (ti.ti_state != TD_THR_SLEEP && ti.ti_startfunc == 0)
diff --git a/gdb/solib.c b/gdb/solib.c
index bd490deef29..93eb06611c1 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1277,7 +1277,7 @@ info_sharedlibrary_command (ignore, from_tty)
if (exec_bfd == NULL)
{
- printf_unfiltered ("No exec file.\n");
+ printf_unfiltered ("No executable file.\n");
return;
}
diff --git a/gdb/somsolib.c b/gdb/somsolib.c
index 81a36506d71..cde7f91d286 100644
--- a/gdb/somsolib.c
+++ b/gdb/somsolib.c
@@ -1445,7 +1445,7 @@ som_sharedlibrary_info_command (ignore, from_tty)
if (exec_bfd == NULL)
{
- printf_unfiltered ("no exec file.\n");
+ printf_unfiltered ("No executable file.\n");
return;
}
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 464fce1701d..c62a136b64a 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -91,7 +91,7 @@ static char *
static struct type *
dbx_alloc_type PARAMS ((int[2], struct objfile *));
-static long read_huge_number PARAMS ((char **, int, int *));
+static LONGEST read_huge_number PARAMS ((char **, int, int *));
static struct type *error_type PARAMS ((char **, struct objfile *));
@@ -4480,7 +4480,7 @@ read_sun_floating_type (pp, typenums, objfile)
If encounter garbage, set *BITS to -1 and return 0. */
-static long
+static LONGEST
read_huge_number (pp, end, bits)
char **pp;
int end;
@@ -4488,12 +4488,12 @@ read_huge_number (pp, end, bits)
{
char *p = *pp;
int sign = 1;
- long n = 0;
+ LONGEST n = 0;
int radix = 10;
char overflow = 0;
int nbits = 0;
int c;
- long upper_limit;
+ LONGEST upper_limit;
if (*p == '-')
{
@@ -4510,9 +4510,9 @@ read_huge_number (pp, end, bits)
}
if (os9k_stabs)
- upper_limit = ULONG_MAX / radix;
+ upper_limit = ULONGEST_MAX / radix;
else
- upper_limit = LONG_MAX / radix;
+ upper_limit = LONGEST_MAX / radix;
while ((c = *p++) >= '0' && c < ('0' + radix))
{
@@ -4593,7 +4593,7 @@ read_range_type (pp, typenums, objfile)
{
char *orig_pp = *pp;
int rangenums[2];
- long n2, n3;
+ LONGEST n2, n3;
int n2bits, n3bits;
int self_subrange;
struct type *result_type;
@@ -4646,8 +4646,8 @@ read_range_type (pp, typenums, objfile)
fit in a long but <large number>-1 does. */
else if ((n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
|| (n2bits != 0 && n3bits == 0
- && (n2bits == sizeof (long) * HOST_CHAR_BIT)
- && n3 == LONG_MAX))
+ && (n2bits == sizeof (LONGEST) * HOST_CHAR_BIT)
+ && n3 == LONGEST_MAX))
{
got_signed = 1;
nbits = n2bits;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ea2809835a2..872aa7b9c31 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,25 @@
+1999-11-12 Stan Shebs <shebs@andros.cygnus.com>
+
+ * gdb.base/dollar.exp: Remove, now in gdb.hp.
+
+1999-11-10 Jimmy Guo <guo@cup.hp.com>
+
+ * gdb.exp (get_compiler_info): pick up compiler.c and compiler.cc
+ from $srcdir/lib/.
+ * lib/compiler.c, lib/compiler.cc: New files, moved from gdb.base/
+ and gdb.c++/.
+
+ * gdb.c++/derivation.exp: remove redundant get compiler info code.
+
+ * gdb.base/commands.exp: add '$gdb_prompt $' anchor to
+ 'continue with watch' test point.
+
+1999-11-08 Jim Blandy <jimb@zenia.red-bean.com>
+
+ Merged from p2linux-990323-branch:
+
+ * lib/gdb.exp (gdb_continue_to_breakpoint): New function.
+
Mon Nov 8 23:07:09 1999 Andrew Cagney <cagney@amy.cygnus.com>
* gdb.base/remote.exp: Test ``set remote memory-write-packet-sized
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index c9cea084d70..71491dbb3b0 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -320,7 +320,7 @@ proc watchpoint_command_test {} {
}
send_gdb "continue\n"
gdb_expect {
- -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:57.*"\
+ -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:57.*$gdb_prompt $"\
{pass "continue with watch"}
-re "$gdb_prompt $"\
{fail "continue with watch"}
diff --git a/gdb/testsuite/gdb.c++/derivation.exp b/gdb/testsuite/gdb.c++/derivation.exp
index 031985a496b..3a4a3076707 100644
--- a/gdb/testsuite/gdb.c++/derivation.exp
+++ b/gdb/testsuite/gdb.c++/derivation.exp
@@ -60,21 +60,6 @@ gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-remote_file build delete ${binfile}.ci
- if {![istarget "hppa*-*-hpux*"]} {
- if { [gdb_compile "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" preprocess ""] != ""
-} {
- gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will auto
-matically fail."
- }
- } else {
- if { [gdb_preprocess "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" "c++"] != "" } {
- perror "Couldn't make ${binfile}.ci file"
- return 1;
- }
- }
-
-source ${binfile}.ci
#
# set it up at a breakpoint so we can play with the variable values
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 64ccaa9362b..a1a839a0baa 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -335,6 +335,31 @@ proc runto_main { } {
}
+### Continue, and expect to hit a breakpoint.
+### Report a pass or fail, depending on whether it seems to have
+### worked. Use NAME as part of the test name; each call to
+### continue_to_breakpoint should use a NAME which is unique within
+### that test file.
+proc gdb_continue_to_breakpoint {name} {
+ global gdb_prompt
+ set full_name "continue to breakpoint: $name"
+
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "Breakpoint .* at .*\r\n$gdb_prompt $" {
+ pass $full_name
+ }
+ -re ".*$gdb_prompt $" {
+ fail $full_name
+ }
+ timeout {
+ fail "$full_name (timeout)"
+ }
+ }
+}
+
+
+
# gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
#
# COMMAND is the command to execute, send to GDB with send_gdb. If
@@ -901,13 +926,13 @@ proc get_compiler_info {binfile args} {
if {![istarget "hppa*-*-hpux*"]} {
if { [llength $args] > 0 } {
if {$args == "c++"} {
- if { [gdb_compile "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" preprocess {}] != "" } {
+ if { [gdb_compile "${srcdir}/lib/compiler.cc" "${binfile}.ci" preprocess {}] != "" } {
perror "Couldn't make ${binfile}.ci file"
return 1;
}
}
} else {
- if { [gdb_compile "${srcdir}/${subdir}/compiler.c" "${binfile}.ci" preprocess {}] != "" } {
+ if { [gdb_compile "${srcdir}/lib/compiler.c" "${binfile}.ci" preprocess {}] != "" } {
perror "Couldn't make ${binfile}.ci file"
return 1;
}
@@ -916,7 +941,7 @@ proc get_compiler_info {binfile args} {
if { [llength $args] > 0 } {
if {$args == "c++"} {
if { [eval gdb_preprocess \
- [list "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci"] \
+ [list "${srcdir}/lib/compiler.cc" "${binfile}.ci"] \
$args] != "" } {
perror "Couldn't make ${binfile}.ci file"
return 1;
@@ -924,7 +949,7 @@ proc get_compiler_info {binfile args} {
}
} elseif { $args != "f77" } {
if { [eval gdb_preprocess \
- [list "${srcdir}/${subdir}/compiler.c" "${binfile}.ci"] \
+ [list "${srcdir}/lib/compiler.c" "${binfile}.ci"] \
$args] != "" } {
perror "Couldn't make ${binfile}.ci file"
return 1;
diff --git a/gdb/utils.c b/gdb/utils.c
index 339b26a31b0..9760cab4756 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -523,31 +523,38 @@ error_begin ()
and the remaining args are passed as arguments to it. */
NORETURN void
+verror (const char *string, va_list args)
+{
+ /* FIXME: cagney/1999-11-10: All error calls should come here.
+ Unfortunatly some code uses the sequence: error_begin(); print
+ error message; return_to_top_level. That code should be
+ flushed. */
+ error_begin ();
+ vfprintf_filtered (gdb_stderr, string, args);
+ fprintf_filtered (gdb_stderr, "\n");
+ /* Save it as the last error as well (no newline) */
+ gdb_file_rewind (gdb_lasterr);
+ vfprintf_filtered (gdb_lasterr, string, args);
+ va_end (args);
+ return_to_top_level (RETURN_ERROR);
+}
+
+NORETURN void
error (const char *string,...)
{
va_list args;
va_start (args, string);
- if (error_hook)
- (*error_hook) ();
- else
- {
- error_begin ();
- vfprintf_filtered (gdb_stderr, string, args);
- fprintf_filtered (gdb_stderr, "\n");
- /* Save it as the last error as well (no newline) */
- gdb_file_rewind (gdb_lasterr);
- vfprintf_filtered (gdb_lasterr, string, args);
- va_end (args);
- return_to_top_level (RETURN_ERROR);
- }
+ verror (string, args);
+ va_end (args);
}
-/* Allows the error message to be passed on a stream buffer */
-
NORETURN void
error_stream (GDB_FILE *stream)
{
- error (tui_file_get_strbuf (stream));
+ long size;
+ char *msg = gdb_file_xstrdup (stream, &size);
+ make_cleanup (free, msg);
+ error ("%s", msg);
}
/* Get the last error message issued by gdb */
@@ -555,26 +562,26 @@ error_stream (GDB_FILE *stream)
char *
error_last_message (void)
{
- return (tui_file_get_strbuf (gdb_lasterr));
+ long len;
+ return gdb_file_xstrdup (gdb_lasterr, &len);
}
-
+
/* This is to be called by main() at the very beginning */
void
error_init (void)
{
- gdb_lasterr = tui_sfileopen (132);
+ gdb_lasterr = mem_fileopen ();
}
/* Print a message reporting an internal error. Ask the user if they
want to continue, dump core, or just exit. */
NORETURN void
-internal_error (char *string, ...)
+internal_verror (const char *fmt, va_list ap)
{
static char msg[] = "Internal GDB error: recursive internal error.\n";
static int dejavu = 0;
- va_list args;
int continue_p;
int dump_core_p;
@@ -596,9 +603,7 @@ internal_error (char *string, ...)
/* Try to get the message out */
fputs_unfiltered ("gdb-internal-error: ", gdb_stderr);
- va_start (args, string);
- vfprintf_unfiltered (gdb_stderr, string, args);
- va_end (args);
+ vfprintf_unfiltered (gdb_stderr, fmt, ap);
fputs_unfiltered ("\n", gdb_stderr);
/* Default (no case) is to quit GDB. When in batch mode this
@@ -632,6 +637,15 @@ Create a core file containing the current state of GDB? ");
return_to_top_level (RETURN_ERROR);
}
+NORETURN void
+internal_error (char *string, ...)
+{
+ va_list ap;
+ va_start (ap, string);
+ internal_verror (string, ap);
+ va_end (ap);
+}
+
/* The strerror() function can return NULL for errno values that are
out of range. Provide a "safe" version that always returns a
printable string. */
@@ -787,7 +801,7 @@ notice_quit ()
immediate_quit = 1;
}
-#else /* !defined(__GO32__) && !defined(_MSC_VER) */
+#else /* !defined(_MSC_VER) */
void
notice_quit ()
@@ -795,7 +809,7 @@ notice_quit ()
/* Done by signals */
}
-#endif /* !defined(__GO32__) && !defined(_MSC_VER) */
+#endif /* !defined(_MSC_VER) */
/* Control C comes here */
void
@@ -1754,19 +1768,20 @@ stdio_fileopen (file)
/* A pure memory based ``struct gdb_file'' that can be used an output
- collector. It's input is available through gdb_file_put(). */
+ buffer. The buffers accumulated contents are available via
+ gdb_file_put(). */
struct mem_file
{
int *magic;
char *buffer;
int sizeof_buffer;
- int strlen_buffer;
+ int length_buffer;
};
-extern gdb_file_fputs_ftype mem_file_fputs;
static gdb_file_rewind_ftype mem_file_rewind;
static gdb_file_put_ftype mem_file_put;
+static gdb_file_write_ftype mem_file_write;
static gdb_file_delete_ftype mem_file_delete;
static struct gdb_file *mem_file_new PARAMS ((void));
static int mem_file_magic;
@@ -1777,12 +1792,13 @@ mem_file_new (void)
struct mem_file *stream = XMALLOC (struct mem_file);
struct gdb_file *file = gdb_file_new ();
set_gdb_file_data (file, stream, mem_file_delete);
- set_gdb_file_fputs (file, mem_file_fputs);
set_gdb_file_rewind (file, mem_file_rewind);
set_gdb_file_put (file, mem_file_put);
+ set_gdb_file_write (file, mem_file_write);
stream->magic = &mem_file_magic;
stream->buffer = NULL;
stream->sizeof_buffer = 0;
+ stream->length_buffer = 0;
return file;
}
@@ -1809,52 +1825,49 @@ mem_file_rewind (struct gdb_file *file)
struct mem_file *stream = gdb_file_data (file);
if (stream->magic != &mem_file_magic)
internal_error ("mem_file_rewind: bad magic number");
- if (stream->buffer != NULL)
- {
- stream->buffer[0] = '\0';
- stream->strlen_buffer = 0;
- }
+ stream->length_buffer = 0;
}
static void
-mem_file_put (struct gdb_file *file, struct gdb_file *dest)
+mem_file_put (struct gdb_file *file,
+ gdb_file_put_method_ftype *write,
+ void *dest)
{
struct mem_file *stream = gdb_file_data (file);
if (stream->magic != &mem_file_magic)
internal_error ("mem_file_put: bad magic number");
- if (stream->buffer != NULL)
- fputs_unfiltered (stream->buffer, dest);
+ if (stream->length_buffer > 0)
+ write (dest, stream->buffer, stream->length_buffer);
}
void
-mem_file_fputs (const char *linebuffer, struct gdb_file *file)
+mem_file_write (struct gdb_file *file,
+ const char *buffer,
+ long length_buffer)
{
struct mem_file *stream = gdb_file_data (file);
if (stream->magic != &mem_file_magic)
- internal_error ("mem_file_fputs: bad magic number");
+ internal_error ("mem_file_write: bad magic number");
if (stream->buffer == NULL)
{
- stream->strlen_buffer = strlen (linebuffer);
- stream->sizeof_buffer = stream->strlen_buffer + 1;
+ stream->length_buffer = length_buffer;
+ stream->sizeof_buffer = length_buffer;
stream->buffer = xmalloc (stream->sizeof_buffer);
- strcpy (stream->buffer, linebuffer);
+ memcpy (stream->buffer, buffer, length_buffer);
}
else
{
- int len = strlen (linebuffer);
- int new_strlen = stream->strlen_buffer + len;
- int new_sizeof = new_strlen + 1;
- if (new_sizeof >= stream->sizeof_buffer)
+ int new_length = stream->length_buffer + length_buffer;
+ if (new_length >= stream->sizeof_buffer)
{
- stream->sizeof_buffer = new_sizeof;
+ stream->sizeof_buffer = new_length;
stream->buffer = xrealloc (stream->buffer, stream->sizeof_buffer);
}
- strcpy (stream->buffer + stream->strlen_buffer, linebuffer);
- stream->strlen_buffer = new_strlen;
+ memcpy (stream->buffer + stream->length_buffer, buffer, length_buffer);
+ stream->length_buffer = new_length;
}
}
-
/* A ``struct gdb_file'' that is compatible with all the legacy
code. */
@@ -1972,17 +1985,15 @@ tui_file_rewind (file)
}
static void
-tui_file_put (file, dest)
- struct gdb_file *file;
- struct gdb_file *dest;
+tui_file_put (struct gdb_file *file,
+ gdb_file_put_method_ftype *write,
+ void *dest)
{
struct tui_stream *stream = gdb_file_data (file);
if (stream->ts_magic != &tui_file_magic)
internal_error ("tui_file_put: bad magic number");
if (stream->ts_streamtype == astring)
- {
- fputs_unfiltered (stream->ts_strbuf, dest);
- }
+ write (dest, stream->ts_strbuf, strlen (stream->ts_strbuf));
}
/* All TUI I/O sent to the *_filtered and *_unfiltered functions
@@ -2149,6 +2160,7 @@ static gdb_file_put_ftype null_file_put;
struct gdb_file
{
+ int *magic;
gdb_file_flush_ftype *to_flush;
gdb_file_write_ftype *to_write;
gdb_file_fputs_ftype *to_fputs;
@@ -2158,11 +2170,13 @@ struct gdb_file
gdb_file_put_ftype *to_put;
void *to_data;
};
+int gdb_file_magic;
struct gdb_file *
gdb_file_new ()
{
struct gdb_file *file = xmalloc (sizeof (struct gdb_file));
+ file->magic = &gdb_file_magic;
set_gdb_file_data (file, NULL, null_file_delete);
set_gdb_file_flush (file, null_file_flush);
set_gdb_file_write (file, null_file_write);
@@ -2196,9 +2210,9 @@ null_file_rewind (file)
}
static void
-null_file_put (file, src)
- struct gdb_file *file;
- struct gdb_file *src;
+null_file_put (struct gdb_file *file,
+ gdb_file_put_method_ftype *write,
+ void *dest)
{
return;
}
@@ -2265,6 +2279,8 @@ void *
gdb_file_data (file)
struct gdb_file *file;
{
+ if (file->magic != &gdb_file_magic)
+ internal_error ("gdb_file_data: bad magic number");
return file->to_data;
}
@@ -2290,11 +2306,11 @@ gdb_file_rewind (file)
}
void
-gdb_file_put (file, dest)
- struct gdb_file *file;
- struct gdb_file *dest;
+gdb_file_put (struct gdb_file *file,
+ gdb_file_put_method_ftype *write,
+ void *dest)
{
- file->to_put (file, dest);
+ file->to_put (file, write, dest);
}
void
@@ -2370,6 +2386,43 @@ set_gdb_file_data (file, data, delete)
file->to_delete = delete;
}
+/* gdb_file utility function for converting a ``struct gdb_file'' into
+ a memory buffer''. */
+
+struct accumulated_gdb_file
+{
+ char *buffer;
+ long length;
+};
+
+static void
+do_gdb_file_xstrdup (void *context, const char *buffer, long length)
+{
+ struct accumulated_gdb_file *acc = context;
+ if (acc->buffer == NULL)
+ acc->buffer = xmalloc (length + 1);
+ else
+ acc->buffer = xrealloc (acc->buffer, acc->length + length + 1);
+ memcpy (acc->buffer + acc->length, buffer, length);
+ acc->length += length;
+ acc->buffer[acc->length] = '\0';
+}
+
+char *
+gdb_file_xstrdup (struct gdb_file *file,
+ long *length)
+{
+ struct accumulated_gdb_file acc;
+ acc.buffer = NULL;
+ acc.length = 0;
+ gdb_file_put (file, do_gdb_file_xstrdup, &acc);
+ if (acc.buffer == NULL)
+ acc.buffer = xstrdup ("");
+ *length = acc.length;
+ return acc.buffer;
+}
+
+
/* Like fputs but if FILTER is true, pause after every screenful.
Regardless of FILTER can wrap at points other than the final