* configure.in: Check for working mmap, ansi headers, string.h,
authorJ.T. Conklin <jtc@acorntoolworks.com>
Tue, 1 Aug 1995 20:14:27 +0000 (20:14 +0000)
committerJ.T. Conklin <jtc@acorntoolworks.com>
Tue, 1 Aug 1995 20:14:27 +0000 (20:14 +0000)
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:
gdb/.Sanitize
gdb/ChangeLog
gdb/alpha-tdep.c
gdb/altos-xdep.c
gdb/arm-tdep.c
gdb/arm-xdep.c
gdb/breakpoint.c
gdb/buildsym.c
gdb/c-typeprint.c
gdb/ch-typeprint.c
gdb/coffread.c
gdb/command.c
gdb/config/i386/xm-ptx.h
gdb/config/m68k/nm-apollo68b.h
gdb/config/m68k/xm-hp300hpux.h
gdb/config/m68k/xm-sun3os4.h
gdb/config/mips/xm-irix3.h
gdb/config/mips/xm-mips.h
gdb/config/mips/xm-news-mips.h
gdb/config/mips/xm-riscos.h
gdb/config/pa/xm-hppah.h
gdb/config/rs6000/xm-rs6000.h
gdb/config/sparc/xm-sun4os4.h
gdb/config/sparc/xm-sun4sol2.h
gdb/config/vax/xm-vaxbsd.h
gdb/config/vax/xm-vaxult.h
gdb/config/vax/xm-vaxult2.h
gdb/config/xm-lynx.h
gdb/config/xm-sysv4.h
gdb/configure
gdb/configure.in
gdb/convex-tdep.c
gdb/convex-xdep.c
gdb/core-sol2.c
gdb/core-svr4.c
gdb/core.c
gdb/coredep.c
gdb/corelow.c
gdb/cp-valprint.c
gdb/cxux-nat.c
gdb/dbxread.c
gdb/dcache.c
gdb/demangle.c
gdb/dpx2-nat.c
gdb/dstread.c
gdb/dwarfread.c
gdb/elfread.c
gdb/environ.c
gdb/eval.c
gdb/exec.c
gdb/f-lang.c
gdb/f-typeprint.c
gdb/f-valprint.c
gdb/findvar.c
gdb/fork-child.c
gdb/gdb_stat.h [new file with mode: 0644]
gdb/gdb_string.h [new file with mode: 0644]
gdb/gdbtk.c
gdb/gdbtypes.c
gdb/gould-xdep.c
gdb/hppa-tdep.c
gdb/hpread.c
gdb/i386-tdep.c
gdb/i386aix-nat.c
gdb/i386b-nat.c
gdb/i386mach-nat.c
gdb/i386v-nat.c
gdb/infcmd.c
gdb/inflow.c
gdb/infptrace.c
gdb/infrun.c
gdb/irix5-nat.c
gdb/language.c
gdb/m2-typeprint.c
gdb/m88k-nat.c
gdb/main.c
gdb/mdebugread.c
gdb/minsyms.c
gdb/mipsread.c
gdb/monitor.c
gdb/nlmread.c
gdb/objfiles.c
gdb/os9kread.c
gdb/osfsolib.c
gdb/parse.c
gdb/printcmd.c
gdb/procfs.c
gdb/pyr-xdep.c
gdb/regex.c
gdb/remote-adapt.c
gdb/remote-arc.c
gdb/remote-array.c
gdb/remote-bug.c
gdb/remote-e7000.c
gdb/remote-eb.c
gdb/remote-es.c
gdb/remote-hms.c
gdb/remote-mm.c
gdb/remote-os9k.c
gdb/remote-pa.c
gdb/remote-sim.c
gdb/remote-st.c
gdb/remote-udi.c
gdb/remote-utils.c
gdb/remote-vx.c
gdb/remote-vx29k.c
gdb/remote-vx68.c
gdb/remote-vx960.c
gdb/remote-vxmips.c
gdb/remote-vxsparc.c
gdb/remote.c
gdb/rs6000-nat.c
gdb/solib.c
gdb/somread.c
gdb/source.c
gdb/stabsread.c
gdb/stack.c
gdb/standalone.c
gdb/stuff.c
gdb/sun386-nat.c
gdb/symfile.c
gdb/symm-nat.c
gdb/symm-tdep.c
gdb/symmisc.c
gdb/symtab.c
gdb/target.c
gdb/top.c
gdb/typeprint.c
gdb/ultra3-nat.c
gdb/ultra3-xdep.c
gdb/umax-xdep.c
gdb/utils.c
gdb/valarith.c
gdb/valops.c
gdb/valprint.c
gdb/values.c
gdb/xcoffread.c

