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.
fork-child.c
frame.h
gcc.patch
+gdb_stat.h
+gdb_string.h
gdb-stabs.h
gdb.1
gdb.gdb
+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
#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. */
#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.
#include <sys/user.h> /* After a.out.h */
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <errno.h>
#endif
void
_initialize_arm_tdep ()
{
- tm_print_insn = print_insn_arm;
+ tm_print_insn = print_insn_little_arm;
}
#include <sys/user.h> /* After a.out.h */
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <errno.h>
#include "thread.h"
#include "target.h"
#include "language.h"
-#include <string.h>
+#include "gdb_string.h"
#include "demangle.h"
#include "annotate.h"
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;
{
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;
&& 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;
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;
}
#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 /**/
#include "c-lang.h"
#include "typeprint.h"
-#include <string.h>
+#include "gdb_string.h"
#include <errno.h>
#include <ctype.h>
#include "ch-lang.h"
#include "typeprint.h"
-#include <string.h>
+#include "gdb_string.h"
#include <errno.h>
static void
#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 */
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;
};
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 =
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));
-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);
+ }
}
}
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));
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;
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);
}
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;
{
register char *rawptr;
struct internal_lineno lptr;
+ if (!linetab)
+ return ;
if (file_offset < linetab_offset)
{
complain (&lineno_complaint, file_offset);
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)
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)
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;
#include "symtab.h"
#include "value.h"
#include <ctype.h>
-#include <string.h>
+#include "gdb_string.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#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
* USER area using the "PEEKUSER" ptrace call.
*/
#define PT_READ_U 3
-
-#define MEM_FNS_DECLARED /* /usr/include/string.h can get it wrong */
#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) \
#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()
#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) \
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
#if !defined (HOST_BYTE_ORDER)
#define HOST_BYTE_ORDER BIG_ENDIAN
#endif
-
-#define MEM_FNS_DECLARED
#define HOST_BYTE_ORDER BIG_ENDIAN
#endif
-#define MEM_FNS_DECLARED
-
#define USG 1
/* setjmp.h requires uid_t. */
#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). */
#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. */
#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()
#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*
/* 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
#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
#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,
#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. */
/* for INT_MIN, to avoid "INT_MIN redefined" warnings from defs.h */
#include <limits.h>
-
-#define MEM_FNS_DECLARED
#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
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
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
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=
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
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; }
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; }
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; }
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; }
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; }
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; }
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
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
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=
#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"
#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>
#include <sys/procfs.h>
#include <fcntl.h>
#include <errno.h>
-#include <string.h>
+#include "gdb_string.h"
#include "inferior.h"
#include "target.h"
#include <sys/procfs.h>
#include <fcntl.h>
#include <errno.h>
-#include <string.h>
+#include "gdb_string.h"
#include "inferior.h"
#include "target.h"
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>
#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
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>
#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
#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"
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>
#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"
#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 {
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. */
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 */
/* 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);
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.
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) \
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
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.
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.
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;
{
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);
/* 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
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;
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);
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)
#include "defs.h"
#include "dcache.h"
#include "gdbcmd.h"
-#include <string.h>
+#include "gdb_string.h"
/*
#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
#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>
#include "buildsym.h"
#include <obstack.h>
-#include <string.h>
+#include "gdb_string.h"
#include "dst.h"
#include "complaints.h"
#include <fcntl.h>
-#include <string.h>
+#include "gdb_string.h"
#ifndef NO_SYS_FILE
#include <sys/file.h>
#include "defs.h"
#include "bfd.h"
-#include <string.h>
+#include "gdb_string.h"
#include "libelf.h"
#include "elf/mips.h"
#include "symtab.h"
#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. */
extern char **environ;
register int i;
+ if (environ == NULL)
+ return;
+
for (i = 0; environ[i]; i++) /*EMPTY*/;
if (e->allocated < i)
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;
}
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"
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
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)));
#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
}
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
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"
#include "typeprint.h"
#include "frame.h" /* ??? */
-#include <string.h>
+#include "gdb_string.h"
#include <errno.h>
#if 0 /* Currently unused */
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"
#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));
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. */
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)
{
registers_pid = inferior_pid;
}
- numregs = ARCH_NUM_REGS;
- for (i = 0; i < numregs; i++)
- if (!register_valid[i])
- {
- target_fetch_registers (-1);
- break;
- }
+ /* See if we are trying to read bytes from out-of-date registers. If so,
+ update just those registers. */
+
+ for (regno = 0; regno < NUM_REGS; regno++)
+ {
+ int regstart, regend;
+ int startin, endin;
+
+ if (register_valid[regno])
+ continue;
+
+ regstart = REGISTER_BYTE (regno);
+ regend = regstart + REGISTER_RAW_SIZE (regno);
+
+ startin = regstart >= inregbyte && regstart < inregend;
+ endin = regend > inregbyte && regend <= inregend;
+
+ if (!startin && !endin)
+ continue;
+
+ /* We've found an invalid register where at least one byte will be read.
+ Update it from the target. */
+
+ target_fetch_registers (regno);
+
+ if (!register_valid[regno])
+ error ("read_register_bytes: Couldn't update register %d.", regno);
+ }
+
if (myaddr != NULL)
- memcpy (myaddr, ®isters[regbyte], len);
+ memcpy (myaddr, ®isters[inregbyte], inlen);
}
/* Read register REGNO into memory at MYADDR, which must be large enough
REGISTER_RAW_SIZE (regno));
}
-/* Copy LEN bytes of consecutive data from memory at MYADDR
- into registers starting with the REGBYTE'th byte of register data. */
+/* Write register REGNO at MYADDR to the target. MYADDR points at
+ REGISTER_RAW_BYTES(REGNO), which must be in target byte-order. */
void
-write_register_bytes (regbyte, myaddr, len)
- int regbyte;
+write_register_gen (regno, myaddr)
+ int regno;
char *myaddr;
- int len;
{
+ int size;
+
+ /* On the sparc, writing %g0 is a no-op, so we don't even want to change
+ the registers array if something writes to this register. */
+ if (CANNOT_STORE_REGISTER (regno))
+ return;
+
if (registers_pid != inferior_pid)
{
registers_changed ();
registers_pid = inferior_pid;
}
- /* Make sure the entire registers array is valid. */
- read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
- memcpy (®isters[regbyte], myaddr, len);
- target_store_registers (-1);
+ size = REGISTER_RAW_SIZE(regno);
+
+ /* If we have a valid copy of the register, and new value == old value,
+ then don't bother doing the actual store. */
+
+ if (register_valid [regno]
+ && memcmp (®isters[REGISTER_BYTE (regno)], myaddr, size) == 0)
+ return;
+
+ target_prepare_to_store ();
+
+ memcpy (®isters[REGISTER_BYTE (regno)], myaddr, size);
+
+ register_valid [regno] = 1;
+
+ target_store_registers (regno);
+}
+
+/* Copy INLEN bytes of consecutive data from memory at MYADDR
+ into registers starting with the MYREGSTART'th byte of register data. */
+
+void
+write_register_bytes (myregstart, myaddr, inlen)
+ int myregstart;
+ char *myaddr;
+ int inlen;
+{
+ int myregend = myregstart + inlen;
+ int regno;
+
+ target_prepare_to_store ();
+
+ /* Scan through the registers updating any that are covered by the range
+ myregstart<=>myregend using write_register_gen, which does nice things
+ like handling threads, and avoiding updates when the new and old contents
+ are the same. */
+
+ for (regno = 0; regno < NUM_REGS; regno++)
+ {
+ int regstart, regend;
+ int startin, endin;
+ char regbuf[MAX_REGISTER_RAW_SIZE];
+
+ regstart = REGISTER_BYTE (regno);
+ regend = regstart + REGISTER_RAW_SIZE (regno);
+
+ startin = regstart >= myregstart && regstart < myregend;
+ endin = regend > myregstart && regend <= myregend;
+
+ if (!startin && !endin)
+ continue; /* Register is completely out of range */
+
+ if (startin && endin) /* register is completely in range */
+ {
+ write_register_gen (regno, myaddr + (regstart - myregstart));
+ continue;
+ }
+
+ /* We may be doing a partial update of an invalid register. Update it
+ from the target before scribbling on it. */
+ read_register_gen (regno, regbuf);
+
+ if (startin)
+ memcpy (registers + regstart,
+ myaddr + regstart - myregstart,
+ myregend - regstart);
+ else /* endin */
+ memcpy (registers + myregstart,
+ myaddr,
+ regend - myregstart);
+ target_store_registers (regno);
+ }
}
/* Return the raw contents of register REGNO, regarding it as an integer. */
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
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"
--- /dev/null
+/* 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) */
--- /dev/null
+/* 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) */
#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"
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"
#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.
/*#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"
#include "defs.h"
#include "bfd.h"
-#include <string.h>
+#include "gdb_string.h"
#include "hp-symtab.h"
#include "syms.h"
#include "symtab.h"
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"
#include <fcntl.h>
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <stddef.h>
#include <sys/ptrace.h>
#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 */
#include <machine/reg.h>
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <sys/core.h>
#endif
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#ifndef NO_SYS_REG_H
#include <sys/reg.h>
/* 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.
#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"
printf_filtered ("\
Single stepping until exit from function %s, \n\
which has no line number information.\n", name);
- gdb_flush (gdb_stdout);
}
}
else
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
#include "target.h"
#include "thread.h"
-#include <string.h>
+#include "gdb_string.h"
#include <signal.h>
#include <fcntl.h>
/* 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.
#include "frame.h"
#include "inferior.h"
#include "target.h"
+#include "gdb_string.h"
#ifdef USG
#include <sys/types.h>
/* 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)
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. */
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
if (errno)
perror_with_name ("ptrace");
}
+#endif /* CHILD_RESUME */
+
\f
#ifdef ATTACH_DETACH
/* Start debugging the process whose number is PID. */
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;
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);
}
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;
}
else
{
- for (regno = 0; regno < NUM_REGS; regno++)
+ numregs = ARCH_NUM_REGS;
+ for (regno = 0; regno < numregs; regno++)
{
if (CANNOT_STORE_REGISTER (regno))
continue;
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"
else
pid = target_wait (-1, &w);
+#ifdef HAVE_NONSTEPPABLE_WATCHPOINT
have_waited:
+#endif
flush_cached_frames ();
(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
/* 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
#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. */
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
#include "demangle.h"
#include "m2-lang.h"
-#include <string.h>
+#include "gdb_string.h"
#include <errno.h>
void
#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"
#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
#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"
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include "symtab.h"
#include "bfd.h"
#include "symfile.h"
mdebugread.c. */
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include "bfd.h"
#include "symtab.h"
#include "symfile.h"
/* 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,
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. */
#include <varargs.h>
#endif
#include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
#include <sys/types.h>
#include "command.h"
#include "serial.h"
static int
monitor_write_memory (memaddr, myaddr, len)
CORE_ADDR memaddr;
- unsigned char *myaddr;
+ char *myaddr;
int len;
{
unsigned LONGEST val;
static int
monitor_read_memory_single (memaddr, myaddr, len)
CORE_ADDR memaddr;
- unsigned char *myaddr;
+ char *myaddr;
int len;
{
unsigned LONGEST val;
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 */
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 */
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"
#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 */
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__)
#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"
#include <sys/types.h>
#include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
#include <fcntl.h>
#include "symtab.h"
come first in the result. */
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "frame.h"
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"
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);
#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;
#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"
#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
#else /* not emacs */
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
/*
* Define the syntax stuff, so we can do the \<...\> things.
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"
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"
#include <varargs.h>
#endif
#include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
#include <sys/types.h>
#include "command.h"
#include "serial.h"
#include "inferior.h"
#include "wait.h"
-#include <string.h>
+#include "gdb_string.h"
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
/* 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);
}
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. */
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 ();
}
}
{
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++;
}
}
}
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';
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;
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)
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;
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];
static char *dir = "";
/* Grab the next token and buy some space for it */
+
static char *
next (ptr)
char **ptr;
char *s;
char *r;
int l = 0;
+
while (*p && *p == ' ')
- {
- p++;
- }
+ p++;
s = p;
while (*p && (*p != ' ' && *p != '\t'))
{
return r;
}
-static
-e7000_login (args, from_tty)
+static void
+e7000_login_command (args, from_tty)
char *args;
int 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;
}
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 */
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)
}
}
-/* 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;
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";
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\
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;
}
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;
{
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;
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
{
}
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;
}
{
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;
{
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 ();
}
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;
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
<- ENQ
ACK ->
<- :
- */
+ */
static int
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];
int check_sum;
int where = 0;
int alen;
+
stride = len - i;
if (stride > maxstride)
stride = maxstride;
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)
{
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
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++)
}
/* 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;
}
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!
{
int count;
int c;
+ char buf[200];
/* Starting address of this pass. */
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 ();
{
int loop;
int c;
+ char buf[200];
if (((memaddr - 1) + len) < memaddr)
{
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)
int length;
int addr;
int i;
+
c = gch ();
switch (c)
{
case '3':
{
int alen;
+
alen = type - '0' + 1;
addr = 0;
while (alen--)
}
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 =");
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
char *args;
int from_tty;
{
-
}
/* Clean up when a program exits.
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)
unsigned char *shadow;
{
int i;
+ char buf[200];
static char nop[2] = NOP;
for (i = 0; i <= MAX_E7000DEBUG_BREAKPOINTS; i++)
{
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;
}
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
}
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;
}
}
-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]))
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]);
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;
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 */
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 =
{
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 */
};
_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.");
}
over the net in real time. */
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include "inferior.h"
#include "bfd.h"
#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"
#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>
#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"
#include <varargs.h>
#endif
#include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
#include <sys/types.h>
#include "command.h"
#include "serial.h"
"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"
#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>
#include <varargs.h>
#endif
#include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
#include <sys/types.h>
#include "serial.h"
#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"
#include <ctype.h>
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include "gdbcmd.h"
#include "target.h"
#include "serial.h"
#include "objfiles.h"
#include "gdb-stabs.h"
-#include <string.h>
+#include "gdb_string.h"
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#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>
#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>
#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>
#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>
#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>
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)
"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"
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));
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
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)
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. */
/* 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\
target_preopen (from_tty);
- unpush_target (&remote_ops);
+ unpush_target (target);
remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
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
{
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;
}
}
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);
}
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 */
/* 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;
{
dcache_poke (remote_dcache, addr, word);
}
+#endif /* 0 (unused?) */
\f
/* Write memory data directly to the remote machine.
char *buf;
int forever;
{
- char *bp;
int c;
int tries;
int timeout;
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
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
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);
}
#include <a.out.h>
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <sys/core.h>
#include <sys/ldr.h>
#include <sys/types.h>
#include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
#include <sys/param.h>
#include <fcntl.h>
#include <unistd.h>
#include "stabsread.h"
#include "gdb-stabs.h"
#include "complaints.h"
-#include <string.h>
+#include "gdb_string.h"
#include "demangle.h"
#include <sys/file.h>
#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>
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"
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"
#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>
#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>
#include <machine/reg.h>
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <sys/core.h>
\f
#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>
#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
#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>
/* 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.
#include "obstack.h"
#include "language.h"
-#include <string.h>
+#include "gdb_string.h"
#ifndef DEV_TTY
#define DEV_TTY "/dev/tty"
case mst_text:
ms_type = 'T';
break;
+ case mst_solib_trampoline:
+ ms_type = 'S';
+ break;
case mst_data:
ms_type = 'D';
break;
{
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)
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 (",
" 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);
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");
}
}
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))
{
}
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++)
{
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)
{
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;
}
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;
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:
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;
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. */
#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 */
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));
}
}
- /* 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;
{
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;
}
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)
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)
/* 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] != '\'')
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. */
}
}
- msymbol = lookup_minimal_symbol (copy, (struct objfile *) NULL);
+ msymbol = lookup_minimal_symbol (copy, NULL, NULL);
if (msymbol != NULL)
{
val.symtab = 0;
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 *);
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 ()
#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"
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
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
#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));
#include "language.h"
#include "demangle.h"
-#include <string.h>
+#include "gdb_string.h"
#include <errno.h>
static void
#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
#include "gdbcore.h"
#include <sys/file.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
/* Assorted operating system circumventions */
#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. */
#include <varargs.h>
#endif
#include <ctype.h>
-#include <string.h>
+#include "gdb_string.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#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). */
#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
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
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;
/* 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.
#include "language.h"
#include <errno.h>
-#include <string.h>
+#include "gdb_string.h"
/* Local functions. */
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);
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))
{
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);
}
/* 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;
}
/* 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.
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"
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
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. */
int format;
enum val_prettyprint pretty;
{
- register unsigned int n, typelen;
-
if (val == 0)
{
printf_filtered ("<address of value unknown>");
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 */
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
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);
/* 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)));
/* 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 ());
}
}
}
-static void
+void
value_print_array_elements (val, stream, format, pretty)
value_ptr val;
GDB_FILE *stream;
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;
}
&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,
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"
#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"