From: Stu Grossman Date: Thu, 21 Oct 1993 00:49:42 +0000 (+0000) Subject: * main.c: Make baud_rate and remote_debug be global variables, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0d8484a4a8b7c803473eaadb4a30513cd8b8d09;p=binutils-gdb.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index eafceeef524..b18a48f8385 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +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 diff --git a/gdb/main.c b/gdb/main.c index d0a5d29b957..deaf6240ef9 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -29,7 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbtypes.h" #include "expression.h" #include "language.h" -#include "serial.h" /* For job_control. */ +#include "terminal.h" /* For job_control. */ #include "getopt.h" @@ -278,7 +278,9 @@ struct cmd_list_element *setchecklist; 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; @@ -311,9 +313,13 @@ char *line; 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. */ @@ -375,6 +381,11 @@ return_to_top_level (reason) 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 @@ -660,8 +671,18 @@ main (argc, argv) 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 @@ -1112,6 +1133,11 @@ gdb_readline (prrompt) 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; } @@ -2763,4 +2789,11 @@ the previous command number shown.", 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); } diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index bfcbea101c5..30444581c35 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -50,7 +50,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* 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)); @@ -665,7 +665,7 @@ int regno; 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", @@ -706,7 +706,7 @@ int regno; 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), @@ -1331,7 +1331,7 @@ fetch_register (regno) supply_register(regno, (char *) &To); - if (kiodebug) + if (remote_debug) printf("Fetching register %s = 0x%x\n", reg_names[regno], To); } /*****************************************************************************/ @@ -1352,7 +1352,7 @@ store_register (regno) 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) @@ -1542,13 +1542,6 @@ Arguments are\n\ 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 diff --git a/gdb/remote-utils.c b/gdb/remote-utils.c index efe166958d9..f4f25e4c490 100644 --- a/gdb/remote-utils.c +++ b/gdb/remote-utils.c @@ -52,8 +52,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 @@ -625,16 +623,9 @@ gr_store_word (addr, word) 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), diff --git a/gdb/remote-utils.h b/gdb/remote-utils.h index 758ce3d7194..59f4d3b3706 100644 --- a/gdb/remote-utils.h +++ b/gdb/remote-utils.h @@ -29,14 +29,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 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; @@ -47,14 +39,16 @@ struct _sr_settings { }; 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) diff --git a/gdb/remote.c b/gdb/remote.c index 329eb4eef7d..266d5f389de 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -133,7 +133,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdb-stabs.h" #include "dcache.h" -#include "remote-utils.h" #if !defined(DONT_USE_REMOTE) #ifdef USG @@ -192,7 +191,7 @@ static int readchar PARAMS ((void)); static int -remote_wait PARAMS ((WAITTYPE *status)); +remote_wait PARAMS ((int pid, WAITTYPE *status)); static int tohex PARAMS ((int nib)); @@ -214,6 +213,10 @@ interrupt_query PARAMS ((void)); 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 @@ -297,7 +300,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); 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); @@ -412,7 +415,7 @@ remote_interrupt (signo) /* 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 */ @@ -455,7 +458,8 @@ Give up (and stop debugging it)? ")) means in the case of this target). */ static int -remote_wait (status) +remote_wait (pid, status) + int pid; WAITTYPE *status; { unsigned char buf[PBUFSIZ]; @@ -656,7 +660,7 @@ remote_fetch_registers (regno) 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); } @@ -998,7 +1002,7 @@ putpkt (buf) while (1) { - if (sr_get_debug ()) + if (remote_debug) { *p = '\0'; printf ("Sending packet: %s...", buf2); fflush(stdout); @@ -1014,7 +1018,7 @@ putpkt (buf) switch (ch) { case '+': - if (sr_get_debug ()) + if (remote_debug) printf("Ack\n"); return; case SERIAL_TIMEOUT: @@ -1024,7 +1028,7 @@ putpkt (buf) 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; } @@ -1077,7 +1081,7 @@ getpkt (buf, forever) 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; } @@ -1095,13 +1099,13 @@ getpkt (buf, forever) 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 */ } @@ -1146,7 +1150,7 @@ out: SERIAL_WRITE (remote_desc, "+", 1); - if (sr_get_debug ()) + if (remote_debug) fprintf (stderr,"Packet received: %s\n", buf); }