diff options
author | J.T. Conklin <jtc@acorntoolworks.com> | 1995-08-01 20:14:27 +0000 |
---|---|---|
committer | J.T. Conklin <jtc@acorntoolworks.com> | 1995-08-01 20:14:27 +0000 |
commit | 2b57629364528ef2fd913154e58f626123d51f1c (patch) | |
tree | 649b55da772d6aa5e9190ebcfa4bee6a5a31f998 | |
parent | a1bdcf913a6f7ee2bbb715dd48b1a75e10a43414 (diff) | |
download | fsf-binutils-gdb-2b57629364528ef2fd913154e58f626123d51f1c.zip fsf-binutils-gdb-2b57629364528ef2fd913154e58f626123d51f1c.tar.gz fsf-binutils-gdb-2b57629364528ef2fd913154e58f626123d51f1c.tar.bz2 |
* configure.in: Check for working mmap, ansi headers, string.h,
strings.h, and memory.h.
* configure: Regenerated.
* gdb_stat.h: New file, "portable" <sys/stat.h>.
* gdb_string.h: New file, "portable" <string.h>.
* altos-xdep.c, arm-tdep.c, arm-xdep.c, convex-tdep.c,
convex-xdep.c, coredep.c, cxux-nat.c, dbxread.c, exec.c,
gould-xdep.c, hppa-tdep.c, i386aix-nat.c, i386b-nat.c,
i386mach-nat.c, i386v-nat.c, infptrace.c, m88k-nat.c, main.c,
mdebugread.c, objfiles.c, os9kread.c, procfs.c, pyr-xdep.c,
rs6000-nat.c, source.c, standalone.c, stuff.c, sun386-nat.c,
symfile.c, symm-nat.c, symm-tdep.c, symtab.c, top.c, ultra3-nat.c,
ultra3-xdep.c, umax-xdep.c, xcoffread.c: Include "gdb_stat.h"
instead of <sys/stat.h>.
* alpha-tdep.c, breakpoint.c, buildsym.c, c-typeprint.c,
ch-typeprint.c, coffread.c, command.c, core-sol2.c, core-svr4.c,
core.c, corelow.c, cp-valprint.c, dbxread.c, dcache.c, demangle.c,
dpx2-nat.c, dstread.c, dwarfread.c, elfread.c, environ.c, eval.c,
exec.c, f-lang.c, f-typeprint.c, f-valprint.c, findvar.c,
fork-child.c, gdbtypes.c, hpread.c, i386-tdep.c, infcmd.c,
inflow.c, infptrace.c, infrun.c, irix5-nat.c, language.c,
m2-typeprint.c, main.c, mdebugread.c, minsyms.c, mipsread.c,
monitor.c, nlmread.c, objfiles.c, os9kread.c, osfsolib.c, parse.c,
printcmd.c, procfs.c, regex.c, remote-adapt.c, remote-arc.c,
remote-array.c, remote-bug.c, remote-e7000.c, remote-eb.c,
remote-es.c, remote-hms.c, remote-mm.c, remote-os9k.c,
remote-pa.c, remote-sim.c, remote-st.c, remote-udi.c,
remote-utils.c, remote-vx.c, remote-vx29k.c, remote-vx68.c,
remote-vx960.c, remote-vxmips.c, remote-vxsparc.c, remote.c,
solib.c, somread.c, source.c, stabsread.c, stack.c, symfile.c,
symmisc.c, symtab.c, target.c, top.c, typeprint.c, utils.c,
valarith.c, valops.c, valprint.c, values.c, xcoffread.c: Include
"gdb_string.h" instead of <string.h>.
* gdbtk.c: Likewise.
* config/xm-sysv4.h, i386/xm-ptx.h, m68k/xm-sun3os4.h,
sparc/xm-sun4os4.h (HAVE_MMAP): Removed.
* config/xm-lynx.h, config/i386/xm-ptx.h,
config/m68k/nm-apollo68b.h, config/m68k/xm-hp300hpux.h,
config/mips/xm-irix3.h, config/mips/xm-mips.h,
config/mips/xm-news-mips.h, config/mips/xm-riscos.h,
config/pa/hppah.h, config/rs6000/xm-rs6000.h,
config/sparc/xm-sun4os4.h, config/sparc/xm-sun4sol2.h,
config/vax/xm-vaxbsd.h, config/vax/xm-vaxult.h,
config/vax/xm-vaxult2.h (MEM_FNS_DECLARED): Removed.
* config/mips/xm-irix3.h, config/mips/xm-mips.h,
config/pa/xm-hppah.h (memcpy, memset): Removed declarations.
137 files changed, 2200 insertions, 1150 deletions
diff --git a/gdb/.Sanitize b/gdb/.Sanitize index 769f91d..bf2fd56 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -157,6 +157,8 @@ findvar.c fork-child.c frame.h gcc.patch +gdb_stat.h +gdb_string.h gdb-stabs.h gdb.1 gdb.gdb diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 09a056c..7cb99f7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,59 @@ +Tue Aug 1 11:44:53 1995 J.T. Conklin <jtc@rtl.cygnus.com> + + * configure.in: Check for working mmap, ansi headers, string.h, + strings.h, and memory.h. + * configure: Regenerated. + + * gdb_stat.h: New file, "portable" <sys/stat.h>. + * gdb_string.h: New file, "portable" <string.h>. + + * altos-xdep.c, arm-tdep.c, arm-xdep.c, convex-tdep.c, + convex-xdep.c, coredep.c, cxux-nat.c, dbxread.c, exec.c, + gould-xdep.c, hppa-tdep.c, i386aix-nat.c, i386b-nat.c, + i386mach-nat.c, i386v-nat.c, infptrace.c, m88k-nat.c, main.c, + mdebugread.c, objfiles.c, os9kread.c, procfs.c, pyr-xdep.c, + rs6000-nat.c, source.c, standalone.c, stuff.c, sun386-nat.c, + symfile.c, symm-nat.c, symm-tdep.c, symtab.c, top.c, ultra3-nat.c, + ultra3-xdep.c, umax-xdep.c, xcoffread.c: Include "gdb_stat.h" + instead of <sys/stat.h>. + + * alpha-tdep.c, breakpoint.c, buildsym.c, c-typeprint.c, + ch-typeprint.c, coffread.c, command.c, core-sol2.c, core-svr4.c, + core.c, corelow.c, cp-valprint.c, dbxread.c, dcache.c, demangle.c, + dpx2-nat.c, dstread.c, dwarfread.c, elfread.c, environ.c, eval.c, + exec.c, f-lang.c, f-typeprint.c, f-valprint.c, findvar.c, + fork-child.c, gdbtypes.c, hpread.c, i386-tdep.c, infcmd.c, + inflow.c, infptrace.c, infrun.c, irix5-nat.c, language.c, + m2-typeprint.c, main.c, mdebugread.c, minsyms.c, mipsread.c, + monitor.c, nlmread.c, objfiles.c, os9kread.c, osfsolib.c, parse.c, + printcmd.c, procfs.c, regex.c, remote-adapt.c, remote-arc.c, + remote-array.c, remote-bug.c, remote-e7000.c, remote-eb.c, + remote-es.c, remote-hms.c, remote-mm.c, remote-os9k.c, + remote-pa.c, remote-sim.c, remote-st.c, remote-udi.c, + remote-utils.c, remote-vx.c, remote-vx29k.c, remote-vx68.c, + remote-vx960.c, remote-vxmips.c, remote-vxsparc.c, remote.c, + solib.c, somread.c, source.c, stabsread.c, stack.c, symfile.c, + symmisc.c, symtab.c, target.c, top.c, typeprint.c, utils.c, + valarith.c, valops.c, valprint.c, values.c, xcoffread.c: Include + "gdb_string.h" instead of <string.h>. +start-sanitize-gdbtk + * gdbtk.c: Likewise. +end-sanitize-gdbtk + + * config/xm-sysv4.h, i386/xm-ptx.h, m68k/xm-sun3os4.h, + sparc/xm-sun4os4.h (HAVE_MMAP): Removed. + + * config/xm-lynx.h, config/i386/xm-ptx.h, + config/m68k/nm-apollo68b.h, config/m68k/xm-hp300hpux.h, + config/mips/xm-irix3.h, config/mips/xm-mips.h, + config/mips/xm-news-mips.h, config/mips/xm-riscos.h, + config/pa/hppah.h, config/rs6000/xm-rs6000.h, + config/sparc/xm-sun4os4.h, config/sparc/xm-sun4sol2.h, + config/vax/xm-vaxbsd.h, config/vax/xm-vaxult.h, + config/vax/xm-vaxult2.h (MEM_FNS_DECLARED): Removed. + * config/mips/xm-irix3.h, config/mips/xm-mips.h, + config/pa/xm-hppah.h (memcpy, memset): Removed declarations. + Tue Aug 1 02:08:30 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) * mips-tdep.c (mips_extract_return_value): Fix returning of diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 83f1602..b6b19e6 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -27,7 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dis-asm.h" #include "symfile.h" #include "objfiles.h" -#include <string.h> +#include "gdb_string.h" /* FIXME: Some of this code should perhaps be merged with mips-tdep.c. */ diff --git a/gdb/altos-xdep.c b/gdb/altos-xdep.c index effb49f..2784d3f 100644 --- a/gdb/altos-xdep.c +++ b/gdb/altos-xdep.c @@ -42,7 +42,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include <sys/user.h> /* After a.out.h */ #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" /* Work with core dump and executable files, for GDB. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 1a8b027..e45bf00 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -35,7 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/user.h> /* After a.out.h */ #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <errno.h> #endif @@ -462,7 +462,7 @@ arm_float_info() void _initialize_arm_tdep () { - tm_print_insn = print_insn_arm; + tm_print_insn = print_insn_little_arm; } diff --git a/gdb/arm-xdep.c b/gdb/arm-xdep.c index bc47b72..c0f944e 100644 --- a/gdb/arm-xdep.c +++ b/gdb/arm-xdep.c @@ -36,7 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/user.h> /* After a.out.h */ #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <errno.h> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 94e1dd5..0b388ad 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -34,7 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "thread.h" #include "target.h" #include "language.h" -#include <string.h> +#include "gdb_string.h" #include "demangle.h" #include "annotate.h" @@ -152,34 +152,6 @@ static int executing_breakpoint_commands; b? (tmp=b->next, 1): 0; \ b = tmp) -/* Provide defaults for systems that don't support hardware watchpoints. */ - -#ifndef TARGET_CAN_USE_HARDWARE_WATCHPOINT - -/* Returns non-zero if we can set a hardware watchpoint of type TYPE. TYPE is - one of bp_hardware_watchpoint, bp_read_watchpoint, bp_write_watchpoint, or - bp_hardware_breakpoint. CNT is the number of such watchpoints used so far - (including this one?). OTHERTYPE is who knows what... */ - -#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0 - -/* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes. TYPE is 1 - for read and 2 for read/write accesses. Returns 0 for success, non-zero for - failure. */ - -#define target_remove_watchpoint(ADDR,LEN,TYPE) -1 -#define target_insert_watchpoint(ADDR,LEN,TYPE) -1 -#endif - -#ifndef target_insert_hw_breakpoint -#define target_remove_hw_breakpoint(ADDR,SHADOW) -1 -#define target_insert_hw_breakpoint(ADDR,SHADOW) -1 -#endif - -#ifndef target_stopped_data_address -#define target_stopped_data_address() 0 -#endif - /* True if breakpoint hit counts should be displayed in breakpoint info. */ int show_breakpoint_hit_counts = 1; @@ -1114,8 +1086,8 @@ watchpoint_check (p) { bpstat bs = (bpstat) p; struct breakpoint *b; - struct frame_info *saved_frame, *fr; - int within_current_scope, saved_level; + struct frame_info *fr; + int within_current_scope; b = bs->breakpoint_at; @@ -1258,14 +1230,6 @@ bpstat_stop_status (pc, not_a_breakpoint) && b->address != bp_addr) continue; -/* If defined, then we need to decr pc by this much after a hardware break- - point. Presumably should override DECR_PC_AFTER_BREAK, though it doesn't - now... */ - -#ifndef DECR_PC_AFTER_HW_BREAK -#define DECR_PC_AFTER_HW_BREAK 0 -#endif - if (b->type == bp_hardware_breakpoint && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK)) continue; @@ -2138,6 +2102,13 @@ set_momentary_breakpoint (sal, frame, type) b->enable = enabled; b->disposition = donttouch; b->frame = (frame ? frame->frame : 0); + + /* If we're debugging a multi-threaded program, then we + want momentary breakpoints to be active in only a + single thread of control. */ + if (in_thread_list (inferior_pid)) + b->thread = pid_to_thread_id (inferior_pid); + return b; } diff --git a/gdb/buildsym.c b/gdb/buildsym.c index fa31e62..ec22b11 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "objfiles.h" #include "gdbtypes.h" #include "complaints.h" -#include <string.h> +#include "gdb_string.h" /* Ask buildsym.h to define the vars it normally declares `extern'. */ #define EXTERN /**/ diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index aa5b014..ac44d1d 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -34,7 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "c-lang.h" #include "typeprint.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <ctype.h> diff --git a/gdb/ch-typeprint.c b/gdb/ch-typeprint.c index f06a85c..8440d36 100644 --- a/gdb/ch-typeprint.c +++ b/gdb/ch-typeprint.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ch-lang.h" #include "typeprint.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> static void diff --git a/gdb/coffread.c b/gdb/coffread.c index c4f06e1..ec7aef2 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -27,7 +27,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include <obstack.h> -#include <string.h> +#include "gdb_string.h" +#include <ctype.h> #include "coff/internal.h" /* Internal format of COFF symbols in BFD */ #include "libcoff.h" /* FIXME secret internal data from BFD */ @@ -44,9 +45,10 @@ struct coff_symfile_info { file_ptr min_lineno_offset; /* Where in file lowest line#s are */ file_ptr max_lineno_offset; /* 1+last byte of line#s in file */ - asection *stabsect; /* Section pointer for .stab section */ + CORE_ADDR textaddr; /* Addr of .text section. */ + unsigned int textsize; /* Size of .text section. */ + struct stab_section_list *stabsects; /* .stab sections. */ asection *stabstrsect; /* Section pointer for .stab section */ - asection *stabindexsect; /* Section pointer for .stab.index section */ char *stabstrdata; }; @@ -132,13 +134,6 @@ static unsigned local_auxesz; static struct symbol *opaque_type_chain[HASHSIZE]; -#if 0 -/* The type of the function we are currently reading in. This is - used by define_symbol to record the type of arguments to a function. */ - -struct type *in_function_type; -#endif - /* Complaints about various problems in the file being read */ struct complaint ef_complaint = @@ -212,6 +207,8 @@ static int init_lineno PARAMS ((bfd *, long, int)); static char *getsymname PARAMS ((struct internal_syment *)); +static char *coff_getfilename PARAMS ((union internal_auxent *)); + static void free_stringtab PARAMS ((void)); static int init_stringtab PARAMS ((bfd *, long)); @@ -263,25 +260,55 @@ static void coff_locate_sections PARAMS ((bfd *, asection *, PTR)); -kingdon). */ static void -coff_locate_sections (ignore_abfd, sectp, csip) - bfd *ignore_abfd; +coff_locate_sections (abfd, sectp, csip) + bfd *abfd; asection *sectp; PTR csip; { register struct coff_symfile_info *csi; + const char *name; csi = (struct coff_symfile_info *) csip; - if (STREQ (sectp->name, ".stab")) + name = bfd_get_section_name (abfd, sectp); + if (STREQ (name, ".text")) + { + csi->textaddr = bfd_section_vma (abfd, sectp); + csi->textsize += bfd_section_size (abfd, sectp); + } + else if (strncmp (name, ".text", sizeof ".text" - 1) == 0) { - csi->stabsect = sectp; + csi->textsize += bfd_section_size (abfd, sectp); } - else if (STREQ (sectp->name, ".stabstr")) + else if (STREQ (name, ".stabstr")) { csi->stabstrsect = sectp; } - else if (STREQ (sectp->name, ".stab.index")) + else if (strncmp (name, ".stab", sizeof ".stab" - 1) == 0) { - csi->stabindexsect = sectp; + const char *s; + + /* We can have multiple .stab sections if linked with + --split-by-reloc. */ + for (s = name + sizeof ".stab" - 1; *s != '\0'; s++) + if (! isdigit (*s)) + break; + if (*s == '\0') + { + struct stab_section_list *n, **pn; + + n = ((struct stab_section_list *) + xmalloc (sizeof (struct stab_section_list))); + n->section = sectp; + n->next = NULL; + for (pn = &csi->stabsects; *pn != NULL; pn = &(*pn)->next) + ; + *pn = n; + + /* This will be run after coffstab_build_psymtabs is called + in coff_symfile_read, at which point we no longer need + the information. */ + make_cleanup (free, n); + } } } @@ -529,17 +556,15 @@ static void coff_symfile_init (objfile) struct objfile *objfile; { - bfd *abfd = objfile->obfd; - /* Allocate struct to keep track of stab reading. */ objfile->sym_stab_info = (PTR) - xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info)); + xmmalloc (objfile->md, sizeof (struct dbx_symfile_info)); memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info)); /* Allocate struct to keep track of the symfile */ - objfile -> sym_private = xmmalloc (objfile -> md, - sizeof (struct coff_symfile_info)); + objfile->sym_private = xmmalloc (objfile->md, + sizeof (struct coff_symfile_info)); memset (objfile->sym_private, 0, sizeof (struct coff_symfile_info)); @@ -607,7 +632,7 @@ coff_symfile_read (objfile, section_offsets, mainline) int symtab_offset; int stringtab_offset; struct cleanup *back_to; - int stabsize, stabstrsize; + int stabstrsize; info = (struct coff_symfile_info *) objfile -> sym_private; dbxinfo = (struct dbx_symfile_info *) objfile->sym_stab_info; @@ -681,19 +706,19 @@ coff_symfile_read (objfile, section_offsets, mainline) bfd_map_over_sections (abfd, coff_locate_sections, (PTR) info); - if (info->stabsect) + if (info->stabsects) { /* FIXME: dubious. Why can't we use something normal like bfd_get_section_contents? */ bfd_seek (abfd, abfd->where, 0); - stabsize = bfd_section_size (abfd, info->stabsect); stabstrsize = bfd_section_size (abfd, info->stabstrsect); coffstab_build_psymtabs (objfile, section_offsets, mainline, - info->stabsect->filepos, stabsize, + info->textaddr, info->textsize, + info->stabsects, info->stabstrsect->filepos, stabstrsize); } @@ -1211,7 +1236,7 @@ getsymname (symbol_entry) only the last component of the name. Result is in static storage and is only good for temporary use. */ -char * +static char * coff_getfilename (aux_entry) union internal_auxent *aux_entry; { @@ -1300,6 +1325,8 @@ enter_linenos (file_offset, first_line, last_line, section_offsets) register char *rawptr; struct internal_lineno lptr; + if (!linetab) + return ; if (file_offset < linetab_offset) { complain (&lineno_complaint, file_offset); @@ -1442,22 +1469,8 @@ process_coff_symbol (cs, aux, section_offsets, objfile) if (ISFCN (cs->c_type)) { SYMBOL_VALUE (sym) += ANOFFSET (section_offsets, SECT_OFF_TEXT); -#if 0 - /* FIXME: This has NOT been tested. The DBX version has.. */ - /* Generate a template for the type of this function. The - types of the arguments will be added as we read the symbol - table. */ - struct type *new = (struct type *) - obstack_alloc (&objfile->symbol_obstack, sizeof (struct type)); - - memcpy (new, lookup_function_type (decode_function_type (cs, cs->c_type, aux)), - sizeof(struct type)); - SYMBOL_TYPE (sym) = new; - in_function_type = SYMBOL_TYPE(sym); -#else SYMBOL_TYPE(sym) = lookup_function_type (decode_function_type (cs, cs->c_type, aux)); -#endif SYMBOL_CLASS (sym) = LOC_BLOCK; if (cs->c_sclass == C_STAT) @@ -1513,11 +1526,6 @@ process_coff_symbol (cs, aux, section_offsets, objfile) case C_ARG: SYMBOL_CLASS (sym) = LOC_ARG; -#if 0 - /* FIXME: This has not been tested. */ - /* Add parameter to function. */ - add_param_to_type(&in_function_type,sym); -#endif add_symbol_to_list (sym, &local_symbols); #if !defined (BELIEVE_PCC_PROMOTION) if (TARGET_BYTE_ORDER == BIG_ENDIAN) @@ -2102,7 +2110,7 @@ coff_symfile_offsets (objfile, addr) section_offsets = (struct section_offsets *) obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct section_offsets) - + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1)); + + sizeof (section_offsets->offsets) * SECT_OFF_MAX); for (i = 0; i < SECT_OFF_MAX; i++) ANOFFSET (section_offsets, i) = addr; diff --git a/gdb/command.c b/gdb/command.c index 0735bae..cfb48db 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "value.h" #include <ctype.h> -#include <string.h> +#include "gdb_string.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif diff --git a/gdb/config/i386/xm-ptx.h b/gdb/config/i386/xm-ptx.h index fe68098..cbf6806 100644 --- a/gdb/config/i386/xm-ptx.h +++ b/gdb/config/i386/xm-ptx.h @@ -29,14 +29,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define HAVE_WAIT_STRUCT -#define HAVE_MMAP - #undef HAVE_TERMIO #define HAVE_TERMIOS #define USG -#define MEM_FNS_DECLARED - #define NEED_POSIX_SETPGID #define USE_O_NOCTTY diff --git a/gdb/config/m68k/nm-apollo68b.h b/gdb/config/m68k/nm-apollo68b.h index c90dfac..85d5a66 100644 --- a/gdb/config/m68k/nm-apollo68b.h +++ b/gdb/config/m68k/nm-apollo68b.h @@ -41,5 +41,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ * USER area using the "PEEKUSER" ptrace call. */ #define PT_READ_U 3 - -#define MEM_FNS_DECLARED /* /usr/include/string.h can get it wrong */ diff --git a/gdb/config/m68k/xm-hp300hpux.h b/gdb/config/m68k/xm-hp300hpux.h index 1719a69..5041c73 100644 --- a/gdb/config/m68k/xm-hp300hpux.h +++ b/gdb/config/m68k/xm-hp300hpux.h @@ -46,10 +46,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #undef USG /* In case it was defined in the Makefile for cplus-dem.c */ #define USG -/* The mem functions are in <string.h>. */ -#undef MEM_FNS_DECLARED -#define MEM_FNS_DECLARED 1 - #define HAVE_TERMIOS #define REGISTER_ADDR(u_ar0, regno) \ diff --git a/gdb/config/m68k/xm-sun3os4.h b/gdb/config/m68k/xm-sun3os4.h index f4db6ad..5b62dc9 100644 --- a/gdb/config/m68k/xm-sun3os4.h +++ b/gdb/config/m68k/xm-sun3os4.h @@ -20,10 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "m68k/xm-sun3.h" #define FPU -/* SunOS 4.x has memory mapped files. */ - -#define HAVE_MMAP - /* If you expect to use the mmalloc package to obtain mapped symbol files, for now you have to specify some parameters that determine how gdb places the mappings in it's address space. See the comments in map_to_address() diff --git a/gdb/config/mips/xm-irix3.h b/gdb/config/mips/xm-irix3.h index cd7037b..f64e3a5 100644 --- a/gdb/config/mips/xm-irix3.h +++ b/gdb/config/mips/xm-irix3.h @@ -22,12 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define HOST_BYTE_ORDER BIG_ENDIAN -/* memcpy and memset return void *, not char *. */ - -extern void *memcpy(); -extern void *memset(); -#define MEM_FNS_DECLARED - /* Override register locations in upage for SGI machines */ #undef REGISTER_U_ADDR #define REGISTER_U_ADDR(addr, blockend, regno) \ diff --git a/gdb/config/mips/xm-mips.h b/gdb/config/mips/xm-mips.h index 9c4b2f8..830644c 100644 --- a/gdb/config/mips/xm-mips.h +++ b/gdb/config/mips/xm-mips.h @@ -33,12 +33,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern char *strdup(); #endif -/* DECstation memcpy and memset return void *, not char *. */ - -extern void *memcpy(); -extern void *memset(); -#define MEM_FNS_DECLARED - #if ! defined (__STDC__) && ! defined (offsetof) # define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) #endif diff --git a/gdb/config/mips/xm-news-mips.h b/gdb/config/mips/xm-news-mips.h index 4413782..e0436ee 100644 --- a/gdb/config/mips/xm-news-mips.h +++ b/gdb/config/mips/xm-news-mips.h @@ -22,5 +22,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if !defined (HOST_BYTE_ORDER) #define HOST_BYTE_ORDER BIG_ENDIAN #endif - -#define MEM_FNS_DECLARED diff --git a/gdb/config/mips/xm-riscos.h b/gdb/config/mips/xm-riscos.h index ba3845e..8eece3e 100644 --- a/gdb/config/mips/xm-riscos.h +++ b/gdb/config/mips/xm-riscos.h @@ -22,8 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define HOST_BYTE_ORDER BIG_ENDIAN #endif -#define MEM_FNS_DECLARED - #define USG 1 /* setjmp.h requires uid_t. */ diff --git a/gdb/config/pa/xm-hppah.h b/gdb/config/pa/xm-hppah.h index 64e7524..d4c4a2c 100644 --- a/gdb/config/pa/xm-hppah.h +++ b/gdb/config/pa/xm-hppah.h @@ -39,14 +39,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define HAVE_TERMIOS -/* HP uses non-ANSI definitions, but with void * results. */ -#define MEM_FNS_DECLARED /* Some non-ANSI use void *, not char *. */ -extern void * -memcpy PARAMS ((void *, const void *, size_t)); /* 4.11.2.1 */ - -extern void * -memset PARAMS ((void *, int, size_t)); /* 4.11.6.1 */ - /* HP defines malloc and realloc as returning void *, even for non-ANSI compilations (such as with the native compiler). */ diff --git a/gdb/config/rs6000/xm-rs6000.h b/gdb/config/rs6000/xm-rs6000.h index 64d08ee..e9f6e97 100644 --- a/gdb/config/rs6000/xm-rs6000.h +++ b/gdb/config/rs6000/xm-rs6000.h @@ -44,11 +44,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define USG 1 #define HAVE_SIGSETMASK 1 -/* AIX declares the mem functions differently than defs.h does. AIX is - right, but defs.h works on more old systems. For now, override it. */ - -#define MEM_FNS_DECLARED 1 - /* This system requires that we open a terminal with O_NOCTTY for it to not become our controlling terminal. */ diff --git a/gdb/config/sparc/xm-sun4os4.h b/gdb/config/sparc/xm-sun4os4.h index 2981c2e..ca94bad 100644 --- a/gdb/config/sparc/xm-sun4os4.h +++ b/gdb/config/sparc/xm-sun4os4.h @@ -20,10 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "sparc/xm-sparc.h" #define FPU -/* SunOS 4.x has memory mapped files. */ - -#define HAVE_MMAP - /* If you expect to use the mmalloc package to obtain mapped symbol files, for now you have to specify some parameters that determine how gdb places the mappings in it's address space. See the comments in map_to_address() @@ -41,14 +37,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define MALLOC_INCOMPATIBLE #include <malloc.h> -/* acc for SunOS4 comes with string.h and memory.h headers which we - pick up somewhere (where?) and which use char *, not void *. The - following should work with acc, gcc, or /bin/cc, at least with - SunOS 4.1.1. */ - -#define MEM_FNS_DECLARED -#include <memory.h> - /* SunOS 4.x uses nonstandard "char *" as type of third argument to ptrace() */ #define PTRACE_ARG3_TYPE char* diff --git a/gdb/config/sparc/xm-sun4sol2.h b/gdb/config/sparc/xm-sun4sol2.h index de7e10f..b4b3656 100644 --- a/gdb/config/sparc/xm-sun4sol2.h +++ b/gdb/config/sparc/xm-sun4sol2.h @@ -51,10 +51,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Solaris PSRVADDR support does not seem to include a place for nPC. */ #define PRSVADDR_BROKEN -/* The mem functions are in <string.h>. */ -#undef MEM_FNS_DECLARED -#define MEM_FNS_DECLARED 1 - /* solaris doesn't have siginterrupt, though it has sigaction; however, in this case siginterrupt would just be setting the default. */ #define NO_SIGINTERRUPT diff --git a/gdb/config/vax/xm-vaxbsd.h b/gdb/config/vax/xm-vaxbsd.h index 68efaac..b42bd70 100644 --- a/gdb/config/vax/xm-vaxbsd.h +++ b/gdb/config/vax/xm-vaxbsd.h @@ -8,6 +8,3 @@ #include <sys/param.h> #include "vax/xm-vax.h" - -/* In non-ANSI compiles, memcpy and memset are still void *, not char *. */ -#define MEM_FNS_DECLARED diff --git a/gdb/config/vax/xm-vaxult.h b/gdb/config/vax/xm-vaxult.h index 20fd368..24c6437 100644 --- a/gdb/config/vax/xm-vaxult.h +++ b/gdb/config/vax/xm-vaxult.h @@ -3,8 +3,6 @@ #include "vax/xm-vax.h" extern char *strdup(); -#define MEM_FNS_DECLARED - /* This is required for Ultrix 3.1b, not for later versions. Ultrix 3.1b can't just use xm-vaxult2.h because Ultrix 3.1b does define FD_SET. Sure, we could have separate configurations for vaxult2, diff --git a/gdb/config/vax/xm-vaxult2.h b/gdb/config/vax/xm-vaxult2.h index f3e2550..d0d3d62 100644 --- a/gdb/config/vax/xm-vaxult2.h +++ b/gdb/config/vax/xm-vaxult2.h @@ -3,7 +3,6 @@ #include "vax/xm-vax.h" extern char *strdup(); -#define MEM_FNS_DECLARED #define NO_PTRACE_H /* Old versions of ultrix have fd_set but not the FD_* macros. */ diff --git a/gdb/config/xm-lynx.h b/gdb/config/xm-lynx.h index 5b9a389..dd9bba3 100644 --- a/gdb/config/xm-lynx.h +++ b/gdb/config/xm-lynx.h @@ -20,5 +20,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* for INT_MIN, to avoid "INT_MIN redefined" warnings from defs.h */ #include <limits.h> - -#define MEM_FNS_DECLARED diff --git a/gdb/config/xm-sysv4.h b/gdb/config/xm-sysv4.h index 9d1451d..dbe2538 100644 --- a/gdb/config/xm-sysv4.h +++ b/gdb/config/xm-sysv4.h @@ -23,10 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #undef HAVE_TERMIO #define HAVE_TERMIOS -/* SVR4 has mmap facilities */ - -#define HAVE_MMAP - /* SVR4 is a derivative of System V Release 3 (USG) */ #define USG diff --git a/gdb/configure b/gdb/configure index e324daf..6478564 100755 --- a/gdb/configure +++ b/gdb/configure @@ -847,7 +847,127 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," -for ac_hdr in unistd.h +# If we cannot run a trivial program, we must be cross compiling. +echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_cross=yes +else +cat > conftest.$ac_ext <<EOF +#line 860 "configure" +#include "confdefs.h" +main(){return(0);} +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + ac_cv_c_cross=no +else + ac_cv_c_cross=yes +fi +fi +rm -fr conftest* +fi +cross_compiling=$ac_cv_c_cross +echo "$ac_t""$ac_cv_c_cross" 1>&6 + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 881 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 903 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 921 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + ac_cv_header_stdc=no +else +cat > conftest.$ac_ext <<EOF +#line 942 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + : +else + ac_cv_header_stdc=no +fi +fi +rm -fr conftest* +fi +fi +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in memory.h string.h strings.h unistd.h do ac_safe=`echo "$ac_hdr" | tr './\055' '___'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -855,7 +975,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 859 "configure" +#line 979 "configure" #include "confdefs.h" #include <$ac_hdr> EOF @@ -883,6 +1003,161 @@ else fi done +echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1012 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <sys/stat.h> + +#if defined(S_ISBLK) && defined(S_IFDIR) +# if S_ISBLK (S_IFDIR) +You lose. +# endif +#endif + +#if defined(S_ISBLK) && defined(S_IFCHR) +# if S_ISBLK (S_IFCHR) +You lose. +# endif +#endif + +#if defined(S_ISLNK) && defined(S_IFREG) +# if S_ISLNK (S_IFREG) +You lose. +# endif +#endif + +#if defined(S_ISSOCK) && defined(S_IFREG) +# if S_ISSOCK (S_IFREG) +You lose. +# endif +#endif + +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "You lose" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_header_stat_broken=yes +else + rm -rf conftest* + ac_cv_header_stat_broken=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_header_stat_broken" 1>&6 +if test $ac_cv_header_stat_broken = yes; then + cat >> confdefs.h <<\EOF +#define STAT_MACROS_BROKEN 1 +EOF + +fi + + +echo $ac_n "checking for working mmap""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_mmap'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_mmap=no +else +cat > conftest.$ac_ext <<EOF +#line 1070 "configure" +#include "confdefs.h" + +/* Thanks to Mike Haertel and Jim Avera for this test. */ +#include <sys/types.h> +#include <fcntl.h> +#include <sys/mman.h> + +#ifdef BSD +# ifndef BSD4_1 +# define HAVE_GETPAGESIZE +# endif +#endif + +#ifndef HAVE_GETPAGESIZE +# include <sys/param.h> +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif +# else +# ifdef NBPC +# define getpagesize() NBPC +# else +# define getpagesize() PAGESIZE /* SVR4 */ +# endif +# endif +# endif +#endif + +#ifdef __osf__ +# define valloc malloc +#endif + +#ifdef __cplusplus +extern "C" { void *valloc(unsigned), *malloc(unsigned); } +#else +char *valloc(), *malloc(); +#endif + +int +main() +{ + char *buf1, *buf2, *buf3; + int i = getpagesize(), j; + int i2 = getpagesize()*2; + int fd; + + buf1 = (char *)valloc(i2); + buf2 = (char *)valloc(i); + buf3 = (char *)malloc(i2); + for (j = 0; j < i2; ++j) + *(buf1 + j) = rand(); + fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); + write(fd, buf1, i2); + mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); + for (j = 0; j < i; ++j) + if (*(buf1 + j) != *(buf2 + j)) + exit(1); + lseek(fd, (long)i, 0); + read(fd, buf2, i); /* read into mapped memory -- file should not change */ + /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */ + lseek(fd, (long)0, 0); + read(fd, buf3, i2); + for (j = 0; j < i2; ++j) + if (*(buf1 + j) != *(buf3 + j)) + exit(1); + exit(0); +} + +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + ac_cv_func_mmap=yes +else + ac_cv_func_mmap=no +fi +fi +rm -fr conftest* +fi +echo "$ac_t""$ac_cv_func_mmap" 1>&6 +if test $ac_cv_func_mmap = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_MMAP 1 +EOF + +fi + ENABLE_CFLAGS= ENABLE_CLIBS= @@ -979,7 +1254,7 @@ test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h cat > conftest.$ac_ext <<EOF -#line 983 "configure" +#line 1258 "configure" #include "confdefs.h" #include <$x_direct_test_include> EOF @@ -1042,7 +1317,7 @@ rm -f conftest* ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <<EOF -#line 1046 "configure" +#line 1321 "configure" #include "confdefs.h" int main() { return 0; } @@ -1160,7 +1435,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $LIBS" cat > conftest.$ac_ext <<EOF -#line 1164 "configure" +#line 1439 "configure" #include "confdefs.h" int main() { return 0; } @@ -1203,7 +1478,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <<EOF -#line 1207 "configure" +#line 1482 "configure" #include "confdefs.h" int main() { return 0; } @@ -1237,7 +1512,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <<EOF -#line 1241 "configure" +#line 1516 "configure" #include "confdefs.h" int main() { return 0; } @@ -1276,7 +1551,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <<EOF -#line 1280 "configure" +#line 1555 "configure" #include "confdefs.h" int main() { return 0; } @@ -1314,7 +1589,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <<EOF -#line 1318 "configure" +#line 1593 "configure" #include "confdefs.h" int main() { return 0; } @@ -1371,7 +1646,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1375 "configure" +#line 1650 "configure" #include "confdefs.h" #include <tk.h> EOF @@ -1473,7 +1748,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1477 "configure" +#line 1752 "configure" #include "confdefs.h" #include <tclInt.h> EOF diff --git a/gdb/configure.in b/gdb/configure.in index 0c1158e..1ef77ce 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -15,7 +15,11 @@ AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..) AC_CANONICAL_SYSTEM AC_ARG_PROGRAM -AC_CHECK_HEADERS(unistd.h) +AC_HEADER_STDC +AC_CHECK_HEADERS(memory.h string.h strings.h unistd.h) +AC_HEADER_STAT + +AC_FUNC_MMAP dnl Handle optional features that can be enabled. ENABLE_CFLAGS= diff --git a/gdb/convex-tdep.c b/gdb/convex-tdep.c index 930d160..bef0bc9 100644 --- a/gdb/convex-tdep.c +++ b/gdb/convex-tdep.c @@ -37,7 +37,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/thread.h> #include <sys/proc.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/mman.h> #include "gdbcmd.h" diff --git a/gdb/convex-xdep.c b/gdb/convex-xdep.c index 6426c6e..080bb97 100644 --- a/gdb/convex-xdep.c +++ b/gdb/convex-xdep.c @@ -37,7 +37,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/thread.h> #include <sys/proc.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/mman.h> #include <convex/vmparam.h> diff --git a/gdb/core-sol2.c b/gdb/core-sol2.c index 4ead2ac..13d9876 100644 --- a/gdb/core-sol2.c +++ b/gdb/core-sol2.c @@ -34,7 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/procfs.h> #include <fcntl.h> #include <errno.h> -#include <string.h> +#include "gdb_string.h" #include "inferior.h" #include "target.h" diff --git a/gdb/core-svr4.c b/gdb/core-svr4.c index e0743fd..f1def9f 100644 --- a/gdb/core-svr4.c +++ b/gdb/core-svr4.c @@ -39,7 +39,7 @@ regardless of whether or not the actual target has floating point hardware. #include <sys/procfs.h> #include <fcntl.h> #include <errno.h> -#include <string.h> +#include "gdb_string.h" #include "inferior.h" #include "target.h" @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/coredep.c b/gdb/coredep.c index 678785d..ae2d0a6 100644 --- a/gdb/coredep.c +++ b/gdb/coredep.c @@ -31,7 +31,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef USG #include <sys/dir.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/user.h> #ifndef NO_PTRACE_H # ifdef PTRACE_IN_WRONG_PLACE diff --git a/gdb/corelow.c b/gdb/corelow.c index 0d6fb81..e4e663f 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index c32dbc7..77c6dc3 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcmd.h" #include "demangle.h" #include "annotate.h" -#include <string.h> +#include "gdb_string.h" int vtblprint; /* Controls printing of vtbl's */ int objectprint; /* Controls looking up an object's derived type diff --git a/gdb/cxux-nat.c b/gdb/cxux-nat.c index b47c19d..6b2e25a 100644 --- a/gdb/cxux-nat.c +++ b/gdb/cxux-nat.c @@ -39,7 +39,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/ioctl.h> #include <fcntl.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include "symtab.h" #include "setjmp.h" diff --git a/gdb/dbxread.c b/gdb/dbxread.c index ddaf192..97c3d3c 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ for real. dbx_psymtab_to_symtab() is the function that does this */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #if defined(USG) || defined(__CYGNUSCLIB__) #include <sys/types.h> @@ -45,7 +45,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef NO_SYS_FILE #include <sys/file.h> #endif -#include <sys/stat.h> +#include "gdb_stat.h" #include <ctype.h> #include "symtab.h" #include "breakpoint.h" @@ -70,9 +70,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define SEEK_CUR 1 #endif -/* Each partial symbol table entry contains a pointer to private data for the - sym_read function to use when expanding a partial symbol table entry - to a full symbol table entry. */ +/* We put a pointer to this structure in the read_symtab_private field + of the psymtab. */ struct symloc { @@ -573,8 +572,8 @@ dbx_symfile_read (objfile, section_offsets, mainline) process them and define symbols accordingly. */ read_dbx_symtab (section_offsets, objfile, - bfd_section_vma (sym_bfd, DBX_TEXT_SECT (objfile)), - bfd_section_size (sym_bfd, DBX_TEXT_SECT (objfile))); + DBX_TEXT_ADDR (objfile), + DBX_TEXT_SIZE (objfile)); /* Add the dynamic symbols. */ @@ -624,6 +623,7 @@ dbx_symfile_init (objfile) int val; bfd *sym_bfd = objfile->obfd; char *name = bfd_get_filename (sym_bfd); + asection *text_sect; unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE]; /* Allocate struct to keep track of the symfile */ @@ -637,9 +637,12 @@ dbx_symfile_init (objfile) /* FIXME POKING INSIDE BFD DATA STRUCTURES */ DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL; - DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text"); - if (!DBX_TEXT_SECT (objfile)) + + text_sect = bfd_get_section_by_name (sym_bfd, ".text"); + if (!text_sect) error ("Can't find .text section in symbol file"); + DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); + DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); DBX_SYMBOL_SIZE (objfile) = obj_symbol_entry_size (sym_bfd); DBX_SYMCOUNT (objfile) = bfd_get_symcount (sym_bfd); @@ -755,6 +758,13 @@ static char *last_function_name; building psymtabs, right? */ static char *stringtab_global; +/* These variables are used to control fill_symbuf when the stabs + symbols are not contiguous (as may be the case when a COFF file is + linked using --split-by-reloc). */ +static struct stab_section_list *symbuf_sections; +static unsigned int symbuf_left; +static unsigned int symbuf_read; + /* Refill the symbol table input buffer and set the variables that control fetching entries from it. Reports an error if no data available. @@ -765,13 +775,37 @@ static void fill_symbuf (sym_bfd) bfd *sym_bfd; { - int nbytes = bfd_read ((PTR)symbuf, sizeof (symbuf), 1, sym_bfd); + unsigned int count; + int nbytes; + + if (symbuf_sections == NULL) + count = sizeof (symbuf); + else + { + if (symbuf_left <= 0) + { + file_ptr filepos = symbuf_sections->section->filepos; + if (bfd_seek (sym_bfd, filepos, SEEK_SET) != 0) + perror_with_name (bfd_get_filename (sym_bfd)); + symbuf_left = bfd_section_size (sym_bfd, symbuf_sections->section); + symbol_table_offset = filepos - symbuf_read; + symbuf_sections = symbuf_sections->next; + } + + count = symbuf_left; + if (count > sizeof (symbuf)) + count = sizeof (symbuf); + } + + nbytes = bfd_read ((PTR)symbuf, count, 1, sym_bfd); if (nbytes < 0) perror_with_name (bfd_get_filename (sym_bfd)); else if (nbytes == 0) error ("Premature end of file reading symbol table"); symbuf_end = nbytes / symbol_size; symbuf_idx = 0; + symbuf_left -= nbytes; + symbuf_read += nbytes; } #define SWAP_SYMBOL(symp, abfd) \ @@ -2096,10 +2130,12 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) int l = colon_pos - name; m = lookup_minimal_symbol_by_pc (last_pc_address); - if (m && STREQN (SYMBOL_NAME (m), name, l)) + if (m && STREQN (SYMBOL_NAME (m), name, l) + && SYMBOL_NAME (m) [l] == '\0') /* last_pc_address was in this function */ valu = SYMBOL_VALUE (m); - else if (m && STREQN (SYMBOL_NAME (m+1), name, l)) + else if (m && STREQN (SYMBOL_NAME (m+1), name, l) + && SYMBOL_NAME (m+1) [l] == '\0') /* last_pc_address was in last function */ valu = SYMBOL_VALUE (m+1); else @@ -2176,9 +2212,10 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) previous_stab_code = type; } -/* FIXME: The only difference between this and elfstab_build_psymtabs is - the call to install_minimal_symbols for elf. If the differences are - really that small, the code should be shared. */ +/* FIXME: The only difference between this and elfstab_build_psymtabs + is the call to install_minimal_symbols for elf, and the support for + split sections. If the differences are really that small, the code + should be shared. */ /* Scan and build partial symbols for an coff symbol file. The coff file has already been processed to get its minimal symbols. @@ -2191,8 +2228,9 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) the base address of the text segment). MAINLINE is true if we are reading the main symbol table (as opposed to a shared lib or dynamically loaded file). - STABOFFSET and STABSIZE define the location in OBJFILE where the .stab - section exists. + TEXTADDR is the address of the text section. + TEXTSIZE is the size of the text section. + STABSECTS is the list of .stab sections in OBJFILE. STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the .stabstr section exists. @@ -2201,13 +2239,14 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) void coffstab_build_psymtabs (objfile, section_offsets, mainline, - staboffset, stabsize, + textaddr, textsize, stabsects, stabstroffset, stabstrsize) struct objfile *objfile; struct section_offsets *section_offsets; int mainline; - file_ptr staboffset; - unsigned int stabsize; + CORE_ADDR textaddr; + unsigned int textsize; + struct stab_section_list *stabsects; file_ptr stabstroffset; unsigned int stabstrsize; { @@ -2215,20 +2254,18 @@ coffstab_build_psymtabs (objfile, section_offsets, mainline, bfd *sym_bfd = objfile->obfd; char *name = bfd_get_filename (sym_bfd); struct dbx_symfile_info *info; + unsigned int stabsize; /* There is already a dbx_symfile_info allocated by our caller. It might even contain some info from the coff symtab to help us. */ info = (struct dbx_symfile_info *) objfile->sym_stab_info; - DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text"); - if (!DBX_TEXT_SECT (objfile)) - error ("Can't find .text section in symbol file"); + DBX_TEXT_ADDR (objfile) = textaddr; + DBX_TEXT_SIZE (objfile) = textsize; #define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */ DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE; - DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile); DBX_STRINGTAB_SIZE (objfile) = stabstrsize; - DBX_SYMTAB_OFFSET (objfile) = staboffset; if (stabstrsize > bfd_get_size (sym_bfd)) error ("ridiculous string table size: %d bytes", stabstrsize); @@ -2254,6 +2291,30 @@ coffstab_build_psymtabs (objfile, section_offsets, mainline, /* In a coff file, we've already installed the minimal symbols that came from the coff (non-stab) symbol table, so always act like an incremental load here. */ + if (stabsects->next == NULL) + { + stabsize = bfd_section_size (sym_bfd, stabsects->section); + DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile); + DBX_SYMTAB_OFFSET (objfile) = stabsects->section->filepos; + } + else + { + struct stab_section_list *stabsect; + + DBX_SYMCOUNT (objfile) = 0; + for (stabsect = stabsects; stabsect != NULL; stabsect = stabsect->next) + { + stabsize = bfd_section_size (sym_bfd, stabsect->section); + DBX_SYMCOUNT (objfile) += stabsize / DBX_SYMBOL_SIZE (objfile); + } + + DBX_SYMTAB_OFFSET (objfile) = stabsects->section->filepos; + + symbuf_sections = stabsects->next; + symbuf_left = bfd_section_size (sym_bfd, stabsects->section); + symbuf_read = 0; + } + dbx_symfile_read (objfile, section_offsets, 0); } @@ -2293,14 +2354,17 @@ elfstab_build_psymtabs (objfile, section_offsets, mainline, bfd *sym_bfd = objfile->obfd; char *name = bfd_get_filename (sym_bfd); struct dbx_symfile_info *info; + asection *text_sect; /* There is already a dbx_symfile_info allocated by our caller. It might even contain some info from the ELF symtab to help us. */ info = (struct dbx_symfile_info *) objfile->sym_stab_info; - DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text"); - if (!DBX_TEXT_SECT (objfile)) + text_sect = bfd_get_section_by_name (sym_bfd, ".text"); + if (!text_sect) error ("Can't find .text section in symbol file"); + DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); + DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); #define ELF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */ DBX_SYMBOL_SIZE (objfile) = ELF_STABS_SYMBOL_SIZE; @@ -2368,6 +2432,7 @@ stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name, char *name = bfd_get_filename (sym_bfd); asection *stabsect; asection *stabstrsect; + asection *text_sect; stabsect = bfd_get_section_by_name (sym_bfd, stab_name); stabstrsect = bfd_get_section_by_name (sym_bfd, stabstr_name); @@ -2382,9 +2447,11 @@ stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name, objfile->sym_stab_info = (PTR) xmalloc (sizeof (struct dbx_symfile_info)); memset (DBX_SYMFILE_INFO (objfile), 0, sizeof (struct dbx_symfile_info)); - DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, text_name); - if (!DBX_TEXT_SECT (objfile)) + text_sect = bfd_get_section_by_name (sym_bfd, text_name); + if (!text_sect) error ("Can't find %s section in symbol file", text_name); + DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); + DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); DBX_SYMBOL_SIZE (objfile) = sizeof (struct external_nlist); DBX_SYMCOUNT (objfile) = bfd_section_size (sym_bfd, stabsect) diff --git a/gdb/dcache.c b/gdb/dcache.c index 4e9f960a..fce1852 100644 --- a/gdb/dcache.c +++ b/gdb/dcache.c @@ -22,7 +22,7 @@ #include "defs.h" #include "dcache.h" #include "gdbcmd.h" -#include <string.h> +#include "gdb_string.h" /* diff --git a/gdb/demangle.c b/gdb/demangle.c index eecd3d3..2fead9a 100644 --- a/gdb/demangle.c +++ b/gdb/demangle.c @@ -26,7 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "command.h" #include "gdbcmd.h" #include "demangle.h" -#include <string.h> +#include "gdb_string.h" /* Select the default C++ demangling style to use. The default is "auto", which allows gdb to attempt to pick an appropriate demangling style for diff --git a/gdb/dpx2-nat.c b/gdb/dpx2-nat.c index c437c75..4f1f0dd 100644 --- a/gdb/dpx2-nat.c +++ b/gdb/dpx2-nat.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "gdbcore.h" -#include <string.h> +#include "gdb_string.h" #include <sys/types.h> #include <sys/param.h> #include <sys/dir.h> diff --git a/gdb/dstread.c b/gdb/dstread.c index 378ed8e..22f239d 100644 --- a/gdb/dstread.c +++ b/gdb/dstread.c @@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "buildsym.h" #include <obstack.h> -#include <string.h> +#include "gdb_string.h" #include "dst.h" diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 3cc9bd1..4a1a57a 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -51,7 +51,7 @@ other things to work on, if you get bored. :-) #include "complaints.h" #include <fcntl.h> -#include <string.h> +#include "gdb_string.h" #ifndef NO_SYS_FILE #include <sys/file.h> diff --git a/gdb/elfread.c b/gdb/elfread.c index 10269bb..cfadc11 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "bfd.h" -#include <string.h> +#include "gdb_string.h" #include "libelf.h" #include "elf/mips.h" #include "symtab.h" diff --git a/gdb/environ.c b/gdb/environ.c index 8d5dba1..193f34d 100644 --- a/gdb/environ.c +++ b/gdb/environ.c @@ -20,8 +20,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "environ.h" -#include <string.h> -#include "defs.h" /* For strsave(). */ +#include "gdb_string.h" +#include "gdbcore.h" /* Return a new environment object. */ @@ -64,6 +64,9 @@ init_environ (e) extern char **environ; register int i; + if (environ == NULL) + return; + for (i = 0; environ[i]; i++) /*EMPTY*/; if (e->allocated < i) @@ -149,26 +152,16 @@ set_in_environ (e, var, value) strcat (s, value); vector[i] = s; - /* Certain variables get exported back to the parent (e.g. our) - environment, too. FIXME: this is a hideous hack and should not be - allowed to live. What if we want to change the environment we pass to - the program without affecting GDB's behavior? */ - if (STREQ(var, "PATH") /* Object file location */ - || STREQ (var, "G960BASE") /* Intel 960 downloads */ - || STREQ (var, "G960BIN") /* Intel 960 downloads */ - ) - { - putenv (strsave (s)); - } + /* This used to handle setting the PATH and GNUTARGET variables + specially. The latter has been replaced by "set gnutarget" + (which has worked since GDB 4.11). The former affects searching + the PATH to find SHELL, and searching the PATH to find the + argument of "symbol-file" or "exec-file". Maybe we should have + some kind of "set exec-path" for that. But in any event, having + "set env" affect anything besides the inferior is a bad idea. + What if we want to change the environment we pass to the program + without afecting GDB's behavior? */ - /* This is a compatibility hack, since GDB 4.10 and older didn't have - `set gnutarget'. Eventually it should go away, so that (for example) - you can debug objdump's handling of GNUTARGET without affecting GDB's - behavior. */ - if (STREQ (var, "GNUTARGET")) - { - set_gnutarget (value); - } return; } @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "value.h" @@ -226,10 +226,8 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) struct type *type; int nargs; value_ptr *argvec; - struct symbol *tmp_symbol; int upper, lower, retcode; int code; - struct internalvar *var; /* This expect_type crap should not be used for C. C expressions do not have any notion of expected types, never has and (goddess @@ -1173,8 +1171,12 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT) error ("Non-integral right operand for \"@\" operator."); if (noside == EVAL_AVOID_SIDE_EFFECTS) - return allocate_repeat_value (VALUE_TYPE (arg1), - longest_to_int (value_as_long (arg2))); + { + if (VALUE_REPEATED (arg1)) + error ("Cannot create artificial arrays of artificial arrays."); + return allocate_repeat_value (VALUE_TYPE (arg1), + longest_to_int (value_as_long (arg2))); + } else return value_repeat (arg1, longest_to_int (value_as_long (arg2))); @@ -32,12 +32,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/param.h> #include <fcntl.h> -#include <string.h> +#include "gdb_string.h" #include "gdbcore.h" #include <ctype.h> -#include <sys/stat.h> +#include "gdb_stat.h" #ifndef O_BINARY #define O_BINARY 0 #endif @@ -588,26 +588,47 @@ ignore (addr, contents) } struct target_ops exec_ops = { - "exec", "Local exec file", - "Use an executable file as a target.\n\ -Specify the filename of the executable file.", - exec_file_command, exec_close, /* open, close */ - find_default_attach, 0, 0, 0, /* attach, detach, resume, wait, */ - 0, 0, /* fetch_registers, store_registers, */ - 0, /* prepare_to_store, */ - xfer_memory, exec_files_info, - ignore, ignore, /* insert_breakpoint, remove_breakpoint, */ - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, 0, /* kill, load */ - 0, /* lookup sym */ - find_default_create_inferior, - 0, /* mourn_inferior */ - 0, /* can_run */ - 0, /* notice_signals */ - file_stratum, 0, /* next */ - 0, 1, 0, 0, 0, /* all mem, mem, stack, regs, exec */ - 0, 0, /* section pointers */ - OPS_MAGIC, /* Always the last thing */ + "exec", /* to_shortname */ + "Local exec file", /* to_longname */ + "Use an executable file as a target.\n\ +Specify the filename of the executable file.", /* to_doc */ + exec_file_command, /* to_open */ + exec_close, /* to_close */ + find_default_attach, /* to_attach */ + 0, /* to_detach */ + 0, /* to_resume */ + 0, /* to_wait */ + 0, /* to_fetch_registers */ + 0, /* to_store_registers */ + 0, /* to_prepare_to_store */ + xfer_memory, /* to_xfer_memory */ + exec_files_info, /* to_files_info */ + ignore, /* to_insert_breakpoint */ + ignore, /* to_remove_breakpoint */ + 0, /* to_terminal_init */ + 0, /* to_terminal_inferior */ + 0, /* to_terminal_ours_for_output */ + 0, /* to_terminal_ours */ + 0, /* to_terminal_info */ + 0, /* to_kill */ + 0, /* to_load */ + 0, /* to_lookup_symbol */ + find_default_create_inferior, /* to_create_inferior */ + 0, /* to_mourn_inferior */ + 0, /* to_can_run */ + 0, /* to_notice_signals */ + 0, /* to_thread_alive */ + 0, /* to_stop */ + file_stratum, /* to_stratum */ + 0, /* to_next */ + 0, /* to_has_all_memory */ + 1, /* to_has_memory */ + 0, /* to_has_stack */ + 0, /* to_has_registers */ + 0, /* to_has_execution */ + 0, /* to_sections */ + 0, /* to_sections_end */ + OPS_MAGIC, /* to_magic */ }; void diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 04a446f..54fb557 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "expression.h" diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 8b1e9fe..ef6fb47 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -36,7 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "typeprint.h" #include "frame.h" /* ??? */ -#include <string.h> +#include "gdb_string.h" #include <errno.h> #if 0 /* Currently unused */ diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 06beea6..7f5fb32 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "expression.h" diff --git a/gdb/findvar.c b/gdb/findvar.c index 591dc7f..fd3a532 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -25,7 +25,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include "inferior.h" #include "target.h" -#include <string.h> +#include "gdb_string.h" + +/* Registers we shouldn't try to store. */ +#if !defined (CANNOT_STORE_REGISTER) +#define CANNOT_STORE_REGISTER(regno) 0 +#endif static void write_register_pid PARAMS ((int regno, LONGEST val, int pid)); @@ -499,6 +504,9 @@ registers_changed () for (i = 0; i < numregs; i++) register_valid[i] = 0; + + if (registers_changed_hook) + registers_changed_hook (); } /* Indicate that all registers have been fetched, so mark them all valid. */ @@ -511,18 +519,33 @@ registers_fetched () register_valid[i] = 1; } -/* Copy LEN bytes of consecutive data from registers - starting with the REGBYTE'th byte of register data +/* read_register_bytes and write_register_bytes are generally a *BAD* idea. + They are inefficient because they need to check for partial updates, which + can only be done by scanning through all of the registers and seeing if the + bytes that are being read/written fall inside of an invalid register. [The + main reason this is necessary is that register sizes can vary, so a simple + index won't suffice.] It is far better to call read_register_gen if you + want to get at the raw register contents, as it only takes a regno as an + argument, and therefore can't do a partial register update. It would also + be good to have a write_register_gen for similar reasons. + + Prior to the recent fixes to check for partial updates, both read and + write_register_bytes always checked to see if any registers were stale, and + then called target_fetch_registers (-1) to update the whole set. This + caused really slowed things down for remote targets. */ + +/* Copy INLEN bytes of consecutive data from registers + starting with the INREGBYTE'th byte of register data into memory at MYADDR. */ void -read_register_bytes (regbyte, myaddr, len) - int regbyte; +read_register_bytes (inregbyte, myaddr, inlen) + int inregbyte; char *myaddr; - int len; + int inlen; { - /* Fetch all registers. */ - int i, numregs; + int inregend = inregbyte + inlen; + int regno; if (registers_pid != inferior_pid) { @@ -530,15 +553,37 @@ read_register_bytes (regbyte, myaddr, len) registers_pid = inferior_pid; } - numregs = ARCH_NUM_REGS; - for (i = 0; i < numregs; i++) - if (!register_valid[i]) - { - target_fetch_registers (-1); - break; - } + /* See if we are trying to read bytes from out-of-date registers. If so, + update just those registers. */ + + for (regno = 0; regno < NUM_REGS; regno++) + { + int regstart, regend; + int startin, endin; + + if (register_valid[regno]) + continue; + + regstart = REGISTER_BYTE (regno); + regend = regstart + REGISTER_RAW_SIZE (regno); + + startin = regstart >= inregbyte && regstart < inregend; + endin = regend > inregbyte && regend <= inregend; + + if (!startin && !endin) + continue; + + /* We've found an invalid register where at least one byte will be read. + Update it from the target. */ + + target_fetch_registers (regno); + + if (!register_valid[regno]) + error ("read_register_bytes: Couldn't update register %d.", regno); + } + if (myaddr != NULL) - memcpy (myaddr, ®isters[regbyte], len); + memcpy (myaddr, ®isters[inregbyte], inlen); } /* Read register REGNO into memory at MYADDR, which must be large enough @@ -562,25 +607,99 @@ read_register_gen (regno, myaddr) REGISTER_RAW_SIZE (regno)); } -/* Copy LEN bytes of consecutive data from memory at MYADDR - into registers starting with the REGBYTE'th byte of register data. */ +/* Write register REGNO at MYADDR to the target. MYADDR points at + REGISTER_RAW_BYTES(REGNO), which must be in target byte-order. */ void -write_register_bytes (regbyte, myaddr, len) - int regbyte; +write_register_gen (regno, myaddr) + int regno; char *myaddr; - int len; { + int size; + + /* On the sparc, writing %g0 is a no-op, so we don't even want to change + the registers array if something writes to this register. */ + if (CANNOT_STORE_REGISTER (regno)) + return; + if (registers_pid != inferior_pid) { registers_changed (); registers_pid = inferior_pid; } - /* Make sure the entire registers array is valid. */ - read_register_bytes (0, (char *)NULL, REGISTER_BYTES); - memcpy (®isters[regbyte], myaddr, len); - target_store_registers (-1); + size = REGISTER_RAW_SIZE(regno); + + /* If we have a valid copy of the register, and new value == old value, + then don't bother doing the actual store. */ + + if (register_valid [regno] + && memcmp (®isters[REGISTER_BYTE (regno)], myaddr, size) == 0) + return; + + target_prepare_to_store (); + + memcpy (®isters[REGISTER_BYTE (regno)], myaddr, size); + + register_valid [regno] = 1; + + target_store_registers (regno); +} + +/* Copy INLEN bytes of consecutive data from memory at MYADDR + into registers starting with the MYREGSTART'th byte of register data. */ + +void +write_register_bytes (myregstart, myaddr, inlen) + int myregstart; + char *myaddr; + int inlen; +{ + int myregend = myregstart + inlen; + int regno; + + target_prepare_to_store (); + + /* Scan through the registers updating any that are covered by the range + myregstart<=>myregend using write_register_gen, which does nice things + like handling threads, and avoiding updates when the new and old contents + are the same. */ + + for (regno = 0; regno < NUM_REGS; regno++) + { + int regstart, regend; + int startin, endin; + char regbuf[MAX_REGISTER_RAW_SIZE]; + + regstart = REGISTER_BYTE (regno); + regend = regstart + REGISTER_RAW_SIZE (regno); + + startin = regstart >= myregstart && regstart < myregend; + endin = regend > myregstart && regend <= myregend; + + if (!startin && !endin) + continue; /* Register is completely out of range */ + + if (startin && endin) /* register is completely in range */ + { + write_register_gen (regno, myaddr + (regstart - myregstart)); + continue; + } + + /* We may be doing a partial update of an invalid register. Update it + from the target before scribbling on it. */ + read_register_gen (regno, regbuf); + + if (startin) + memcpy (registers + regstart, + myaddr + regstart - myregstart, + myregend - regstart); + else /* endin */ + memcpy (registers + myregstart, + myaddr, + regend - myregstart); + target_store_registers (regno); + } } /* Return the raw contents of register REGNO, regarding it as an integer. */ @@ -624,11 +743,6 @@ read_register_pid (regno, pid) return retval; } -/* Registers we shouldn't try to store. */ -#if !defined (CANNOT_STORE_REGISTER) -#define CANNOT_STORE_REGISTER(regno) 0 -#endif - /* Store VALUE, into the raw contents of register number REGNO. */ void diff --git a/gdb/fork-child.c b/gdb/fork-child.c index 2b2daeb..39bfa8f 100644 --- a/gdb/fork-child.c +++ b/gdb/fork-child.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "frame.h" /* required by inferior.h */ #include "inferior.h" #include "target.h" diff --git a/gdb/gdb_stat.h b/gdb/gdb_stat.h new file mode 100644 index 0000000..d863735 --- /dev/null +++ b/gdb/gdb_stat.h @@ -0,0 +1,68 @@ +/* Portable <sys/stat.h> + Copyright 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if !defined(GDB_STAT_H) +#define GDB_STAT_H + +#include <sys/types.h> +#include <sys/stat.h> + +#ifdef STAT_MACROS_BROKEN +#undef S_ISBLK +#undef S_ISCHR +#undef S_ISDIR +#undef S_ISREG +#undef S_ISFIFO +#undef S_ISLNK +#undef S_ISSOCK +#undef S_ISMPB +#undef S_ISMPC +#undef S_ISNWK +#endif + +#if !defined(S_ISBLK) && defined(S_IFBLK) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#endif +#if !defined(S_ISCHR) && defined(S_IFCHR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#endif +#if !defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif +#if !defined(S_ISREG) && defined(S_IFREG) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif +#if !defined(S_ISFIFO) && defined(S_IFIFO) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#endif +#if !defined(S_ISLNK) && defined(S_IFLNK) +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif +#if !defined(S_ISSOCK) && defined(S_IFSOCK) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +#endif +#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ +#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) +#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +#endif +#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ +#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +#endif + +#endif /* !defined(GDB_STAT_H) */ diff --git a/gdb/gdb_string.h b/gdb/gdb_string.h new file mode 100644 index 0000000..761ec91 --- /dev/null +++ b/gdb/gdb_string.h @@ -0,0 +1,48 @@ +/* Portable <string.h> + Copyright 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if !defined(GDB_STRING_H) +#define GDB_STRING_H + +#ifdef STDC_HEADERS +#include <string.h> +#else +# ifdef HAVE_STRING_H +# include <string.h> +# else +# include <strings.h> +# endif +extern char *strchr(); +extern char *strrchr(); +extern char *strstr(); +extern char *strtok(); +extern char *strerror(); +# ifdef HAVE_MEMORY_H +# include <memory.h> +# else +extern void *memset(); +extern void *memcpy(); +extern void *memmove(); +extern int memcmp(); +# endif +#endif + +extern char *strdup(); + +#endif /* !defined(GDB_STRING_H) */ diff --git a/gdb/gdbtk.c b/gdb/gdbtk.c index 87b9e33..882221d 100644 --- a/gdb/gdbtk.c +++ b/gdb/gdbtk.c @@ -40,7 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <setjmp.h> #include "top.h" #include <sys/ioctl.h> -#include <string.h> +#include "gdb_string.h" #include "dis-asm.h" #include <stdio.h> #include "gdbcmd.h" diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f5a8c3f..0794d9f 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "bfd.h" #include "symtab.h" #include "symfile.h" diff --git a/gdb/gould-xdep.c b/gdb/gould-xdep.c index 8b0060b..8dd5abd 100644 --- a/gdb/gould-xdep.c +++ b/gdb/gould-xdep.c @@ -31,7 +31,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" /* Work with core dump and executable files, for GDB. diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 4869772..e8f01ef 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -46,7 +46,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /*#include <sys/user.h> After a.out.h */ #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include "wait.h" #include "gdbcore.h" diff --git a/gdb/hpread.c b/gdb/hpread.c index 7b36650..31556971 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -22,7 +22,7 @@ #include "defs.h" #include "bfd.h" -#include <string.h> +#include "gdb_string.h" #include "hp-symtab.h" #include "syms.h" #include "symtab.h" diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index d01b693..139bb85 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -17,7 +17,7 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <string.h> +#include "gdb_string.h" #include "defs.h" #include "frame.h" #include "inferior.h" diff --git a/gdb/i386aix-nat.c b/gdb/i386aix-nat.c index 6a26380..9454aab 100644 --- a/gdb/i386aix-nat.c +++ b/gdb/i386aix-nat.c @@ -35,7 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <fcntl.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <stddef.h> #include <sys/ptrace.h> diff --git a/gdb/i386b-nat.c b/gdb/i386b-nat.c index ae17ce1..c3473c7 100644 --- a/gdb/i386b-nat.c +++ b/gdb/i386b-nat.c @@ -90,7 +90,7 @@ i386_register_u_addr (blockend, regnum) #include <sys/user.h> #undef curpcb #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/ptrace.h> extern void print_387_control_word (); /* i387-tdep.h */ diff --git a/gdb/i386mach-nat.c b/gdb/i386mach-nat.c index 4e2d323..cddc2ec 100644 --- a/gdb/i386mach-nat.c +++ b/gdb/i386mach-nat.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <machine/reg.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/core.h> diff --git a/gdb/i386v-nat.c b/gdb/i386v-nat.c index 8ecbad9..8cd8466 100644 --- a/gdb/i386v-nat.c +++ b/gdb/i386v-nat.c @@ -39,7 +39,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #endif #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #ifndef NO_SYS_REG_H #include <sys/reg.h> diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 0ca4d56..539c528 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1,5 +1,5 @@ /* Memory-access and commands for "inferior" process, for GDB. - Copyright 1986, 1987, 1988, 1989, 1991, 1992 Free Software Foundation, Inc. + Copyright 1986, 1987, 1988, 1989, 1991, 1992, 1995 Free Software Foundation, Inc. This file is part of GDB. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include <signal.h> #include <sys/param.h> -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "frame.h" @@ -359,7 +359,6 @@ step_1 (skip_subroutines, single_inst, count_string) printf_filtered ("\ Single stepping until exit from function %s, \n\ which has no line number information.\n", name); - gdb_flush (gdb_stdout); } } else @@ -571,7 +570,7 @@ run_stack_dummy (addr, buffer) bpt = set_momentary_breakpoint (sal, get_current_frame (), bp_call_dummy); - bpt->disposition = delete; + bpt->disposition = del; /* If all error()s out of proceed ended up calling normal_stop (and perhaps they should; it already does in the special case of error diff --git a/gdb/inflow.c b/gdb/inflow.c index 56dc0e6..788d786 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -27,7 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "target.h" #include "thread.h" -#include <string.h> +#include "gdb_string.h" #include <signal.h> #include <fcntl.h> diff --git a/gdb/infptrace.c b/gdb/infptrace.c index 011224e..0013e91 100644 --- a/gdb/infptrace.c +++ b/gdb/infptrace.c @@ -1,5 +1,6 @@ /* Low level Unix child interface to ptrace, for GDB when running under Unix. - Copyright 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995 + Free Software Foundation, Inc. This file is part of GDB. @@ -21,6 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "frame.h" #include "inferior.h" #include "target.h" +#include "gdb_string.h" #ifdef USG #include <sys/types.h> @@ -69,7 +71,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Don't think this is used anymore. On the sequent (not sure whether it's dynix or ptx or both), it is included unconditionally by sys/user.h and not protected against multiple inclusion. */ -#include <sys/stat.h> +#include "gdb_stat.h" #endif #if !defined (FETCH_INFERIOR_REGISTERS) @@ -110,13 +112,18 @@ kill_inferior () if (inferior_pid == 0) return; /* ptrace PT_KILL only works if process is stopped!!! So stop it with - a real signal first, if we can. */ + a real signal first, if we can. FIXME: This is bogus. When the inferior + is not stopped, GDB should just be waiting for it. Either the following + line is unecessary, or there is some problem elsewhere in GDB which + causes us to get here when the inferior is not stopped. */ kill (inferior_pid, SIGKILL); ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0); wait ((int *)0); target_mourn_inferior (); } +#ifndef CHILD_RESUME + /* Resume execution of the inferior process. If STEP is nonzero, single-step it. If SIGNAL is nonzero, give it that signal. */ @@ -131,15 +138,9 @@ child_resume (pid, step, signal) if (pid == -1) /* Resume all threads. */ -#ifdef PIDGET - /* This is for Lynx, and should be cleaned up by having Lynx be - a separate debugging target, with its own target_resume function. */ - pid = PIDGET (inferior_pid); -#else /* I think this only gets used in the non-threaded case, where "resume all threads" and "resume inferior_pid" are the same. */ pid = inferior_pid; -#endif /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where it was. (If GDB wanted it to start some other way, we have already @@ -160,6 +161,8 @@ child_resume (pid, step, signal) if (errno) perror_with_name ("ptrace"); } +#endif /* CHILD_RESUME */ + #ifdef ATTACH_DETACH /* Start debugging the process whose number is PID. */ @@ -243,7 +246,8 @@ static void fetch_register (regno) int regno; { - register unsigned int regaddr; + /* This isn't really an address. But ptrace thinks of it as one. */ + CORE_ADDR regaddr; char buf[MAX_REGISTER_RAW_SIZE]; char mess[128]; /* For messages */ register int i; @@ -283,9 +287,14 @@ void fetch_inferior_registers (regno) int regno; { + int numregs; + if (regno == -1) - for (regno = 0; regno < NUM_REGS; regno++) - fetch_register (regno); + { + numregs = ARCH_NUM_REGS; + for (regno = 0; regno < numregs; regno++) + fetch_register (regno); + } else fetch_register (regno); } @@ -303,9 +312,10 @@ void store_inferior_registers (regno) int regno; { - register unsigned int regaddr; + /* This isn't really an address. But ptrace thinks of it as one. */ + CORE_ADDR regaddr; char buf[80]; - register int i; + register int i, numregs; unsigned int offset = U_REGS_OFFSET; @@ -327,7 +337,8 @@ store_inferior_registers (regno) } else { - for (regno = 0; regno < NUM_REGS; regno++) + numregs = ARCH_NUM_REGS; + for (regno = 0; regno < numregs; regno++) { if (CANNOT_STORE_REGISTER (regno)) continue; diff --git a/gdb/infrun.c b/gdb/infrun.c index 5ad2bfc..a55744a 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <ctype.h> #include "symtab.h" #include "frame.h" @@ -479,7 +479,9 @@ wait_for_inferior () else pid = target_wait (-1, &w); +#ifdef HAVE_NONSTEPPABLE_WATCHPOINT have_waited: +#endif flush_cached_frames (); @@ -527,6 +529,12 @@ wait_for_inferior () (unsigned int)w.value.integer); else printf_filtered ("\nProgram exited normally.\n"); + + /* Record the exit code in the convenience variable $_exitcode, so + that the user can inspect this again later. */ + set_internalvar (lookup_internalvar ("_exitcode"), + value_from_longest (builtin_type_int, + (LONGEST) w.value.integer)); gdb_flush (gdb_stdout); target_mourn_inferior (); #ifdef NO_SINGLE_STEP @@ -650,32 +658,28 @@ wait_for_inferior () /* It's a SIGTRAP or a signal we're interested in. Switch threads, and fall into the rest of wait_for_inferior(). */ + /* Save infrun state for the old thread. */ + save_infrun_state (inferior_pid, prev_pc, + prev_func_start, prev_func_name, + trap_expected, step_resume_breakpoint, + through_sigtramp_breakpoint, + step_range_start, step_range_end, + step_frame_address, handling_longjmp, + another_trap); + inferior_pid = pid; + + /* Load infrun state for the new thread. */ + load_infrun_state (inferior_pid, &prev_pc, + &prev_func_start, &prev_func_name, + &trap_expected, &step_resume_breakpoint, + &through_sigtramp_breakpoint, + &step_range_start, &step_range_end, + &step_frame_address, &handling_longjmp, + &another_trap); printf_filtered ("[Switching to %s]\n", target_pid_to_str (pid)); flush_cached_frames (); - trap_expected = 0; - if (step_resume_breakpoint) - { - delete_breakpoint (step_resume_breakpoint); - step_resume_breakpoint = NULL; - } - - /* Not sure whether we need to blow this away too, - but probably it is like the step-resume - breakpoint. */ - if (through_sigtramp_breakpoint) - { - delete_breakpoint (through_sigtramp_breakpoint); - through_sigtramp_breakpoint = NULL; - } - prev_pc = 0; - prev_func_name = NULL; - step_range_start = 0; - step_range_end = 0; - step_frame_address = 0; - handling_longjmp = 0; - another_trap = 0; } #ifdef NO_SINGLE_STEP diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c index c6c8c52..d70c6e3 100644 --- a/gdb/irix5-nat.c +++ b/gdb/irix5-nat.c @@ -27,7 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include "target.h" -#include <string.h> +#include "gdb_string.h" #include <sys/time.h> #include <sys/procfs.h> #include <setjmp.h> /* For JB_XXX. */ diff --git a/gdb/language.c b/gdb/language.c index f989cb2..224b8a9 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ whenever the working language changes. That would be a lot faster. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #ifdef ANSI_PROTOTYPES #include <stdarg.h> #else diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index c9ee800..6a3d3fe 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "demangle.h" #include "m2-lang.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> void diff --git a/gdb/m88k-nat.c b/gdb/m88k-nat.c index b16c523..852bfb0 100644 --- a/gdb/m88k-nat.c +++ b/gdb/m88k-nat.c @@ -34,7 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/ioctl.h> #include <fcntl.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include "symtab.h" #include "setjmp.h" @@ -28,10 +28,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "getopt.h" #include <sys/types.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <ctype.h> -#include <string.h> +#include "gdb_string.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 54d4b6a..88b7a08 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -77,8 +77,8 @@ typedef struct mips_extra_func_info { #include <sys/param.h> #include <sys/file.h> -#include <sys/stat.h> -#include <string.h> +#include "gdb_stat.h" +#include "gdb_string.h" #include "gdb-stabs.h" diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 354b8ff..f34985a 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -38,7 +38,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "bfd.h" #include "symfile.h" diff --git a/gdb/mipsread.c b/gdb/mipsread.c index 9a90dd1..80fcec7 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -24,7 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ mdebugread.c. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "bfd.h" #include "symtab.h" #include "symfile.h" @@ -101,7 +101,8 @@ mipscoff_symfile_read (objfile, section_offsets, mainline) /* Now that the executable file is positioned at symbol table, process it and define symbols accordingly. */ - if (ecoff_slurp_symbolic_info (abfd) == false) + if (!((*ecoff_backend (abfd)->debug_swap.read_debug_info) + (abfd, (asection *) NULL, &ecoff_data (abfd)->debug_info))) error ("Error reading symbol table: %s", bfd_errmsg (bfd_get_error ())); mdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap, @@ -112,13 +113,6 @@ mipscoff_symfile_read (objfile, section_offsets, mainline) if (mainline) read_alphacoff_dynamic_symtab (section_offsets, objfile); - if (!have_partial_symbols ()) - { - wrap_here (""); - printf_filtered ("(no debugging symbols found)..."); - wrap_here (""); - } - /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ diff --git a/gdb/monitor.c b/gdb/monitor.c index 1eb07b9..e76421d 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -38,7 +38,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <varargs.h> #endif #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <sys/types.h> #include "command.h" #include "serial.h" @@ -865,7 +865,7 @@ monitor_files_info (ops) static int monitor_write_memory (memaddr, myaddr, len) CORE_ADDR memaddr; - unsigned char *myaddr; + char *myaddr; int len; { unsigned LONGEST val; @@ -929,7 +929,7 @@ monitor_write_memory (memaddr, myaddr, len) static int monitor_read_memory_single (memaddr, myaddr, len) CORE_ADDR memaddr; - unsigned char *myaddr; + char *myaddr; int len; { unsigned LONGEST val; @@ -1426,7 +1426,7 @@ monitor_make_srec (buffer, type, memaddr, myaddr, len) unsigned char checksum; int i; char *buf; - static char hextab[16] = "0123456789ABCDEF"; + static char hextab[] = "0123456789ABCDEF"; static char data_code_table[] = { 0,0,1,2,3}; static char term_code_table[] = { 0,0,9,8,7}; int addr_size; /* Number of bytes in the record */ @@ -1545,6 +1545,7 @@ static struct target_ops monitor_ops = monitor_mourn_inferior, /* to_mourn_inferior */ 0, /* to_can_run */ 0, /* to_notice_signals */ + 0, /* to_thread_alive */ monitor_stop, /* to_stop */ process_stratum, /* to_stratum */ 0, /* to_next */ diff --git a/gdb/nlmread.c b/gdb/nlmread.c index 7ba977a..a31a04d 100644 --- a/gdb/nlmread.c +++ b/gdb/nlmread.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "bfd.h" #include "symtab.h" #include "symfile.h" diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 80ec2b6..bd53342 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -30,10 +30,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "target.h" #include <sys/types.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <fcntl.h> #include <obstack.h> -#include <string.h> +#include "gdb_string.h" /* Prototypes for local functions */ diff --git a/gdb/os9kread.c b/gdb/os9kread.c index 6a91cd6..a34dd6d 100644 --- a/gdb/os9kread.c +++ b/gdb/os9kread.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ for real. os9k_psymtab_to_symtab() is the function that does this */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <stdio.h> #if defined(USG) || defined(__CYGNUSCLIB__) @@ -46,7 +46,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef NO_SYS_FILE #include <sys/file.h> #endif -#include <sys/stat.h> +#include "gdb_stat.h" #include <ctype.h> #include "symtab.h" #include "breakpoint.h" diff --git a/gdb/osfsolib.c b/gdb/osfsolib.c index 017d4a9..9230f55 100644 --- a/gdb/osfsolib.c +++ b/gdb/osfsolib.c @@ -24,7 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/types.h> #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <fcntl.h> #include "symtab.h" diff --git a/gdb/parse.c b/gdb/parse.c index 36f7c39..aa3c4f6 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -29,7 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ come first in the result. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "frame.h" diff --git a/gdb/printcmd.c b/gdb/printcmd.c index e271806..22fbad5 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "frame.h" #include "symtab.h" #include "gdbtypes.h" @@ -945,7 +945,7 @@ address_info (exp, from_tty) printf_filtered ("Symbol \""); fprintf_symbol_filtered (gdb_stdout, SYMBOL_NAME (sym), current_language->la_language, DMGL_ANSI); - printf_filtered ("\" is ", SYMBOL_NAME (sym)); + printf_filtered ("\" is "); val = SYMBOL_VALUE (sym); basereg = SYMBOL_BASEREG (sym); @@ -1702,7 +1702,7 @@ print_frame_nameless_args (fi, start, num, first, stream) #ifdef PRINT_TYPELESS_INTEGER PRINT_TYPELESS_INTEGER (stream, builtin_type_int, (LONGEST) arg_value); #else - fprintf_filtered (stream, "%d", arg_value); + fprintf_filtered (stream, "%ld", arg_value); #endif /* PRINT_TYPELESS_INTEGER */ #endif /* PRINT_NAMELESS_INTEGER */ first = 0; diff --git a/gdb/procfs.c b/gdb/procfs.c index 9584bd1..383bdcc 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -41,11 +41,11 @@ regardless of whether or not the actual target has floating point hardware. #include <sys/procfs.h> #include <fcntl.h> #include <errno.h> -#include <string.h> +#include "gdb_string.h" #include <stropts.h> #include <poll.h> #include <unistd.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include "inferior.h" #include "target.h" diff --git a/gdb/pyr-xdep.c b/gdb/pyr-xdep.c index bdfdd5f..b7f327a 100644 --- a/gdb/pyr-xdep.c +++ b/gdb/pyr-xdep.c @@ -30,7 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include <sys/user.h> /* After a.out.h */ #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" void diff --git a/gdb/regex.c b/gdb/regex.c index fc31eba..96ccaf1 100644 --- a/gdb/regex.c +++ b/gdb/regex.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #else /* not emacs */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" /* * Define the syntax stuff, so we can do the \<...\> things. diff --git a/gdb/remote-adapt.c b/gdb/remote-adapt.c index 62562c7..ecacd04 100644 --- a/gdb/remote-adapt.c +++ b/gdb/remote-adapt.c @@ -30,7 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 7/91 o - Freeze mode tracing can be done on a 29050. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "inferior.h" #include "wait.h" #include "value.h" diff --git a/gdb/remote-arc.c b/gdb/remote-arc.c index df984bd..81e6de0 100644 --- a/gdb/remote-arc.c +++ b/gdb/remote-arc.c @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <fcntl.h> #include "frame.h" #include "inferior.h" diff --git a/gdb/remote-array.c b/gdb/remote-array.c index 2ee7c9a..0d98892 100644 --- a/gdb/remote-array.c +++ b/gdb/remote-array.c @@ -34,7 +34,7 @@ #include <varargs.h> #endif #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <sys/types.h> #include "command.h" #include "serial.h" diff --git a/gdb/remote-bug.c b/gdb/remote-bug.c index b3b72d2..52d608e 100644 --- a/gdb/remote-bug.c +++ b/gdb/remote-bug.c @@ -24,7 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inferior.h" #include "wait.h" -#include <string.h> +#include "gdb_string.h" #include <ctype.h> #include <fcntl.h> #include <signal.h> diff --git a/gdb/remote-e7000.c b/gdb/remote-e7000.c index 644650e..b4aaaed 100644 --- a/gdb/remote-e7000.c +++ b/gdb/remote-e7000.c @@ -1,5 +1,5 @@ /* Remote debugging interface for Hitachi E7000 ICE, for GDB - Copyright 1993 Free Software Foundation, Inc. + Copyright 1993, 1994 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain for Cygnus Support. @@ -20,87 +20,117 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* The E7000 is an in-circuit emulator for the Hitachi H8/300-H and + Hitachi-SH processor. It has serial port and a lan port. + + The monitor command set makes it difficult to load large ammounts of + data over the lan without using ftp - so try not to issue load + commands when communicating over ethernet; use the ftpload command. + + The monitor pauses for a second when dumping srecords to the serial + line too, so we use a slower per byte mechanism but without the + startup overhead. Even so, it's pretty slow... */ #include "defs.h" #include "gdbcore.h" +#include "inferior.h" #include "target.h" #include "wait.h" -#include <varargs.h> +#include "value.h" +#include "command.h" #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <sys/types.h> #include "serial.h" +#include "remote-utils.h" +#if 0 +#define HARD_BREAKPOINTS +#define BC_BREAKPOINTS 0 +#endif -/* The E7000 is an in-circuit emulator for the Hitachi H8/300-H and -Hitachi-SH processor. It has serial port and a lan port. - -The monitor command set makes it difficult to load large ammounts of -data over the lan without using ftp - so try not to issue load -commands when communicating over ethernet; use the ftpload command. - -The monitor pauses for a second when dumping srecords to the serial -line too, so we use a slower per byte mechanism but without the -startup overhead. Even so, it's pretty slow... */ - -int using_tcp; /* nonzero if using the tcp serial driver */ - -extern struct target_ops e7000_ops; /* Forward declaration */ #define CTRLC 0x03 #define ENQ 0x05 #define ACK 0x06 #define CTRLZ 0x1a -char *ENQSTRING = "\005"; +extern void notice_quit PARAMS ((void)); -int echo; -int ctrl_c; -static void e7000_close (); -static void e7000_fetch_register (); -static void e7000_store_register (); +/* Local function declarations. */ -static int timeout = 5; +static void e7000_close PARAMS ((int)); + +static void e7000_fetch_register PARAMS ((int)); + +static void e7000_store_register PARAMS ((int)); + +static void e7000_command PARAMS ((char *, int)); + +static void e7000_login_command PARAMS ((char *, int)); + +static void e7000_ftp_command PARAMS ((char *, int)); + +static void e7000_drain_command PARAMS ((char *, int)); static void expect PARAMS ((char *)); -static void expect_full_prompt PARAMS (()); -static void expect_prompt PARAMS (()); + +static void expect_full_prompt PARAMS ((void)); + +static void expect_prompt PARAMS ((void)); + +/* Variables. */ + static serial_t e7000_desc; +/* Nonzero if using the tcp serial driver. */ -/* Send data to e7000debug. Works just like printf. */ -#if 0 -static void -printf_e7000debug (va_alist) - va_dcl -{ - va_list args; - char *pattern; - char buf[200]; +static int using_tcp; - va_start (args); +/* Nonzero if using the pc isa card. */ - pattern = va_arg (args, char *); +static int using_pc; - vsprintf (buf, pattern, args); -#else +extern struct target_ops e7000_ops; /* Forward declaration */ + +char *ENQSTRING = "\005"; + +/* Nonzero if some routine (as opposed to the user) wants echoing. + FIXME: Do this reentrantly with an extra parameter. */ + +static int echo; + +static int ctrl_c; + +static int timeout = 5; + +/* Send data to e7000debug. */ static void -printf_e7000debug(a,b,c,d,e) - { - char buf[200]; - sprintf(buf, a,b,c,d,e); -#endif +puts_e7000debug (buf) + char *buf; +{ + if (!e7000_desc) + error ("Use \"target e7000 ...\" first."); + + if (remote_debug) + printf("Sending %s\n", buf); + if (SERIAL_WRITE (e7000_desc, buf, strlen (buf))) fprintf (stderr, "SERIAL_WRITE failed: %s\n", safe_strerror (errno)); - /* And expect to see it echoed */ - expect (buf); + /* And expect to see it echoed, unless using the pc interface */ +#if 0 + if (!using_pc) +#endif + expect (buf); } static void putchar_e7000 (x) + int x; { char b[1]; + b[0] = x; SERIAL_WRITE (e7000_desc, b, 1); } @@ -112,6 +142,15 @@ write_e7000 (s) SERIAL_WRITE (e7000_desc, s, strlen (s)); } +static int +normal (x) + int x; +{ + if (x == '\n') + return '\r'; + return x; +} + /* Read a character from the remote system, doing all the fancy timeout stuff. */ @@ -120,47 +159,78 @@ readchar (timeout) int timeout; { int c; + do { c = SERIAL_READCHAR (e7000_desc, timeout); } while (c > 127); + if (c == SERIAL_TIMEOUT) { if (timeout == 0) - return c; /* Polls shouldn't generate timeout errors */ - + return -1; + echo = 0; error ("Timeout reading from remote system."); } - return c; + if (remote_debug) + { + putchar (c); + fflush (stdout); + } + + return normal (c); } +#if 0 +char * +tl (x) +{ + static char b[8][10]; + static int p; + + p++; + p &= 7; + if (x >= ' ') + { + b[p][0] = x; + b[p][1] = 0; + } + else + { + sprintf(b[p], "<%d>", x); + } + + return b[p]; +} +#endif + +/* Scan input from the remote system, until STRING is found. If + DISCARD is non-zero, then discard non-matching input, else print it + out. Let the user break out immediately. */ -/* Scan input from the remote system, until STRING is found. If DISCARD is - non-zero, then discard non-matching input, else print it out. - Let the user break out immediately. */ static void expect (string) char *string; { char *p = string; int c; + int nl = 0; while (1) - { c = readchar (timeout); - notice_quit (); if (quit_flag == 1) { - if (ctrl_c) { - putchar_e7000(CTRLC); - ctrl_c -- ; - } + if (ctrl_c) + { + putchar_e7000(CTRLC); + --ctrl_c; + } else { - quit(); + quit (); } } @@ -168,22 +238,32 @@ expect (string) { error ("Serial communication error"); } - if (echo) + if (echo || remote_debug) { - if (c != '\r') - putchar (c); + if (c == '\r' || c == '\n') + { + if (!nl) + putchar ('\n'); + nl = 1; + } + else + { + nl = 0; + putchar (c); + } fflush (stdout); } - if (c == *p++) + if (normal (c) == normal (*p++)) { if (*p == '\0') - { - return; - } + return; } else { p = string; + + if (normal (c) == normal (string[0])) + p++; } } } @@ -194,27 +274,29 @@ expect (string) o give your command o *then* wait for the prompt. - Thus the last thing that a procedure does with the serial line - will be an expect_prompt(). Exception: e7000_resume does not - wait for the prompt, because the terminal is being handed over - to the inferior. However, the next thing which happens after that - is a e7000_wait which does wait for the prompt. - Note that this includes abnormal exit, e.g. error(). This is - necessary to prevent getting into states from which we can't - recover. */ + Thus the last thing that a procedure does with the serial line will + be an expect_prompt(). Exception: e7000_resume does not wait for + the prompt, because the terminal is being handed over to the + inferior. However, the next thing which happens after that is a + e7000_wait which does wait for the prompt. Note that this includes + abnormal exit, e.g. error(). This is necessary to prevent getting + into states from which we can't recover. */ + static void expect_prompt () { expect (":"); } + static void expect_full_prompt () { - expect ("\n:"); + expect ("\r:"); } static int -get_hex_digit (ch) +convert_hex_digit (ch) + int ch; { if (ch >= '0' && ch <= '9') return ch - '0'; @@ -223,20 +305,17 @@ get_hex_digit (ch) else if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10; return -1; - } - - static int get_hex (start) int *start; { - int value = get_hex_digit (*start); + int value = convert_hex_digit (*start); int try; *start = readchar (timeout); - while ((try = get_hex_digit (*start)) >= 0) + while ((try = convert_hex_digit (*start)) >= 0) { value <<= 4; value += try; @@ -245,8 +324,9 @@ get_hex (start) return value; } -/* Get N 32-bit words from remote, each preceded by a space, - and put them in registers starting at REGNO. */ +#if 0 +/* Get N 32-bit words from remote, each preceded by a space, and put + them in registers starting at REGNO. */ static void get_hex_regs (n, regno) @@ -266,9 +346,11 @@ get_hex_regs (n, regno) supply_register (regno++, (char *) &val); } } +#endif /* This is called not only when we first attach, but also when the user types "run" after having attached. */ + static void e7000_create_inferior (execfile, args, env) char *execfile; @@ -308,8 +390,8 @@ e7000_create_inferior (execfile, args, env) proceed ((CORE_ADDR) entry_pt, -1, 0); /* Let 'er rip... */ } -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ +/* Open a connection to a remote debugger. NAME is the filename used + for communication. */ static int baudrate = 9600; static char dev_name[100]; @@ -320,6 +402,7 @@ static char *passwd = ""; static char *dir = ""; /* Grab the next token and buy some space for it */ + static char * next (ptr) char **ptr; @@ -328,10 +411,9 @@ next (ptr) char *s; char *r; int l = 0; + while (*p && *p == ' ') - { - p++; - } + p++; s = p; while (*p && (*p != ' ' && *p != '\t')) { @@ -345,8 +427,8 @@ next (ptr) return r; } -static -e7000_login (args, from_tty) +static void +e7000_login_command (args, from_tty) char *args; int from_tty; { @@ -369,26 +451,34 @@ e7000_login (args, from_tty) /* Start an ftp transfer from the E7000 to a host */ -static -e7000_ftp (args, from_tty) +static void +e7000_ftp_command (args, from_tty) char *args; int from_tty; { + /* FIXME: arbitrary limit on machine names and such. */ + char buf[200]; + int oldtimeout = timeout; timeout = 10; - printf_e7000debug ("ftp %s\r", machine); + + sprintf (buf, "ftp %s\r", machine); + puts_e7000debug (buf); expect (" Username : "); - printf_e7000debug ("%s\r", user); + sprintf (buf, "%s\r", user); + puts_e7000debug (buf); expect (" Password : "); write_e7000 (passwd); write_e7000 ("\r"); expect ("success\r"); expect ("FTP>"); - printf_e7000debug ("cd %s\r", dir); + sprintf (buf, "cd %s\r", dir); + puts_e7000debug (buf); expect ("FTP>"); - printf_e7000debug ("ll 0;s:%s\r", args); + sprintf (buf, "ll 0;s:%s\r", args); + puts_e7000debug (buf); expect ("FTP>"); - printf_e7000debug ("bye\r"); + puts_e7000debug ("bye\r"); expect (":"); timeout = oldtimeout; } @@ -399,46 +489,65 @@ e7000_open (args, from_tty) int from_tty; { int n; + int loop; char junk[100]; int sync; target_preopen (from_tty); - if (args) - n = sscanf (args, " %s %d %s", dev_name, &baudrate, junk); - else - n = 0; - if (n != 1 && n != 2) - error ("Bad arguments. Usage:\ttarget e7000 <device> <speed>\n\ -or \t\ttarget e7000 <host>[:<port>]\n"); - - if (n == 1 && strchr (dev_name, ':') == 0) + n = 0; + if (args && strcasecmp (args, "pc") == 0) + { + strcpy (dev_name, args); + } + else { - /* Default to normal telnet port */ - strcat (dev_name, ":23"); + if (args) + { + n = sscanf (args, " %s %d %s", dev_name, &baudrate, junk); + } + + if (n != 1 && n != 2) + { + error ("Bad arguments. Usage:\ttarget e7000 <device> <speed>\n\ +or \t\ttarget e7000 <host>[:<port>]\n\ +or \t\ttarget e7000 pc\n"); + } + +#ifndef __GO32__ + if (n == 1 && strchr (dev_name, ':') == 0) + { + /* Default to normal telnet port */ + strcat (dev_name, ":23"); + } +#endif } push_target (&e7000_ops); - e7000_desc = SERIAL_OPEN (dev_name); + e7000_desc = SERIAL_OPEN (dev_name); if (!e7000_desc) perror_with_name (dev_name); using_tcp = strcmp (e7000_desc->ops->name, "tcp") == 0; + using_pc = strcmp (e7000_desc->ops->name, "pc") == 0; SERIAL_SETBAUDRATE (e7000_desc, baudrate); SERIAL_RAW (e7000_desc); /* Hello? Are you there? */ sync = 0; + loop = 0; putchar_e7000 (CTRLC); while (!sync) { int c; + if (from_tty) printf_unfiltered ("[waiting for e7000...]\n"); - write_e7000 ("\r\n"); - c = SERIAL_READCHAR (e7000_desc, 3); + + write_e7000 ("\r"); + c = SERIAL_READCHAR (e7000_desc, 1); while (c != SERIAL_TIMEOUT) { /* Dont echo cr's */ @@ -448,18 +557,27 @@ or \t\ttarget e7000 <host>[:<port>]\n"); fflush (stdout); } if (c == ':') + sync = 1; + + if (loop++ == 20) { - sync = 1; + putchar_e7000 (CTRLC); + loop = 0; } - c = SERIAL_READCHAR (e7000_desc, 3); + + QUIT ; + + if (quit_flag) { putchar_e7000 (CTRLC); quit_flag = 0; } + c = SERIAL_READCHAR (e7000_desc, 1); } } - printf_e7000debug ("\r\n"); + puts_e7000debug ("\r"); + expect_prompt (); if (from_tty) @@ -484,9 +602,9 @@ e7000_close (quitting) } } -/* Terminate the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ +/* Terminate the open connection to the remote debugger. Use this + when you want to detach and do something else with your gdb. */ + static void e7000_detach (from_tty) int from_tty; @@ -503,31 +621,26 @@ e7000_resume (pid, step, sig) int pid, step, sig; { if (step) - { - printf_e7000debug ("S\r"); - } + puts_e7000debug ("S\r"); else - { - printf_e7000debug ("G\r"); - } + puts_e7000debug ("G\r"); } /* Read the remote registers into the block REGS. For the H8/300 a register dump looks like: - - PC=00021A CCR=80:I******* - ER0 - ER3 0000000A 0000002E 0000002E 00000000 - ER4 - ER7 00000000 00000000 00000000 00FFEFF6 - 000218 MOV.B R1L,R2L - STEP NORMAL END or - BREAK POINT - */ + PC=00021A CCR=80:I******* + ER0 - ER3 0000000A 0000002E 0000002E 00000000 + ER4 - ER7 00000000 00000000 00000000 00FFEFF6 + 000218 MOV.B R1L,R2L + STEP NORMAL END or + BREAK POINT + */ #ifdef GDB_TARGET_IS_H8300 -char *want = "\n\ - PC=%p CCR=%c\n\ + +char *want = "PC=%p CCR=%c\n\ ER0 - ER3 %0 %1 %2 %3\n\ ER4 - ER7 %4 %5 %6 %7\n"; @@ -535,14 +648,15 @@ char *want_nopc = "%p CCR=%c\n\ ER0 - ER3 %0 %1 %2 %3\n\ ER4 - ER7 %4 %5 %6 %7"; - #endif + #ifdef GDB_TARGET_IS_SH -char *want = "\n PC=%16 SR=%22\n\ - PR=%17 GBR=%18 VBR=%19\n\ - MACH=%20 MACL=%21\n\ - R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\ - R8-15 %8 %9 %10 %11 %12 %13 %14 %15\n"; + +char *want = "PC=%16 SR=%22\n\ +PR=%17 GBR=%18 VBR=%19\n\ +MACH=%20 MACL=%21\n\ +R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\ +R8-15 %8 %9 %10 %11 %12 %13 %14 %15\n"; char *want_nopc = "%16 SR=%22\n\ PR=%17 GBR=%18 VBR=%19\n\ @@ -550,31 +664,29 @@ char *want_nopc = "%16 SR=%22\n\ R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\ R8-15 %8 %9 %10 %11 %12 %13 %14 %15"; - #endif -static -int +static int gch () { int c = readchar (timeout); - if (echo) + + if (remote_debug) { if (c >= ' ') printf ("%c", c); else if (c == '\n') - printf ("\n", c); + printf ("\n"); } return c; } - -static -unsigned int +static unsigned int gbyte () { - int high = get_hex_digit (gch ()); - int low = get_hex_digit (gch ()); + int high = convert_hex_digit (gch ()); + int low = convert_hex_digit (gch ()); + return (high << 4) + low; } @@ -586,24 +698,27 @@ fetch_regs_from_dump (nextchar, want) int regno; char buf[MAX_REGISTER_RAW_SIZE]; - int thischar = nextchar(); - + int thischar = nextchar (); + while (*want) { switch (*want) { case '\n': - while (thischar != '\n') - thischar = nextchar(); - thischar = nextchar(); - while (thischar == '\r') - thischar = nextchar(); + /* Skip to end of line and then eat all new line type stuff */ + while (thischar != '\n' && thischar != '\r') + thischar = nextchar (); + while (thischar == '\n' || thischar == '\r') + thischar = nextchar (); want++; break; case ' ': - while (thischar == ' ' || thischar == '\t' || thischar == '\r' || thischar == '\n') - thischar = nextchar(); + while (thischar == ' ' + || thischar == '\t' + || thischar == '\r' + || thischar == '\n') + thischar = nextchar (); want++; break; @@ -612,15 +727,16 @@ fetch_regs_from_dump (nextchar, want) { want++; if (*want) - thischar = nextchar(); + thischar = nextchar (); } - else if (thischar == ' ') + else if (thischar == ' ' || thischar == '\n' || thischar == '\r') { - thischar = nextchar(); + thischar = nextchar (); } else { - error("out of sync in fetch registers"); + error ("out of sync in fetch registers wanted <%s>, got <%c 0x%x>", + want, thischar, thischar); } break; @@ -654,14 +770,13 @@ fetch_regs_from_dump (nextchar, want) break; #endif - default: - if (isdigit(want[0])) + if (isdigit (want[0])) { - if (isdigit(want[1])) + if (isdigit (want[1])) { regno = (want[0] - '0') * 10 + want[1] - '0'; - want+=2; + want += 2; } else { @@ -671,11 +786,11 @@ fetch_regs_from_dump (nextchar, want) } else - abort(); + abort (); } store_signed_integer (buf, REGISTER_RAW_SIZE(regno), - (LONGEST)get_hex(&thischar, nextchar)); + (LONGEST) get_hex (&thischar, nextchar)); supply_register (regno, buf); break; } @@ -687,22 +802,22 @@ e7000_fetch_registers () { int regno; - printf_e7000debug ("R\r"); + puts_e7000debug ("R\r"); fetch_regs_from_dump (gch, want); /* And supply the extra ones the simulator uses */ for (regno = NUM_REALREGS; regno < NUM_REGS; regno++) { int buf = 0; + supply_register (regno, (char *) (&buf)); } } -/* Fetch register REGNO, or all registers if REGNO is -1. - Returns errno value. */ +/* Fetch register REGNO, or all registers if REGNO is -1. Returns + errno value. */ -static -void +static void e7000_fetch_register (regno) int regno; { @@ -722,80 +837,84 @@ e7000_store_registers () registers_changed (); } -/* Store register REGNO, or all if REGNO == 0. - Return errno value. */ +/* Store register REGNO, or all if REGNO == 0. Return errno value. */ + static void e7000_store_register (regno) int regno; { + char buf[200]; + if (regno == -1) { e7000_store_registers (); return; } + #ifdef GDB_TARGET_IS_H8300 if (regno <= 7) { - printf_e7000debug (".ER%d %x\r", regno, - read_register (regno)); - + sprintf (buf, ".ER%d %x\r", regno, read_register (regno)); + puts_e7000debug (buf); } else if (regno == PC_REGNUM) { - printf_e7000debug (".PC %x\r", - read_register (regno)); + sprintf (buf, ".PC %x\r", read_register (regno)); + puts_e7000debug (buf); } else if (regno == CCR_REGNUM) { - printf_e7000debug (".CCR %x\r", - read_register (regno)); + sprintf (buf, ".CCR %x\r", read_register (regno)); + puts_e7000debug (buf); } -#endif +#endif /* GDB_TARGET_IS_H8300 */ #ifdef GDB_TARGET_IS_SH switch (regno) { default: - printf_e7000debug (".R%d %x\r", regno, - read_register (regno)); - + sprintf (buf, ".R%d %x\r", regno, read_register (regno)); + puts_e7000debug (buf); break; + case PC_REGNUM: - printf_e7000debug (".PC %x\r", - read_register (regno)); + sprintf (buf, ".PC %x\r", read_register (regno)); + puts_e7000debug (buf); break; + case SR_REGNUM: - printf_e7000debug (".SR %x\r", - read_register (regno)); + sprintf (buf, ".SR %x\r", read_register (regno)); + puts_e7000debug (buf); break; case PR_REGNUM: - printf_e7000debug (".PR %x\r", - read_register (regno)); + sprintf (buf, ".PR %x\r", read_register (regno)); + puts_e7000debug (buf); break; case GBR_REGNUM: - printf_e7000debug (".GBR %x\r", - read_register (regno)); + sprintf (buf, ".GBR %x\r", read_register (regno)); + puts_e7000debug (buf); break; case VBR_REGNUM: - printf_e7000debug (".VBR %x\r", - read_register (regno)); + sprintf (buf, ".VBR %x\r", read_register (regno)); + puts_e7000debug (buf); break; case MACH_REGNUM: - printf_e7000debug (".MACH %x\r", - read_register (regno)); + sprintf (buf, ".MACH %x\r", read_register (regno)); + puts_e7000debug (buf); break; case MACL_REGNUM: - printf_e7000debug (".MACL %x\r", - read_register (regno)); + sprintf (buf, ".MACL %x\r", read_register (regno)); + puts_e7000debug (buf); break; } -#endif +#endif /* GDB_TARGET_IS_SH */ + expect_prompt (); } @@ -814,23 +933,24 @@ e7000_prepare_to_store () static void e7000_files_info () { - printf ("\tAttached to %s at %d baud.\n", - dev_name, baudrate); + printf ("\tAttached to %s at %d baud.\n", dev_name, baudrate); } -static -int +static int stickbyte (where, what) char *where; unsigned int what; { static CONST char digs[] = "0123456789ABCDEF"; + where[0] = digs[(what >> 4) & 0xf]; where[1] = digs[(what & 0xf) & 0xf]; + return what; } -/* Write a small ammount of memory */ +/* Write a small ammount of memory. */ + static int write_small (memaddr, myaddr, len) CORE_ADDR memaddr; @@ -838,30 +958,34 @@ write_small (memaddr, myaddr, len) int len; { int i; + char buf[200]; + for (i = 0; i < len; i++) { - if (((memaddr + i) & 3) == 0 - && (i + 3 < len)) + if (((memaddr + i) & 3) == 0 && (i + 3 < len)) { /* Can be done with a long word */ - printf_e7000debug ("m %x %x%02x%02x%02x;l\r", - memaddr + i, - myaddr[i], - myaddr[i + 1], - myaddr[i + 2], - myaddr[i + 3]); + sprintf (buf, "m %x %x%02x%02x%02x;l\r", + memaddr + i, + myaddr[i], myaddr[i + 1], myaddr[i + 2], myaddr[i + 3]); + puts_e7000debug (buf); i += 3; } else { - printf_e7000debug ("m %x %x\r", memaddr + i, myaddr[i]); + sprintf (buf, "m %x %x\r", memaddr + i, myaddr[i]); + puts_e7000debug (buf); } } + expect_prompt (); + return len; } -/* Write a large ammount of memory, this only works with the serial mode enabled. - Command is sent as + +/* Write a large ammount of memory, this only works with the serial + mode enabled. Command is sent as + il ;s:s\r -> <- il ;s:s\r <- ENQ @@ -872,7 +996,7 @@ write_small (memaddr, myaddr, len) <- ENQ ACK -> <- : - */ + */ static int write_large (memaddr, myaddr, len) @@ -881,14 +1005,14 @@ write_large (memaddr, myaddr, len) int len; { int i; - int c; #define maxstride 128 int stride; - printf_e7000debug ("IL ;S:FK\r"); + puts_e7000debug ("IL ;S:FK\r"); expect (ENQSTRING); putchar_e7000 (ACK); expect ("LO FK\r"); + for (i = 0; i < len; i += stride) { char compose[maxstride * 2 + 50]; @@ -897,6 +1021,7 @@ write_large (memaddr, myaddr, len) int check_sum; int where = 0; int alen; + stride = len - i; if (stride > maxstride) stride = maxstride; @@ -904,17 +1029,15 @@ write_large (memaddr, myaddr, len) compose[where++] = 'S'; check_sum = 0; if (address >= 0xffffff) - { - alen = 4; - } + alen = 4; else if (address >= 0xffff) - { - alen = 3; - } + alen = 3; else alen = 2; - compose[where++] = alen - 1 + '0'; /* insert type */ - check_sum += stickbyte (compose + where, alen + stride + 1); /* Insert length */ + /* Insert type. */ + compose[where++] = alen - 1 + '0'; + /* Insert length. */ + check_sum += stickbyte (compose + where, alen + stride + 1); where += 2; while (alen > 0) { @@ -928,81 +1051,69 @@ write_large (memaddr, myaddr, len) check_sum += stickbyte (compose + where, myaddr[i + j]); where += 2; } - stickbyte (compose + where, ~check_sum); - where += 2; compose[where++] = '\r'; compose[where++] = '\n'; compose[where++] = 0; - { - char *z; - for (z = compose; *z; z++) ; + + SERIAL_WRITE (e7000_desc, compose, where); + j = SERIAL_READCHAR (e7000_desc, 0); + if (j == SERIAL_TIMEOUT) { - SERIAL_WRITE (e7000_desc, compose, where); - j = SERIAL_READCHAR (e7000_desc, 0); - if (j == SERIAL_TIMEOUT) - { - /* This is ok - nothing there */ - } - else if (j == ENQ) - { - /* Hmm, it's trying to tell us something */ - expect (":"); - error ("Error writing memory"); - } - else + /* This is ok - nothing there */ + } + else if (j == ENQ) + { + /* Hmm, it's trying to tell us something */ + expect (":"); + error ("Error writing memory"); + } + else + { + printf ("@%d}@", j); + while ((j = SERIAL_READCHAR(e7000_desc,0)) > 0) { - printf ("@%d}@", j); - while ((j = SERIAL_READCHAR(e7000_desc,0)) > 0) - { - printf ("@{%d}@",j); - } + printf ("@{%d}@",j); } } - } } + /* Send the trailer record */ write_e7000 ("S70500000000FA\r"); putchar_e7000 (CTRLZ); expect (ENQSTRING); putchar_e7000 (ACK); expect (":"); + return len; } -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns length moved. +/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's + memory at MEMADDR. Returns length moved. + + Can't use the Srecord load over ethernet, so don't use fast method + then. */ - Can't use the Srecord load over ethernet, so dont use - fast method then. - */ static int e7000_write_inferior_memory (memaddr, myaddr, len) CORE_ADDR memaddr; unsigned char *myaddr; int len; { - if (len < 16 || using_tcp) - { - return write_small (memaddr, myaddr, len); - } + if (len < 16 || using_tcp || using_pc) + return write_small (memaddr, myaddr, len); else - { - return write_large (memaddr, myaddr, len); - } + return write_large (memaddr, myaddr, len); } - /* Read LEN bytes from inferior memory at MEMADDR. Put the result at debugger address MYADDR. Returns length moved. - Small transactions we send m <addr>;l and receive 00000000 12345678 ? - */ static int @@ -1014,30 +1125,33 @@ e7000_read_inferior_memory (memaddr, myaddr, len) int count; int c; int i; + char buf[200]; /* Starting address of this pass. */ +/* printf("READ INF %x %x %d\n", memaddr, myaddr, len);*/ if (((memaddr - 1) + len) < memaddr) { errno = EIO; return 0; } - printf_e7000debug ("m %x;l\r", memaddr); + sprintf (buf, "m %x;l\r", memaddr); + puts_e7000debug (buf); for (count = 0; count < len; count += 4) { /* Suck away the address */ - c = gch(); + c = gch (); while (c != ' ') - c = gch(); - c = gch(); + c = gch (); + c = gch (); if (c == '*') { /* Some kind of error */ expect_prompt(); return -1; } while (c != ' ') - c = gch(); + c = gch (); /* Now read in the data */ for (i = 0; i < 4; i++) @@ -1049,14 +1163,16 @@ e7000_read_inferior_memory (memaddr, myaddr, len) } /* Skip the trailing ? and send a . to end and a cr for more */ - gch(); - gch(); + gch (); + gch (); if (count + 4 >= len) - printf_e7000debug(".\r"); + puts_e7000debug(".\r"); else - printf_e7000debug("\r"); + puts_e7000debug("\r"); + } expect_prompt(); + return len; } @@ -1075,7 +1191,6 @@ e7000_read_inferior_memory (memaddr, myaddr, len) A cost in chars for each transaction of 80 + 5*n-bytes. - Large transactions could be done with the srecord load code, but there is a pause for a second before dumping starts, which slows the average rate down! @@ -1089,6 +1204,7 @@ e7000_read_inferior_memory (memaddr, myaddr, len) { int count; int c; + char buf[200]; /* Starting address of this pass. */ @@ -1098,7 +1214,8 @@ e7000_read_inferior_memory (memaddr, myaddr, len) return 0; } - printf_e7000debug ("d %x %x\r", memaddr, memaddr + len - 1); + sprintf (buf, "d %x %x\r", memaddr, memaddr + len - 1); + puts_e7000debug (buf); count = 0; c = gch (); @@ -1156,6 +1273,7 @@ fast_but_for_the_pause_e7000_read_inferior_memory (memaddr, myaddr, len) { int loop; int c; + char buf[200]; if (((memaddr - 1) + len) < memaddr) { @@ -1163,7 +1281,8 @@ fast_but_for_the_pause_e7000_read_inferior_memory (memaddr, myaddr, len) return 0; } - printf_e7000debug ("is %x@%x:s\r", memaddr, len); + sprintf (buf, "is %x@%x:s\r", memaddr, len); + puts_e7000debug (buf); gch (); c = gch (); if (c != ENQ) @@ -1180,6 +1299,7 @@ fast_but_for_the_pause_e7000_read_inferior_memory (memaddr, myaddr, len) int length; int addr; int i; + c = gch (); switch (c) { @@ -1207,6 +1327,7 @@ fast_but_for_the_pause_e7000_read_inferior_memory (memaddr, myaddr, len) case '3': { int alen; + alen = type - '0' + 1; addr = 0; while (alen--) @@ -1216,14 +1337,14 @@ fast_but_for_the_pause_e7000_read_inferior_memory (memaddr, myaddr, len) } for (i = 0; i < length - 1; i++) - { - myaddr[i + addr - memaddr] = gbyte (); - } + myaddr[i + addr - memaddr] = gbyte (); + gbyte (); /* Ignore checksum */ } } } } + putchar_e7000 (ACK); expect ("TOP ADDRESS ="); expect ("END ADDRESS ="); @@ -1243,13 +1364,9 @@ e7000_xfer_inferior_memory (memaddr, myaddr, len, write, target) struct target_ops *target; /* ignored */ { if (write) - { - return e7000_write_inferior_memory( memaddr, myaddr, len); - } + return e7000_write_inferior_memory( memaddr, myaddr, len); else - { - return e7000_read_inferior_memory( memaddr, myaddr, len); - } + return e7000_read_inferior_memory( memaddr, myaddr, len); } static void @@ -1257,7 +1374,6 @@ e7000_kill (args, from_tty) char *args; int from_tty; { - } /* Clean up when a program exits. @@ -1274,11 +1390,15 @@ e7000_mourn_inferior () generic_mourn_inferior (); /* Do all the proper things now */ } +#ifdef HARD_BREAKPOINTS +#define MAX_E7000DEBUG_BREAKPOINTS (BC_BREAKPOINTS ? 5 : 200) +#else #define MAX_E7000DEBUG_BREAKPOINTS 200 +#endif extern int memory_breakpoint_size; -static CORE_ADDR breakaddr[MAX_E7000DEBUG_BREAKPOINTS] = -{0}; + +static CORE_ADDR breakaddr[MAX_E7000DEBUG_BREAKPOINTS] = {0}; static int e7000_insert_breakpoint (addr, shadow) @@ -1286,6 +1406,7 @@ e7000_insert_breakpoint (addr, shadow) unsigned char *shadow; { int i; + char buf[200]; static char nop[2] = NOP; for (i = 0; i <= MAX_E7000DEBUG_BREAKPOINTS; i++) @@ -1293,14 +1414,30 @@ e7000_insert_breakpoint (addr, shadow) { breakaddr[i] = addr; /* Save old contents, and insert a nop in the space */ +#ifdef HARD_BREAKPOINTS + if (BC_BREAKPOINTS) + { + sprintf (buf, "BC%d A=%x\r", i+1, addr); + puts_e7000debug (buf); + } + else + { + sprintf (buf, "B %x\r", addr); + puts_e7000debug (buf); + } +#else e7000_read_inferior_memory (addr, shadow, 2); e7000_write_inferior_memory (addr, nop, 2); - printf_e7000debug ("B %x\r", addr); + + sprintf (buf, "B %x\r", addr); + puts_e7000debug (buf); +#endif expect_prompt (); return 0; } - error("Too many breakpoints ( > %d) for the E7000\n", MAX_E7000DEBUG_BREAKPOINTS); + error ("Too many breakpoints ( > %d) for the E7000\n", + MAX_E7000DEBUG_BREAKPOINTS); return 1; } @@ -1310,48 +1447,74 @@ e7000_remove_breakpoint (addr, shadow) unsigned char *shadow; { int i; + char buf[200]; for (i = 0; i < MAX_E7000DEBUG_BREAKPOINTS; i++) if (breakaddr[i] == addr) { breakaddr[i] = 0; - printf_e7000debug ("B - %x\r", addr); +#ifdef HARD_BREAKPOINTS + if (BC_BREAKPOINTS) + { + sprintf (buf, "BC%d - \r", i+1); + puts_e7000debug (buf); + } + else + { + sprintf (buf, "B - %x\r", addr); + puts_e7000debug (buf); + } expect_prompt (); +#else + sprintf (buf, "B - %x\r", addr); + puts_e7000debug (buf); + expect_prompt (); + /* Replace the insn under the break */ e7000_write_inferior_memory (addr, shadow, 2); +#endif + return 0; } - fprintf (stderr, "Can't find breakpoint associated with 0x%x\n", addr); + warning ("Can't find breakpoint associated with 0x%x\n", addr); return 1; } - -/* Put a command string, in args, out to STDBUG. Output from STDBUG is placed - on the users terminal until the prompt is seen. */ +/* Put a command string, in args, out to STDBUG. Output from STDBUG + is placed on the users terminal until the prompt is seen. */ static void e7000_command (args, fromtty) char *args; int fromtty; { + /* FIXME: arbitrary limit on length of args. */ + char buf[200]; + + echo = 0; if (!e7000_desc) error ("e7000 target not open."); if (!args) { - printf_e7000debug ("\r"); + puts_e7000debug ("\r"); } else { - printf_e7000debug ("%s\r", args); + sprintf (buf, "%s\r", args); + puts_e7000debug (buf); } + echo++; ctrl_c = 2; expect_full_prompt (); echo--; ctrl_c = 0; printf_unfiltered ("\n"); + + /* Who knows what the command did... */ + registers_changed (); } static void @@ -1363,17 +1526,19 @@ e7000_load (args, fromtty) } static void -e7000_drain (args, fromtty) +e7000_drain_command (args, fromtty) char *args; int fromtty; { int c; - printf_e7000debug("end\r"); + + puts_e7000debug("end\r"); putchar_e7000 (CTRLC); + while ((c = SERIAL_READCHAR (e7000_desc, 1) != SERIAL_TIMEOUT)) { - if(quit_flag) + if (quit_flag) { putchar_e7000(CTRLC); quit_flag = 0; @@ -1385,36 +1550,30 @@ e7000_drain (args, fromtty) } } -e7000_noecho () -{ - echo = !echo; - if (echo) - printf_filtered ("Snoop enabled\n"); - else - printf_filtered ("Snoop disabled\n"); +#define NITEMS 7 -} - -#define NITEMS 3 static int why_stop () { - static char *strings[NITEMS] = - { - "STEP NORMAL", - "BREAK POINT", - "BREAK KEY", - }; + static char *strings[NITEMS] = { + "STEP NORMAL", + "BREAK POINT", + "BREAK KEY", + "BREAK CONDI", + "CYCLE ACCESS", + "ILLEGAL INSTRUCTION", + "WRITE PROTECT", + }; char *p[NITEMS]; int c; - p[0] = strings[0]; - p[1] = strings[1]; - p[2] = strings[2]; + int i; + + for (i = 0; i < NITEMS; ++i) + p[i] = strings[i]; - c = gch(); + c = gch (); while (1) { - int i; for (i = 0; i < NITEMS; i++) { if (c == *(p[i])) @@ -1426,18 +1585,19 @@ why_stop () return i; } } - else { + else p[i] = strings[i]; - } } - c = gch(); + c = gch (); } } + /* Suck characters, if a string match, then return the strings index - otherwise echo them */ + otherwise echo them. */ + int -expect_n ( strings) +expect_n (strings) char **strings; { char *(ptr[10]); @@ -1447,120 +1607,132 @@ char **strings; char *buffer = saveaway; /* Count number of expect strings */ - for (n =0; strings[n]; n++) + for (n = 0; strings[n]; n++) { ptr[n] = strings[n]; } - while (1) { - int i; - int gotone = 0; + while (1) + { + int i; + int gotone = 0; - c = SERIAL_READCHAR (e7000_desc, 1); - if (c == SERIAL_TIMEOUT) { - printf_unfiltered ("[waiting for e7000...]\n"); - } + c = SERIAL_READCHAR (e7000_desc, 1); + if (c == SERIAL_TIMEOUT) + { + printf_unfiltered ("[waiting for e7000...]\n"); + } #ifdef __GO32__ - if (kbhit()) - { - int k = getkey(); - if (k == 1) - quit_flag = 1; - } -#endif - - if (quit_flag) - { - putchar_e7000 (CTRLC); /* interrupt the running program */ - quit_flag = 0; - } + if (kbhit ()) + { + int k = getkey(); - for (i = 0; i < n; i++) - { - if (c == ptr[i][0]) - { - ptr[i]++; - if (ptr[i][0] == 0) - { - /* Gone all the way */ - return i; - } - gotone = 1; - } - else - { - ptr[i] = strings[i]; - } - } + if (k == 1) + quit_flag = 1; + } +#endif + if (quit_flag) + { + putchar_e7000 (CTRLC); /* interrupt the running program */ + quit_flag = 0; + } + for (i = 0; i < n; i++) + { + if (c == ptr[i][0]) + { + ptr[i]++; + if (ptr[i][0] == 0) + { + /* Gone all the way */ + return i; + } + gotone = 1; + } + else + { + ptr[i] = strings[i]; + } + } - if (gotone) - { - /* Save it up incase we find that there was no match */ - *buffer ++ = c; - } - else - { - if (buffer != saveaway) - { - *buffer++ = 0; - printf(buffer); - buffer = saveaway; - } - if (c != SERIAL_TIMEOUT) { - putchar (c); - fflush(stdout); + if (gotone) + { + /* Save it up incase we find that there was no match */ + *buffer ++ = c; } - } - } + else + { + if (buffer != saveaway) + { + *buffer++ = 0; + printf ("%s", buffer); + buffer = saveaway; + } + if (c != SERIAL_TIMEOUT) + { + putchar (c); + fflush (stdout); + } + } + } } -/* We subtract two from the pc here rather than use DECR_PC_AFTER_BREAK - since the e7000 doesn't always add two to the pc, and the simulators never do. */ +/* We subtract two from the pc here rather than use + DECR_PC_AFTER_BREAK since the e7000 doesn't always add two to the + pc, and the simulators never do. */ static void -sub2_from_pc() +sub2_from_pc () { char buf[4]; + char buf2[200]; + store_signed_integer (buf, REGISTER_RAW_SIZE(PC_REGNUM), read_register (PC_REGNUM) -2); supply_register (PC_REGNUM, buf); - printf_e7000debug (".PC %x\r", read_register (PC_REGNUM)); + sprintf (buf2, ".PC %x\r", read_register (PC_REGNUM)); + puts_e7000debug (buf2); } + #define WAS_SLEEP 0 #define WAS_INT 1 #define WAS_RUNNING 2 #define WAS_OTHER 3 -static char *estrings[] = { "** SLEEP", "BREAK !", "** PC", "PC", 0}; -/* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ +static char *estrings[] = { + "** SLEEP", + "BREAK !", + "** PC", + "PC", + NULL +}; + +/* Wait until the remote machine stops, then return, storing status in + STATUS just as `wait' would. */ static int e7000_wait (pid, status) int pid; - WAITTYPE *status; + struct target_waitstatus *status; { - int c; - int reset_pc; + int stop_reason; int regno; int running_count = 0; int had_sleep = 0; int loop = 1; - char *reg; - int time = 0; - WSETSTOP ((*status), 0); + /* Then echo chars until PC= string seen */ gch (); /* Drop cr */ gch (); /* and space */ + while (loop) { - switch (expect_n(estrings)) + switch (expect_n (estrings)) { case WAS_OTHER: /* how did this happen ? */ - loop =0; + loop = 0; break; case WAS_SLEEP: had_sleep = 1; @@ -1578,10 +1750,14 @@ e7000_wait (pid, status) running_count = 0; } break; + default: + /* error? */ + break; } } - /* Skip till the PC=*/ - expect("="); + + /* Skip till the PC= */ + expect ("="); fetch_regs_from_dump (gch, want_nopc); /* And supply the extra ones the simulator uses */ @@ -1591,36 +1767,56 @@ e7000_wait (pid, status) supply_register (regno, (char *) &buf); } - reset_pc = why_stop (); + stop_reason = why_stop (); expect_full_prompt (); - switch (reset_pc) + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = TARGET_SIGNAL_TRAP; + + switch (stop_reason) { case 1: /* Breakpoint */ - - WSETSTOP ((*status), SIGTRAP); + status->value.sig = TARGET_SIGNAL_TRAP; break; - case 0: - /* Single step */ - WSETSTOP ((*status), SIGTRAP); + case 0: /* Single step */ + status->value.sig = TARGET_SIGNAL_TRAP; break; - case 2: - /* Interrupt */ + case 2: /* Interrupt */ if (had_sleep) { - sub2_from_pc(); - WSETSTOP ((*status), SIGTRAP); + status->value.sig = TARGET_SIGNAL_TRAP; + sub2_from_pc (); } else { - WSETSTOP ((*status), SIGINT); + status->value.sig = TARGET_SIGNAL_INT; } break; + case 3: + break; + case 4: + printf_unfiltered ("a cycle address error?\n"); + status->value.sig = TARGET_SIGNAL_UNKNOWN; + break; + case 5: + status->value.sig = TARGET_SIGNAL_ILL; + break; + case 6: + status->value.sig = TARGET_SIGNAL_SEGV; + break; + case 7: /* Anything else (NITEMS + 1) */ + printf_unfiltered ("a write protect error?\n"); + status->value.sig = TARGET_SIGNAL_UNKNOWN; + break; + default: + /* Get the user's attention - this should never happen. */ + abort (); } + return 0; } -/* Define the target subroutine names */ +/* Define the target subroutine names. */ struct target_ops e7000_ops = { @@ -1633,40 +1829,47 @@ the speed to connect at in bits per second.\n\ eg\n\ target e7000 /dev/ttya 9600\n\ target e7000 foobar", - e7000_open, - e7000_close, - 0, - e7000_detach, - e7000_resume, - e7000_wait, - e7000_fetch_register, - e7000_store_register, - e7000_prepare_to_store, - e7000_xfer_inferior_memory, - e7000_files_info, -0,0,/* e7000_insert_breakpoint, - e7000_remove_breakpoint, /* Breakpoints */ - 0, - 0, - 0, - 0, - 0, /* Terminal handling */ - e7000_kill, - e7000_load, /* load */ - 0, /* lookup_symbol */ - e7000_create_inferior, - e7000_mourn_inferior, - 0, /* can_run */ - 0, /* notice_signals */ - process_stratum, - 0, /* next */ - 1, - 1, - 1, - 1, - 1, /* all mem, mem, stack, regs, exec */ - 0, - 0, /* Section pointers */ + e7000_open, /* to_open */ + e7000_close, /* to_close */ + 0, /* to_attach */ + e7000_detach, /* to_detach */ + e7000_resume, /* to_resume */ + e7000_wait, /* to_wait */ + e7000_fetch_register, /* to_fetch_registers */ + e7000_store_register, /* to_store_registers */ + e7000_prepare_to_store, /* to_prepare_to_store */ + e7000_xfer_inferior_memory, /* to_xfer_memory */ + e7000_files_info, /* to_files_info */ +#ifdef HARD_BREAKPOINTS + e7000_insert_breakpoint, /* to_insert_breakpoint */ + e7000_remove_breakpoint, /* to_remove_breakpoint */ +#else + memory_insert_breakpoint, /* to_insert_breakpoint */ + memory_remove_breakpoint, /* to_remove_breakpoint */ +#endif + 0, /* to_terminal_init */ + 0, /* to_terminal_inferior */ + 0, /* to_terminal_ours_for_output */ + 0, /* to_terminal_ours */ + 0, /* to_terminal_info */ + e7000_kill, /* to_kill */ + e7000_load, /* to_load */ + 0, /* to_lookup_symbol */ + e7000_create_inferior, /* to_create_inferior */ + e7000_mourn_inferior, /* to_mourn_inferior */ + 0, /* to_can_run */ + 0, /* to_notice_signals */ + 0, /* to_thread_alive */ + 0, /* to_stop */ + process_stratum, /* to_stratum */ + 0, /* next (unused) */ + 1, /* to_has_all_memory */ + 1, /* to_has_memory */ + 1, /* to_has_stack */ + 1, /* to_has_registers */ + 1, /* to_has_execution */ + 0, /* to_sections */ + 0, /* to_sections_end */ OPS_MAGIC, /* Always the last thing */ }; @@ -1674,16 +1877,16 @@ void _initialize_remote_e7000 () { add_target (&e7000_ops); + add_com ("e7000 <command>", class_obscure, e7000_command, "Send a command to the e7000 monitor."); - add_com ("ftplogin <machine> <name> <passwd> <dir>", class_obscure, e7000_login, + add_com ("ftplogin <machine> <name> <passwd> <dir>", class_obscure, e7000_login_command, "Login to machine and change to directory."); - add_com ("ftpload <file>", class_obscure, e7000_ftp, + add_com ("ftpload <file>", class_obscure, e7000_ftp_command, "Fetch and load a file from previously described place."); - add_com ("drain", class_obscure, e7000_drain, + add_com ("drain", class_obscure, e7000_drain_command, "Drain pending e7000 text buffers."); - add_com ("snoop", class_obscure, e7000_noecho, "Toggle monitor echo."); } diff --git a/gdb/remote-eb.c b/gdb/remote-eb.c index 0d9b377..af9f505a4 100644 --- a/gdb/remote-eb.c +++ b/gdb/remote-eb.c @@ -26,7 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ over the net in real time. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "inferior.h" #include "bfd.h" diff --git a/gdb/remote-es.c b/gdb/remote-es.c index bd5e2bc..4aa384f 100644 --- a/gdb/remote-es.c +++ b/gdb/remote-es.c @@ -96,7 +96,7 @@ STP #include <sys/file.h> #include <errno.h> #include <ctype.h> -#include <string.h> +#include "gdb_string.h" #include <setjmp.h> #include <fcntl.h> #include "defs.h" diff --git a/gdb/remote-hms.c b/gdb/remote-hms.c index 0d42aa9..c3c42b8 100644 --- a/gdb/remote-hms.c +++ b/gdb/remote-hms.c @@ -172,7 +172,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya)."; #include "inferior.h" #include "wait.h" #include "value.h" -#include <string.h> +#include "gdb_string.h" #include <ctype.h> #include <fcntl.h> #include <signal.h> diff --git a/gdb/remote-mm.c b/gdb/remote-mm.c index 9b798a8..e66f0c0 100644 --- a/gdb/remote-mm.c +++ b/gdb/remote-mm.c @@ -37,7 +37,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <fcntl.h> #include <signal.h> #include <errno.h> -#include <string.h> +#include "gdb_string.h" #include "terminal.h" #include "minimon.h" #include "target.h" diff --git a/gdb/remote-os9k.c b/gdb/remote-os9k.c index 69cf3e4..23f04eb 100644 --- a/gdb/remote-os9k.c +++ b/gdb/remote-os9k.c @@ -43,7 +43,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <varargs.h> #endif #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <sys/types.h> #include "command.h" #include "serial.h" diff --git a/gdb/remote-pa.c b/gdb/remote-pa.c index f12b8ba..d29ebcd 100644 --- a/gdb/remote-pa.c +++ b/gdb/remote-pa.c @@ -135,7 +135,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ "0* " means the same as "0000". */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <fcntl.h> #include "frame.h" #include "inferior.h" diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 79e5701..0e5a671 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inferior.h" #include "wait.h" #include "value.h" -#include <string.h> +#include "gdb_string.h" #include <ctype.h> #include <fcntl.h> #include <signal.h> diff --git a/gdb/remote-st.c b/gdb/remote-st.c index 50c5678..ffb20b1 100644 --- a/gdb/remote-st.c +++ b/gdb/remote-st.c @@ -44,7 +44,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <varargs.h> #endif #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <sys/types.h> #include "serial.h" diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index a608b56..35fde32 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -40,7 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <fcntl.h> #include <signal.h> #include <errno.h> -#include <string.h> +#include "gdb_string.h" #include "terminal.h" #include "target.h" #include "29k-share/udi/udiproc.h" diff --git a/gdb/remote-utils.c b/gdb/remote-utils.c index ddd5239..b2208ed 100644 --- a/gdb/remote-utils.c +++ b/gdb/remote-utils.c @@ -42,7 +42,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <ctype.h> #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "gdbcmd.h" #include "target.h" #include "serial.h" diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c index f999bf9..5c3e490 100644 --- a/gdb/remote-vx.c +++ b/gdb/remote-vx.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "objfiles.h" #include "gdb-stabs.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/remote-vx29k.c b/gdb/remote-vx29k.c index 5621bce..b489594 100644 --- a/gdb/remote-vx29k.c +++ b/gdb/remote-vx29k.c @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" /* for struct complaint */ -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/remote-vx68.c b/gdb/remote-vx68.c index ed6bbb0..e44005b 100644 --- a/gdb/remote-vx68.c +++ b/gdb/remote-vx68.c @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" /* for struct complaint */ -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/remote-vx960.c b/gdb/remote-vx960.c index b979523..3558f15 100644 --- a/gdb/remote-vx960.c +++ b/gdb/remote-vx960.c @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" /* for struct complaint */ -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/remote-vxmips.c b/gdb/remote-vxmips.c index b88f2ba..bce5f11 100644 --- a/gdb/remote-vxmips.c +++ b/gdb/remote-vxmips.c @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" /* for struct complaint */ -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/remote-vxsparc.c b/gdb/remote-vxsparc.c index fef7125..3648542 100644 --- a/gdb/remote-vxsparc.c +++ b/gdb/remote-vxsparc.c @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" /* for struct complaint */ -#include <string.h> +#include "gdb_string.h" #include <errno.h> #include <signal.h> #include <fcntl.h> diff --git a/gdb/remote.c b/gdb/remote.c index 8e59d4c..103bf15 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -135,6 +135,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ running and the debugger should continue to wait for 'W', 'T', etc. + thread alive TXX Find out if the thread XX is alive. + reply OK thread is still alive + ENN thread is dead + + remote restart RXX Restart the remote server + + extended ops ! Use the extended remote protocol. + Sticky -- only needs to be set once. + kill request k toggle debug d toggle debug flag (see 386 & 68k stubs) @@ -165,7 +174,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ "0* " means the same as "0000". */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include <fcntl.h> #include "frame.h" #include "inferior.h" @@ -213,10 +222,24 @@ static int remote_start_remote PARAMS ((char *dummy)); static void remote_open PARAMS ((char *name, int from_tty)); +static void extended_remote_open PARAMS ((char *name, int from_tty)); + +static void remote_open_1 PARAMS ((char *, int, struct target_ops *)); + static void remote_close PARAMS ((int quitting)); static void remote_store_registers PARAMS ((int regno)); +static void remote_mourn PARAMS ((void)); + +static void extended_remote_restart PARAMS ((void)); + +static void extended_remote_mourn PARAMS ((void)); + +static void extended_remote_create_inferior PARAMS ((char *, char *, char **)); + +static void remote_mourn_1 PARAMS ((struct target_ops *)); + static void getpkt PARAMS ((char *buf, int forever)); static int putpkt PARAMS ((char *buf)); @@ -242,6 +265,7 @@ static void remote_interrupt_twice PARAMS ((int signo)); static void interrupt_query PARAMS ((void)); extern struct target_ops remote_ops; /* Forward decl */ +extern struct target_ops extended_remote_ops; /* Forward decl */ /* This was 5 seconds, which is a long time to sit and wait. Unless this is going though some terminal server or multiplexer or @@ -313,7 +337,7 @@ set_thread (th, gen) cont_thread = th; } -/* Return nonzero if the thread TH is still alive on the remote system. */ +/* Return nonzero if the thread TH is still alive on the remote system. */ static int remote_thread_alive (th) @@ -330,6 +354,25 @@ remote_thread_alive (th) getpkt (buf, 0); return (buf[0] == 'O' && buf[1] == 'K'); } + +/* Restart the remote side; this is an extended protocol operation. */ + +static void +extended_remote_restart () +{ + char buf[PBUFSIZ]; + + /* Send the restart command; for reasons I don't understand the + remote side really expects a number after the "R". */ + buf[0] = 'R'; + sprintf (&buf[1], "%x", 0); + putpkt (buf); + + /* Now query for status so this looks just like we restarted + gdbserver from scratch. */ + putpkt ("?"); + getpkt (buf, 0); +} /* Clean up connection to a remote debugger. */ @@ -420,12 +463,41 @@ remote_start_remote (dummy) /* Open a connection to a remote debugger. NAME is the filename used for communication. */ +static void +remote_open (name, from_tty) + char *name; + int from_tty; +{ + remote_open_1 (name, from_tty, &remote_ops); +} + +/* Open a connection to a remote debugger using the extended + remote gdb protocol. NAME is hte filename used for communication. */ + +static void +extended_remote_open (name, from_tty) + char *name; + int from_tty; +{ + char buf[PBUFSIZ]; + + /* Do the basic remote open stuff. */ + remote_open_1 (name, from_tty, &extended_remote_ops); + + /* Now tell the remote that we're using the extended protocol. */ + putpkt ("!"); + getpkt (buf, 0); + +} + +/* Generic code for opening a connection to a remote target. */ static DCACHE *remote_dcache; static void -remote_open (name, from_tty) +remote_open_1 (name, from_tty, target) char *name; int from_tty; + struct target_ops *target; { if (name == 0) error ("To open a remote debug connection, you need to specify what serial\n\ @@ -433,7 +505,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); target_preopen (from_tty); - unpush_target (&remote_ops); + unpush_target (target); remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes); @@ -463,7 +535,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); puts_filtered (name); puts_filtered ("\n"); } - push_target (&remote_ops); /* Switch to using remote target now */ + push_target (target); /* Switch to using remote target now */ /* Start out by trying the 'P' request to set registers. We set this each time that we open a new target so that if the user switches from one @@ -669,20 +741,21 @@ remote_wait (pid, status) { unsigned char *p1; char *p_temp; + unsigned LONGEST val; - regno = strtol (p, &p_temp, 16); /* Read the register number */ + regno = strtol ((const char *) p, &p_temp, 16); /* Read the register number */ p1 = (unsigned char *)p_temp; if (p1 == p) { - p1 = (unsigned char *) strchr (p, ':'); + p1 = (unsigned char *) strchr ((const char *) p, ':'); if (p1 == NULL) warning ("Malformed packet (missing colon): %s\n\ Packet: '%s'\n", p, buf); - if (strncmp (p, "thread", p1 - p) == 0) + if (strncmp ((const char *) p, "thread", p1 - p) == 0) { - thread_num = strtol (++p1, &p_temp, 16); + thread_num = strtol ((const char *) ++p1, &p_temp, 16); p = (unsigned char *)p_temp; } } @@ -696,17 +769,20 @@ Packet: '%s'\n", p, buf); if (regno >= NUM_REGS) - warning ("Remote sent bad register number %d: %s\n\ + warning ("Remote sent bad register number %ld: %s\n\ Packet: '%s'\n", regno, p, buf); + val = 0L; for (i = 0; i < REGISTER_RAW_SIZE (regno); i++) { if (p[0] == 0 || p[1] == 0) warning ("Remote reply is too short: %s", buf); - regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]); + val = val * 256 + fromhex (p[0]) * 16 + fromhex (p[1]); p += 2; + } + store_unsigned_integer (regs, REGISTER_RAW_SIZE (regno), val); supply_register (regno, regs); } @@ -750,8 +826,8 @@ Packet: '%s'\n", last_sent_signal = TARGET_SIGNAL_0; target_terminal_inferior (); - strcpy (buf, last_sent_step ? "s" : "c"); - putpkt (buf); + strcpy ((char *) buf, last_sent_step ? "s" : "c"); + putpkt ((char *) buf); continue; } /* else fallthrough */ @@ -928,6 +1004,7 @@ remote_store_registers (regno) /* Read a word from remote address ADDR and return it. This goes through the data cache. */ +#if 0 /* unused? */ static int remote_fetch_word (addr) CORE_ADDR addr; @@ -945,6 +1022,7 @@ remote_store_word (addr, word) { dcache_poke (remote_dcache, addr, word); } +#endif /* 0 (unused?) */ /* Write memory data directly to the remote machine. @@ -1403,7 +1481,6 @@ getpkt (buf, forever) char *buf; int forever; { - char *bp; int c; int tries; int timeout; @@ -1502,9 +1579,62 @@ remote_kill () static void remote_mourn () { - unpush_target (&remote_ops); + remote_mourn_1 (&remote_ops); +} + +static void +extended_remote_mourn () +{ + /* We do _not_ want to mourn the target like this; this will + remove the extended remote target from the target stack, + and the next time the user says "run" it'll fail. + + FIXME: What is the right thing to do here? */ +#if 0 + remote_mourn_1 (&extended_remote_ops); +#endif +} + +/* Worker function for remote_mourn. */ +static void +remote_mourn_1 (target) + struct target_ops *target; +{ + unpush_target (target); generic_mourn_inferior (); } + +/* In the extended protocol we want to be able to do things like + "run" and have them basically work as expected. So we need + a special create_inferior function. + + FIXME: One day add support for changing the exec file + we're debugging, arguments and an environment. */ + +static void +extended_remote_create_inferior (exec_file, args, env) + char *exec_file; + char *args; + char **env; +{ + /* Rip out the breakpoints; we'll reinsert them after restarting + the remote server. */ + remove_breakpoints (); + + /* Now restart the remote server. */ + extended_remote_restart (); + + /* Now put the breakpoints back in. This way we're safe if the + restart function works via a unix fork on the remote side. */ + insert_breakpoints (); + + /* Clean up from the last time we were running. */ + clear_proceed_status (); + + /* Let the remote process run. */ + proceed (-1, TARGET_SIGNAL_0, 0); +} + #ifdef REMOTE_BREAKPOINT @@ -1512,9 +1642,6 @@ remote_mourn () than other targets. */ static unsigned char break_insn[] = REMOTE_BREAKPOINT; -/* Check that it fits in BREAKPOINT_MAX bytes. */ -static unsigned char check_break_insn_size[BREAKPOINT_MAX] = REMOTE_BREAKPOINT; - #else /* No REMOTE_BREAKPOINT. */ /* Same old breakpoint instruction. This code does nothing different @@ -1602,8 +1729,55 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */ OPS_MAGIC /* to_magic */ }; +struct target_ops extended_remote_ops = { + "extended-remote", /* to_shortname */ + "Extended remote serial target in gdb-specific protocol",/* to_longname */ + "Use a remote computer via a serial line, using a gdb-specific protocol.\n\ +Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */ + extended_remote_open, /* to_open */ + remote_close, /* to_close */ + NULL, /* to_attach */ + remote_detach, /* to_detach */ + remote_resume, /* to_resume */ + remote_wait, /* to_wait */ + remote_fetch_registers, /* to_fetch_registers */ + remote_store_registers, /* to_store_registers */ + remote_prepare_to_store, /* to_prepare_to_store */ + remote_xfer_memory, /* to_xfer_memory */ + remote_files_info, /* to_files_info */ + + remote_insert_breakpoint, /* to_insert_breakpoint */ + remote_remove_breakpoint, /* to_remove_breakpoint */ + + NULL, /* to_terminal_init */ + NULL, /* to_terminal_inferior */ + NULL, /* to_terminal_ours_for_output */ + NULL, /* to_terminal_ours */ + NULL, /* to_terminal_info */ + remote_kill, /* to_kill */ + generic_load, /* to_load */ + NULL, /* to_lookup_symbol */ + extended_remote_create_inferior,/* to_create_inferior */ + extended_remote_mourn, /* to_mourn_inferior */ + 0, /* to_can_run */ + 0, /* to_notice_signals */ + remote_thread_alive, /* to_thread_alive */ + 0, /* to_stop */ + process_stratum, /* to_stratum */ + NULL, /* to_next */ + 1, /* to_has_all_memory */ + 1, /* to_has_memory */ + 1, /* to_has_stack */ + 1, /* to_has_registers */ + 1, /* to_has_execution */ + NULL, /* sections */ + NULL, /* sections_end */ + OPS_MAGIC /* to_magic */ +}; + void _initialize_remote () { add_target (&remote_ops); + add_target (&extended_remote_ops); } diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 8fac1d8..b2b2d20 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -40,7 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <a.out.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/core.h> #include <sys/ldr.h> diff --git a/gdb/solib.c b/gdb/solib.c index 2548e62..d44156d 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/types.h> #include <signal.h> -#include <string.h> +#include "gdb_string.h" #include <sys/param.h> #include <fcntl.h> #include <unistd.h> diff --git a/gdb/somread.c b/gdb/somread.c index c2ebf14..49aa5de 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -30,7 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "stabsread.h" #include "gdb-stabs.h" #include "complaints.h" -#include <string.h> +#include "gdb_string.h" #include "demangle.h" #include <sys/file.h> diff --git a/gdb/source.c b/gdb/source.c index 7b7aead..e2ceb91 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -27,9 +27,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "frame.h" #include <sys/types.h> -#include <string.h> +#include "gdb_string.h" #include <sys/param.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <fcntl.h> #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/gdb/stabsread.c b/gdb/stabsread.c index ccd7b8e..db80a0d 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -25,7 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Avoid placing any object file format specific code in this file. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "bfd.h" #include "obstack.h" #include "symtab.h" diff --git a/gdb/stack.c b/gdb/stack.c index 71e74ad..5bde58e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -18,7 +18,7 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <string.h> +#include "gdb_string.h" #include "defs.h" #include "value.h" #include "symtab.h" diff --git a/gdb/standalone.c b/gdb/standalone.c index fa9b26f..c3a4638 100644 --- a/gdb/standalone.c +++ b/gdb/standalone.c @@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/ioctl.h> #include <errno.h> #include <sys/types.h> -#include <sys/stat.h> +#include "gdb_stat.h" #if defined (SIGTSTP) && defined (SIGIO) #include <sys/time.h> diff --git a/gdb/stuff.c b/gdb/stuff.c index 3c069c7..dde7eb1 100644 --- a/gdb/stuff.c +++ b/gdb/stuff.c @@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <a.out.h> #include <sys/types.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/file.h> #include <varargs.h> diff --git a/gdb/sun386-nat.c b/gdb/sun386-nat.c index 767fe75..65890f0 100644 --- a/gdb/sun386-nat.c +++ b/gdb/sun386-nat.c @@ -37,7 +37,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <machine/reg.h> #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/core.h> diff --git a/gdb/symfile.c b/gdb/symfile.c index 6a14c24..24b19a4 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -39,8 +39,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/types.h> #include <fcntl.h> -#include <string.h> -#include <sys/stat.h> +#include "gdb_string.h" +#include "gdb_stat.h" #include <ctype.h> #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/gdb/symm-nat.c b/gdb/symm-nat.c index 6f235bd..436f68c 100644 --- a/gdb/symm-nat.c +++ b/gdb/symm-nat.c @@ -36,7 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/proc.h> #include <sys/dir.h> #include <sys/ioctl.h> -#include <sys/stat.h> +#include "gdb_stat.h" #ifdef _SEQUENT_ #include <sys/ptrace.h> #else diff --git a/gdb/symm-tdep.c b/gdb/symm-tdep.c index 279d4f3..6e4e026 100644 --- a/gdb/symm-tdep.c +++ b/gdb/symm-tdep.c @@ -29,7 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/user.h> #include <sys/dir.h> #include <sys/ioctl.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include "gdbcore.h" #include <fcntl.h> diff --git a/gdb/symmisc.c b/gdb/symmisc.c index daca178..e9af39f 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -1,5 +1,6 @@ /* Do various things to symbol tables (other than lookup), for GDB. - Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994 + Free Software Foundation, Inc. This file is part of GDB. @@ -28,7 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "obstack.h" #include "language.h" -#include <string.h> +#include "gdb_string.h" #ifndef DEV_TTY #define DEV_TTY "/dev/tty" @@ -234,6 +235,9 @@ dump_msymbols (objfile, outfile) case mst_text: ms_type = 'T'; break; + case mst_solib_trampoline: + ms_type = 'S'; + break; case mst_data: ms_type = 'D'; break; @@ -262,6 +266,10 @@ dump_msymbols (objfile, outfile) { fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol)); } +#ifdef SOFUN_ADDRESS_MAYBE_MISSING + if (msymbol->filename) + fprintf_filtered (outfile, " %s", msymbol->filename); +#endif fputs_filtered ("\n", outfile); } if (objfile -> minimal_symbol_count != index) @@ -282,7 +290,7 @@ dump_psymtab (objfile, psymtab, outfile) fprintf_filtered (outfile, "\nPartial symtab for source file %s ", psymtab -> filename); - fprintf_filtered (outfile, "(object )"); + fprintf_filtered (outfile, "(object "); gdb_print_address (psymtab, outfile); fprintf_filtered (outfile, ")\n\n"); fprintf_unfiltered (outfile, " Read from object file %s (", @@ -296,22 +304,26 @@ dump_psymtab (objfile, psymtab, outfile) " Full symtab was read (at "); gdb_print_address (psymtab->symtab, outfile); fprintf_filtered (outfile, " by function at "); - gdb_print_address (psymtab->read_symtab, outfile); + gdb_print_address ((PTR)psymtab->read_symtab, outfile); fprintf_filtered (outfile, ")\n"); } fprintf_filtered (outfile, " Relocate symbols by "); for (i = 0; i < psymtab->objfile->num_sections; ++i) { + if (i != 0) + fprintf_filtered (outfile, ", "); wrap_here (" "); - print_address_numeric (ANOFFSET (psymtab->section_offsets, i), outfile); - fprintf_filtered (outfile, ", "); + print_address_numeric (ANOFFSET (psymtab->section_offsets, i), + 1, + outfile); } + fprintf_filtered (outfile, "\n"); fprintf_filtered (outfile, " Symbols cover text addresses "); - print_address_numeric (psymtab->textlow, outfile); + print_address_numeric (psymtab->textlow, 1, outfile); fprintf_filtered (outfile, "-"); - print_address_numeric (psymtab->texthigh, outfile); + print_address_numeric (psymtab->texthigh, 1, outfile); fprintf_filtered (outfile, "\n"); fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", psymtab -> number_of_dependencies); @@ -365,7 +377,7 @@ dump_symtab (objfile, symtab, outfile) for (i = 0; i < len; i++) { fprintf_filtered (outfile, " line %d at ", l->item[i].line); - print_address_numeric (l->item[i].pc, outfile); + print_address_numeric (l->item[i].pc, 1, outfile); fprintf_filtered (outfile, "\n"); } } @@ -382,9 +394,9 @@ dump_symtab (objfile, symtab, outfile) gdb_print_address (b, outfile); fprintf_filtered (outfile, ") "); fprintf_filtered (outfile, "["); - print_address_numeric (BLOCK_START (b), outfile); + print_address_numeric (BLOCK_START (b), 1, outfile); fprintf_filtered (outfile, ".."); - print_address_numeric (BLOCK_END (b), outfile); + print_address_numeric (BLOCK_END (b), 1, outfile); fprintf_filtered (outfile, "]"); if (BLOCK_SUPERBLOCK (b)) { @@ -403,7 +415,7 @@ dump_symtab (objfile, symtab, outfile) } if (BLOCK_GCC_COMPILED(b)) fprintf_filtered (outfile, " gcc%d compiled", BLOCK_GCC_COMPILED(b)); - fprintf_filtered ('\n', outfile); + fprintf_filtered (outfile, "\n"); blen = BLOCK_NSYMS (b); for (j = 0; j < blen; j++) { @@ -435,7 +447,8 @@ maintenance_print_symbols (args, from_tty) if (args == NULL) { - error ("print-symbols takes an output file name and optional symbol file name"); + error ("\ +Arguments missing: an output file name and an optional symbol file name"); } else if ((argv = buildargv (args)) == NULL) { @@ -486,7 +499,7 @@ print_symbol (args) if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE) { fprintf_filtered (outfile, "label %s at ", SYMBOL_SOURCE_NAME (symbol)); - print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), outfile); + print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); fprintf_filtered (outfile, "\n"); return 1; } @@ -546,7 +559,7 @@ print_symbol (args) case LOC_STATIC: fprintf_filtered (outfile, "static at "); - print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), outfile); + print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1,outfile); fprintf_filtered (outfile, ","); break; @@ -596,7 +609,7 @@ print_symbol (args) case LOC_LABEL: fprintf_filtered (outfile, "label at "); - print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), outfile); + print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); break; case LOC_BLOCK: @@ -604,6 +617,7 @@ print_symbol (args) gdb_print_address (SYMBOL_BLOCK_VALUE (symbol), outfile); fprintf_filtered (outfile, ") starting at "); print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)), + 1, outfile); fprintf_filtered (outfile, ","); break; @@ -834,6 +848,92 @@ maintenance_print_objfiles (ignore, from_tty) immediate_quit--; } +/* Check consistency of psymtabs and symtabs. */ + +void +maintenance_check_symtabs (ignore, from_tty) + char *ignore; + int from_tty; +{ + register struct symbol *sym; + register struct partial_symbol *psym; + register struct symtab *s = NULL; + register struct partial_symtab *ps; + struct blockvector *bv; + register struct objfile *objfile; + register struct block *b; + int length; + + ALL_PSYMTABS (objfile, ps) + { + s = PSYMTAB_TO_SYMTAB(ps); + if (s == NULL) + continue; + bv = BLOCKVECTOR (s); + b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); + psym = ps->objfile->static_psymbols.list + ps->statics_offset; + length = ps->n_static_syms; + while (length--) + { + sym = lookup_block_symbol (b, SYMBOL_NAME (psym), + SYMBOL_NAMESPACE (psym)); + if (!sym) + { + printf_filtered ("Static symbol `"); + puts_filtered (SYMBOL_NAME (psym)); + printf_filtered ("' only found in "); + puts_filtered (ps->filename); + printf_filtered (" psymtab\n"); + } + psym++; + } + b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); + psym = ps->objfile->global_psymbols.list + ps->globals_offset; + length = ps->n_global_syms; + while (length--) + { + sym = lookup_block_symbol (b, SYMBOL_NAME (psym), + SYMBOL_NAMESPACE (psym)); + if (!sym) + { + printf_filtered ("Global symbol `"); + puts_filtered (SYMBOL_NAME (psym)); + printf_filtered ("' only found in "); + puts_filtered (ps->filename); + printf_filtered (" psymtab\n"); + } + psym++; + } + if (ps->texthigh < ps->textlow) + { + printf_filtered ("Psymtab "); + puts_filtered (ps->filename); + printf_filtered (" covers bad range "); + print_address_numeric (ps->textlow, 1, stdout); + printf_filtered (" - "); + print_address_numeric (ps->texthigh, 1, stdout); + printf_filtered ("\n"); + continue; + } + if (ps->texthigh == 0) + continue; + if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)) + { + printf_filtered ("Psymtab "); + puts_filtered (ps->filename); + printf_filtered (" covers "); + print_address_numeric (ps->textlow, 1, stdout); + printf_filtered (" - "); + print_address_numeric (ps->texthigh, 1, stdout); + printf_filtered (" but symtab covers only "); + print_address_numeric (BLOCK_START (b), 1, stdout); + printf_filtered (" - "); + print_address_numeric (BLOCK_END (b), 1, stdout); + printf_filtered ("\n"); + } + } +} + /* Return the nexting depth of a block within other blocks in its symtab. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 3f6c00e..cdb1793 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -38,8 +38,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/types.h> #include <fcntl.h> -#include <string.h> -#include <sys/stat.h> +#include "gdb_string.h" +#include "gdb_stat.h" #include <ctype.h> /* Prototypes for local functions */ @@ -585,7 +585,7 @@ found: if (namespace == VAR_NAMESPACE) { - msymbol = lookup_minimal_symbol (name, (struct objfile *) NULL); + msymbol = lookup_minimal_symbol (name, NULL, NULL); if (msymbol != NULL) { s = find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)); @@ -686,42 +686,6 @@ found: } } - /* Now search all per-file blocks for static mangled symbols. - Do the symtabs first, then check the psymtabs. */ - - if (namespace == VAR_NAMESPACE) - { - ALL_SYMTABS (objfile, s) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_block_symbol (block, name, VAR_NAMESPACE); - if (sym) - { - block_found = block; - if (symtab != NULL) - *symtab = s; - return sym; - } - } - - ALL_PSYMTABS (objfile, ps) - { - if (!ps->readin && lookup_partial_symbol (ps, name, 0, VAR_NAMESPACE)) - { - s = PSYMTAB_TO_SYMTAB(ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_block_symbol (block, name, VAR_NAMESPACE); - if (!sym) - error ("Internal: mangled static symbol `%s' found in %s psymtab but not in symtab", name, ps->filename); - if (symtab != NULL) - *symtab = s; - return sym; - } - } - } - if (symtab != NULL) *symtab = NULL; return 0; @@ -1282,6 +1246,10 @@ find_pc_line (pc, notcurrent) { val.symtab = alt_symtab; val.line = alt->line - 1; + + /* Don't return line 0, that means that we didn't find the line. */ + if (val.line == 0) ++val.line; + val.pc = BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)); val.end = alt->pc; } @@ -1652,14 +1620,35 @@ operator_chars (p, end) return *end; } +/* Return the number of methods described for TYPE, including the + methods from types it derives from. This can't be done in the symbol + reader because the type of the baseclass might still be stubbed + when the definition of the derived class is parsed. */ + +static int total_number_of_methods PARAMS ((struct type *type)); + +static int +total_number_of_methods (type) + struct type *type; +{ + int n; + int count; + + check_stub_type (type); + count = TYPE_NFN_FIELDS_TOTAL (type); + + for (n = 0; n < TYPE_N_BASECLASSES (type); n++) + count += total_number_of_methods (TYPE_BASECLASS (type, n)); + + return count; +} + /* Recursive helper function for decode_line_1. - * Look for methods named NAME in type T. - * Return number of matches. - * Put matches in SYM_ARR (which better be big enough!). - * These allocations seem to define "big enough": - * sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*)); - * Note that this function is g++ specific. - */ + Look for methods named NAME in type T. + Return number of matches. + Put matches in SYM_ARR, which should have been allocated with + a size of total_number_of_methods (T) * sizeof (struct symbol *). + Note that this function is g++ specific. */ int find_methods (t, name, sym_arr) @@ -2020,7 +2009,8 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) sym = 0; i1 = 0; /* counter for the symbol array */ t = SYMBOL_TYPE (sym_class); - sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*)); + sym_arr = (struct symbol **) alloca(total_number_of_methods (t) + * sizeof(struct symbol *)); /* Cfront objects don't have fieldlists. */ if (destructor_name_p (copy, t) && TYPE_FN_FIELDLISTS (t) != NULL) @@ -2200,7 +2190,9 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) /* Arg token is not digits => try it as a variable name Find the next token (everything up to end or next whitespace). */ - if (is_quoted) + if (**argptr == '$') /* Convenience variable */ + p = skip_quoted (*argptr + 1); + else if (is_quoted) { p = skip_quoted (*argptr); if (p[-1] != '\'') @@ -2228,6 +2220,32 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) while (*p == ' ' || *p == '\t') p++; *argptr = p; + /* See if it's a convenience variable */ + + if (*copy == '$') + { + value_ptr valx; + int need_canonical = (s == 0) ? 1 : 0; + + valx = value_of_internalvar (lookup_internalvar (copy + 1)); + if (TYPE_CODE (VALUE_TYPE (valx)) != TYPE_CODE_INT) + error ("Convenience variables used in line specs must have integer values."); + + val.symtab = s ? s : default_symtab; + val.line = value_as_long (valx); + val.pc = 0; + + values.sals = (struct symtab_and_line *)xmalloc (sizeof val); + values.sals[0] = val; + values.nelts = 1; + + if (need_canonical) + build_canonical_line_spec (values.sals, NULL, canonical); + + return values; + } + + /* Look up that token as a variable. If file specified, use that file's per-file block to start with. */ @@ -2285,7 +2303,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) } } - msymbol = lookup_minimal_symbol (copy, (struct objfile *) NULL); + msymbol = lookup_minimal_symbol (copy, NULL, NULL); if (msymbol != NULL) { val.symtab = 0; @@ -3004,6 +3022,19 @@ completion_list_add_name (symname, sym_text, sym_text_len, text, word) strcat (new, symname); } + /* Recheck for duplicates if we intend to add a modified symbol. */ + if (word != sym_text) + { + for (i = 0; i < return_val_index; ++i) + { + if (STREQ (new, return_val[i])) + { + free (new); + return; + } + } + } + if (return_val_index + 3 > return_val_size) { newsize = (return_val_size *= 2) * sizeof (char *); @@ -3203,51 +3234,6 @@ make_symbol_completion_list (text, word) } -#if 0 -/* Add the type of the symbol sym to the type of the current - function whose block we are in (assumed). The type of - this current function is contained in *TYPE. - - This basically works as follows: When we find a function - symbol (N_FUNC with a 'f' or 'F' in the symbol name), we record - a pointer to its type in the global in_function_type. Every - time we come across a parameter symbol ('p' in its name), then - this procedure adds the name and type of that parameter - to the function type pointed to by *TYPE. (Which should correspond - to in_function_type if it was called correctly). - - Note that since we are modifying a type, the result of - lookup_function_type() should be memcpy()ed before calling - this. When not in strict typing mode, the expression - evaluator can choose to ignore this. - - Assumption: All of a function's parameter symbols will - appear before another function symbol is found. The parameters - appear in the same order in the argument list as they do in the - symbol table. */ - -void -add_param_to_type (type,sym) - struct type **type; - struct symbol *sym; -{ - int num = ++(TYPE_NFIELDS(*type)); - - if(TYPE_NFIELDS(*type)-1) - TYPE_FIELDS(*type) = (struct field *) - (*current_objfile->xrealloc) ((char *)(TYPE_FIELDS(*type)), - num*sizeof(struct field)); - else - TYPE_FIELDS(*type) = (struct field *) - (*current_objfile->xmalloc) (num*sizeof(struct field)); - - TYPE_FIELD_BITPOS(*type,num-1) = num-1; - TYPE_FIELD_BITSIZE(*type,num-1) = 0; - TYPE_FIELD_TYPE(*type,num-1) = SYMBOL_TYPE(sym); - TYPE_FIELD_NAME(*type,num-1) = SYMBOL_NAME(sym); -} -#endif - void _initialize_symtab () { diff --git a/gdb/target.c b/gdb/target.c index 838afb6..9ae8941 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include <errno.h> #include <ctype.h> -#include <string.h> +#include "gdb_string.h" #include "target.h" #include "gdbcmd.h" #include "symtab.h" @@ -333,7 +333,7 @@ cleanup_target (t) de_fault (to_mourn_inferior, (void (*)())noprocess); de_fault (to_can_run, return_zero); de_fault (to_notice_signals, (void (*)())ignore); - de_fault (to_thread_alive, (void (*)())ignore); + de_fault (to_thread_alive, (int (*)())ignore); de_fault (to_stop, (void (*)())ignore); #undef de_fault @@ -1778,13 +1778,14 @@ debug_to_notice_signals (pid) fprintf_unfiltered (stderr, "target_notice_signals (%d)\n", pid); } -static void +static int debug_to_thread_alive (pid) int pid; { debug_target.to_thread_alive (pid); fprintf_unfiltered (stderr, "target_thread_alive (%d)\n", pid); + return (0); } static void @@ -47,12 +47,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <unistd.h> #endif -#include <string.h> +#include "gdb_string.h" #ifndef NO_SYS_FILE #include <sys/file.h> #endif #include <sys/param.h> -#include <sys/stat.h> +#include "gdb_stat.h" #include <ctype.h> extern void initialize_targets PARAMS ((void)); diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 785ec61..37d6ebc 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -31,7 +31,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "language.h" #include "demangle.h" -#include <string.h> +#include "gdb_string.h" #include <errno.h> static void diff --git a/gdb/ultra3-nat.c b/gdb/ultra3-nat.c index f1b81b7..0ff415c 100644 --- a/gdb/ultra3-nat.c +++ b/gdb/ultra3-nat.c @@ -34,7 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" /* Assumes support for AMD's Binary Compatibility Standard for ptrace(). If you define ULTRA3, the ultra3 extensions to diff --git a/gdb/ultra3-xdep.c b/gdb/ultra3-xdep.c index bda2697..994138a 100644 --- a/gdb/ultra3-xdep.c +++ b/gdb/ultra3-xdep.c @@ -34,7 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbcore.h" #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" /* Assorted operating system circumventions */ diff --git a/gdb/umax-xdep.c b/gdb/umax-xdep.c index 800e8c0..83012a7 100644 --- a/gdb/umax-xdep.c +++ b/gdb/umax-xdep.c @@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define PTRACE_DETACH PT_FREEPROC #include <sys/file.h> -#include <sys/stat.h> +#include "gdb_stat.h" /* Work with core dump and executable files, for GDB. This code would be in core.c if it weren't machine-dependent. */ diff --git a/gdb/utils.c b/gdb/utils.c index fdf7938..757db69 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -29,7 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <varargs.h> #endif #include <ctype.h> -#include <string.h> +#include "gdb_string.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif diff --git a/gdb/valarith.c b/gdb/valarith.c index 79c0943..9af5bb0 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -26,7 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "target.h" #include "language.h" #include "demangle.h" -#include <string.h> +#include "gdb_string.h" /* Define whether or not the C operator '/' truncates towards zero for differently signed operands (truncation direction is undefined in C). */ @@ -35,7 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2) #endif -static value_ptr value_subscripted_rvalue PARAMS ((value_ptr, value_ptr)); +static value_ptr value_subscripted_rvalue PARAMS ((value_ptr, value_ptr, int)); value_ptr @@ -125,29 +125,44 @@ value_ptr value_subscript (array, idx) value_ptr array, idx; { - int lowerbound; value_ptr bound; - struct type *range_type; + int c_style = current_language->c_style_arrays; COERCE_REF (array); + COERCE_VARYING_ARRAY (array); if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_ARRAY || TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_STRING) { - range_type = TYPE_FIELD_TYPE (VALUE_TYPE (array), 0); - lowerbound = TYPE_FIELD_BITPOS (range_type, 0); + struct type *range_type = TYPE_FIELD_TYPE (VALUE_TYPE (array), 0); + int lowerbound = TYPE_LOW_BOUND (range_type); + int upperbound = TYPE_HIGH_BOUND (range_type); + + if (VALUE_LVAL (array) != lval_memory) + return value_subscripted_rvalue (array, idx, lowerbound); + + if (c_style == 0) + { + LONGEST index = value_as_long (idx); + if (index >= lowerbound && index <= upperbound) + return value_subscripted_rvalue (array, idx, lowerbound); + warning ("array or string index out of range"); + /* fall doing C stuff */ + c_style = 1; + } + if (lowerbound != 0) { bound = value_from_longest (builtin_type_int, (LONGEST) lowerbound); idx = value_sub (idx, bound); } - if (VALUE_LVAL (array) != lval_memory) - { - return value_subscripted_rvalue (array, idx); - } + array = value_coerce_array (array); } - return value_ind (value_add (array, idx)); + if (c_style) + return value_ind (value_add (array, idx)); + else + error ("not an array or string"); } /* Return the value of EXPR[IDX], expr an aggregate rvalue @@ -155,24 +170,29 @@ value_subscript (array, idx) to doubles, but no longer does. */ static value_ptr -value_subscripted_rvalue (array, idx) +value_subscripted_rvalue (array, idx, lowerbound) value_ptr array, idx; + int lowerbound; { struct type *elt_type = TYPE_TARGET_TYPE (VALUE_TYPE (array)); int elt_size = TYPE_LENGTH (elt_type); - int elt_offs = elt_size * longest_to_int (value_as_long (idx)); + LONGEST index = value_as_long (idx); + int elt_offs = elt_size * longest_to_int (index - lowerbound); value_ptr v; - if (elt_offs >= TYPE_LENGTH (VALUE_TYPE (array))) + if (index < lowerbound || elt_offs >= TYPE_LENGTH (VALUE_TYPE (array))) error ("no such vector element"); v = allocate_value (elt_type); - memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs, elt_size); + if (VALUE_LAZY (array)) + VALUE_LAZY (v) = 1; + else + memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs, elt_size); if (VALUE_LVAL (array) == lval_internalvar) VALUE_LVAL (v) = lval_internalvar_component; else - VALUE_LVAL (v) = not_lval; + VALUE_LVAL (v) = VALUE_LVAL (array); VALUE_ADDRESS (v) = VALUE_ADDRESS (array); VALUE_OFFSET (v) = VALUE_OFFSET (array) + elt_offs; VALUE_BITSIZE (v) = elt_size * 8; diff --git a/gdb/valops.c b/gdb/valops.c index ea0a343..79a72a3 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1,5 +1,5 @@ /* Perform non-arithmetic operations on values, for GDB. - Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994 + Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. This file is part of GDB. @@ -30,7 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "language.h" #include <errno.h> -#include <string.h> +#include "gdb_string.h" /* Local functions. */ @@ -728,10 +728,6 @@ value_addr (arg1) VALUE_TYPE (arg2) = lookup_pointer_type (TYPE_TARGET_TYPE (type)); return arg2; } - if (current_language->c_style_arrays - && (VALUE_REPEATED (arg1) - || TYPE_CODE (type) == TYPE_CODE_ARRAY)) - return value_coerce_array (arg1); if (TYPE_CODE (type) == TYPE_CODE_FUNC) return value_coerce_function (arg1); @@ -840,7 +836,16 @@ value_arg_coerce (arg, param_type) value_ptr arg; struct type *param_type; { - register struct type *type = param_type ? param_type : VALUE_TYPE (arg); + register struct type *type; + +#if 1 /* FIXME: This is only a temporary patch. -fnf */ + if (current_language->c_style_arrays + && (VALUE_REPEATED (arg) + || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY)) + arg = value_coerce_array (arg); +#endif + + type = param_type ? param_type : VALUE_TYPE (arg); switch (TYPE_CODE (type)) { @@ -866,15 +871,24 @@ value_arg_coerce (arg, param_type) case TYPE_CODE_FUNC: type = lookup_pointer_type (type); break; + case TYPE_CODE_UNDEF: + case TYPE_CODE_PTR: + case TYPE_CODE_ARRAY: + case TYPE_CODE_STRUCT: + case TYPE_CODE_UNION: + case TYPE_CODE_VOID: + case TYPE_CODE_SET: + case TYPE_CODE_RANGE: + case TYPE_CODE_STRING: + case TYPE_CODE_BITSTRING: + case TYPE_CODE_ERROR: + case TYPE_CODE_MEMBER: + case TYPE_CODE_METHOD: + case TYPE_CODE_COMPLEX: + default: + break; } -#if 1 /* FIXME: This is only a temporary patch. -fnf */ - if (current_language->c_style_arrays - && (VALUE_REPEATED (arg) - || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY)) - arg = value_coerce_array (arg); -#endif - return value_cast (type, arg); } @@ -1436,7 +1450,10 @@ typecmp (staticp, t1, t2) /* We should be doing hairy argument matching, as below. */ && (TYPE_CODE (TYPE_TARGET_TYPE (tt1)) == TYPE_CODE (tt2))) { - t2[i] = value_addr (t2[i]); + if (TYPE_CODE (tt2) == TYPE_CODE_ARRAY || VALUE_REPEATED (t2[i])) + t2[i] = value_coerce_array (t2[i]); + else + t2[i] = value_addr (t2[i]); continue; } diff --git a/gdb/valprint.c b/gdb/valprint.c index d4c8696..591978a 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1,5 +1,6 @@ /* Print values for GDB, the GNU debugger. - Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc. + Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994 + Free Software Foundation, Inc. This file is part of GDB. @@ -18,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "value.h" @@ -61,9 +62,6 @@ set_output_radix PARAMS ((char *, int, struct cmd_list_element *)); static void set_output_radix_1 PARAMS ((int, unsigned)); -static void value_print_array_elements PARAMS ((value_ptr, GDB_FILE *, int, - enum val_prettyprint)); - /* Maximum number of chars to print for a string pointer value or vector contents, or UINT_MAX for no limit. Note that "set print elements 0" stores UINT_MAX in print_max, which displays in a show command as @@ -84,8 +82,17 @@ int output_format = 0; unsigned int repeat_count_threshold = 10; -int prettyprint_structs; /* Controls pretty printing of structures */ -int prettyprint_arrays; /* Controls pretty printing of arrays. */ +/* If nonzero, stops printing of char arrays at first null. */ + +int stop_print_at_null; + +/* Controls pretty printing of structures. */ + +int prettyprint_structs; + +/* Controls pretty printing of arrays. */ + +int prettyprint_arrays; /* If nonzero, causes unions inside structures or other unions to be printed. */ @@ -163,8 +170,6 @@ value_print (val, stream, format, pretty) int format; enum val_prettyprint pretty; { - register unsigned int n, typelen; - if (val == 0) { printf_filtered ("<address of value unknown>"); @@ -175,59 +180,7 @@ value_print (val, stream, format, pretty) printf_filtered ("<value optimized out>"); return 0; } - - /* A "repeated" value really contains several values in a row. - They are made by the @ operator. - Print such values as if they were arrays. */ - - if (VALUE_REPEATED (val)) - { - n = VALUE_REPETITIONS (val); - typelen = TYPE_LENGTH (VALUE_TYPE (val)); - fprintf_filtered (stream, "{"); - /* Print arrays of characters using string syntax. */ - if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT - && format == 0) - LA_PRINT_STRING (stream, VALUE_CONTENTS (val), n, 0); - else - { - value_print_array_elements (val, stream, format, pretty); - } - fprintf_filtered (stream, "}"); - return (n * typelen); - } - else - { - struct type *type = VALUE_TYPE (val); - - /* If it is a pointer, indicate what it points to. - - Print type also if it is a reference. - - C++: if it is a member pointer, we will take care - of that when we print it. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR || - TYPE_CODE (type) == TYPE_CODE_REF) - { - /* Hack: remove (char *) for char strings. Their - type is indicated by the quoted string anyway. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR && - TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof(char) && - TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT && - !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type))) - { - /* Print nothing */ - } - else - { - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") "); - } - } - return (val_print (type, VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, 1, 0, pretty)); - } + return LA_VALUE_PRINT (val, stream, format, pretty); } /* Called by various <lang>_val_print routines to print TYPE_CODE_INT's */ @@ -252,29 +205,41 @@ val_print_type_code_int (type, valaddr, stream) sizeof (LONGEST) ones. */ len = TYPE_LENGTH (type); -#if TARGET_BYTE_ORDER == BIG_ENDIAN - for (p = valaddr; - len > sizeof (LONGEST) && p < valaddr + TYPE_LENGTH (type); - p++) -#else /* Little endian. */ - first_addr = valaddr; - for (p = valaddr + TYPE_LENGTH (type) - 1; - len > sizeof (LONGEST) && p >= valaddr; - p--) -#endif /* Little endian. */ + if (TARGET_BYTE_ORDER == BIG_ENDIAN) { - if (*p == 0) + for (p = valaddr; + len > sizeof (LONGEST) && p < valaddr + TYPE_LENGTH (type); + p++) { - len--; + if (*p == 0) + { + len--; + } + else + { + break; + } } - else + first_addr = p; + } + else + { + first_addr = valaddr; + for (p = valaddr + TYPE_LENGTH (type) - 1; + len > sizeof (LONGEST) && p >= valaddr; + p--) { - break; + if (*p == 0) + { + len--; + } + else + { + break; + } } } -#if TARGET_BYTE_ORDER == BIG_ENDIAN - first_addr = p; -#endif + if (len <= sizeof (LONGEST)) { /* The most significant bytes are zero, so we can just get @@ -363,6 +328,7 @@ print_longest (stream, format, use_local, val_long) fprintf_filtered (stream, use_local ? local_octal_format_custom ("ll") : "%llo", + val_long); break; case 'b': fprintf_filtered (stream, local_hex_format_custom ("02ll"), val_long); @@ -499,13 +465,16 @@ print_floating (valaddr, type, stream) /* Assume that floating point byte order is the same as integer byte order. */ -#if TARGET_BYTE_ORDER == BIG_ENDIAN - low = extract_unsigned_integer (valaddr + 4, 4); - high = extract_unsigned_integer (valaddr, 4); -#else - low = extract_unsigned_integer (valaddr, 4); - high = extract_unsigned_integer (valaddr + 4, 4); -#endif + if (TARGET_BYTE_ORDER == BIG_ENDIAN) + { + low = extract_unsigned_integer (valaddr + 4, 4); + high = extract_unsigned_integer (valaddr, 4); + } + else + { + low = extract_unsigned_integer (valaddr, 4); + high = extract_unsigned_integer (valaddr + 4, 4); + } nonnegative = ((high & 0x80000000) == 0); is_nan = (((high >> 20) & 0x7ff) == 0x7ff && ! ((((high & 0xfffff) == 0)) && (low == 0))); @@ -553,17 +522,23 @@ print_hex_chars (stream, valaddr, len) /* FIXME: We should be not printing leading zeroes in most cases. */ fprintf_filtered (stream, local_hex_format_prefix ()); -#if TARGET_BYTE_ORDER == BIG_ENDIAN - for (p = valaddr; - p < valaddr + len; - p++) -#else /* Little endian. */ - for (p = valaddr + len - 1; - p >= valaddr; - p--) -#endif + if (TARGET_BYTE_ORDER == BIG_ENDIAN) { - fprintf_filtered (stream, "%02x", *p); + for (p = valaddr; + p < valaddr + len; + p++) + { + fprintf_filtered (stream, "%02x", *p); + } + } + else + { + for (p = valaddr + len - 1; + p >= valaddr; + p--) + { + fprintf_filtered (stream, "%02x", *p); + } } fprintf_filtered (stream, local_hex_format_suffix ()); } @@ -657,7 +632,7 @@ val_print_array_elements (type, valaddr, address, stream, format, deref_ref, } } -static void +void value_print_array_elements (val, stream, format, pretty) value_ptr val; GDB_FILE *stream; @@ -696,7 +671,7 @@ value_print_array_elements (val, stream, format, pretty) val_print (VALUE_TYPE (val), VALUE_CONTENTS (val) + typelen * i, VALUE_ADDRESS (val) + typelen * i, stream, format, 1, 0, pretty); - fprintf_unfiltered (stream, " <repeats %u times>", reps); + fprintf_filtered (stream, " <repeats %u times>", reps); i = rep1 - 1; things_printed += repeat_count_threshold; } @@ -1056,6 +1031,13 @@ _initialize_valprint () &showprintlist); add_show_from_set + (add_set_cmd ("null-stop", no_class, var_boolean, + (char *)&stop_print_at_null, + "Set printing of char arrays to stop at first null char.", + &setprintlist), + &showprintlist); + + add_show_from_set (add_set_cmd ("repeats", no_class, var_uinteger, (char *)&repeat_count_threshold, "Set threshold for repeated print elements.\n\ diff --git a/gdb/values.c b/gdb/values.c index accb0d5..22aa4f8 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include <string.h> +#include "gdb_string.h" #include "symtab.h" #include "gdbtypes.h" #include "value.h" diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index fec6b4e..bda6caa 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -32,14 +32,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/types.h> #include <fcntl.h> #include <ctype.h> -#include <string.h> +#include "gdb_string.h" #include "obstack.h" #include <sys/param.h> #ifndef NO_SYS_FILE #include <sys/file.h> #endif -#include <sys/stat.h> +#include "gdb_stat.h" #include <sys/debug.h> #include "coff/internal.h" |