/* Print values for GNU debugger GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994, 1995
+ Copyright 1986, 87, 88, 89, 90, 91, 93, 94, 95, 1998
Free Software Foundation, Inc.
This file is part of GDB.
int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info *));
disassemble_info tm_print_insn_info;
-/* Prototypes for local functions. */
+/* Prototypes for exported functions. */
+
+void output_command PARAMS ((char *, int));
+
+void _initialize_printcmd PARAMS ((void));
+
+/* Prototypes for local functions. */
static void delete_display PARAMS ((int));
static void display_command PARAMS ((char *, int));
-static void x_command PARAMS ((char *, int));
+void x_command PARAMS ((char *, int));
static void address_info PARAMS ((char *, int));
static void set_command PARAMS ((char *, int));
-static void output_command PARAMS ((char *, int));
-
static void call_command PARAMS ((char *, int));
static void inspect_command PARAMS ((char *, int));
static int print_insn PARAMS ((CORE_ADDR, GDB_FILE *));
+static void sym_info PARAMS ((char *, int));
+
\f
/* Decode a format specification. *STRING_PTR should point to it.
OFORMAT and OSIZE are used as defaults for the format and size
switch (format)
{
case 's':
+ /* FIXME: Need to handle wchar_t's here... */
next_address = VALUE_ADDRESS (val)
- + val_print_string (VALUE_ADDRESS (val), 0, gdb_stdout);
+ + val_print_string (VALUE_ADDRESS (val), -1, 1, gdb_stdout);
next_section = VALUE_BFD_SECTION (val);
break;
/* These are the types that $__ will get after an examine command of one
of these sizes. */
+static struct type *examine_i_type;
+
static struct type *examine_b_type;
static struct type *examine_h_type;
static struct type *examine_w_type;
if (format == 's' || format == 'i')
size = 'b';
- if (size == 'b')
+ if (format == 'i')
+ val_type = examine_i_type;
+ else if (size == 'b')
val_type = examine_b_type;
else if (size == 'h')
val_type = examine_h_type;
/* Note that print_formatted sets next_address for the next
object. */
last_examine_address = next_address;
- last_examine_value = value_at (val_type, next_address, sect);
+ /* The value to be displayed is not fetched greedily.
+ Instead, to avoid the posibility of a fetched value not
+ being used, its retreval is delayed until the print code
+ uses it. When examining an instruction stream, the
+ disassembler will perform its own memory fetch using just
+ the address stored in LAST_EXAMINE_VALUE. FIXME: Should
+ the disassembler be modified so that LAST_EXAMINE_VALUE
+ is left with the byte sequence from the last complete
+ instruction fetched from memory? */
+ last_examine_value = value_at_lazy (val_type, next_address, sect);
print_formatted (last_examine_value, format, size);
}
printf_filtered ("\n");
extern int objectprint;
struct type *type;
expr = parse_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
+ old_chain = make_cleanup ((make_cleanup_func) free_current_contents,
+ &expr);
cleanup = 1;
val = evaluate_expression (expr);
}
/* ARGSUSED */
-static void
+void
output_command (exp, from_tty)
char *exp;
int from_tty;
}
expr = parse_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
+ old_chain = make_cleanup ((make_cleanup_func) free_current_contents, &expr);
val = evaluate_expression (expr);
{
struct expression *expr = parse_expression (exp);
register struct cleanup *old_chain
- = make_cleanup (free_current_contents, &expr);
+ = make_cleanup ((make_cleanup_func) free_current_contents, &expr);
evaluate_expression (expr);
do_cleanups (old_chain);
}
break;
case LOC_REGISTER:
- printf_filtered ("a variable in register %s", reg_names[val]);
+ printf_filtered ("a variable in register %s", REGISTER_NAME (val));
break;
case LOC_STATIC:
break;
case LOC_REGPARM:
- printf_filtered ("an argument in register %s", reg_names[val]);
+ printf_filtered ("an argument in register %s", REGISTER_NAME (val));
break;
case LOC_REGPARM_ADDR:
- printf_filtered ("address of an argument in register %s", reg_names[val]);
+ printf_filtered ("address of an argument in register %s", REGISTER_NAME (val));
break;
case LOC_ARG:
case LOC_BASEREG:
printf_filtered ("a variable at offset %ld from register %s",
- val, reg_names[basereg]);
+ val, REGISTER_NAME (basereg));
break;
case LOC_BASEREG_ARG:
printf_filtered ("an argument at offset %ld from register %s",
- val, reg_names[basereg]);
+ val, REGISTER_NAME (basereg));
break;
case LOC_TYPEDEF:
printf_filtered (".\n");
}
\f
-static void
+void
x_command (exp, from_tty)
char *exp;
int from_tty;
But don't clobber a user-defined command's definition. */
if (from_tty)
*exp = 0;
- old_chain = make_cleanup (free_current_contents, &expr);
+ old_chain = make_cleanup ((make_cleanup_func) free_current_contents,
+ &expr);
val = evaluate_expression (expr);
if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF)
val = value_ind (val);
(LONGEST) last_examine_address));
/* Make contents of last address examined available to the user as $__.*/
- set_internalvar (lookup_internalvar ("__"), last_examine_value);
+ /* If the last value has not been fetched from memory then don't
+ fetch it now - instead mark it by voiding the $__ variable. */
+ if (VALUE_LAZY (last_examine_value))
+ set_internalvar (lookup_internalvar ("__"),
+ allocate_value (builtin_type_void));
+ else
+ set_internalvar (lookup_internalvar ("__"), last_examine_value);
}
}
annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val));
if (val)
+ {
+#ifdef GDB_TARGET_IS_D10V
+ if (SYMBOL_CLASS(sym) == LOC_REGPARM && TYPE_CODE(VALUE_TYPE(val)) == TYPE_CODE_PTR)
+ TYPE_LENGTH(VALUE_TYPE(val)) = 2;
+#endif
val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val),
stream, 0, 0, 2, Val_no_prettyprint);
+ }
else
fputs_filtered ("???", stream);
char *arg;
int from_tty;
{
- register char *f;
+ register char *f = NULL;
register char *s = arg;
- char *string;
+ char *string = NULL;
value_ptr *val_args;
char *substrings;
char *current_substring;
struct cleanup *old_cleanups;
val_args = (value_ptr *) xmalloc (allocated_args * sizeof (value_ptr));
- old_cleanups = make_cleanup (free_current_contents, &val_args);
+ old_cleanups = make_cleanup ((make_cleanup_func) free_current_contents,
+ &val_args);
if (s == 0)
error_no_arg ("format-control string and values to print");
char *name;
CORE_ADDR pc, pc_masked;
char *space_index;
- asection *section;
name = NULL;
if (!arg)
pc = parse_and_eval_address (arg);
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
error ("No function contains specified address.\n");
- if (overlay_debugging)
- {
- section = find_pc_overlay (pc);
- if (pc_in_unmapped_range (pc, section))
- {
- /* find_pc_partial_function will have returned low and high
- relative to the symbolic (mapped) address range. Need to
- translate them back to the unmapped range where PC is. */
- low = overlay_unmapped_address (low, section);
- high = overlay_unmapped_address (high, section);
- }
- }
low += FUNCTION_START_OFFSET;
}
else
CORE_ADDR memaddr;
GDB_FILE *stream;
{
- /* If there's no disassembler, something is very wrong. */
- if (tm_print_insn == NULL)
- abort ();
-
if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- tm_print_insn_info.endian = BFD_ENDIAN_BIG;
+ TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG;
else
- tm_print_insn_info.endian = BFD_ENDIAN_LITTLE;
+ TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE;
- if (target_architecture != NULL)
- tm_print_insn_info.mach = target_architecture->mach;
+ if (TARGET_ARCHITECTURE != NULL)
+ TARGET_PRINT_INSN_INFO->mach = TARGET_ARCHITECTURE->mach;
/* else: should set .mach=0 but some disassemblers don't grok this */
- return (*tm_print_insn) (memaddr, &tm_print_insn_info);
+ return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO);
}
\f
&setprintlist),
&showprintlist);
+ /* For examine/instruction a single byte quantity is specified as
+ the data. This avoids problems with value_at_lazy() requiring a
+ valid data type (and rejecting VOID). */
+ examine_i_type = init_type (TYPE_CODE_INT, 1, 0, "examine_i_type", NULL);
+
examine_b_type = init_type (TYPE_CODE_INT, 1, 0, "examine_b_type", NULL);
examine_h_type = init_type (TYPE_CODE_INT, 2, 0, "examine_h_type", NULL);
examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL);