/* Print values for GNU debugger GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994
- Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994, 1995
+ Free Software Foundation, Inc.
This file is part of GDB.
static int display_number;
-/* Prototypes for local functions */
+/* Pointer to the target-dependent disassembly function. */
-static void
-delete_display PARAMS ((int));
+int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info *));
-static void
-enable_display PARAMS ((char *, int));
+/* Prototypes for local functions. */
-static void
-disable_display_command PARAMS ((char *, int));
+static void delete_display PARAMS ((int));
-static void
-disassemble_command PARAMS ((char *, int));
+static void enable_display PARAMS ((char *, int));
-static void
-printf_command PARAMS ((char *, int));
+static void disable_display_command PARAMS ((char *, int));
-static void
-print_frame_nameless_args PARAMS ((struct frame_info *, long, int, int,
- GDB_FILE *));
+static void disassemble_command PARAMS ((char *, int));
-static void
-display_info PARAMS ((char *, int));
+static void printf_command PARAMS ((char *, int));
-static void
-do_one_display PARAMS ((struct display *));
+static void print_frame_nameless_args PARAMS ((struct frame_info *, long,
+ int, int, GDB_FILE *));
-static void
-undisplay_command PARAMS ((char *, int));
+static void display_info PARAMS ((char *, int));
-static void
-free_display PARAMS ((struct display *));
+static void do_one_display PARAMS ((struct display *));
-static void
-display_command PARAMS ((char *, int));
+static void undisplay_command PARAMS ((char *, int));
-static void
-x_command PARAMS ((char *, int));
+static void free_display PARAMS ((struct display *));
-static void
-address_info PARAMS ((char *, int));
+static void display_command PARAMS ((char *, int));
-static void
-set_command PARAMS ((char *, int));
+static void x_command PARAMS ((char *, int));
-static void
-output_command PARAMS ((char *, int));
+static void address_info PARAMS ((char *, int));
-static void
-call_command PARAMS ((char *, int));
+static void set_command PARAMS ((char *, int));
-static void
-inspect_command PARAMS ((char *, int));
+static void output_command PARAMS ((char *, int));
-static void
-print_command PARAMS ((char *, int));
+static void call_command PARAMS ((char *, int));
-static void
-print_command_1 PARAMS ((char *, int, int));
+static void inspect_command PARAMS ((char *, int));
-static void
-validate_format PARAMS ((struct format_data, char *));
+static void print_command PARAMS ((char *, int));
-static void
-do_examine PARAMS ((struct format_data, CORE_ADDR));
+static void print_command_1 PARAMS ((char *, int, int));
-static void
-print_formatted PARAMS ((value_ptr, int, int));
+static void validate_format PARAMS ((struct format_data, char *));
-static struct format_data
-decode_format PARAMS ((char **, int, int));
+static void do_examine PARAMS ((struct format_data, CORE_ADDR));
+
+static void print_formatted PARAMS ((value_ptr, int, int));
+
+static struct format_data decode_format PARAMS ((char **, int, int));
+
+static int print_insn PARAMS ((CORE_ADDR, GDB_FILE *));
\f
/* Decode a format specification. *STRING_PTR should point to it.
case 'a':
case 's':
/* Pick the appropriate size for an address. */
-#if TARGET_PTR_BIT == 64
- val.size = osize ? 'g' : osize;
- break;
-#else /* Not 64 */
-#if TARGET_PTR_BIT == 32
- val.size = osize ? 'w' : osize;
- break;
-#else /* Not 32 */
-#if TARGET_PTR_BIT == 16
- val.size = osize ? 'h' : osize;
- break;
-#else /* Not 16 */
- #error Bad value for TARGET_PTR_BIT
-#endif /* Not 16 */
-#endif /* Not 32 */
-#endif /* Not 64 */
+ if (TARGET_PTR_BIT == 64)
+ val.size = osize ? 'g' : osize;
+ else if (TARGET_PTR_BIT == 32)
+ val.size = osize ? 'w' : osize;
+ else if (TARGET_PTR_BIT == 16)
+ val.size = osize ? 'h' : osize;
+ else
+ /* Bad value for TARGET_PTR_BIT */
+ abort ();
break;
case 'f':
/* Floating point has to be word or giantword. */
{
case 's':
next_address = VALUE_ADDRESS (val)
- + value_print (value_addr (val), gdb_stdout, format, Val_pretty_default);
+ + val_print_string (VALUE_ADDRESS (val), 0, gdb_stdout);
break;
case 'i':
void
print_variable_value (var, frame, stream)
struct symbol *var;
- FRAME frame;
+ struct frame_info *frame;
GDB_FILE *stream;
{
value_ptr val = read_var_value (var, frame);
+
value_print (val, stream, 0, Val_pretty_default);
}
we do not know. We pass 2 as "recurse" to val_print because our
standard indentation here is 4 spaces, and val_print indents
2 for each recurse. */
- val = read_var_value (sym, FRAME_INFO_ID (fi));
+ val = read_var_value (sym, fi);
annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val));
of the first nameless arg, and NUM is the number of nameless args to
print. FIRST is nonzero if this is the first argument (not just
the first nameless arg). */
+
static void
print_frame_nameless_args (fi, start, num, first, stream)
struct frame_info *fi;
gdb_flush (gdb_stdout);
}
+/* Print the instruction at address MEMADDR in debugged memory,
+ on STREAM. Returns length of the instruction, in bytes. */
+
+static int
+print_insn (memaddr, stream)
+ CORE_ADDR memaddr;
+ GDB_FILE *stream;
+{
+ disassemble_info info;
+
+#define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \
+ (INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \
+ (INFO).stream = (STREAM), \
+ (INFO).read_memory_func = dis_asm_read_memory, \
+ (INFO).memory_error_func = dis_asm_memory_error, \
+ (INFO).print_address_func = dis_asm_print_address, \
+ (INFO).insn_info_valid = 0
+
+ GDB_INIT_DISASSEMBLE_INFO(info, stream);
+
+ /* If there's no disassembler, something is very wrong. */
+ if (tm_print_insn == NULL)
+ abort ();
+
+ return (*tm_print_insn) (memaddr, &info);
+}
+
\f
void
_initialize_printcmd ()
"Describe where variable VAR is stored.");
add_com ("x", class_vars, x_command,
- "Examine memory: x/FMT ADDRESS.\n\
+ concat ("Examine memory: x/FMT ADDRESS.\n\
ADDRESS is an expression for the memory address to examine.\n\
FMT is a repeat count followed by a format letter and a size letter.\n\
Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
- t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\
-Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
+ t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n",
+"Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
The specified number of objects of the specified size are printed\n\
according to the format.\n\n\
Defaults for format and size letters are those previously used.\n\
Default count is 1. Default address is following last thing printed\n\
-with this command or \"print\".");
+with this command or \"print\".", NULL));
add_com ("disassemble", class_vars, disassemble_command,
"Disassemble a specified section of memory.\n\
as in the \"x\" command, and then EXP is used to get the address to examine\n\
and examining is done as in the \"x\" command.\n\n\
With no argument, display all currently requested auto-display expressions.\n\
-Use \"undisplay\" to cancel display requests previously made.");
+Use \"undisplay\" to cancel display requests previously made."
+);
add_cmd ("display", class_vars, enable_display,
"Enable some expressions to be displayed when program stops.\n\
add_com ("printf", class_vars, printf_command,
"printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
This is useful for formatted output in user-defined commands.");
+
add_com ("output", class_vars, output_command,
"Like \"print\" but don't put in value history and don't print newline.\n\
This is useful in user-defined commands.");
add_prefix_cmd ("set", class_vars, set_command,
-"Evaluate expression EXP and assign result to variable VAR, using assignment\n\
+concat ("Evaluate expression EXP and assign result to variable VAR, using assignment\n\
syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
example). VAR may be a debugger \"convenience\" variable (names starting\n\
with $), a register (a few standard names starting with $), or an actual\n\
-variable in the program being debugged. EXP is any valid expression.\n\
-Use \"set variable\" for variables with names identical to set subcommands.\n\
+variable in the program being debugged. EXP is any valid expression.\n",
+"Use \"set variable\" for variables with names identical to set subcommands.\n\
\nWith a subcommand, this command modifies parts of the gdb environment.\n\
-You can see these environment settings with the \"show\" command.",
+You can see these environment settings with the \"show\" command.", NULL),
&setlist, "set ", 1, &cmdlist);
/* "call" is the same as "set", but handy for dbx users to call fns. */
\n\
$NUM gets previous value number NUM. $ and $$ are the last two values.\n\
$$NUM refers to NUM'th value back from the last one.\n\
-Names starting with $ refer to registers (with the values they would have\n\
-if the program were to return to the stack frame now selected, restoring\n\
+Names starting with $ refer to registers (with the values they would have\n",
+"if the program were to return to the stack frame now selected, restoring\n\
all registers saved by frames farther in) or else to debugger\n\
\"convenience\" variables (any such name not a known register).\n\
Use assignment expressions to give values to convenience variables.\n",
&setprintlist),
&showprintlist);
- examine_b_type = init_type (TYPE_CODE_INT, 1, 0, NULL, NULL);
- examine_h_type = init_type (TYPE_CODE_INT, 2, 0, NULL, NULL);
- examine_w_type = init_type (TYPE_CODE_INT, 4, 0, NULL, NULL);
- examine_g_type = init_type (TYPE_CODE_INT, 8, 0, NULL, 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);
+ examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type", NULL);
}
#include "serial.h"
#include <sys/types.h>
#include <sys/time.h>
+#include <unistd.h>
+#ifndef __GO32__
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
-#include <unistd.h>
+#endif
extern struct target_ops sparclite_ops; /* Forward decl */
extern struct target_ops remote_ops;
static char *remote_target_name = NULL;
static serial_t remote_desc = NULL;
-static int udp_fd = -1;
static int serial_flag;
+#ifndef __GO32__
+static int udp_fd = -1;
+#endif
static serial_t open_tty PARAMS ((char *name));
static int send_resp PARAMS ((serial_t desc, char c));
static void close_tty PARAMS ((int ignore));
+#ifndef __GO32__
static int recv_udp_buf PARAMS ((int fd, unsigned char *buf, int len, int timeout));
static int send_udp_buf PARAMS ((int fd, unsigned char *buf, int len));
+#endif
static void sparclite_open PARAMS ((char *name, int from_tty));
static void sparclite_close PARAMS ((int quitting));
static void download PARAMS ((char *target_name, char *args, int from_tty,
static void sparclite_serial_write PARAMS ((bfd *from_bfd, asection *from_sec,
file_ptr from_addr,
bfd_vma to_addr, int len));
+#ifndef __GO32__
static unsigned short calc_checksum PARAMS ((unsigned char *buffer,
int count));
static void sparclite_udp_start PARAMS ((bfd_vma entry));
static void sparclite_udp_write PARAMS ((bfd *from_bfd, asection *from_sec,
file_ptr from_addr, bfd_vma to_addr,
int len));
+#endif
static void sparclite_download PARAMS ((char *filename, int from_tty));
#define DDA2_SUP_ASI 0xb000000
remote_desc = NULL;
}
+#ifndef __GO32__
static int
recv_udp_buf (fd, buf, len, timeout)
int fd, len;
error ("Short count in send: tried %d, sent %d\n", len, cc);
}
+#endif /* __GO32__ */
static void
sparclite_open (name, from_tty)
}
else
{
+#ifndef __GO32__
struct hostent *he;
struct sockaddr_in sockaddr;
unsigned char buffer[100];
if (cc < 3)
error ("SPARClite appears to be ill.");
+#else
+ error ("UDP downloading is not supported for DOS hosts.");
+#endif /* __GO32__ */
}
printf_unfiltered ("[SPARClite appears to be alive]\n");
{
if (serial_flag)
close_tty (0);
+#ifndef __GO32__
else
if (udp_fd != -1)
close (udp_fd);
+#endif
}
#define LOAD_ADDRESS 0x40000000
error ("Bad checksum from load command (0x%x)", i);
}
+#ifndef __GO32__
+
static unsigned short
calc_checksum (buffer, count)
unsigned char *buffer;
}
}
+#endif /* __GO32__ */
+
static void
sparclite_download (filename, from_tty)
char *filename;
int from_tty;
{
if (!serial_flag)
+#ifndef __GO32__
download (remote_target_name, filename, from_tty, sparclite_udp_write,
sparclite_udp_start);
+#else
+ abort (); /* sparclite_open should prevent this! */
+#endif
else
download (remote_target_name, filename, from_tty, sparclite_serial_write,
sparclite_serial_start);
0, /* to_can_run */
0, /* to_notice_signals */
0, /* to_stop */
- process_stratum, /* to_stratum */
+ download_stratum, /* to_stratum */
0, /* to_next */
0, /* to_has_all_memory */
0, /* to_has_memory */