index 769f91d043ca29a3220ccbf24b10e4e86b8fc9a9..bf2fd56e7610c76a864ddc1b290d44f67ee22dc2 100644 (file)
@@ -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
index 09a056cd070b35c0271dd34f122aae048026e553..7cb99f7b54b448020c4af114a5dd605bc759f6bd 100644 (file)
@@ -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
index 83f1602ac31b57fe5711e5b8763e592dd8c6ca8c..b6b19e608d4238d4853c82214727a054ab9c3464 100644 (file)
@@ -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.  */
 
index effb49f67b39e7113c5687372ab77eb122649460..2784d3f55509da0cbfaf6b51863b7c10a6ca4839 100644 (file)
@@ -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"
 
 \f
 /* Work with core dump and executable files, for GDB. 
index 1a8b0277e4662601690173e620be14a8a623a8e9..e45bf00ef5e5d221d67d4682889cf5d93f8b45a6 100644 (file)
@@ -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;
 }
 
 
index bc47b72df6a8f661a14ec68edf4f189f894766e4..c0f944e2e761c3422e05e6c1b17d8ea394083c64 100644 (file)
@@ -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>
 
index 94e1dd5e4faf5720f82bb0eae69dfd089939b01b..0b388adc4e3f3a1081df4ad05cf4fdb544d49b1c 100644 (file)
@@ -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;
 }
 
index fa31e6243d47355d5efa3c32db2e18889cd26de8..ec22b11f847920ec9b0648ebdc20a3ae6ded069f 100644 (file)
@@ -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  /**/
index aa5b014689950d1a79e361cb0a2141c446f52213..ac44d1dfc005140a7f164e56326911d5b60956c0 100644 (file)
@@ -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>
 
index f06a85cca79baa2b6aed401561eddcd212e5c1fd..8440d36e4339946aa071552f8665b4d2b5bcb0f0 100644 (file)
@@ -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
index c4f06e14d23aeff1689122f5ff3ebe645be28c5f..ec7aef24346fffc284931d464a5593d57bb2944e 100644 (file)
@@ -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;
index 0735baed27022696b800098ba73fcd8f8b82e3ba..cfb48db602279420e84f6a8c8e1402a079a233bd 100644 (file)
@@ -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
index fe6809856b89ab1d4e58e88fc446c2ea574888a2..cbf680640d25e80336ae4cae0d8a955d7f4c2667 100644 (file)
@@ -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
index c90dfacbd889f536b8662322da48fda32722af3c..85d5a66353cb8113f598066b00acb7735d6a7929 100644 (file)
@@ -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 */
index 1719a69dcdeadf4be5bd75501dc942bf1ee51590..5041c73d62265eff6946eadebe8175b831ccd915 100644 (file)
@@ -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)                                    \
index f4db6addb7b9d862399b1ef790d53ed55c09bbc1..5b62dc9ae176f70592d75e70c94e139891502d01 100644 (file)
@@ -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()
index cd7037b1b22e73e1add74059a95e22da1e64beb0..f64e3a52f25ae9e060ae349792d9bfcccb70c502 100644 (file)
@@ -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)                 \
index 9c4b2f8b84ec23e366cbc76a0b2465ba8fd2f340..830644ca69945ab64ff4fa3fda08c2c699fcce3f 100644 (file)
@@ -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
index 441378253aeac50e831056986aeadcae6b284ca5..e0436ee2f69e419f7f79a312db07842bb9f37cf7 100644 (file)
@@ -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
index ba3845ed937deef27a14f7814559467e30325f93..8eece3ec87ca62c7095604e6b3022fc2ad28f328 100644 (file)
@@ -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.  */
index 64e75244a94c7c624f9b449300df726be5d7b03c..d4c4a2c343949cd40c44691f5b776e5ebad3fbdd 100644 (file)
@@ -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). */
 
index 64d08eef567473f55cc629c10fba0d0ef0efd119..e9f6e97f11a2404bf85a2a26341cd18b0415d394 100644 (file)
@@ -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.  */
 
index 2981c2ee28aa761602ada58ee23a7ca998df852d..ca94bad7e7dc39b0b402b91c885475c2808c5b67 100644 (file)
@@ -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*
index de7e10f46711092880eca9cd731814bd9cacb5e2..b4b36566ad69b368c20a741e8ae0180795b648b7 100644 (file)
@@ -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
index 68efaac198b5bd869f1ccefdff235e4713ce2368..b42bd704681da751332c575d71d1d735db59e878 100644 (file)
@@ -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
index 20fd3685f8c5400f89946bc0dac7e50c4b175c5c..24c643706018d46124d90dd9e3b5d29c3a89af29 100644 (file)
@@ -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,
index f3e2550ba8a28fbb98b49008e9374ac5c4298cfb..d0d3d62c7aa50039d680e8069b0084021840898a 100644 (file)
@@ -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.  */
index 5b9a3891247402877bfcee4251660f0b59084244..dd9bba368da0087118fc448134b144d480855e08 100644 (file)
@@ -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
index 9d1451de1a65c6d21d2f354d4358ef907cfdfd40..dbe2538ab42532c0e192e62dade063ca0c13f9ec 100644 (file)
@@ -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
index e324daf0d138b5ccf6aec4cfa9353fa63447fc04..6478564b43d9146cedb8e78b6cfd547cacb8bc6f 100755 (executable)
@@ -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
index 0c1158e3a8b930ee04c089bfec3a60a1cfdb56da..1ef77ce4b130ba3909520ed7352b075bb8f5f517 100644 (file)
@@ -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=
index 930d1601ef75f8f4cfd4fcce8c825c60b84003fb..bef0bc9b26b9be05a6dca5cae2bdbb80ca469bc0 100644 (file)
@@ -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"
index 6426c6e8ab18164d6205ca671b213a49946bb0e6..080bb971a72a0bfe9f5ae860e637b862551cb4d0 100644 (file)
@@ -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>
index 4ead2ac2085759ebdc1f114747948f72cda79a59..13d987692b03d7443ad13d864a88b45cbd33e6a1 100644 (file)
@@ -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"
index e0743fdf37a4ce92d2c5708cb0d3b8722417583b..f1def9f97ef2895362e7e5ba703ddcf48ae91dfb 100644 (file)
@@ -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"
index 974e55c1859de6cdf1f8ae1ef42a01e868b2be1e..d4b29ca001f343c442b0f0f24598b55b4ece776e 100644 (file)
@@ -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>
index 678785d0f5d1f346b73739d01ce5124a13382eee..ae2d0a62b930d155397ba4ce15f78b3c5234a375 100644 (file)
@@ -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
index 0d6fb81ff86b390651da8c0d313e906c75f54b98..e4e663fd36df1d34b461f151fa376b46b25ce795 100644 (file)
@@ -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>
index c32dbc728dc17f3d6b559fb3811b7559cfd817ab..77c6dc334114b90f6f1c9069471d7a66015632eb 100644 (file)
@@ -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
index b47c19d4889ef576461170477fa28d834deca072..6b2e25a70fa38db9e0c9c7973cf2fa260d3197a1 100644 (file)
@@ -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"
index ddaf1927f203c219c0cd7f2a55605e69848e0905..97c3d3cbed23f557bf8ef5b4f2220166d2a4ba53 100644 (file)
@@ -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
 \f
