/* Evaluate expressions for GDB.
- Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
else
error ("Expression of type other than \"Function returning ...\" used as function");
}
- return target_call_function (argvec[0], nargs, argvec + 1);
+ return call_function_by_hand (argvec[0], nargs, argvec + 1);
case STRUCTOP_STRUCT:
tem = strlen (&exp->elts[pc + 1].string);
{
enum exp_opcode op;
register int pc;
+ struct symbol *var;
pc = (*pos);
op = exp->elts[pc].opcode;
evaluate_subexp (NULL_TYPE, exp, pos, noside));
case OP_VAR_VALUE:
+ var = exp->elts[pc + 1].symbol;
+
+ /* C++: The "address" of a reference should yield the address
+ * of the object pointed to. Let value_addr() deal with it. */
+ if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_REF)
+ goto default_case;
+
(*pos) += 3;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type =
- lookup_pointer_type (SYMBOL_TYPE (exp->elts[pc + 1].symbol));
- enum address_class sym_class =
- SYMBOL_CLASS (exp->elts[pc + 1].symbol);
+ lookup_pointer_type (SYMBOL_TYPE (var));
+ enum address_class sym_class = SYMBOL_CLASS (var);
if (sym_class == LOC_CONST
|| sym_class == LOC_CONST_BYTES
value_zero (type, not_lval);
}
else
- return locate_var_value (exp->elts[pc + 1].symbol, (FRAME) 0);
+ return locate_var_value (var, (FRAME) 0);
default:
+ default_case:
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
value x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
register enum exp_opcode op;
register int pc;
register value val;
+ struct symbol *var;
pc = (*pos);
op = exp->elts[pc].opcode;
switch (op)
{
case OP_VAR_VALUE:
- if (TYPE_CODE (SYMBOL_TYPE (exp->elts[pc + 1].symbol)) == TYPE_CODE_ARRAY)
+ var = exp->elts[pc + 1].symbol;
+ if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_ARRAY)
{
(*pos) += 3;
- val = locate_var_value (exp->elts[pc + 1].symbol, (FRAME) 0);
- return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (exp->elts[pc + 1].symbol))),
+ val = locate_var_value (var, (FRAME) 0);
+ return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (var))),
val);
}
default:
/* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18.
- Copyright 1990, 1991 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu).
Adapted from work done at Cygnus Support in remote-eb.c.
/* External data declarations */
extern int stop_soon_quietly; /* for wait_for_inferior */
-/* External function declarations */
-extern struct value *call_function_by_hand();
-
/* Forward data declarations */
extern struct target_ops adapt_ops; /* Forward declaration */
0, 0, 0, 0, 0, /* Terminal handling */
adapt_kill, /* FIXME, kill */
adapt_load,
- call_function_by_hand,
0, /* lookup_symbol */
adapt_create_inferior, /* create_inferior */
adapt_mourn, /* mourn_inferior FIXME */
/* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB.
- Copyright 1990, 1991 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Jim Kingdon for Cygnus.
This file is part of GDB.
#include "target.h"
#include "gdbcore.h"
-extern struct value *call_function_by_hand();
-
extern struct target_ops eb_ops; /* Forward declaration */
static void eb_close();
0, 0, 0, 0, 0, /* Terminal handling */
eb_kill,
0, /* load */
- call_function_by_hand,
0, /* lookup_symbol */
eb_create_inferior,
eb_mourn_inferior,
/* Remote debugging interface for Hitachi HMS Monitor Version 1.0
-
Copyright 1992 Free Software Foundation, Inc.
-
- Contributed by Steve Chamberlain sac@cygnus.com
-
+ Contributed by Cygnus Support. Written by Steve Chamberlain
+ (sac@cygnus.com).
This file is part of GDB.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
#include <stdio.h>
-#include <string.h>
#include "defs.h"
#include "inferior.h"
#include "wait.h"
#include "value.h"
+#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
/* External data declarations */
extern int stop_soon_quietly; /* for wait_for_inferior */
-/* External function declarations */
-extern struct value *call_function_by_hand();
-
/* Forward data declarations */
extern struct target_ops hms_ops; /* Forward declaration */
0, 0, 0, 0, 0, /* Terminal handling */
hms_kill, /* FIXME, kill */
hms_load,
- call_function_by_hand,
0, /* lookup_symbol */
hms_create_inferior, /* create_inferior */
hms_mourn, /* mourn_inferior FIXME */
/* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB.
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
Originally written by Daniel Mann at AMD.
This file is part of GDB.
extern int stop_soon_quietly; /* for wait_for_inferior */
-extern struct value *call_function_by_hand();
-
static void mm_resume();
static void mm_fetch_registers ();
static int fetch_register ();
0, 0, 0, 0, 0, /* Terminal handling */
mm_kill, /* FIXME, kill */
mm_load,
- call_function_by_hand,
0, /* lookup_symbol */
mm_create_inferior, /* create_inferior */
mm_mourn, /* mourn_inferior FIXME */
/* Memory-access and commands for remote NINDY process, for GDB.
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
Contributed by Intel Corporation. Modified from remote.c by Chris Benenati.
GDB is distributed in the hope that it will be useful, but WITHOUT ANY
extern char *mktemp();
extern char *coffstrip();
-extern value call_function_by_hand ();
extern void generic_mourn_inferior ();
extern struct target_ops nindy_ops;
0, 0, 0, 0, 0, /* Terminal crud */
nindy_kill,
nindy_load,
- call_function_by_hand,
0, /* lookup_symbol */
nindy_create_inferior,
nindy_mourn_inferior,
#include <value.h>
#include <symtab.h>
-extern value call_function_by_hand ();
extern void symbol_file_command ();
extern int stop_soon_quietly; /* for wait_for_inferior */
#ifdef FIXME
/* FIXME, function calls are really fried. GO back to manual method. */
value
-vx_call_function (function, nargs, args)
+call_function (function, nargs, args)
value function;
int nargs;
value *args;
start_sp = text_end;
errcode = target_write_memory (start_sp, dummy1, sizeof dummy);
if (errcode != 0)
- error ("Cannot write text segment -- call_function failed");
+ error ("Cannot write text segment -- vx_call_function failed");
}
#endif /* After text_end. */
#endif /* Not on stack. */
0, 0, 0, 0, 0, /* terminal stuff */
0, /* vx_kill, */
vx_add_file_command,
- call_function_by_hand, /* FIXME, calling fns is maybe botched? */
vx_lookup_symbol,
vx_create_inferior, 0, /* mourn_inferior */
core_stratum, 0, /* next */
0, 0, 0, 0, 0, /* terminal stuff */
0, /* vx_kill, */
vx_add_file_command,
- call_function_by_hand, /* FIXME, calling fns is maybe botched? */
vx_lookup_symbol,
vx_create_inferior, vx_mourn_inferior,
process_stratum, 0, /* next */
/* Memory-access and commands for remote VxWorks processes, for GDB.
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
Contributed by Wind River Systems and Cygnus Support.
This file is part of GDB.
#include <value.h>
#include <symtab.h>
-extern value call_function_by_hand ();
extern void symbol_file_command ();
extern int stop_soon_quietly; /* for wait_for_inferior */
0, 0, 0, 0, 0, /* terminal stuff */
0, /* vx_kill, */
vx_load_command,
- 0, /* call_function */
vx_lookup_symbol,
vx_create_inferior, 0, /* mourn_inferior */
core_stratum, 0, /* next */
0, 0, 0, 0, 0, /* terminal stuff */
vx_kill,
vx_load_command,
- call_function_by_hand, /* FIXME, calling fns is maybe botched? */
vx_lookup_symbol,
0, vx_mourn_inferior,
process_stratum, 0, /* next */
/* Select target systems and architectures at runtime for GDB.
- Copyright (C) 1990 Free Software Foundation, Inc.
+ Copyright 1990, 1992 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB.
-GDB is free software; you can redistribute it and/or modify
+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.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+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 GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <errno.h>
#include "bfd.h"
#include "symfile.h"
+extern int errno;
+
extern int memory_insert_breakpoint(), memory_remove_breakpoint();
extern void host_convert_to_virtual(), host_convert_from_virtual();
-extern void add_syms_addr_command();
static void cleanup_target ();
0, 0, /* bkpts */
0, 0, 0, 0, 0, /* terminal */
0, 0, /* kill, load */
- add_syms_addr_command, /* add_syms */
- 0, 0, /* call_function, lookup_symbol */
+ 0, /* lookup_symbol */
0, 0, /* create_inferior, mourn_inferior */
dummy_stratum, 0, /* stratum, next */
0, 0, 0, 0, 0, /* all mem, mem, stack, regs, exec */
+ 0, 0, /* section pointers */
OPS_MAGIC,
};
kill_or_be_killed (from_tty)
int from_tty;
{
- /* FIXME: What is savecur for? Why isn't it used? */
- struct target_ops *savecur;
-
if (target_has_execution)
{
printf ("You are already running a program:\n");
target_files_info ();
if (query ("Kill it? ")) {
- savecur = current_target;
- target_kill (0, from_tty);
+ target_kill ();
if (target_has_execution)
error ("Killing the program did not help.");
return;
de_fault (to_detach, (void (*)())ignore);
de_fault (to_resume, (void (*)())noprocess);
de_fault (to_wait, noprocess);
- de_fault (to_fetch_registers, noprocess);
- de_fault (to_store_registers, noprocess);
+ de_fault (to_fetch_registers, ignore);
+ de_fault (to_store_registers, (void (*)())noprocess);
de_fault (to_prepare_to_store, (void (*)())noprocess);
de_fault (to_convert_to_virtual, host_convert_to_virtual);
de_fault (to_convert_from_virtual, host_convert_from_virtual);
de_fault (to_terminal_info, default_terminal_info);
de_fault (to_kill, (void (*)())noprocess);
de_fault (to_load, tcomplain);
- de_fault (to_add_syms, tcomplain);
- de_fault (to_call_function, (struct value *(*)())noprocess);
de_fault (to_lookup_symbol, nosymbol);
de_fault (to_create_inferior, maybe_kill_then_create_inferior);
de_fault (to_mourn_inferior, (void (*)())noprocess);
push_target (&dummy_target);
}
+#define MIN(A, B) (((A) <= (B)) ? (A) : (B))
+
+/* target_read_string -- read a null terminated string from MEMADDR in target.
+ The read may also be terminated early by getting an error from target_xfer_
+ memory.
+ LEN is the size of the buffer pointed to by MYADDR. Note that a terminating
+ null will only be written if there is sufficient room. The return value is
+ is the number of bytes (including the null) actually transferred.
+*/
+
+int
+target_read_string (memaddr, myaddr, len)
+ CORE_ADDR memaddr;
+ char *myaddr;
+ int len;
+{
+ int tlen, origlen, offset, i;
+ char buf[4];
+
+ origlen = len;
+
+ while (len > 0)
+ {
+ tlen = MIN (len, 4 - (memaddr & 3));
+ offset = memaddr & 3;
+
+ if (target_xfer_memory (memaddr & ~3, buf, 4, 0))
+ return origlen - len;
+
+ for (i = 0; i < tlen; i++)
+ {
+ *myaddr++ = buf[i + offset];
+ if (buf[i + offset] == '\000')
+ return (origlen - len) + i + 1;
+ }
+
+ memaddr += tlen;
+ len -= tlen;
+ }
+ return origlen;
+}
+
/* Move memory to or from the targets. Iterate until all of it has
been moved, if necessary. The top target gets priority; anything
it doesn't want, is offered to the next one down, etc. Note the
struct target_ops *t;
/* The quick case is that the top target does it all. */
- res = current_target->to_xfer_memory(memaddr, myaddr, len, write);
+ res = current_target->to_xfer_memory
+ (memaddr, myaddr, len, write, current_target);
if (res == len)
return 0;
t;
t = t->to_has_all_memory? 0: t->to_next)
{
- res = t->to_xfer_memory(memaddr, myaddr, curlen, write);
+ res = t->to_xfer_memory(memaddr, myaddr, curlen, write, t);
if (res > 0) break; /* Handled all or part of xfer */
if (res == 0) continue; /* Handled none */
curlen = -res; /* Could handle once we get past res bytes */
read zeros if reading, or do nothing if writing. Return error. */
if (!write)
bzero (myaddr, len);
- return EIO;
+ if (errno == 0)
+ return EIO;
+ else
+ return errno;
}
bump:
memaddr += res;
struct target_ops *t;
int has_all_mem = 0;
- if (symfile != 0)
- printf ("Symbols from \"%s\".\n", symfile);
+ if (symfile_objfile != 0)
+ printf ("Symbols from \"%s\".\n", symfile_objfile->name);
#ifdef FILES_INFO_HOOK
if (FILES_INFO_HOOK ())
if (has_all_mem)
printf("\tWhile running this, gdb does not access memory from...\n");
printf("%s:\n", t->to_longname);
- (t->to_files_info)();
+ (t->to_files_info)(t);
has_all_mem = t->to_has_all_memory;
}
}
if (target_has_execution)
{
if (query ("A program is being debugged already. Kill it? "))
- target_kill ((char *)0, from_tty);
+ target_kill ();
else
error ("Program not killed.");
}
/* Perform arithmetic and other operations on values, for GDB.
- Copyright 1986, 1989, 1991 Free Software Foundation, Inc.
+ Copyright 1986, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
argvec[1] = argvec[0];
argvec++;
}
- return target_call_function (argvec[0], 2 - static_memfuncp, argvec + 1);
+ return call_function_by_hand (argvec[0], 2 - static_memfuncp, argvec + 1);
}
error ("member function %s not found", tstr);
#ifdef lint
- return target_call_function (argvec[0], 2 - static_memfuncp, argvec + 1);
+ return call_function_by_hand (argvec[0], 2 - static_memfuncp, argvec + 1);
#endif
}
argvec[1] = argvec[0];
argvec++;
}
- return target_call_function (argvec[0], 1 - static_memfuncp, argvec + 1);
+ return call_function_by_hand (argvec[0], 1 - static_memfuncp, argvec + 1);
}
error ("member function %s not found", tstr);
return 0; /* For lint -- never reached */
/* Perform non-arithmetic operations on values, for GDB.
- Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
int v; /* FIXME, this won't work for large bitfields */
read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
&v, sizeof v);
- modify_field (&v, (int) value_as_long (fromval),
+ modify_field ((char *) &v, (int) value_as_long (fromval),
VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
(char *)&v, sizeof v);
int v;
read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- &v, sizeof v);
- modify_field (&v, (int) value_as_long (fromval),
+ (char *) &v, sizeof v);
+ modify_field ((char *) &v, (int) value_as_long (fromval),
VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
- &v, sizeof v);
+ (char *) &v, sizeof v);
}
else if (use_buffer)
write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
value_addr (arg1)
value arg1;
{
+ extern value value_copy ();
struct type *type = VALUE_TYPE (arg1);
if (TYPE_CODE (type) == TYPE_CODE_REF)
{
CORE_ADDR funaddr;
int using_gcc;
+ if (!target_has_execution)
+ noprocess();
+
save_inferior_status (&inf_status, 1);
old_chain = make_cleanup (restore_inferior_status, &inf_status);
}
blocklen = value_from_longest (builtin_type_int, (LONGEST) (len + 1));
- val = target_call_function (val, 1, &blocklen);
+ val = call_function_by_hand (val, 1, &blocklen);
if (value_zerop (val))
error ("No memory available for string constant.");
write_memory (value_as_pointer (val), copy, len + 1);
/* Definitions for values of C expressions, for GDB.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
This file is part of GDB.
-GDB is free software; you can redistribute it and/or modify
+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.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+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 GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#if !defined (VALUE_H)
#define VALUE_H 1
/* In a register series in a frame not the current one, which may have been
partially saved or saved in different places (otherwise would be
lval_register or lval_memory). */
- lval_reg_frame_relative,
+ lval_reg_frame_relative
};
struct value
/* Convert a REF to the object referenced. */
#define COERCE_REF(arg) \
-{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
+{ if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_REF) \
arg = value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg)), \
unpack_long (VALUE_TYPE (arg), \
VALUE_CONTENTS (arg)));}
/* If ARG is an enum, convert it to an integer. */
#define COERCE_ENUM(arg) \
-{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \
+{ if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_REF) \
arg = value_ind (arg); \
if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \
arg = value_cast (builtin_type_unsigned_int, arg); \
};
\f
#include "symtab.h"
-LONGEST value_as_long ();
-double value_as_double ();
-LONGEST unpack_long ();
-double unpack_double ();
+LONGEST value_as_long (
+#ifdef __STDC__
+ value
+#endif
+ );
+double value_as_double (
+#ifdef __STDC__
+ value
+#endif
+ );
+CORE_ADDR value_as_pointer (
+#ifdef __STDC__
+ value
+#endif
+ );
+LONGEST unpack_long (
+#ifdef __STDC__
+ struct type *, char *
+#endif
+ );
+double unpack_double (
+#ifdef __STDC__
+ struct type *, char *, int *
+#endif
+ );
+CORE_ADDR unpack_pointer (
+#ifdef __STDC__
+ struct type *, char *
+#endif
+ );
long unpack_field_as_long ();
-value value_from_long ();
+value value_from_longest ();
value value_from_double ();
value value_at ();
value value_at_lazy ();
value evaluate_type ();
value parse_and_eval ();
value parse_to_comma_and_eval ();
+struct type *parse_and_eval_type ();
extern CORE_ADDR parse_and_eval_address ();
extern CORE_ADDR parse_and_eval_address_1 ();
int value_print ();
int val_print ();
void print_variable_value ();
+void typedef_print ();
char *internalvar_name ();
void clear_value_history ();
void clear_internalvars ();
+extern value
+call_function_by_hand PARAMS ((value, int value *));
+
#endif /* value.h not already included. */
/* Execute AIXcoff files, for GDB.
- Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
+ Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
Derived from exec.c. Modified by IBM Corporation.
Donated by IBM Corporation and Cygnus Support.
0, 0, /* insert_breakpoint, remove_breakpoint, */
0, 0, 0, 0, 0, /* terminal stuff */
0, 0, /* kill, load */
- 0, 0, /* call fn, lookup sym */
+ 0, /* lookup sym */
child_create_inferior,
0, /* mourn_inferior */
file_stratum, 0, /* next */