symtab.h, tm-i386v4.h, valprint.c, values.c: Lint.
* breakpoint.c, c-exp.y, coffread.c, command.c, environ.c, eval.c,
findvar.c, infcmd.c, infptrace.c, infrun.c, m2-exp.y, parse.c,
putenv.c, solib.c, sparc-xdep.c, symtab.c, tm-i386v.h, tm-sparc.h,
utils.c, valarith.c, valops.c, valprint.c, values.c:
Replace bcopy() use with memcpy(), which is more standard and can
take advantage of gcc's builtin functions for increased performance.
* breakpoint.c, buildsym.c, coffread.c, dbxread.c, i386-tdep.c,
ieee-float.c, infcmd.c, sparc-tdep.c, stack.c, symtab.c, symtab.h,
target.c, values.c:
Replace bzero() use with memset(), which is more standard and can
take advantage of gcc's builtin functions for increased performance.
* i386-tdep.c, main.c, valprint.c:
Replace bcmp() use with memcmp(), which is more standard and can
take advantage of gcc's builtin functions for increased performance.
+Mon Jun 29 16:30:25 1992 Fred Fish (fnf@cygnus.com)
+
+ * dbxread.c, i386-pinsn.c, i386-tdep.c, regex.c, solib.c, symmisc.c,
+ symtab.h, tm-i386v4.h, valprint.c, values.c: Lint.
+ * breakpoint.c, c-exp.y, coffread.c, command.c, environ.c, eval.c,
+ findvar.c, infcmd.c, infptrace.c, infrun.c, m2-exp.y, parse.c,
+ putenv.c, solib.c, sparc-xdep.c, symtab.c, tm-i386v.h, tm-sparc.h,
+ utils.c, valarith.c, valops.c, valprint.c, values.c:
+ Replace bcopy() use with memcpy(), which is more standard and can
+ take advantage of gcc's builtin functions for increased performance.
+ * breakpoint.c, buildsym.c, coffread.c, dbxread.c, i386-tdep.c,
+ ieee-float.c, infcmd.c, sparc-tdep.c, stack.c, symtab.c, symtab.h,
+ target.c, values.c:
+ Replace bzero() use with memset(), which is more standard and can
+ take advantage of gcc's builtin functions for increased performance.
+ * i386-tdep.c, main.c, valprint.c:
+ Replace bcmp() use with memcmp(), which is more standard and can
+ take advantage of gcc's builtin functions for increased performance.
+
Sun Jun 28 13:30:22 1992 Fred Fish (fnf@cygnus.com)
* remote.c (remote_wait): Fix cast on signal() call.
bptlen -= (membpt + bptlen) - (memaddr + len);
}
- bcopy (b->shadow_contents + bptoffset,
- myaddr + membpt - memaddr, bptlen);
+ (void) memcpy (myaddr + membpt - memaddr,
+ b->shadow_contents + bptoffset, bptlen);
if (membpt > memaddr)
{
for (; bs != NULL; bs = bs->next)
{
tmp = (bpstat) xmalloc (sizeof (*tmp));
- bcopy (bs, tmp, sizeof (*tmp));
+ (void) memcpy (tmp, bs, sizeof (*tmp));
if (p == NULL)
/* This is the first thing in the chain. */
retval = tmp;
register struct breakpoint *b, *b1;
b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
- bzero (b, sizeof *b);
+ (void) memset (b, 0, sizeof (*b));
b->address = sal.pc;
b->symtab = sal.symtab;
b->line_number = sal.line;
if (b->symtab)
printf_filtered (": file %s, line %d.",
b->symtab->filename, b->line_number);
+ break;
+ case bp_until:
+ case bp_finish:
+ case bp_longjmp:
+ case bp_longjmp_resume:
+ break;
}
printf_filtered ("\n");
}
bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
- bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
+ (void) memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
while (block != 0)
{
type_vector = (struct type **)
xrealloc ((char *) type_vector,
(type_vector_length * sizeof (struct type *)));
- bzero (&type_vector[old_len],
- (type_vector_length - old_len) * sizeof (struct type *));
+ (void) memset (&type_vector[old_len], 0,
+ (type_vector_length - old_len) * sizeof (struct type *));
}
return &type_vector[index];
}
f->length *= 2;
f->vector = (struct type **)
xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
- bzero (&f->vector[f_orig_length],
- (f->length - f_orig_length) * sizeof (struct type *));
+ (void) memset (&f->vector[f_orig_length], 0,
+ (f->length - f_orig_length) * sizeof (struct type *));
}
return &f->vector[index];
}
buildsym_new_init ()
{
/* Empty the hash table of global syms looking for values. */
- bzero (global_sym_chain, sizeof global_sym_chain);
+ (void) memset (global_sym_chain, 0, sizeof global_sym_chain);
buildsym_init ();
}
/* Create range type. */
range_type = (struct type *)
obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
- bzero (range_type, sizeof (struct type));
+ (void) memset (range_type, 0, sizeof (struct type));
TYPE_OBJFILE (range_type) = objfile;
TYPE_CODE (range_type) = TYPE_CODE_RANGE;
TYPE_TARGET_TYPE (range_type) = index_type;
n = read_number (pp, ',');
sym = (struct symbol *) obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
- bzero (sym, sizeof (struct symbol));
+ (void) memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = name;
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
result_type = (struct type *)
obstack_alloc (&objfile -> type_obstack,
sizeof (struct type));
- bzero (result_type, sizeof (struct type));
+ (void) memset (result_type, 0, sizeof (struct type));
TYPE_OBJFILE (result_type) = objfile;
TYPE_LENGTH (result_type) = nbits / TARGET_CHAR_BIT;
TYPE_CODE (result_type) = TYPE_CODE_INT;
result_type = (struct type *)
obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
- bzero (result_type, sizeof (struct type));
+ (void) memset (result_type, 0, sizeof (struct type));
TYPE_OBJFILE (result_type) = objfile;
TYPE_CODE (result_type) = TYPE_CODE_RANGE;
TYPE_FIELDS (result_type) =
(struct field *) obstack_alloc (&objfile -> type_obstack,
2 * sizeof (struct field));
- bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field));
+ (void) memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
TYPE_FIELD_BITPOS (result_type, 0) = n2;
TYPE_FIELD_BITPOS (result_type, 1) = n3;
else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID)
{
rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
- bzero (rval + n, sizeof (struct type *));
+ (void) memset (rval + n, 0, sizeof (struct type *));
}
else
{
{
char *err_copy = (char *) alloca (p - tokstart + 1);
- bcopy (tokstart, err_copy, p - tokstart);
+ (void) memcpy (err_copy, tokstart, p - tokstart);
err_copy[p - tokstart] = 0;
error ("Invalid number \"%s\".", err_copy);
}
type_vector = (struct type **)
xrealloc ((char *) type_vector,
type_vector_length * sizeof (struct type *));
- bzero (&type_vector[old_vector_length],
+ (void) memset (&type_vector[old_vector_length], 0,
(type_vector_length - old_vector_length) * sizeof(struct type *));
}
return &type_vector[index];
int num_symbols;
int symtab_offset;
int stringtab_offset;
- struct symtab *s;
info = (struct coff_symfile_info *) objfile -> sym_private;
symfile_bfd = abfd; /* Kludge for swap routines */
nlist_stream_global = stream;
nlist_nsyms_global = nsyms;
last_source_file = 0;
- bzero (opaque_type_chain, sizeof opaque_type_chain);
+ (void) memset (opaque_type_chain, 0, sizeof opaque_type_chain);
if (type_vector) /* Get rid of previous one */
free ((PTR)type_vector);
type_vector_length = 160;
type_vector = (struct type **)
xmalloc (type_vector_length * sizeof (struct type *));
- bzero (type_vector, type_vector_length * sizeof (struct type *));
+ (void) memset (type_vector, 0, type_vector_length * sizeof (struct type *));
coff_start_symtab ();
if (stringtab == NULL)
return -1;
- bcopy (&length, stringtab, sizeof length);
+ (void) memcpy (stringtab, &length, sizeof length);
if (length == sizeof length) /* Empty table -- just the count */
return 0;
return -1;
/* Terminate it with an all-zero sentinel record */
- bzero (linetab + size, local_linesz);
+ (void) memset (linetab + size, 0, local_linesz);
make_cleanup (free, linetab); /* Be sure it gets de-allocated. */
return 0;
TYPE_FIELDS (target) = (struct field *)
obstack_alloc (¤t_objfile -> type_obstack, field_size);
- bcopy (TYPE_FIELDS (real_target), TYPE_FIELDS (target), field_size);
+ (void) memcpy (TYPE_FIELDS (target), TYPE_FIELDS (real_target), field_size);
if (TYPE_NAME (real_target))
{
#endif
struct type *temptype;
- bzero (sym, sizeof (struct symbol));
+ (void) memset (sym, 0, sizeof (struct symbol));
name = cs->c_name;
name = (name[0] == '_' ? name + offset : name);
SYMBOL_NAME (sym) = obstack_copy0 (&objfile->symbol_obstack, name, strlen (name));
struct type *new = (struct type *)
obstack_alloc (&objfile->symbol_obstack, sizeof (struct type));
- bcopy(lookup_function_type (decode_function_type (cs, cs->c_type, aux)),
- new, sizeof(struct type));
+ (void) 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
type = (struct type *)
obstack_alloc (¤t_objfile -> type_obstack,
sizeof (struct type));
- bzero (type, sizeof (struct type));
+ (void) memset (type, 0, sizeof (struct type));
TYPE_OBJFILE (type) = current_objfile;
base_type = decode_type (cs, new_c_type, aux);
{
case C_MOE:
sym = (struct symbol *) xmalloc (sizeof (struct symbol));
- bzero (sym, sizeof (struct symbol));
+ (void) memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = savestring (name, strlen (name));
SYMBOL_CLASS (sym) = LOC_CONST;
struct cmd_list_element *showcmd =
(struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
- bcopy (setcmd, showcmd, sizeof (struct cmd_list_element));
+ (void) memcpy (showcmd, setcmd, sizeof (struct cmd_list_element));
delete_cmd (showcmd->name, list);
showcmd->type = show_cmd;
static char *
mop_up PARAMS ((string *, struct work_stuff *, int));
+#if 0
static int
demangle_method_args PARAMS ((string *, const char **, struct work_stuff *));
+#endif
static int
demangle_template PARAMS ((string *declp, const char **, struct work_stuff *));
static void
string_clear PARAMS ((string *));
+#if 0
static int
string_empty PARAMS ((string *));
+#endif
static void
string_append PARAMS ((string *, const char *));
string decl;
int success = 0;
struct work_stuff work[1];
- const char *p;
char *demangled = NULL;
if ((mangled != NULL) && (*mangled != '\0'))
struct work_stuff *work;
{
int i;
- int n;
string tname;
string trawname;
int is_pointer;
{
case 'P':
case 'R':
- done = is_pointer = 1;
- break;
+ done = is_pointer = 1;
+ break;
case 'C': /* const */
case 'S': /* explicitly signed [char] */
case 'U': /* unsigned */
case 'F': /* function */
case 'M': /* member function */
case 'O': /* ??? */
- old_p++;
- continue;
+ old_p++;
+ continue;
case 'Q': /* repetition of following */
case 'T': /* remembered type */
- abort ();
- break;
+ abort ();
+ break;
case 'v': /* void */
- abort ();
- break;
+ abort ();
+ break;
case 'x': /* long long */
case 'l': /* long */
case 'i': /* int */
case 's': /* short */
case 'c': /* char */
- done = is_integral = 1;
- break;
+ done = is_integral = 1;
+ break;
case 'r': /* long double */
case 'd': /* double */
case 'f': /* float */
- done = is_real = 1;
- break;
+ done = is_real = 1;
+ break;
default:
- abort ();
+ abort ();
}
}
if (is_integral)
success = demangle_args (declp, mangled, work);
}
}
+ return (success);
}
/*
s->p = s->b;
}
+#if 0
+
static int
string_empty (s)
string *s;
return (s->b == s->p);
}
+#endif
+
static void
string_append (p, s)
string *p;
}
#if 0
+
static void
string_prepends (p, s)
string *p, *s;
string_prependn (p, s->b, s->p - s->b);
}
}
+
#endif
static void
header_files[i].length = 10;
header_files[i].vector
= (struct type **) xmalloc (10 * sizeof (struct type *));
- bzero (header_files[i].vector, 10 * sizeof (struct type *));
+ (void) memset (header_files[i].vector, 0, 10 * sizeof (struct type *));
add_this_object_header_file (i);
}
int i;
struct symbol *sym =
(struct symbol *) xmmalloc (objfile -> md, sizeof (struct symbol));
- bzero (sym, sizeof *sym);
+ (void) memset (sym, 0, sizeof *sym);
SYMBOL_NAME (sym) = savestring (name, strlen (name));
SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_NAMESPACE (sym) = (enum namespace)((long)
DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
DBX_SYMTAB_OFFSET (objfile) = staboffset;
- if (stabstrsize < 0)
+ if (stabstrsize < 0) /* FIXME: stabstrsize is unsigned; never true! */
error ("ridiculous string table size: %d bytes", stabstrsize);
DBX_STRINGTAB (objfile) = (char *)
obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1);
extern double
atof PARAMS ((const char *nptr)); /* 4.10.1.1 */
+extern int
+atoi PARAMS ((const char *)); /* 4.10.1.2 */
+
#ifndef MALLOC_INCOMPATIBLE
extern PTR
size_t size,
int (*comp)(const void *, const void *)));
+extern PTR
+memcpy PARAMS ((void *, const void *, size_t)); /* 4.11.2.1 */
+
+extern int
+memcmp PARAMS ((const void *, const void *, size_t)); /* 4.11.4.1 */
+
extern char *
strchr PARAMS ((const char *, int)); /* 4.11.5.2 */
extern char *
strtok PARAMS ((char *, const char *)); /* 4.11.5.8 */
+extern PTR
+memset PARAMS ((void *, int, size_t)); /* 4.11.6.1 */
+
extern char *
strerror PARAMS ((int)); /* 4.11.6.2 */
static void
elf_symtab_read PARAMS ((bfd *, CORE_ADDR, struct objfile *));
+#if 0
static void
record_minimal_symbol PARAMS ((char *, CORE_ADDR, enum minimal_symbol_type,
struct objfile *));
+#endif
+
+static void
+record_minimal_symbol_and_info PARAMS ((char *, CORE_ADDR,
+ enum minimal_symbol_type, char *,
+ struct objfile *));
static void
elf_locate_sections PARAMS ((bfd *, asection *, PTR));
*/
+#if 0 /* FIXME: Unused */
+
static void
record_minimal_symbol (name, address, ms_type, objfile)
char *name;
prim_record_minimal_symbol (name, address, ms_type);
}
+#endif
+
static void
record_minimal_symbol_and_info (name, address, ms_type, info, objfile)
char *name;
/* environ.c -- library for manipulating environments for GNU.
Copyright (C) 1986, 1989 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
+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.
+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. */
+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. */
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
+#include "defs.h"
#include "environ.h"
#include <string.h>
+#include "defs.h" /* For strsave(). */
-extern char *xmalloc ();
-extern char *xrealloc ();
-extern void free ();
\f
/* Return a new environment object. */
(e->allocated + 1) * sizeof (char *));
}
- bcopy (environ, e->vector, (i + 1) * sizeof (char *));
+ (void) memcpy (e->vector, environ, (i + 1) * sizeof (char *));
while (--i >= 0)
{
register int len = strlen (e->vector[i]);
register char *new = (char *) xmalloc (len + 1);
- bcopy (e->vector[i], new, len + 1);
+ (void) memcpy (new, e->vector[i], len + 1);
e->vector[i] = new;
}
}
char *
get_in_environ (e, var)
- struct environ *e;
- char *var;
+ const struct environ *e;
+ const char *var;
{
register int len = strlen (var);
register char **vector = e->vector;
register char *s;
- for (; s = *vector; vector++)
+ for (; (s = *vector) != NULL; vector++)
if (!strncmp (s, var, len)
&& s[len] == '=')
return &s[len + 1];
void
set_in_environ (e, var, value)
struct environ *e;
- char *var;
- char *value;
+ const char *var;
+ const char *value;
{
register int i;
register int len = strlen (var);
register char **vector = e->vector;
register char *s;
- for (i = 0; s = vector[i]; i++)
+ for (i = 0; (s = vector[i]) != NULL; i++)
if (!strncmp (s, var, len)
&& s[len] == '=')
break;
register char **vector = e->vector;
register char *s;
- for (; s = *vector; vector++)
+ for (; (s = *vector) != NULL; vector++)
if (!strncmp (s, var, len)
&& s[len] == '=')
{
free (s);
- bcopy (vector + 1, vector,
- (e->allocated - (vector - e->vector)) * sizeof (char *));
+ (void) memcpy (vector, vector + 1,
+ (e->allocated - (vector - e->vector)) * sizeof (char *));
e->vector[e->allocated - 1] = 0;
return;
}
char *tmp = (char *)alloca (length + 4);
struct expression *expr;
tmp[0] = '(';
- bcopy (p, tmp+1, length);
+ (void) memcpy (tmp+1, p, length);
tmp[length+1] = ')';
tmp[length+2] = '0';
tmp[length+3] = '\0';
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <stdio.h>
#include "defs.h"
#include "symtab.h"
+#include "gdbtypes.h"
#include "frame.h"
#include "value.h"
#include "gdbcore.h"
if (optimized != NULL)
*optimized = 0;
addr = find_saved_register (frame, regnum);
- if (addr != NULL)
+ if (addr != 0)
{
if (lval != NULL)
*lval = lval_memory;
int optim;
if (regnum == FP_REGNUM && selected_frame)
{
- bcopy (&FRAME_FP(selected_frame), myaddr, sizeof (CORE_ADDR));
- SWAP_TARGET_AND_HOST (myaddr, sizeof (CORE_ADDR)); /* in target order */
+ (void) memcpy (myaddr, &FRAME_FP(selected_frame),
+ REGISTER_RAW_SIZE(FP_REGNUM));
+ SWAP_TARGET_AND_HOST (myaddr, REGISTER_RAW_SIZE(FP_REGNUM)); /* in target order */
return 0;
}
target_convert_to_virtual (regnum, raw_buffer, virtual_buffer);
val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum));
- bcopy (virtual_buffer, VALUE_CONTENTS_RAW (val),
- REGISTER_VIRTUAL_SIZE (regnum));
+ (void) memcpy (VALUE_CONTENTS_RAW (val), virtual_buffer,
+ REGISTER_VIRTUAL_SIZE (regnum));
VALUE_LVAL (val) = lval;
VALUE_ADDRESS (val) = addr;
VALUE_REGNO (val) = regnum;
break;
}
if (myaddr != NULL)
- bcopy (®isters[regbyte], myaddr, len);
+ (void) memcpy (myaddr, ®isters[regbyte], len);
}
/* Read register REGNO into memory at MYADDR, which must be large enough
{
if (!register_valid[regno])
target_fetch_registers (regno);
- bcopy (®isters[REGISTER_BYTE (regno)], myaddr, REGISTER_RAW_SIZE (regno));
+ (void) memcpy (myaddr, ®isters[REGISTER_BYTE (regno)],
+ REGISTER_RAW_SIZE (regno));
}
/* Copy LEN bytes of consecutive data from memory at MYADDR
{
/* Make sure the entire registers array is valid. */
read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
- bcopy (myaddr, ®isters[regbyte], len);
+ (void) memcpy (®isters[regbyte], myaddr, len);
target_store_registers (-1);
}
/* Return the contents of register REGNO, regarding it as an integer. */
+/* FIXME, this loses when the REGISTER_VIRTUAL (REGNO) is true. Also,
+ why is the return type CORE_ADDR rather than some integer type? */
CORE_ADDR
read_register (regno)
int regno;
{
- int reg;
+ REGISTER_TYPE reg;
+
if (!register_valid[regno])
target_fetch_registers (regno);
- /* FIXME, this loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
- reg = *(int *) ®isters[REGISTER_BYTE (regno)];
- SWAP_TARGET_AND_HOST (®, sizeof (int));
+ memcpy (®, ®isters[REGISTER_BYTE (regno)], sizeof (REGISTER_TYPE));
+ SWAP_TARGET_AND_HOST (®, sizeof (REGISTER_TYPE));
return reg;
}
#endif
/* Store VALUE in the register number REGNO, regarded as an integer. */
+/* FIXME, this loses when REGISTER_VIRTUAL (REGNO) is true. Also,
+ shouldn't the val arg be a LONGEST or something? */
void
write_register (regno, val)
int regno, val;
{
+ REGISTER_TYPE reg;
+
/* 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;
- SWAP_TARGET_AND_HOST (&val, sizeof (int));
+ reg = val;
+ SWAP_TARGET_AND_HOST (®, sizeof (REGISTER_TYPE));
target_prepare_to_store ();
register_valid [regno] = 1;
- /* FIXME, this loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
- /* FIXME, this depends on REGISTER_BYTE (regno) being aligned for host */
- *(int *) ®isters[REGISTER_BYTE (regno)] = val;
+ memcpy (®isters[REGISTER_BYTE (regno)], ®, sizeof (REGISTER_TYPE));
target_store_registers (regno);
}
char *val;
{
register_valid[regno] = 1;
- bcopy (val, ®isters[REGISTER_BYTE (regno)], REGISTER_RAW_SIZE (regno));
+ (void) memcpy (®isters[REGISTER_BYTE (regno)], val,
+ REGISTER_RAW_SIZE (regno));
}
\f
/* Given a struct symbol for a variable,
switch (SYMBOL_CLASS (var))
{
case LOC_CONST:
- bcopy (&SYMBOL_VALUE (var), VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), &SYMBOL_VALUE (var), len);
SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len);
VALUE_LVAL (v) = not_lval;
return v;
case LOC_LABEL:
addr = SYMBOL_VALUE_ADDRESS (var);
- bcopy (&addr, VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), &addr, len);
SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len);
VALUE_LVAL (v) = not_lval;
return v;
{
char *bytes_addr;
bytes_addr = SYMBOL_VALUE_BYTES (var);
- bcopy (bytes_addr, VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), bytes_addr, len);
VALUE_LVAL (v) = not_lval;
return v;
}
addr = SYMBOL_VALUE_ADDRESS (var);
break;
-/* Nonzero if a struct which is located in a register or a LOC_ARG
- really contains
- the address of the struct, not the struct itself. GCC_P is nonzero
- if the function was compiled with GCC. */
-#if !defined (REG_STRUCT_HAS_ADDR)
-#define REG_STRUCT_HAS_ADDR(gcc_p) 0
-#endif
-
case LOC_ARG:
- fi = get_frame_info (frame);
- if (fi == NULL)
- return 0;
- addr = FRAME_ARGS_ADDRESS (fi);
- if (!addr) {
- return 0;
- }
+ if (SYMBOL_BASEREG_VALID (var))
+ {
+ addr = FRAME_GET_BASEREG_VALUE (frame, SYMBOL_BASEREG (var));
+ }
+ else
+ {
+ fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
+ addr = FRAME_ARGS_ADDRESS (fi);
+ }
+ if (!addr)
+ {
+ return 0;
+ }
addr += SYMBOL_VALUE (var);
break;
case LOC_REF_ARG:
- fi = get_frame_info (frame);
- if (fi == NULL)
- return 0;
- addr = FRAME_ARGS_ADDRESS (fi);
- if (!addr) {
- return 0;
- }
+ if (SYMBOL_BASEREG_VALID (var))
+ {
+ addr = FRAME_GET_BASEREG_VALUE (frame, SYMBOL_BASEREG (var));
+ }
+ else
+ {
+ fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
+ addr = FRAME_ARGS_ADDRESS (fi);
+ }
+ if (!addr)
+ {
+ return 0;
+ }
addr += SYMBOL_VALUE (var);
- read_memory (addr, &addr, sizeof (CORE_ADDR));
+ read_memory (addr, (char *) &addr, sizeof (CORE_ADDR));
break;
case LOC_LOCAL:
case LOC_LOCAL_ARG:
- fi = get_frame_info (frame);
- if (fi == NULL)
- return 0;
- addr = SYMBOL_VALUE (var) + FRAME_LOCALS_ADDRESS (fi);
+ if (SYMBOL_BASEREG_VALID (var))
+ {
+ addr = FRAME_GET_BASEREG_VALUE (frame, SYMBOL_BASEREG (var));
+ }
+ else
+ {
+ fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
+ addr = FRAME_LOCALS_ADDRESS (fi);
+ }
+ addr += SYMBOL_VALUE (var);
break;
case LOC_TYPEDEF:
v = value_from_register (type, SYMBOL_VALUE (var), frame);
+ /* Nonzero if a struct which is located in a register or a LOC_ARG
+ really contains
+ the address of the struct, not the struct itself. GCC_P is nonzero
+ if the function was compiled with GCC. */
+#if !defined (REG_STRUCT_HAS_ADDR)
+#define REG_STRUCT_HAS_ADDR(gcc_p) 0
+#endif
+
if (REG_STRUCT_HAS_ADDR (BLOCK_GCC_COMPILED (b))
- && TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ && ( (TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ || (TYPE_CODE (type) == TYPE_CODE_UNION)))
addr = *(CORE_ADDR *)VALUE_CONTENTS (v);
else
return v;
endian machines. */
/* Copy into the contents section of the value. */
- bcopy (value_bytes, VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), value_bytes, len);
return v;
}
with raw type `extended' and virtual type `double'.
Fetch it as a `double' and then convert to `float'. */
v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum));
- bcopy (virtual_buffer, VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, len);
v = value_cast (type, v);
}
else
- bcopy (virtual_buffer, VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer, len);
}
else
{
}
#endif
- bcopy (virtual_buffer + VALUE_OFFSET (v),
- VALUE_CONTENTS_RAW (v), len);
+ (void) memcpy (VALUE_CONTENTS_RAW (v), virtual_buffer + VALUE_OFFSET (v),
+ len);
}
return v;
|| TYPE_CODE (type) == TYPE_CODE_FUNC)
{
addr = VALUE_ADDRESS (lazy_value);
-
- /* C++: The "address" of a reference should yield the address
- * of the object pointed to. So force an extra de-reference. */
-
- if (TYPE_CODE (type) == TYPE_CODE_REF)
- {
- char *buf = alloca (TYPE_LENGTH (type));
- read_memory (addr, buf, TYPE_LENGTH (type));
- addr = unpack_pointer (type, buf);
- type = TYPE_TARGET_TYPE (type);
- }
-
return value_from_longest (lookup_pointer_type (type), (LONGEST) addr);
}
int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C();
int OP_D(), OP_T(), OP_rm();
+static void dofloat (), putop (), append_prefix (), set_op ();
+static int get16 (), get32 ();
#define b_mode 1
#define v_mode 2
static int prefixes;
+static void
ckprefix ()
{
prefixes = 0;
* 100 bytes is certainly enough, unless symbol printing is added later
* The function returns the length of this instruction in bytes.
*/
+
+int
i386dis (pc, inbuf, stream)
int pc;
unsigned char *inbuf;
FILE *stream;
{
struct dis386 *dp;
- char *p;
int i;
int enter_instruction;
char *first, *second, *third;
},
};
-
+static void
dofloat ()
{
struct dis386 *dp;
}
/* ARGSUSED */
+int
OP_ST (ignore)
+ int ignore;
{
oappend ("%st");
+ return (0);
}
/* ARGSUSED */
+int
OP_STi (ignore)
+ int ignore;
{
sprintf (scratchbuf, "%%st(%d)", rm);
oappend (scratchbuf);
+ return (0);
}
/* capital letters in template are macros */
+static void
putop (template)
char *template;
{
static void
oappend (s)
-char *s;
+ char *s;
{
strcpy (obufp, s);
obufp += strlen (s);
*obufp = 0;
}
+static void
append_prefix ()
{
if (prefixes & PREFIX_CS)
oappend ("%gs:");
}
+int
OP_indirE (bytemode)
+ int bytemode;
{
oappend ("*");
OP_E (bytemode);
+ return (0);
}
+int
OP_E (bytemode)
+ int bytemode;
{
int disp;
int havesib;
- int didoutput = 0;
int base;
int index;
int scale;
oappend ("<bad dis table>");
break;
}
- return;
+ return (0);
}
append_prefix ();
}
oappend (")");
}
+ return (0);
}
+int
OP_G (bytemode)
+ int bytemode;
{
switch (bytemode)
{
oappend ("<internal disassembler error>");
break;
}
+ return (0);
}
+static int
get32 ()
{
int x = 0;
return (x);
}
+static int
get16 ()
{
int x = 0;
return (x);
}
+static void
set_op (op)
-int op;
+ int op;
{
op_index[op_ad] = op_ad;
op_address[op_ad] = op;
}
+int
OP_REG (code)
+ int code;
{
char *s;
break;
}
oappend (s);
+ return (0);
}
+int
OP_I (bytemode)
+ int bytemode;
{
int op;
break;
default:
oappend ("<internal disassembler error>");
- return;
+ return (0);
}
sprintf (scratchbuf, "$0x%x", op);
oappend (scratchbuf);
+ return (0);
}
+int
OP_sI (bytemode)
+ int bytemode;
{
int op;
break;
default:
oappend ("<internal disassembler error>");
- return;
+ return (0);
}
sprintf (scratchbuf, "$0x%x", op);
oappend (scratchbuf);
+ return (0);
}
+int
OP_J (bytemode)
+ int bytemode;
{
int disp;
int mask = -1;
break;
default:
oappend ("<internal disassembler error>");
- return;
+ return (0);
}
disp = (start_pc + codep - start_codep + disp) & mask;
set_op (disp);
sprintf (scratchbuf, "0x%x", disp);
oappend (scratchbuf);
+ return (0);
}
/* ARGSUSED */
+int
OP_SEG (dummy)
+ int dummy;
{
static char *sreg[] = {
"%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
};
oappend (sreg[reg]);
+ return (0);
}
+int
OP_DIR (size)
+ int size;
{
int seg, offset;
oappend ("<internal disassembler error>");
break;
}
+ return (0);
}
/* ARGSUSED */
+int
OP_OFF (bytemode)
+ int bytemode;
{
int off;
sprintf (scratchbuf, "0x%x", off);
oappend (scratchbuf);
+ return (0);
}
/* ARGSUSED */
+int
OP_ESDI (dummy)
+ int dummy;
{
oappend ("%es:(");
oappend (aflag ? "%edi" : "%di");
oappend (")");
+ return (0);
}
/* ARGSUSED */
+int
OP_DSSI (dummy)
+ int dummy;
{
oappend ("%ds:(");
oappend (aflag ? "%esi" : "%si");
oappend (")");
+ return (0);
}
/* ARGSUSED */
+int
OP_ONE (dummy)
+ int dummy;
{
oappend ("1");
+ return (0);
}
/* ARGSUSED */
+int
OP_C (dummy)
+ int dummy;
{
codep++; /* skip mod/rm */
sprintf (scratchbuf, "%%cr%d", reg);
oappend (scratchbuf);
+ return (0);
}
/* ARGSUSED */
+int
OP_D (dummy)
+ int dummy;
{
codep++; /* skip mod/rm */
sprintf (scratchbuf, "%%db%d", reg);
oappend (scratchbuf);
+ return (0);
}
/* ARGSUSED */
+int
OP_T (dummy)
+ int dummy;
{
codep++; /* skip mod/rm */
sprintf (scratchbuf, "%%tr%d", reg);
oappend (scratchbuf);
+ return (0);
}
+int
OP_rm (bytemode)
+ int bytemode;
{
switch (bytemode)
{
oappend (names16[rm]);
break;
}
+ return (0);
}
#define MAXLEN 20
+
+int
print_insn (memaddr, stream)
CORE_ADDR memaddr;
FILE *stream;
#include "frame.h"
#include "inferior.h"
#include "gdbcore.h"
+#include "target.h"
#ifdef USE_PROC_FS /* Target dependent support for /proc */
#include <sys/procfs.h>
static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 };
pos = codestream_tell ();
codestream_read (buf, 4);
- if (bcmp (buf, proto1, 3) == 0)
+ if (memcmp (buf, proto1, 3) == 0)
pos += 3;
- else if (bcmp (buf, proto2, 4) == 0)
+ else if (memcmp (buf, proto2, 4) == 0)
pos += 4;
codestream_seek (pos);
struct frame_saved_regs *fsrp;
{
long locals;
- unsigned char *p;
unsigned char op;
CORE_ADDR dummy_bottom;
CORE_ADDR adr;
int i;
- bzero (fsrp, sizeof *fsrp);
+ (void) memset (fsrp, 0, sizeof *fsrp);
/* if frame is the end of a dummy, compute where the
* beginning would be
#endif /* defined (FP0_REGNUM) */
#endif /* USE_PROC_FS */
+
+#ifdef GET_LONGJMP_TARGET
+
+/* Figure out where the longjmp will land. Slurp the args out of the stack.
+ We expect the first arg to be a pointer to the jmp_buf structure from which
+ we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
+ This routine returns true on success. */
+
+int
+get_longjmp_target(pc)
+ CORE_ADDR *pc;
+{
+ CORE_ADDR sp, jb_addr;
+
+ sp = read_register(SP_REGNUM);
+
+ if (target_read_memory(sp + SP_ARG0, /* Offset of first arg on stack */
+ (char *) &jb_addr,
+ sizeof(CORE_ADDR)))
+ return 0;
+
+
+ SWAP_TARGET_AND_HOST(&jb_addr, sizeof(CORE_ADDR));
+
+ if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) pc,
+ sizeof(CORE_ADDR)))
+ return 0;
+
+ SWAP_TARGET_AND_HOST(pc, sizeof(CORE_ADDR));
+
+ return 1;
+}
+
+#endif /* GET_LONGJMP_TARGET */
unsigned long mant0, mant1, exponent;
unsigned char tobytes[8];
- bzero (to, TOTALSIZE);
+ (void) memset (to, 0, TOTALSIZE);
if (dfrom == 0)
return; /* Result is zero */
if (dfrom != dfrom) {
/* On return, the stack dummy has been popped already. */
- bcopy (stop_registers, buffer, sizeof stop_registers);
+ (void) memcpy (buffer, stop_registers, sizeof stop_registers);
}
\f
/* Proceed until we reach a different source line with pc greater than
/* Copy data to be written over corresponding part of buffer */
- bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
+ (void) memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr,
+ len);
/* Write the entire buffer. */
}
/* Copy appropriate bytes out of the buffer. */
- bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
+ (void) memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)),
+ len);
}
return len;
}
inf_status->restore_stack_info = restore_stack_info;
inf_status->proceed_to_finish = proceed_to_finish;
- bcopy (stop_registers, inf_status->stop_registers, REGISTER_BYTES);
+ (void) memcpy (inf_status->stop_registers, stop_registers, REGISTER_BYTES);
record_selected_frame (&(inf_status->selected_frame_address),
&(inf_status->selected_level));
breakpoint_proceeded = inf_status->breakpoint_proceeded;
proceed_to_finish = inf_status->proceed_to_finish;
- bcopy (inf_status->stop_registers, stop_registers, REGISTER_BYTES);
+ (void) memcpy (stop_registers, inf_status->stop_registers, REGISTER_BYTES);
/* The inferior can be gone if the user types "print exit(0)"
(and perhaps other times). */
return (TYPE_CODE(type) == TYPE_CODE_INT) &&
TYPE_LENGTH(type) == sizeof(char)
? 1 : 0;
+ default:
+ return (0);
}
- return (0);
}
/* Returns non-zero if the value is a boolean type */
case language_c:
case language_cplus:
return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
+ default:
+ return (0);
}
- return (0);
}
/* Returns non-zero if the value is a floating-point type */
return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
(TYPE_CODE(type) == TYPE_CODE_SET) ||
(TYPE_CODE(type) == TYPE_CODE_ARRAY);
+ default:
+ return (0);
}
- return (0);
}
\f
/* This page contains functions that return info about
{
char *err_copy = (char *) alloca (p - tokstart + 1);
- bcopy (tokstart, err_copy, p - tokstart);
+ (void) memcpy (err_copy, tokstart, p - tokstart);
err_copy[p - tokstart] = 0;
error ("Invalid number \"%s\".", err_copy);
}
/* Top level `main' program for GDB, the GNU debugger.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992
+ Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include "gdbcmd.h"
+#include "call-cmds.h"
#include "symtab.h"
#include "inferior.h"
#include "signals.h"
}
error_pre_print = "\n\n";
- warning_pre_print = "\n\nwarning: ";
+ /* We may get more than one warning, don't double space all of them... */
+ warning_pre_print = "\nwarning: ";
/* Now perform all the actions indicated by the arguments. */
if (cdarg != NULL)
for (i = 0; i < ndir; i++)
if (!setjmp (to_top_level))
directory_command (dirarg[i], 0);
- free (dirarg);
+ free ((PTR)dirarg);
do_cleanups (ALL_CLEANUPS);
if (execarg != NULL
the same file (it should exist, also). */
if (!homedir
- || bcmp ((char *) &homebuf,
- (char *) &cwdbuf,
- sizeof (struct stat)))
+ || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat)))
if (!inhibit_gdbinit && access (gdbinit, R_OK) == 0)
if (!setjmp (to_top_level))
source_command (gdbinit, 0);
source_command (cmdarg[i], !batch);
do_cleanups (ALL_CLEANUPS);
}
- free (cmdarg);
+ free ((PTR)cmdarg);
/* Read in the old history after all the command files have been read. */
initialize_history();
/* Variables which are necessary for fancy command line editing. */
char *gdb_completer_word_break_characters =
" \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,";
+/* Characters that can be used to quote completion strings. Note that we
+ can't include '"' because the gdb C parser treats such quoted sequences
+ as strings. */
+char *gdb_completer_quote_characters =
+ "'";
/* Functions that are used as part of the fancy command line editing. */
return NULL;
}
-/* Generate symbol names one by one for the completer. If STATE is
- zero, then we need to initialize, otherwise the initialization has
- already taken place. TEXT is what we expect the symbol to start
- with. RL_LINE_BUFFER is available to be looked at; it contains the
- entire text of the line. RL_POINT is the offset in that line of
- the cursor. You should pretend that the line ends at RL_POINT.
- The result is NULL if there are no more completions, else a char
- string which is a possible completion. */
+/* Generate symbol names one by one for the completer. Each time we are
+ called return another potential completion to the caller.
+
+ TEXT is what we expect the symbol to start with.
+
+ MATCHES is the number of matches that have currently been collected from
+ calling this completion function. When zero, then we need to initialize,
+ otherwise the initialization has already taken place and we can just
+ return the next potential completion string.
+ Returns NULL if there are no more completions, else a pointer to a string
+ which is a possible completion.
+
+ RL_LINE_BUFFER is available to be looked at; it contains the entire text
+ of the line. RL_POINT is the offset in that line of the cursor. You
+ should pretend that the line ends at RL_POINT. */
+
static char *
-symbol_completion_function (text, state)
+symbol_completion_function (text, matches)
char *text;
- int state;
+ int matches;
{
- static char **list = (char **)NULL;
- static int index;
- char *output;
- extern char *rl_line_buffer;
- extern int rl_point;
+ static char **list = (char **)NULL; /* Cache of completions */
+ static int index; /* Next cached completion */
+ char *output = NULL;
char *tmp_command, *p;
struct cmd_list_element *c, *result_list;
+ extern char *rl_line_buffer;
+ extern int rl_point;
- if (!state)
+ if (matches == 0)
{
- /* Free the storage used by LIST, but not by the strings inside. This is
- because rl_complete_internal () frees the strings. */
+ /* The caller is beginning to accumulate a new set of completions, so
+ we need to find all of them now, and cache them for returning one at
+ a time on future calls. */
+
if (list)
- free (list);
+ {
+ /* Free the storage used by LIST, but not by the strings inside.
+ This is because rl_complete_internal () frees the strings. */
+ free ((PTR)list);
+ }
list = 0;
index = 0;
- /* Decide whether to complete on a list of gdb commands or on
- symbols. */
+ /* Decide whether to complete on a list of gdb commands or on symbols. */
tmp_command = (char *) alloca (rl_point + 1);
p = tmp_command;
if (rl_point == 0)
{
- /* An empty line we want to consider ambiguous; that is,
- it could be any command. */
+ /* An empty line we want to consider ambiguous; that is, it
+ could be any command. */
c = (struct cmd_list_element *) -1;
result_list = 0;
}
else
- c = lookup_cmd_1 (&p, cmdlist, &result_list, 1);
+ {
+ c = lookup_cmd_1 (&p, cmdlist, &result_list, 1);
+ }
/* Move p up to the next interesting thing. */
while (*p == ' ' || *p == '\t')
- p++;
+ {
+ p++;
+ }
if (!c)
- /* He's typed something unrecognizable. Sigh. */
- list = (char **) 0;
+ {
+ /* He's typed something unrecognizable. Sigh. */
+ list = NULL;
+ }
else if (c == (struct cmd_list_element *) -1)
{
/* If we didn't recognize everything up to the thing that
yet, we are in trouble. Part of the trouble might be
that the list of delimiters used by readline includes
'-', which we use in commands. Check for this. */
- if (p + strlen(text) != tmp_command + rl_point) {
- if (tmp_command[rl_point - strlen(text) - 1] == '-')
- text = p;
- else {
- /* This really should not produce an error. Better would
- be to pretend to hit RETURN here; this would produce a
- response like "Ambiguous command: foo, foobar, etc",
- and leave the line available for re-entry with ^P. Instead,
- this error blows away the user's typed input without
- any way to get it back. */
- error (" Unrecognized command.");
+
+ if (p + strlen(text) != tmp_command + rl_point)
+ {
+ if (tmp_command[rl_point - strlen(text) - 1] == '-')
+ {
+ text = p;
+ }
+ else
+ {
+ /* This really should not produce an error. Better would
+ be to pretend to hit RETURN here; this would produce a
+ response like "Ambiguous command: foo, foobar, etc",
+ and leave the line available for re-entry with ^P.
+ Instead, this error blows away the user's typed input
+ without any way to get it back. */
+ error (" Unrecognized command.");
+ }
}
- }
/* He's typed something ambiguous. This is easier. */
if (result_list)
- list = complete_on_cmdlist (*result_list->prefixlist, text);
+ {
+ list = complete_on_cmdlist (*result_list->prefixlist, text);
+ }
else
- list = complete_on_cmdlist (cmdlist, text);
+ {
+ list = complete_on_cmdlist (cmdlist, text);
+ }
}
else
{
command. */
if (!*p && *text)
- /* Always (might be longer versions of thie command). */
- list = complete_on_cmdlist (result_list, text);
+ {
+ /* Always (might be longer versions of thie command). */
+ list = complete_on_cmdlist (result_list, text);
+ }
else if (!*p && !*text)
{
if (c->prefixlist)
- list = complete_on_cmdlist (*c->prefixlist, "");
+ {
+ list = complete_on_cmdlist (*c->prefixlist, "");
+ }
else
- list = (*c->completer) ("");
+ {
+ list = (*c->completer) ("");
+ }
}
else
{
if (c->prefixlist && !c->allow_unknown)
{
-#if 0
- /* Something like "info adsfkdj". But error() is not
- the proper response; just return no completions
- instead. */
- *p = '\0';
- error ("\"%s\" command requires a subcommand.",
- tmp_command);
-#else
+ /* Something like "info adsfkdj". But error() is not the
+ proper response; just return no completions instead. */
list = NULL;
-#endif
}
else
- list = (*c->completer) (text);
+ {
+ list = (*c->completer) (text);
+ }
}
}
}
- /* If the debugged program wasn't compiled with symbols, or if we're
- clearly completing on a command and no command matches, return
- NULL. */
- if (!list)
- return ((char *)NULL);
+ /* If we found a list of potential completions during initialization then
+ dole them out one at a time. The vector of completions is NULL
+ terminated, so after returning the last one, return NULL (and continue
+ to do so) each time we are called after that, until a new list is
+ available. */
- output = list[index];
- if (output)
- index++;
+ if (list)
+ {
+ output = list[index];
+ if (output)
+ {
+ index++;
+ }
+ }
return (output);
}
+
+/* Skip over a possibly quoted word (as defined by the quote characters
+ and word break characters the completer uses). Returns pointer to the
+ location after the "word". */
+
+char *
+skip_quoted (str)
+ char *str;
+{
+ char quote_char = '\0';
+ char *scan;
+
+ for (scan = str; *scan != '\0'; scan++)
+ {
+ if (quote_char != '\0')
+ {
+ /* Ignore everything until the matching close quote char */
+ if (*scan == quote_char)
+ {
+ /* Found matching close quote. */
+ scan++;
+ break;
+ }
+ }
+ else if (strchr (gdb_completer_quote_characters, *scan))
+ {
+ /* Found start of a quoted string. */
+ quote_char = *scan;
+ }
+ else if (strchr (gdb_completer_word_break_characters, *scan))
+ {
+ break;
+ }
+ }
+ return (scan);
+}
+
\f
#ifdef STOP_SIGNAL
static void
{
next = l->next;
free (l->line);
- free (l);
+ free ((PTR)l);
l = next;
}
}
}
}
+/* This is just a placeholder in the command data structures. */
+static void
+user_defined_command (ignore, from_tty)
+ char *ignore;
+ int from_tty;
+{
+}
+
static void
define_command (comname, from_tty)
char *comname;
if (c && c->class == class_user)
free_command_lines (&c->user_commands);
- newc = add_cmd (comname, class_user, not_just_help_class_command,
+ newc = add_cmd (comname, class_user, user_defined_command,
(c && c->class == class_user)
? c->doc : savestring ("User-defined.", 13), &cmdlist);
newc->user_commands = cmds;
/* Setup important stuff for command line editing. */
rl_completion_entry_function = (int (*)()) symbol_completion_function;
rl_completer_word_break_characters = gdb_completer_word_break_characters;
+ rl_completer_quote_characters = gdb_completer_quote_characters;
rl_readline_name = "gdb";
/* Define the classes of commands.
#include "coff/mips.h" /* COFF-like aspects of ecoff files */
#include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */
+#include "libbfd.h" /* FIXME Secret internal BFD stuff (bfd_read) */
#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* STABS information */
CORE_ADDR addr;
int mainline;
{
- bfd *abfd = objfile -> obfd;
-
init_minimal_symbol_collection ();
make_cleanup (discard_minimal_symbols, 0);
xzalloc(size)
unsigned int size;
{
- PTR p = xmalloc(size);
+ PTR p = xmalloc (size);
- memset(p, 0, size);
- return p;
+ (void) memset (p, 0, size);
+ return p;
}
/* Exported procedure: Builds a symtab from the PST partial one.
/* This function depends on the external and internal forms
of the MIPS symbol table taking identical space. Check this
assumption at compile-time. */
+#if 0 /* FIXME: Unused */
static check_hdr1[1 + sizeof (struct hdr_ext) - sizeof (HDRR)] = {0};
static check_hdr2[1 + sizeof (HDRR) - sizeof (struct hdr_ext)] = {0};
static check_fdr1[1 + sizeof (struct fdr_ext) - sizeof (FDR)] = {0};
static check_ext2[1 + sizeof (EXTR) - sizeof (struct ext_ext)] = {0};
static check_rfd1[1 + sizeof (struct rfd_ext) - sizeof (RFDT)] = {0};
static check_rfd2[1 + sizeof (RFDT) - sizeof (struct rfd_ext)] = {0};
+#endif
/* Swap in the header record. */
ecoff_swap_hdr_in (abfd, hdr, hdr);
/* Throw away undef entries when done with file index F_IDX */
/* FIXME -- storage leak. This is never called!!! --gnu */
+#if 0
+
static void
free_pending(f_idx)
int f_idx;
pending_list[f_idx] = 0;
}
+#endif
+
static char *
prepend_tag_kind(tag_name, type_code)
char *tag_name;
SYMR *sh = (SYMR*)pr->isym;
struct block *b;
struct mips_extra_func_info *e;
- char name[100];
char *sh_name;
/* Static procedure at address pr->adr. Sigh. */
* This symbol table contains stabs-in-ecoff entries.
*/
- SYMR *sh;
PDR *pr;
/* Parse local symbols first */
free_objfile (objfile)
struct objfile *objfile;
{
- struct objfile *ofp;
int mmfd;
/* First do any symbol file specific actions required when we are
xrealloc ((char *) expout, (sizeof (struct expression)
+ (expout_size * sizeof (union exp_element))));
}
- bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len);
+ (void) memcpy ((char *) &expout->elts[expout_ptr - lenelt], str.ptr, len);
((char *) &expout->elts[expout_ptr - lenelt])[len] = 0;
write_exp_elt_longcst ((LONGEST) len);
}
copy_name (token)
struct stoken token;
{
- bcopy (token.ptr, namecopy, token.length);
+ (void) memcpy (namecopy, token.ptr, token.length);
namecopy[token.length] = 0;
return namecopy;
}
temp = (struct expression *) alloca (len);
/* Copy the original expression into temp. */
- bcopy (expr, temp, len);
+ (void) memcpy (temp, expr, len);
prefixify_subexp (temp, expr, inpos, outpos);
}
/* Copy the final operator itself, from the end of the input
to the beginning of the output. */
inend -= oplen;
- bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg],
- oplen * sizeof (union exp_element));
+ (void) memcpy (&outexpr->elts[outbeg], &inexpr->elts[inend],
+ oplen * sizeof (union exp_element));
outbeg += oplen;
/* Find the lengths of the arg subexpressions. */
#include <sys/procfs.h>
#include <fcntl.h>
#include <errno.h>
+#include <string.h>
#include "inferior.h"
#include "target.h"
+#include "command.h"
#define MAX_SYSCALLS 256 /* Maximum number of syscalls for table */
static void
init_syscall_table ()
{
- int syscallnum;
-
#if defined (SYS_exit)
syscall_table[SYS_exit] = "exit";
#endif
int funcstat = 0;
struct prmap *prmaps;
struct prmap *prmap;
- CORE_ADDR baseaddr = 0;
if (pi.valid && (ioctl (pi.fd, PIOCNMAP, &nmap) == 0))
{
struct procinfo pii;
struct procinfo *pip;
struct cleanup *old_chain;
- char *nexttok;
char **argv;
int argsize;
int summary = 1;
if ( new_environ == (char **) NULL )
return( -1 );
- bcopy( (char *) environ, (char *) new_environ, size*PSIZE );
+ (void) memcpy ((char *) new_environ, (char *) environ, size*PSIZE );
new_environ[size] = entry;
new_environ[size+1] = NULL;
int
re_set_syntax (syntax)
+ int syntax;
{
int ret;
register char *fastmap = bufp->fastmap;
register unsigned char *p = pattern;
register unsigned char *pend = pattern + size;
- register int j, k;
+ register int j;
unsigned char *translate = (unsigned char *) bufp->translate;
unsigned char *stackb[NFAILURES];
struct objfile *objfile; /* objfile for loaded lib */
struct section_table *sections;
struct section_table *sections_end;
+ struct section_table *textsection;
};
static struct so_list *so_list_head; /* List of known shared objects */
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
+extern int
+fdmatch PARAMS ((int, int)); /* In libiberty */
+
/* Local function prototypes */
static void
disable_break PARAMS ((void));
static void
-info_sharedlibrary_command PARAMS ((void));
+info_sharedlibrary_command PARAMS ((char *, int));
static int
symbol_add_stub PARAMS ((char *));
p -> addr += (CORE_ADDR) LM_ADDR (so);
p -> endaddr += (CORE_ADDR) LM_ADDR (so);
so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
+ if (strcmp (p -> sec_ptr -> name, ".text") == 0)
+ {
+ so -> textsection = p;
+ }
}
}
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
- (unsigned int) LM_ADDR (so), 0, 0, 0);
+ (unsigned int) so -> textsection -> addr,
+ 0, 0, 0);
return (1);
}
if (so -> so_name[0])
{
count = so -> sections_end - so -> sections;
- bcopy (so -> sections, (char *)(target -> to_sections + old),
- (sizeof (struct section_table)) * count);
+ (void) memcpy ((char *) (target -> to_sections + old),
+ so -> sections,
+ (sizeof (struct section_table)) * count);
old += count;
}
}
*/
static void
-info_sharedlibrary_command ()
+info_sharedlibrary_command (ignore, from_tty)
+ char *ignore;
+ int from_tty;
{
register struct so_list *so = NULL; /* link map state variable */
int header_done = 0;
enable_break ()
{
- int j;
-
#ifndef SVR4_SHARED_LIBS
+ int j;
int in_debugger;
-
+
/* Get link_dynamic structure */
j = target_read_memory (debug_base, (char *) &dynamic_copy,
struct so_list *so;
{
#ifndef SVR4_SHARED_LIBS
+ int j;
+
+ if (debug_addr == 0)
+ {
+ /* Get link_dynamic structure */
+
+ j = target_read_memory (debug_base, (char *) &dynamic_copy,
+ sizeof (dynamic_copy));
+ if (j)
+ {
+ /* unreadable */
+ return;
+ }
+
+ /* Calc address of debugger interface structure */
+ /* FIXME, this needs work for cross-debugging of core files
+ (byteorder, size, alignment, etc). */
+
+ debug_addr = (CORE_ADDR) dynamic_copy.ldd;
+ }
/* Read the debugger structure from the inferior, just to make sure
we have a current copy. */
- read_memory (debug_addr, (char *) &debug_copy, sizeof (debug_copy));
+ j = target_read_memory (debug_addr, (char *) &debug_copy,
+ sizeof (debug_copy));
+ if (j)
+ return; /* unreadable */
/* Get common symbol definitions for the loaded object. */
if (!fid)
fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS");
- bzero (saved_regs_addr, sizeof (*saved_regs_addr));
+ (void) memset (saved_regs_addr, 0, sizeof (*saved_regs_addr));
/* Old test.
if (fi->pc >= frame - CALL_DUMMY_LENGTH - 0x140
perror("ptrace_getregs");
registers[REGISTER_BYTE (0)] = 0;
- bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * REGISTER_RAW_SIZE (G0_REGNUM));
+ (void) memcpy (®isters[REGISTER_BYTE (1)], &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G0_REGNUM));
*(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
*(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
*(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc;
(PTRACE_ARG3_TYPE) &inferior_fp_registers,
0))
perror("ptrace_getfpregs");
- bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)],
- sizeof inferior_fp_registers.fpu_fr);
+ (void) memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)],
+ &inferior_fp_registers,
+ sizeof inferior_fp_registers.fpu_fr);
/* bcopy (&inferior_fp_registers.Fpu_fsr,
®isters[REGISTER_BYTE (FPS_REGNUM)],
sizeof (FPU_FSR_TYPE)); FIXME??? -- gnu@cyg */
{
if (!register_valid[G1_REGNUM]) abort();
- bcopy (®isters[REGISTER_BYTE (G1_REGNUM)],
- &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G1_REGNUM));
+ (void) memcpy (&inferior_registers.r_g1,
+ ®isters[REGISTER_BYTE (G1_REGNUM)],
+ 15 * REGISTER_RAW_SIZE (G1_REGNUM));
inferior_registers.r_ps =
*(int *)®isters[REGISTER_BYTE (PS_REGNUM)];
if (wanna_store & FP_REGS)
{
if (!register_valid[FP0_REGNUM+9]) abort();
- bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)],
- &inferior_fp_registers,
- sizeof inferior_fp_registers.fpu_fr);
+ (void) memcpy (&inferior_fp_registers,
+ ®isters[REGISTER_BYTE (FP0_REGNUM)],
+ sizeof inferior_fp_registers.fpu_fr);
-/* bcopy (®isters[REGISTER_BYTE (FPS_REGNUM)],
- &inferior_fp_registers.Fpu_fsr,
- sizeof (FPU_FSR_TYPE));
+/* (void) memcpy (&inferior_fp_registers.Fpu_fsr,
+ ®isters[REGISTER_BYTE (FPS_REGNUM)],
+ sizeof (FPU_FSR_TYPE));
****/
if (0 !=
ptrace (PTRACE_SETFPREGS, inferior_pid,
*(int *)®isters[REGISTER_BYTE (0)] = 0;
/* The globals and output registers. */
- bcopy (&gregs->r_g1,
- ®isters[REGISTER_BYTE (G1_REGNUM)],
- 15 * REGISTER_RAW_SIZE (G1_REGNUM));
+ (void) memcpy (®isters[REGISTER_BYTE (G1_REGNUM)],
+ &gregs->r_g1,
+ 15 * REGISTER_RAW_SIZE (G1_REGNUM));
*(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
*(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
*(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
#define fpuregs ((struct fpu *) core_reg_sect)
if (core_reg_size >= sizeof (struct fpu))
{
- bcopy (fpuregs->fpu_regs,
- ®isters[REGISTER_BYTE (FP0_REGNUM)],
- sizeof (fpuregs->fpu_regs));
- bcopy (&fpuregs->fpu_fsr,
- ®isters[REGISTER_BYTE (FPS_REGNUM)],
- sizeof (FPU_FSR_TYPE));
+ (void) memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)],
+ fpuregs->fpu_regs,
+ sizeof (fpuregs->fpu_regs));
+ (void) memcpy (®isters[REGISTER_BYTE (FPS_REGNUM)],
+ &fpuregs->fpu_fsr,
+ sizeof (FPU_FSR_TYPE));
}
else
fprintf (stderr, "Couldn't read float regs from core file\n");
bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
- bzero (blocks_printed, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
+ (void) memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
while (block != 0)
{
#include "breakpoint.h"
#include "command.h"
#include "obstack.h"
+#include "language.h"
#include <string.h>
psymtab -> filename);
fprintf_filtered (outfile, "(object 0x%x)\n\n", psymtab);
fprintf (outfile, " Read from object file %s (0x%x)\n",
- objfile -> name, objfile);
+ objfile -> name, (unsigned int) objfile);
if (psymtab -> readin)
{
fprintf (outfile, "\nSymtab for file %s\n", symtab->filename);
fprintf (outfile, "Read from object file %s (%x)\n", objfile->name,
- objfile);
+ (unsigned int) objfile);
fprintf (outfile, "Language: %s\n", language_str (symtab -> language));
/* First print the line table. */
b = BLOCKVECTOR_BLOCK (bv, i);
depth = block_depth (b) * 2;
print_spaces (depth, outfile);
- fprintf (outfile, "block #%03d (object 0x%x) ", i, b);
+ fprintf (outfile, "block #%03d (object 0x%x) ", i, (unsigned int) b);
fprintf (outfile, "[0x%x..0x%x]", BLOCK_START (b), BLOCK_END (b));
if (BLOCK_SUPERBLOCK (b))
- fprintf (outfile, " (under 0x%x)", BLOCK_SUPERBLOCK (b));
+ fprintf (outfile, " (under 0x%x)", (unsigned int) BLOCK_SUPERBLOCK (b));
if (BLOCK_FUNCTION (b))
fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
fputc ('\n', outfile);
break;
case LOC_ARG:
- fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol));
+ if (SYMBOL_BASEREG_VALID (symbol))
+ {
+ fprintf (outfile, "arg at 0x%lx from register %d,",
+ SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
+ }
+ else
+ {
+ fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol));
+ }
break;
case LOC_LOCAL_ARG:
- fprintf (outfile, "arg at offset 0x%x from fp,",
- SYMBOL_VALUE (symbol));
+ if (SYMBOL_BASEREG_VALID (symbol))
+ {
+ fprintf (outfile, "arg at offset 0x%lx from register %d,",
+ SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
+ }
+ else
+ {
+ fprintf (outfile, "arg at offset 0x%lx from fp,",
+ SYMBOL_VALUE (symbol));
+ }
case LOC_REF_ARG:
fprintf (outfile, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol));
break;
case LOC_LOCAL:
- fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol));
+ if (SYMBOL_BASEREG_VALID (symbol))
+ {
+ fprintf (outfile, "local at 0x%lx from register %d",
+ SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
+ }
+ else
+ {
+ fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol));
+ }
break;
case LOC_TYPEDEF:
case LOC_BLOCK:
fprintf (outfile, "block (object 0x%x) starting at 0x%x,",
- SYMBOL_BLOCK_VALUE (symbol),
+ (unsigned int) SYMBOL_BLOCK_VALUE (symbol),
BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)));
break;
p1 = p;
while (p != *argptr && p[-1] == ' ') --p;
copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
+ (void) memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = 0;
/* Discard the class name from the arg. */
else
{
copy = (char *) alloca (p - *argptr + 1 + (q1 - q));
- bcopy (*argptr, copy, p - *argptr);
+ (void) memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = '\0';
}
p1 = p;
while (p != *argptr && p[-1] == ' ') --p;
copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
+ (void) memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = 0;
/* Find that file's data. */
p = skip_quoted (*argptr);
copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
+ (void) memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = '\0';
if ((copy[0] == copy [p - *argptr - 1])
&& strchr (gdb_completer_quote_characters, copy[0]) != NULL)
values.sals = (struct symtab_and_line *)
xmalloc (sizeof (struct symtab_and_line));
values.nelts = 1;
- bzero (&values.sals[0], sizeof (values.sals[0]));
+ (void) memset (&values.sals[0], 0, sizeof (values.sals[0]));
values.sals[0].symtab = sym_symtab;
values.sals[0].line = SYMBOL_LINE (sym);
return values;
error ("cancelled");
else if (num == 1)
{
- bcopy (values.sals, return_values.sals, (nelts * sizeof(struct symtab_and_line)));
+ (void) memcpy (return_values.sals, values.sals,
+ (nelts * sizeof(struct symtab_and_line)));
return_values.nelts = nelts;
return return_values;
}
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 bcopy()ed before calling
+ lookup_function_type() should be memcpy()ed before calling
this. When not in strict typing mode, the expression
evaluator can choose to ignore this.
#define obstack_chunk_free free
/* Some macros for char-based bitfields. */
-#define B_SET(a,x) (a[x>>3] |= (1 << (x&7)))
-#define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7)))
-#define B_TST(a,x) (a[x>>3] & (1 << (x&7)))
+#define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
+#define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
+#define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
#define B_TYPE unsigned char
#define B_BYTES(x) ( 1 + ((x)>>3) )
-#define B_CLRALL(a,x) bzero (a, B_BYTES(x))
+#define B_CLRALL(a,x) (void) memset ((a), 0, B_BYTES(x))
/* Define a simple structure used to hold some very basic information about
#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
#define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line
+#if 0
+/* This currently fails because some symbols are not being initialized
+ to zero on allocation, and no code is currently setting this value.
+ Basereg handling will probably change significantly in the next release.
+ FIXME -fnf */
#define SYMBOL_BASEREG_VALID(symbol) (symbol)->aux_value.basereg.regno_valid
+#else
+#define SYMBOL_BASEREG_VALID(symbol) 0
+#endif
#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg.regno
/* The virtual function table is now an array of structures
prim_record_minimal_symbol PARAMS ((const char *, CORE_ADDR,
enum minimal_symbol_type));
+extern void
+prim_record_minimal_symbol_and_info PARAMS ((const char *, CORE_ADDR,
+ enum minimal_symbol_type,
+ char *info));
+
extern struct minimal_symbol *
lookup_minimal_symbol PARAMS ((const char *, struct objfile *));
/* symtab.c */
+extern void
+clear_symtab_users_once PARAMS ((void));
+
extern struct partial_symtab *
find_main_psymtab PARAMS ((void));
#include "inferior.h"
#include "bfd.h"
#include "symfile.h"
+#include "objfiles.h"
extern int errno;
int len;
int write;
{
+ errno = EIO; /* Can't read/write this location */
return 0; /* No bytes handled */
}
/* If this address is for nonexistent memory,
read zeros if reading, or do nothing if writing. Return error. */
if (!write)
- bzero (myaddr, len);
+ (void) memset (myaddr, 0, len);
if (errno == 0)
return EIO;
else
/* Convert data from raw format for register REGNUM
to virtual format for register REGNUM. */
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
+#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
+ {(void) memcpy ((TO), (FROM), 4);}
/* Convert data from virtual format for register REGNUM
to raw format for register REGNUM. */
-#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
+#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
+ {(void) memcpy ((TO), (FROM), 4);}
/* Return the GDB type object for the "standard" data type
of data in register N. */
into VALBUF. */
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
- bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
+ (void) memcpy ((VALBUF), (REGBUF), TYPE_LENGTH (TYPE))
/* Write into appropriate registers a function return value
of type TYPE, given in virtual format. */
we extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
This routine returns true on success */
+extern int
+get_longjmp_target PARAMS ((CORE_ADDR *));
+
#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
to virtual format for register REGNUM. */
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
-{ bcopy ((FROM), (TO), 4); }
+{ (void) memcpy ((TO), (FROM), 4); }
/* Convert data from virtual format for register REGNUM
to raw format for register REGNUM. */
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
-{ bcopy ((FROM), (TO), 4); }
+{ (void) memcpy ((TO), (FROM), 4); }
/* Return the GDB type object for the "standard" data type
of data in register N. */
{ \
if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
{ \
- bcopy (((int *)(REGBUF))+FP0_REGNUM, \
- (VALBUF), TYPE_LENGTH(TYPE)); \
+ (void) memcpy ((VALBUF), \
+ ((int *)(REGBUF))+FP0_REGNUM, \
+ TYPE_LENGTH(TYPE)); \
} \
else \
- bcopy ((char *)(REGBUF) + 4 * 8 + \
- (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \
- (VALBUF), TYPE_LENGTH(TYPE)); \
+ (void) memcpy ((VALBUF), \
+ (char *)(REGBUF) + 4 * 8 + \
+ (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \
+ TYPE_LENGTH(TYPE)); \
}
/* Write into appropriate registers a function return value
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
-
+#if !defined(__GO32__)
#include <sys/ioctl.h>
#include <sys/param.h>
#include <pwd.h>
+#endif
#include <varargs.h>
#include <ctype.h>
#include <string.h>
{
target_terminal_ours ();
wrap_here ((char *)0); /* Force out any pending output */
+#if !defined(__GO32__)
#ifdef HAVE_TERMIO
ioctl (fileno (stdout), TCFLSH, 1);
#else /* not HAVE_TERMIO */
#else
error ("Quit (expect signal %d when inferior is resumed)", SIGINT);
#endif /* TIOCGPGRP */
+#endif
}
/* Control C comes here */
int size;
{
register char *p = (char *) xmalloc (size + 1);
- bcopy (ptr, p, size);
+ (void) memcpy (p, ptr, size);
p[size] = 0;
return p;
}
int size;
{
register char *p = (char *) xmmalloc (md, size + 1);
- bcopy (ptr, p, size);
+ (void) memcpy (p, ptr, size);
p[size] = 0;
return p;
}
\f
/* C++ demangler stuff. */
+/* Make a copy of a symbol, applying C++ demangling if demangling is enabled
+ and a demangled version exists. Note that the value returned from
+ cplus_demangle is already allocated in malloc'd memory. */
+
+char *
+strdup_demangled (name)
+ const char *name;
+{
+ char *demangled = NULL;
+
+ if (demangle)
+ {
+ demangled = cplus_demangle (name, DMGL_PARAMS | DMGL_ANSI);
+ }
+ return ((demangled != NULL) ? demangled : strdup (name));
+}
+
+
/* Print NAME on STREAM, demangling if necessary. */
void
fprint_symbol (stream, name)
free (demangled);
}
}
+
+/* Do a strcmp() type operation on STRING1 and STRING2, ignoring any
+ differences in whitespace. Returns 0 if they match, non-zero if they
+ don't (slightly different than strcmp()'s range of return values). */
+
+int
+strcmp_iw (string1, string2)
+ const char *string1;
+ const char *string2;
+{
+ while ((*string1 != '\0') && (*string2 != '\0'))
+ {
+ while (isspace (*string1))
+ {
+ string1++;
+ }
+ while (isspace (*string2))
+ {
+ string2++;
+ }
+ if (*string1 != *string2)
+ {
+ break;
+ }
+ if (*string1 != '\0')
+ {
+ string1++;
+ string2++;
+ }
+ }
+ return (!((*string1 == '\0') && (*string2 == '\0')));
+}
+
+/* Demangle NAME and compare the result with LOOKFOR, ignoring any differences
+ in whitespace.
+
+ If a match is found, returns a pointer to the demangled version of NAME
+ in malloc'd memory, which needs to be freed by the caller after use.
+ If a match is not found, returns NULL.
+
+ OPTIONS is a flags word that controls the demangling process and is just
+ passed on to the demangler.
+
+ When the caller sees a non-NULL result, it knows that NAME is the mangled
+ equivalent of LOOKFOR, and it can use either NAME, the "official demangled"
+ version of NAME (the return value) or the "unofficial demangled" version
+ of NAME (LOOKFOR, which it already knows). */
+
+char *
+demangle_and_match (name, lookfor, options)
+ const char *name;
+ const char *lookfor;
+ int options;
+{
+ char *demangled;
+
+ if ((demangled = cplus_demangle (name, options)) != NULL)
+ {
+ if (strcmp_iw (demangled, lookfor) != 0)
+ {
+ free (demangled);
+ demangled = NULL;
+ }
+ }
+ return (demangled);
+}
+
\f
void
_initialize_utils ()
/* These defaults will be used if we are unable to get the correct
values from termcap. */
+#if defined(__GO32__)
+ lines_per_page = ScreenRows();
+ chars_per_line = ScreenCols();
+#else
lines_per_page = 24;
chars_per_line = 80;
/* Initialize the screen height and width from termcap. */
/* If there is a better way to determine the window size, use it. */
SIGWINCH_HANDLER ();
#endif
-
+#endif
/* If the output is not a terminal, don't paginate it. */
if (!ISATTY (stdout))
lines_per_page = UINT_MAX;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <stdio.h>
-
#include "defs.h"
#include "value.h"
#include "symtab.h"
+#include "gdbtypes.h"
#include "expression.h"
#include "target.h"
#include <string.h>
error ("no such vector element");
v = allocate_value (elt_type);
- bcopy (VALUE_CONTENTS (array) + elt_offs, VALUE_CONTENTS (v), elt_size);
+ (void) memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs,
+ elt_size);
if (VALUE_LVAL (array) == lval_internalvar)
VALUE_LVAL (v) = lval_internalvar_component;
return val;
}
\f
-/* Simulate the C operator ! -- return 1 if ARG1 contains zeros. */
+/* Simulate the C operator ! -- return 1 if ARG1 contains zero. */
int
value_zerop (arg1)
COERCE_ARRAY (arg1);
+ if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FLT)
+ return 0 == value_as_double (arg1);
+
len = TYPE_LENGTH (VALUE_TYPE (arg1));
p = VALUE_CONTENTS (arg1);
{
register value val = allocate_value (type);
- memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (type));
+ (void) memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (type));
VALUE_LVAL (val) = lv;
return val;
amount_copied += reg_size, regno++)
{
get_saved_register (buffer + amount_copied,
- (int *)NULL, (CORE_ADDR)NULL,
+ (int *)NULL, (CORE_ADDR *)NULL,
frame, regno, (enum lval_type *)NULL);
}
(int) value_as_long (fromval),
VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
else if (use_buffer)
- bcopy (raw_buffer, buffer + byte_offset, use_buffer);
+ (void) memcpy (buffer + byte_offset, raw_buffer, use_buffer);
else
- bcopy (VALUE_CONTENTS (fromval), buffer + byte_offset,
- TYPE_LENGTH (type));
+ (void) memcpy (buffer + byte_offset, VALUE_CONTENTS (fromval),
+ TYPE_LENGTH (type));
/* Copy it back. */
for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset,
}
val = allocate_value (type);
- bcopy (toval, val, VALUE_CONTENTS_RAW (val) - (char *) val);
- bcopy (VALUE_CONTENTS (fromval), VALUE_CONTENTS_RAW (val), TYPE_LENGTH (type));
+ (void) memcpy (val, toval, VALUE_CONTENTS_RAW (val) - (char *) val);
+ (void) memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
+ TYPE_LENGTH (type));
VALUE_TYPE (val) = type;
return val;
/* Create a call sequence customized for this function
and the number of arguments for it. */
- bcopy (dummy, dummy1, sizeof dummy);
+ (void) memcpy (dummy1, dummy, sizeof dummy);
for (i = 0; i < sizeof dummy / sizeof (REGISTER_TYPE); i++)
SWAP_TARGET_AND_HOST (&dummy1[i], sizeof (REGISTER_TYPE));
FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
to resolve user expressions of the form "DOMAIN::NAME". */
value
-value_struct_elt_for_reference (domain, curtype, name, intype)
+value_struct_elt_for_reference (domain, offset, curtype, name, intype)
struct type *domain, *curtype, *intype;
+ int offset;
char *name;
{
register struct type *t = curtype;
return value_from_longest
(lookup_reference_type (lookup_member_type (TYPE_FIELD_TYPE (t, i),
domain)),
- (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
+ offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
}
}
for (i = TYPE_N_BASECLASSES (t) - 1; i >= 0; i--)
{
+ value v;
+ int base_offset;
+
+ if (BASETYPE_VIA_VIRTUAL (t, i))
+ base_offset = 0;
+ else
+ base_offset = TYPE_BASECLASS_BITPOS (t, i) / 8;
v = value_struct_elt_for_reference (domain,
+ offset + base_offset,
TYPE_BASECLASS (t, i),
name,
intype);
if (len == sizeof (float))
{
/* It's single precision. */
- bcopy (valaddr, &low, sizeof (low));
+ (void) memcpy ((char *) &low, valaddr, sizeof (low));
/* target -> host. */
SWAP_TARGET_AND_HOST (&low, sizeof (float));
nonnegative = low >= 0;
/* It's double precision. Get the high and low words. */
#if TARGET_BYTE_ORDER == BIG_ENDIAN
- bcopy (valaddr+4, &low, sizeof (low));
- bcopy (valaddr+0, &high, sizeof (high));
+ (void) memcpy (&low, valaddr+4, sizeof (low));
+ (void) memcpy (&high, valaddr+0, sizeof (high));
#else
- bcopy (valaddr+0, &low, sizeof (low));
- bcopy (valaddr+4, &high, sizeof (high));
+ (void) memcpy (&low, valaddr+0, sizeof (low));
+ (void) memcpy (&high, valaddr+4, sizeof (high));
#endif
SWAP_TARGET_AND_HOST (&low, sizeof (low));
SWAP_TARGET_AND_HOST (&high, sizeof (high));
rep1 = i + 1;
reps = 1;
while (rep1 < n
- && !bcmp (VALUE_CONTENTS (val) + typelen * i,
+ && !memcmp (VALUE_CONTENTS (val) + typelen * i,
VALUE_CONTENTS (val) + typelen * rep1, typelen))
{
++reps;
rep1 = i + 1;
reps = 1;
while (rep1 < len
- && !bcmp (valaddr + i * eltlen,
- valaddr + rep1 * eltlen, eltlen))
+ && !memcmp (valaddr + i * eltlen,
+ valaddr + rep1 * eltlen, eltlen))
{
++reps;
++rep1;
case TYPE_CODE_ERROR:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL:
+ case TYPE_CODE_SET:
+ case TYPE_CODE_RANGE:
+ case TYPE_CODE_PASCAL_ARRAY:
/* These types need no prefix. They are listed here so that
gcc -Wall will reveal any types that haven't been handled. */
break;
case TYPE_CODE_ERROR:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL:
+ case TYPE_CODE_SET:
+ case TYPE_CODE_RANGE:
+ case TYPE_CODE_PASCAL_ARRAY:
/* These types do not need a suffix. They are listed so that
gcc -Wall will report types that may not have been considered. */
break;
VALUE_LAZY (val) = VALUE_LAZY (arg);
if (!VALUE_LAZY (val))
{
- bcopy (VALUE_CONTENTS_RAW (arg), VALUE_CONTENTS_RAW (val),
- TYPE_LENGTH (VALUE_TYPE (arg))
- * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1));
+ memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS_RAW (arg),
+ TYPE_LENGTH (VALUE_TYPE (arg))
+ * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1));
}
return val;
}
register struct value_history_chunk *new
= (struct value_history_chunk *)
xmalloc (sizeof (struct value_history_chunk));
- bzero (new->values, sizeof new->values);
+ (void) memset (new->values, 0, sizeof new->values);
new->next = value_history_chain;
value_history_chain = new;
}
modify_field (addr, (int) value_as_long (newval),
bitpos, bitsize);
else
- bcopy (VALUE_CONTENTS (newval), addr,
- TYPE_LENGTH (VALUE_TYPE (newval)));
+ (void) memcpy (addr, VALUE_CONTENTS (newval),
+ TYPE_LENGTH (VALUE_TYPE (newval)));
}
void
if (len == sizeof (float))
{
float retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (double))
{
double retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (short))
{
unsigned short retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (int))
{
unsigned int retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (long))
{
unsigned long retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (long long))
{
unsigned long long retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (char))
{
SIGNED char retval; /* plain chars might be unsigned on host */
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (short))
{
short retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (int))
{
int retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (long))
{
long retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (long long))
{
long long retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof(long))
{
unsigned long retval;
- bcopy (valaddr, &retval, sizeof(retval));
+ (void) memcpy (&retval, valaddr, sizeof(retval));
SWAP_TARGET_AND_HOST (&retval, sizeof(retval));
return retval;
}
else if (len == sizeof(short))
{
unsigned short retval;
- bcopy (valaddr, &retval, len);
+ (void) memcpy (&retval, valaddr, len);
SWAP_TARGET_AND_HOST (&retval, len);
return retval;
}
if (len == sizeof (float))
{
float retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (double))
{
double retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (len == sizeof (CORE_ADDR))
{
CORE_ADDR retval;
- bcopy (valaddr, &retval, sizeof (retval));
+ (void) memcpy (&retval, valaddr, sizeof (retval));
SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
return retval;
}
if (VALUE_LAZY (arg1))
VALUE_LAZY (v) = 1;
else
- bcopy (VALUE_CONTENTS_RAW (arg1) + offset,
- VALUE_CONTENTS_RAW (v),
- TYPE_LENGTH (type));
+ (void) memcpy (VALUE_CONTENTS_RAW (v),
+ VALUE_CONTENTS_RAW (arg1) + offset, TYPE_LENGTH (type));
}
VALUE_LVAL (v) = VALUE_LVAL (arg1);
if (VALUE_LVAL (arg1) == lval_internalvar)
/* First collect the vtables we must look at for this object. */
/* FIXME-tiemann: right now, just look at top-most vtable. */
value vtbl, entry, best_entry = 0;
- /* FIXME: entry_type is never used. */
- struct type *entry_type;
int i, nelems;
int offset, best_offset = 0;
struct symbol *sym;
know that we aren't happy, but don't throw an error.
FIXME: there has to be a better way to do this. */
struct type *error_type = (struct type *)xmalloc (sizeof (struct type));
- bcopy (VALUE_TYPE (arg), error_type, sizeof (struct type));
+ (void) memcpy (error_type, VALUE_TYPE (arg), sizeof (struct type));
TYPE_NAME (error_type) = savestring ("suspicious *", sizeof ("suspicious *"));
VALUE_TYPE (arg) = error_type;
return arg;
int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
int lsbcount;
- bcopy (valaddr + bitpos / 8, &val, sizeof (val));
+ (void) memcpy (&val, valaddr + bitpos / 8, sizeof (val));
SWAP_TARGET_AND_HOST (&val, sizeof (val));
/* Extract bits. See comment above. */
&& 0 != (fieldval & ~((1<<bitsize)-1)))
error ("Value %d does not fit in %d bits.", fieldval, bitsize);
- bcopy (addr, &oword, sizeof oword);
+ (void) memcpy (&oword, addr, sizeof oword);
SWAP_TARGET_AND_HOST (&oword, sizeof oword); /* To host format */
/* Shifting for bit field depends on endianness of the target machine. */
oword |= fieldval << bitpos;
SWAP_TARGET_AND_HOST (&oword, sizeof oword); /* To target format */
- bcopy (&oword, addr, sizeof oword);
+ (void) memcpy (addr, &oword, sizeof oword);
}
\f
/* Convert C numbers into newly allocated values */