-/* 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;
 }
 \f
-/* 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);
 }
 \f
@@ -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)
index 4e9f960a43b093d8050505b6b87a8256312100c9..fce1852353cfb82915c812c1db1da3190dd73acd 100644 (file)
@@ -22,7 +22,7 @@
 #include "defs.h"
 #include "dcache.h"
 #include "gdbcmd.h"
-#include <string.h>
+#include "gdb_string.h"
 
 
 /* 
index eecd3d3ed4297c5cb915771959450d09a55d5656..2fead9af3dac8653b3d24bc0eea48ab1f4375deb 100644 (file)
@@ -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
index c437c7596dbd1e200101d03de85393b17ebc8798..4f1f0dd041e5d1e13e91d8ecbb89d605b19af739 100644 (file)
@@ -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>
index 378ed8ee554618e78fc132defcf778fc877b0cff..22f239dcf103403a66de27fa11f4a3eeca9ca1ff 100644 (file)
@@ -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"
 
index 3cc9bd178d4e120a712b9bcb7baa8865afbd8e56..4a1a57a4ba7f6963ae4e34320baa22c2a9e0efc8 100644 (file)
@@ -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>
index 10269bb58a1c40e841d5fd0edcb9551bf7918a53..cfadc1126f5d3833a0c939f49ebd3f096d2ff83b 100644 (file)
@@ -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"
index 8d5dba1339342a3d04a5f25e816d6671fa015d15..193f34de53afaf6c4b75c07814f3719ce641c680 100644 (file)
@@ -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"
 
 \f
 /* 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;
 }
 
index 7563c5911226c7b2f638da9f60c60bfaae078e71..9964c31c6cbc4b5647f2406083520d0ca180c247 100644 (file)
@@ -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)));
 
index af5ef8354ed423eb663a1f6526d9e68fbedcdd24..e866ab6bf773792a3df17055a599ea3d3bcb521a 100644 (file)
@@ -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
index 04a446f41efdec91f8c9dd240ffbcbd25b879a9a..54fb5578ac27d3e14300f6d3404ac793e0335ac4 100644 (file)
@@ -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"
index 8b1e9fe88e5893522cf4662c5e38c5d223b38621..ef6fb47a4d5af2d716acaa2be75b63fb9cfe8f5b 100644 (file)
@@ -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 */
index 06beea6c5103e659548e2598aa5d4ea46fcd52ad..7f5fb320ec8f31b6e026e8b0bca6c06488d88be5 100644 (file)
@@ -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"
index 591dc7f987f863c32398f1297565278e436f09cf..fd3a532af24675136bc27e119d052403a3b17d06 100644 (file)
@@ -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, &registers[regbyte], len);
+    memcpy (myaddr, &registers[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 (&registers[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 (&registers[REGISTER_BYTE (regno)], myaddr, size) == 0)
+    return;
+  
+  target_prepare_to_store ();
+
+  memcpy (&registers[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
index 2b2daeb14eee9c80753deab591bc5507b9d8236d..39bfa8ff87c2ddde7d305e2fde0027e4d179214e 100644 (file)
@@ -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 (file)
index 0000000..d863735
--- /dev/null
@@ -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 (file)
index 0000000..761ec91
--- /dev/null
@@ -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) */
index 87b9e33f135ea58fa4b8f7cc3dbd7156e56b4ee8..882221d9658458ef7bfa9d4720133fbc757edd5f 100644 (file)
@@ -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"
index f5a8c3fb74f383df2da2d4ef3ab38bb208d90435..0794d9fb71d48e1d36bee4ed08dd903365287414 100644 (file)
@@ -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"
index 8b0060bffd944a775f831d59ffa2284e8acce6b3..8dd5abd6b8559393b2c5093c0c4a249e85894a56 100644 (file)
@@ -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"
 
 \f
 /* Work with core dump and executable files, for GDB. 
index 4869772b6a41e221b9b7f8301fee37f399640ec4..e8f01ef08a1345a13df0638de1570fea97b06ce2 100644 (file)
@@ -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"
index 7b366505dc24e4f72168769b501fbc873a77ff59..31556971514d0e9ab2222b8f5b7fe0c0063ce375 100644 (file)
@@ -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"
index d01b693a9a6ea7a75bb04254a7f3636f41ce76c0..139bb855caf1c7a2f7b97e43d944064b802d42d2 100644 (file)
@@ -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"
index 6a26380a89612fb7deb92d45dbe802434a3eb196..9454aab30163c1bcfa9ddb9cf01aa9d9a7d7018e 100644 (file)
@@ -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>
index ae17ce16762a129bba864033b356f76697244447..c3473c7fc4112fbc5402d0f4bb055c6b71457af4 100644 (file)
@@ -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 */
index 4e2d323d70ce97198a797004abcff90f8166dd23..cddc2eca78ae6fd18ae00155a209eb8288a982e5 100644 (file)
@@ -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>
 
 
index 8ecbad99d760a0491d7b3aacb7656345edba87b0..8cd8466f0e2452f540270a3e47534f1f82d32aac 100644 (file)
@@ -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>
index 0ca4d5668e192090dad665070e03d3161ade1319..539c528d052b21c6a1652499eacd33c79d6d007d 100644 (file)
@@ -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
index 56dc0e679244583dc115239e57c3a0ae569746cf..788d786074f3e2e515f61a10c2f7d056712d4fdb 100644 (file)
@@ -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>
 
index 011224e4ae980174411619564c76e0e7d266468f..0013e91b97ce0292ed490cf3aaeb0c32523d2ec7 100644 (file)
@@ -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 */
+
 \f
 #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;
index 5ad2bfc45dbf47159f80bf40c3b61d25312ab2ba..a55744a20c092ece68a3ddc88bc5699c0f6b78dd 100644 (file)
@@ -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
index c6c8c5233edb7978d486f2b04b3b4b1b3ea2dc89..d70c6e3e8964de02cb3b0fd97851a7c0b3a88b7a 100644 (file)
@@ -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.  */
index f989cb2aec15b9e0eee0abf0cccdd75aa5d28aa9..224b8a921fd8f7a3a641f397ca0ee94ae5d43a90 100644 (file)
@@ -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
index c9ee800f31800a560cdc95e1aadadb3cc87b3810..6a3d3feb6a1e588f8457eeb72f19821c0f3cf95f 100644 (file)
@@ -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
index b16c52313de4977a885fa225f0df55c4716910bf..852bfb0427443fa229cf41690537438c84eb664a 100644 (file)
@@ -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"
index 150b066b721c44a5d76d6859e2d9cca613366a9a..42621ffa6ffde1fb39041a26367216843ec4eab2 100644 (file)
@@ -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
index 54d4b6a76e02b0e161be31882237d2458a759105..88b7a0857ed11a77d0983750664601f69b19c13e 100644 (file)
@@ -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"
 
index 354b8ff319d0e9cdc34b8f362ceef6eabd561364..f34985a1e934b2744ad4ea3d5ce4f096306d5f72 100644 (file)
@@ -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"
index 9a90dd16d270a5ff0ea48a165091ff4651a59f42..80fcec7d5e5b6167440bea3a71151c878c420dc8 100644 (file)
@@ -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. */
 
index 1eb07b9291cea3debe838684b509bb765ab2267b..e76421d177a0ca74ef40d3a8d5816f2e43def8d9 100644 (file)
@@ -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 */
index 7ba977a87cbb6850b729fc01d63c1309b8ebf3ae..a31a04ddf0d2435c2e95b4faaf45732954ddb5d7 100644 (file)
@@ -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"
index 80ec2b6d9ff6860f45683c7630ddc91fdd13612b..bd53342dad7d94d1c036795f375a3d476e4420fc 100644 (file)
@@ -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 */
 
index 6a91cd67d99aa80593139b0bfedbdc5edbe0d1cb..a34dd6d87b8588a8e8a637619b8184f2f3bcf634 100644 (file)
@@ -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"
index 017d4a99c465d111a2057db842516e7f095cbdf0..9230f55d9fe810ccf9f841493be3db1c40cd926e 100644 (file)
@@ -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"
index 36f7c3917b4d23d9a2c23bf0a5fe4587900ddb20..aa3c4f683e3b4fffac50665d234114fee3b320ef 100644 (file)
@@ -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"
index e2718065e93ce2da55ffb65aeaf288173121e43e..22fbad57a01e069dab56d1c382b2f5dfc393e388 100644 (file)
@@ -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;
index 9584bd1f5d2318f0a7112be48f83ca00c6e9b0d9..383bdccc72197e410c3126b1b2531d1878fc7e5c 100644 (file)
@@ -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"
index bdfdd5f4ce1fa9bccd54d10ff3fa59e09c189d39..b7f327ab23fa9835bf639a405fda43b28578ac33 100644 (file)
@@ -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"
 
 \f
 void
index fc31eba9a602a686729b7c7cf46fd2c2c4085634..96ccaf14fa28457dc30d914093fc857812176b6a 100644 (file)
@@ -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.
index 62562c7d2b4de25dd026eb3dbc8167c46865fa7e..ecacd04b01b8858cfc4d5fe2bfd191b4877f7390 100644 (file)
@@ -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"
index df984bd79aac2211b7a38bad60b07af678144871..81e6de019c47be4ed7c5e48b8b2ccb60adc53b50 100644 (file)
@@ -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"
index 2ee7c9a49a03a51d355a1b55e016a236141b0961..0d98892a5c135faf6e22ec6786286653b83cc3d0 100644 (file)
@@ -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"
index b3b72d28eca475e1d9928d236804d07aed9e5889..52d608e802957023b310856803d606b16d1dc494 100644 (file)
@@ -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>
index 644650e5a2b150d55b6190c85b448153dbfc7bb2..b4aaaed310e408614f99fc835c4c4a0a696aacba 100644 (file)
@@ -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.
    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.");
 }
index 0d9b37745edcab39c7b9b3e091c17548c05ac764..af9f505a46ca614c55a58cc2f0be8adf31b4c985 100644 (file)
@@ -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"
index bd5e2bcfe984a8b0a2ae7cc5870aae2fefa90fa8..4aa384f7caca9836e708e5e3a36fad738700a305 100644 (file)
@@ -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"
index 0d42aa964f22a48653b694e9eaa1348cddbb3762..c3c42b8425372289590dcb68c02f0edad6de0d89 100644 (file)
@@ -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>
index 9b798a8366aa474376f00c090c58ea166b538353..e66f0c03584765b6269a70c3cf5efefa9373ddf1 100644 (file)
@@ -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"
index 69cf3e46dc2e55787ece4b5667c1de0d7c90ab31..23f04eb8c904216ed8904909ca2e54f9cfb4afc5 100644 (file)
@@ -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"
index f12b8baa5867419b641f5b342a134386b58e47b5..d29ebcd2704b219abea712e7ff8c59dd1acda4af 100644 (file)
@@ -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"
index 79e5701a8336a4b6907bfae174cc099c1c39a4cc..0e5a67109c81496c54c15f020d9bade80dd350e2 100644 (file)
@@ -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>
index 50c5678bffad3e0058cffb5080f85e02b3727d7f..ffb20b162757f99caebcbe668b51eb80f94446a6 100644 (file)
@@ -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"
 
index a608b5667ec1b7c85b4e737f2b20a082d56cc08a..35fde329031f231cada632693509f4d8f6c155c2 100644 (file)
@@ -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"
index ddd5239014a0b2db7d3a2ad89493512d42ac19cd..b2208ed429898668e56c004900aadc33b2318271 100644 (file)
@@ -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"
index f999bf9e3857c100d46609cbf2c734ba96cd8e93..5c3e490f32077cfb77896c3d3dba4b410eaa643d 100644 (file)
@@ -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>
index 5621bcebb96fd12bc9fbddb41d45eb9622fbd297..b4895942d705a0b8182b44b8a1f68ed0c32cb6a3 100644 (file)
@@ -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>
index ed6bbb05c746e9e425c3432d1373ce380118af63..e44005b1ec4e6673aed6337c406cf4ffccffce8a 100644 (file)
@@ -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>
index b979523966de8c53e9ba4ecb25fd15f84f6ff140..3558f15eba9bb004b9a33e43b86fd00839f9d203 100644 (file)
@@ -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>
index b88f2bae4f555ac73d12020a80964fb1f648638f..bce5f116c88e91aac5f04c543528d042882e1521 100644 (file)
@@ -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>
index fef7125ae7f3a448d4df9d00e01eab226376f8d1..3648542e16ea50693b70f24b453b4c5006ada1cd 100644 (file)
@@ -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>
index 8e59d4cab1e0f9e65809e3c72c38b2644a8cf6e3..103bf156dac6fee6b817af5386757135351a7e4e 100644 (file)
@@ -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;
 }
 \f
-/*   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);
+}
 \f
 /* 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?) */
 
 \f
 /* 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);
+}
+
 \f
 #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);
 }
index 8fac1d847a12aee646cda8beed935922c369312d..b2b2d20dc3e182c62c766aae4acf58aa26a40656 100644 (file)
@@ -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>
 
index 2548e62d99f34363458eb56e92fb9d5d514e0fc0..d44156d1866b65e45904bfe172f6514c5e2fa222 100644 (file)
@@ -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>
index c2ebf14312573a5c10a19733ab07e00bfe6fc2ae..49aa5ded773f182869d8582324e3f34fb4f97272 100644 (file)
@@ -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>
 
index 7b7aead22e1581f7e14d14e01813d2010b8ab0ec..e2ceb91cc328e5add4606977b3596fa79a2d4eea 100644 (file)
@@ -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>
index ccd7b8e28b0db7496a2bc7855e4d7b3d92706de8..db80a0d2553fdcbde680e8c06f9402fc054ae030 100644 (file)
@@ -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"
index 71e74ade80ed5a7fe844320532f84e662d5ef93d..5bde58e70007f4e230df27262c357c6f3ec0d364 100644 (file)
@@ -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"
index fa9b26f222fa08863a6dcbe00f5bc54782a6c548..c3a4638bb94875eb714a0d96b5bb8b51ac2f6033 100644 (file)
@@ -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>
index 3c069c72d5220826d6ac4c4e649b199494c8446f..dde7eb167b900f6eac5facd39b6dca0898acb267 100644 (file)
@@ -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>
 
index 767fe7599f462dec065a77e308d2d46d74a9769b..65890f097b436e0b7f3e270682bebf48a0deab79 100644 (file)
@@ -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>
 
 \f
index 6a14c248a4e4606d3aacd0f044a5630d836a7116..24b19a44b5d72929fc1fadc8c304f297fadc0d15 100644 (file)
@@ -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>
index 6f235bd27ca34e683e81561525a4f6e8df0d493e..436f68c88ef2f45afec18be32985a05fcca676b9 100644 (file)
@@ -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
index 279d4f38d11676f7a436dcd3c88af718b749c886..6e4e02691cd46bf8b769dbd31e6b06583fa41b0c 100644 (file)
@@ -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>
 
index daca178bc54df9c776db9c79927724507bc19c12..e9af39f76f86e3e64a698681a2b576ca49c1b91e 100644 (file)
@@ -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");
+       }
+    }
+}
+
 \f
 /* Return the nexting depth of a block within other blocks in its symtab.  */
 
index 3f6c00efeb7053560df1afc433198368feff76c5..cdb17936c33d43e6209dfaf6355350c4437990fd 100644 (file)
@@ -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 *);
@@ -3202,51 +3233,6 @@ make_symbol_completion_list (text, word)
   return (return_val);
 }
 
