+Wed Oct 20 17:47:42 1993 Stu Grossman (grossman at cygnus.com)
+
+ * main.c: Make baud_rate and remote_debug be global variables,
+ remove #include "remote-utils.h". This makes it possible to build
+ GDB without remote-utils.c. Also, move setting of remote_debug
+ into main, so that all remote*.c files can use it (not just the
+ serial line ones). And, make baud_rate be an int.
+ * remote-udi.c: Change kiodebug to remote_debug.
+ * remote-utils.c: Move setting of baud rate and debug into main.c.
+ * remote-utils.h: Redefine sr_{get set}_debug and sr_{get set}_baud
+ to use baud_rate and remote_debug globals for compatibility.
+ * remote.c: Use remote_debug and baud_rate globals directly,
+ instead of sr_ functions, so that we don't need to load
+ remote-utils.c.
+
Wed Oct 20 11:35:43 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* stabsread.c (define_symbol): When combining a LOC_ARG and a
#include "gdbtypes.h"
#include "expression.h"
#include "language.h"
-#include "serial.h" /* For job_control. */
+#include "terminal.h" /* For job_control. */
#include "getopt.h"
struct cmd_list_element *showchecklist;
-/* stdio stream that command input is being read from. */
+/* stdio stream that command input is being read from. Set to stdin normally.
+ Set by source_command to the file we are sourcing. Set to NULL if we are
+ executing a user-defined command. */
FILE *instream;
int linesize = 100;
/* Baud rate specified for talking to serial target systems. Default
- is left as a zero pointer, so targets can choose their own defaults. */
+ is left as -1, so targets can choose their own defaults. */
-char *baud_rate;
+int baud_rate = -1;
+
+/* Non-zero tells remote* modules to output debugging info. */
+
+int remote_debug = 0;
/* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */
print ERRSTRING, print the specific error message, then return
zero.
+ Must not be called with immediate_quit in effect (bad things might
+ happen, say we got a signal in the middle of a memcpy to quit_return).
+ This is an OK restriction; with very few exceptions immediate_quit can
+ be replaced by judicious use of QUIT.
+
MASK specifies what to catch; it is normally set to
RETURN_MASK_ALL, if for no other reason than that the code which
calls catch_errors might not be set up to deal with a quit which
quiet = 1;
break;
case 'b':
- baud_rate = optarg;
+ {
+ int i;
+ char *p;
+
+ i = strtol (optarg, &p, 0);
+ if (i == 0 && p == optarg)
+ warning ("Could not set baud rate to `%s'.\n", optarg);
+ else
+ baud_rate = i;
+ }
break;
+
#ifdef ADDITIONAL_OPTION_CASES
ADDITIONAL_OPTION_CASES
#endif
if (c == EOF)
{
+ if (input_index > 0)
+ /* The last line does not end with a newline. Return it, and
+ if we are called again fgetc will still return EOF and
+ we'll return NULL then. */
+ break;
free (result);
return NULL;
}
add_cmd ("version", no_class, show_version,
"Show what version of GDB this is.", &showlist);
+
+ add_show_from_set (
+ add_set_cmd ("remotedebug", no_class, var_boolean, (char *)&remote_debug,
+ "Set debugging of remote protocol.\n\
+When enabled, each packet sent or received with the remote target\n\
+is displayed.", &setlist),
+ &showlist);
}
/* access the register store directly, without going through
the normal handler functions. This avoids an extra data copy. */
-static int kiodebug;
+extern int remote_debug;
extern int stop_soon_quietly; /* for wait_for_inferior */
extern struct value *call_function_by_hand();
static void udi_resume PARAMS ((int pid, int step, int sig));
register_valid[i] = 1;
}
- if (kiodebug)
+ if (remote_debug)
{
printf("Fetching all registers\n");
printf("Fetching PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n",
return;
}
- if (kiodebug)
+ if (remote_debug)
{
printf("Storing all registers\n");
printf("PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n", read_register(NPC_REGNUM),
supply_register(regno, (char *) &To);
- if (kiodebug)
+ if (remote_debug)
printf("Fetching register %s = 0x%x\n", reg_names[regno], To);
}
/*****************************************************************************/
From = read_register (regno); /* get data value */
- if (kiodebug)
+ if (remote_debug)
printf("Storing register %s = 0x%x\n", reg_names[regno], From);
if (regno == GR1_REGNUM)
void _initialize_remote_udi()
{
add_target (&udi_ops);
- add_show_from_set (
- add_set_cmd ("remotedebug", no_class, var_boolean,
- (char *)&kiodebug,
- "Set debugging of UDI I/O.\n\
-When enabled, debugging info is displayed.",
- &setlist),
- &showlist);
}
#ifdef NO_HIF_SUPPORT
#include "remote-utils.h"
struct _sr_settings sr_settings = {
- 0, /* debug */
- 9600, /* baud */
4, /* timeout:
remote-hms.c had 2
remote-bug.c had "with a timeout of 2, we time out waiting for
void
_initialize_sr_support ()
{
- add_show_from_set (add_set_cmd ("remotedebug", no_class,
- var_zinteger, (char *)&sr_settings.debug,
- "Set debugging of remote serial I/O.\n\
-When non-zero, each packet sent or received with the remote target\n\
-is displayed. Higher numbers produce more debugging.", &setlist),
- &showlist);
-
/* FIXME-now: if target is open when baud changes... */
add_show_from_set (add_set_cmd ("remotebaud", no_class,
- var_zinteger, (char *)&sr_settings.baud_rate,
+ var_zinteger, (char *)&baud_rate,
"Set baud rate for remote serial I/O.\n\
This value is used to set the speed of the serial port when debugging\n\
using remote targets.", &setlist),
remote targets. */
struct _sr_settings {
- /* Debugging level. 0 is off, and non-zero values mean to print
- some debug information (higher values, more information). */
- unsigned int debug;
-
- /* Baud rate specified for talking to remote target systems via a
- serial port. */
- unsigned int baud_rate;
-
unsigned int timeout;
int retries;
};
extern struct _sr_settings sr_settings;
+extern int remote_debug;
+extern int baud_rate;
/* get and set debug value. */
-#define sr_get_debug() (sr_settings.debug)
-#define sr_set_debug(newval) (sr_settings.debug = (newval))
+#define sr_get_debug() (remote_debug)
+#define sr_set_debug(newval) (remote_debug = (newval))
/* get and set baud rate. */
-#define sr_get_baud_rate() (sr_settings.baud_rate)
-#define sr_set_baud_rate(newval) (sr_settings.baud_rate = (newval))
+#define sr_get_baud_rate() (baud_rate)
+#define sr_set_baud_rate(newval) (baud_rate = (newval))
/* get and set timeout. */
#define sr_get_timeout() (sr_settings.timeout)
#include "gdb-stabs.h"
#include "dcache.h"
-#include "remote-utils.h"
#if !defined(DONT_USE_REMOTE)
#ifdef USG
readchar PARAMS ((void));
static int
-remote_wait PARAMS ((WAITTYPE *status));
+remote_wait PARAMS ((int pid, WAITTYPE *status));
static int
tohex PARAMS ((int nib));
extern struct target_ops remote_ops; /* Forward decl */
+extern int baud_rate;
+
+extern int remote_debug;
+
/* This was 5 seconds, which is a long time to sit and wait.
Unless this is going though some terminal server or multiplexer or
other form of hairy serial connection, I would think 2 seconds would
if (!remote_desc)
perror_with_name (name);
- if (SERIAL_SETBAUDRATE (remote_desc, sr_get_baud_rate()))
+ if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
{
SERIAL_CLOSE (remote_desc);
perror_with_name (name);
/* If this doesn't work, try more severe steps. */
signal (signo, remote_interrupt_twice);
- if (sr_get_debug ())
+ if (remote_debug)
printf ("remote_interrupt called\n");
SERIAL_WRITE (remote_desc, "\003", 1); /* Send a ^C */
means in the case of this target). */
static int
-remote_wait (status)
+remote_wait (pid, status)
+ int pid;
WAITTYPE *status;
{
unsigned char buf[PBUFSIZ];
while ((buf[0] < '0' || buf[0] > '9')
&& (buf[0] < 'a' || buf[0] > 'f'))
{
- if (sr_get_debug () > 0)
+ if (remote_debug)
printf ("Bad register packet; fetching a new packet\n");
getpkt (buf, 0);
}
while (1)
{
- if (sr_get_debug ())
+ if (remote_debug)
{
*p = '\0';
printf ("Sending packet: %s...", buf2); fflush(stdout);
switch (ch)
{
case '+':
- if (sr_get_debug ())
+ if (remote_debug)
printf("Ack\n");
return;
case SERIAL_TIMEOUT:
case SERIAL_EOF:
error ("putpkt: EOF while trying to read ACK");
default:
- if (sr_get_debug ())
+ if (remote_debug)
printf ("%02X %c ", ch&0xFF, ch);
continue;
}
if (forever)
continue;
if (++retries >= MAX_RETRIES)
- if (sr_get_debug ()) puts_filtered ("Timed out.\n");
+ if (remote_debug) puts_filtered ("Timed out.\n");
goto out;
}
c = readchar ();
if (c == SERIAL_TIMEOUT)
{
- if (sr_get_debug ())
+ if (remote_debug)
puts_filtered ("Timeout in mid-packet, retrying\n");
goto whole; /* Start a new packet, count retries */
}
if (c == '$')
{
- if (sr_get_debug ())
+ if (remote_debug)
puts_filtered ("Saw new packet start in middle of old one\n");
goto whole; /* Start a new packet, count retries */
}
SERIAL_WRITE (remote_desc, "+", 1);
- if (sr_get_debug ())
+ if (remote_debug)
fprintf (stderr,"Packet received: %s\n", buf);
}
\f