aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/core.c3
-rw-r--r--gdb/gdbtk.c22
-rw-r--r--gdb/printcmd.c175
-rw-r--r--gdb/ser-go32.c15
-rw-r--r--gdb/sparcl-tdep.c30
-rw-r--r--gdb/top.c6
7 files changed, 160 insertions, 108 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 769a041..f952444 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,20 @@
+Fri Feb 3 11:19:20 1995 Stu Grossman (grossman@cygnus.com)
+
+ * core.c (dis_asm_read_memory), defs.h, gdbtk.c (gdb_disassemble),
+ top.c : Get rid of dis_asm_read_memory_hook. We can now call the
+ disassemblers directly and have no need for this hook anymore.
+ * defs.h, printcmd.c: Make print_insn be static.
+
+ * ser-go32.c (dos_comisr): Make this 8 bit clean.
+ * (dos_open dos_close): Allow multiple opens to the same device.
+ Use a ref count to prevent unwanted deallocations.
+ * sparcl-tdep.c: Put #ifdefs around all socket stuff to make GO32
+ happy.
+ * (sparclite_ops): Switch to download_stratum.
+ * target.h (enum strata): Move download_stratum before
+ process_stratum so that executable targets get pushed on top of
+ download targets.
+
Thu Feb 2 19:02:45 1995 Rob Savoye <rob@darkstar.cygnus.com>
* array-rom.c: Remove the non GDB remote protocol config stuff.
diff --git a/gdb/core.c b/gdb/core.c
index 52bb3aa..974e55c 100644
--- a/gdb/core.c
+++ b/gdb/core.c
@@ -181,9 +181,6 @@ dis_asm_read_memory (memaddr, myaddr, len, info)
int len;
disassemble_info *info;
{
- if (dis_asm_read_memory_hook)
- return dis_asm_read_memory_hook (memaddr, myaddr, len, info);
-
return target_read_memory (memaddr, (char *) myaddr, len);
}
diff --git a/gdb/gdbtk.c b/gdb/gdbtk.c
index 35b2a91..5951b08 100644
--- a/gdb/gdbtk.c
+++ b/gdb/gdbtk.c
@@ -667,8 +667,6 @@ call_wrapper (clientData, interp, argc, argv)
finish_saving_output (); /* Restore stdout to normal */
- dis_asm_read_memory_hook = 0; /* Restore disassembly hook */
-
gdb_flush (gdb_stderr); /* Flush error output */
gdb_flush (gdb_stdout); /* Sometimes error output comes here as well */
@@ -783,6 +781,16 @@ gdb_disassemble (clientData, interp, argc, argv)
{
CORE_ADDR pc, low, high;
int mixed_source_and_assembly;
+ static disassemble_info di = {
+ (fprintf_ftype) fprintf_filtered, /* fprintf_func */
+ gdb_stdout, /* stream */
+ NULL, /* application_data */
+ 0, /* flags */
+ NULL, /* private_data */
+ NULL, /* read_memory_func */
+ dis_asm_memory_error, /* memory_error_func */
+ dis_asm_print_address /* print_address_func */
+ };
if (argc != 3 && argc != 4)
{
@@ -836,7 +844,9 @@ gdb_disassemble (clientData, interp, argc, argv)
disassemble_from_exec = 1; /* It's remote, read the exec file */
if (disassemble_from_exec)
- dis_asm_read_memory_hook = gdbtk_dis_asm_read_memory;
+ di.read_memory_func = gdbtk_dis_asm_read_memory;
+ else
+ di.read_memory_func = dis_asm_read_memory;
/* If just doing straight assembly, all we need to do is disassemble
everything between low and high. If doing mixed source/assembly, we've
@@ -940,7 +950,7 @@ gdb_disassemble (clientData, interp, argc, argv)
fputs_unfiltered (" ", gdb_stdout);
print_address (pc, gdb_stdout);
fputs_unfiltered (":\t ", gdb_stdout);
- pc += print_insn (pc, gdb_stdout);
+ pc += tm_print_insn (pc, &di);
fputs_unfiltered ("\n", gdb_stdout);
}
}
@@ -954,13 +964,11 @@ assembly_only:
fputs_unfiltered (" ", gdb_stdout);
print_address (pc, gdb_stdout);
fputs_unfiltered (":\t ", gdb_stdout);
- pc += print_insn (pc, gdb_stdout);
+ pc += tm_print_insn (pc, &di);
fputs_unfiltered ("\n", gdb_stdout);
}
}
- dis_asm_read_memory_hook = 0;
-
gdb_flush (gdb_stdout);
return TCL_OK;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 467b0ae..bde7709 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1,6 +1,6 @@
/* 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.
@@ -111,77 +111,60 @@ static struct display *display_chain;
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 *));
/* Decode a format specification. *STRING_PTR should point to it.
@@ -246,22 +229,15 @@ decode_format (string_ptr, oformat, osize)
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. */
@@ -305,7 +281,7 @@ print_formatted (val, format, size)
{
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':
@@ -1500,10 +1476,11 @@ disable_display_command (args, from_tty)
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);
}
@@ -1656,7 +1633,7 @@ print_frame_args (func, fi, num, stream)
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));
@@ -1692,6 +1669,7 @@ print_frame_args (func, fi, num, stream)
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;
@@ -2074,6 +2052,33 @@ disassemble_command (arg, from_tty)
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);
+}
+
void
_initialize_printcmd ()
@@ -2084,17 +2089,17 @@ _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\
@@ -2125,7 +2130,8 @@ Do \"info display\" to see current list of code numbers.",
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\
@@ -2148,19 +2154,20 @@ Do \"info display\" to see current list of code numbers.", &deletelist);
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. */
@@ -2186,8 +2193,8 @@ stack frame, plus all those whose scope is global or an entire file.\n\
\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",
@@ -2220,8 +2227,8 @@ environment, the value is printed in its own window.");
&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);
}
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index a1c0b6e..b4a7591 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -196,6 +196,7 @@ static struct dos_ttystate
{
int base;
int irq;
+ int refcnt;
struct intrupt *intrupt;
int fifo;
int baudrate;
@@ -311,7 +312,7 @@ dos_comisr (irq)
port->oflo++;
}
- if (dos_putc (c & 0x7f, port) < 0)
+ if (dos_putc (c, port) < 0)
{
COUNT (CNT_ORUN);
}
@@ -474,11 +475,11 @@ dos_open (scb, name)
fd = name[3] - '1';
port = &ports[fd];
- if (port->intrupt)
+ if (port->refcnt++ > 0)
{
- /* already open (EBUSY not defined!) */
- errno = EACCES;
- return -1;
+ /* Device already opened another user. Just point at it. */
+ scb->fd = fd;
+ return 0;
}
/* force access to ID reg */
@@ -559,6 +560,10 @@ dos_close (scb)
return;
port = &ports[scb->fd];
+
+ if (port->refcnt-- > 1)
+ return;
+
if (!(intrupt = port->intrupt))
return;
diff --git a/gdb/sparcl-tdep.c b/gdb/sparcl-tdep.c
index 9a70b92..bf3d87b 100644
--- a/gdb/sparcl-tdep.c
+++ b/gdb/sparcl-tdep.c
@@ -24,24 +24,30 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#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,
@@ -54,12 +60,14 @@ static void sparclite_serial_start PARAMS ((bfd_vma entry));
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
@@ -316,6 +324,7 @@ close_tty (ignore)
remote_desc = NULL;
}
+#ifndef __GO32__
static int
recv_udp_buf (fd, buf, len, timeout)
int fd, len;
@@ -368,6 +377,7 @@ send_udp_buf (fd, buf, len)
error ("Short count in send: tried %d, sent %d\n", len, cc);
}
+#endif /* __GO32__ */
static void
sparclite_open (name, from_tty)
@@ -439,6 +449,7 @@ or: target sparclite udp host");
}
else
{
+#ifndef __GO32__
struct hostent *he;
struct sockaddr_in sockaddr;
unsigned char buffer[100];
@@ -472,6 +483,9 @@ or: target sparclite udp host");
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");
@@ -489,9 +503,11 @@ sparclite_close (quitting)
{
if (serial_flag)
close_tty (0);
+#ifndef __GO32__
else
if (udp_fd != -1)
close (udp_fd);
+#endif
}
#define LOAD_ADDRESS 0x40000000
@@ -668,6 +684,8 @@ sparclite_serial_write (from_bfd, from_sec, from_addr, to_addr, len)
error ("Bad checksum from load command (0x%x)", i);
}
+#ifndef __GO32__
+
static unsigned short
calc_checksum (buffer, count)
unsigned char *buffer;
@@ -780,14 +798,20 @@ sparclite_udp_write (from_bfd, from_sec, from_addr, to_addr, len)
}
}
+#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);
@@ -827,7 +851,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
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 */
diff --git a/gdb/top.c b/gdb/top.c
index f035ebe..d958c16 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -419,12 +419,6 @@ int (*target_wait_hook) PARAMS ((int pid, struct target_waitstatus *status));
void (*call_command_hook) PARAMS ((struct cmd_list_element *c, char *cmd,
int from_tty));
-/* An alternate way to read memory for disassembly. This is used to provide a
- switch that allows disassembly to come from an exec file rather than a
- remote target. This is a speed hack. */
-
-int (*dis_asm_read_memory_hook) PARAMS ((bfd_vma memaddr, bfd_byte *myaddr,
- int len, disassemble_info *info));
/* Takes control from error (). Typically used to prevent longjmps out of the
middle of the GUI. Usually used in conjunction with a catch routine. */