-\f
-#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 
 \f
 void
 _initialize_symtab ()
index 838afb6b626e7daf08223be4ac14691d036b3e90..9ae8941482a56297270da18af8981df5cb7d0df0 100644 (file)
@@ -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
index 72fa4642765057720c1811b7d162561a166d4b21..cd8a37c8a7e99ec995872ee627fbfbcdf3e6ccbd 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -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));
index 785ec619af6fd2a7686773d9adb168dab8abd7aa..37d6ebc39b2aad65e22ddff6f45b04668c9ab378 100644 (file)
@@ -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
index f1b81b78da0adb3077f62dc5d243bdf6171eab87..0ff415c12ef9e2c870ad4716fad169879960217b 100644 (file)
@@ -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
index bda2697b473bc73a2128460f967a96ccbf7da472..994138afc258c01e99ce87150e0e9053a729c10c 100644 (file)
@@ -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 */
 
index 800e8c068c84db4dbb9580c92154f20d31e6a772..83012a79ffc25dd92197e70385a059bc34d3cb1f 100644 (file)
@@ -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. */
index fdf793820a53d66064d98f9b438e0426c9057c68..757db697f316d6c7402c6081d349a5fd1c6f5bfb 100644 (file)
@@ -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
index 79c09438b07918de0c8a6b1c50763df231f96e9b..9af5bb0fa7a34ab4265e68531a1b3630a491b554 100644 (file)
@@ -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));
 
 \f
 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;
index ea0a3437b0004c7b7a31ad1c33a02c89d1dc3fbc..79a72a3fd92d22a767d12536b917afb493214af1 100644 (file)
@@ -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;
        }
 
index d4c86969837cd46d82e92430a37fe79c274705f1..591978a4f10147859693c49e3ae17e39c4fb02e3 100644 (file)
@@ -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;
        }
@@ -1055,6 +1030,13 @@ _initialize_valprint ()
                  &setprintlist),
      &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,
index accb0d595801516018973cb15aea40c9da6b170d..22aa4f89ce0f0bd4eb52dfbf3b2a4e50a35e621a 100644 (file)
@@ -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"
index fec6b4e2d24651c3d8484216637479e0d76385b4..bda6caa9f6829a8cefe5c6bb906aa51e5fe1ad14 100644 (file)
@@ -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"
This page took 0.138359 seconds and 4 git commands to generate.