From 0729219dab3a669a294ea00f471fe18c4ba65d79 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Tue, 9 Apr 2002 21:11:35 +0000 Subject: [PATCH] 2002-04-09 Daniel Jacobowitz * gdbserver/Makefile.in: Add WARN_CFLAGS. Update configury dependencies. * gdbserver/configure.in: Check for * gdbserver/configure: Regenerate. * gdbserver/config.in: Regenerate. * gdbserver/gdbreplay.c: Include needed system headers. (remote_open): Remove strchr prototype. * gdbserver/linux-low.h: Correct #ifdef to HAVE_LINUX_USRREGS. * gdbserver/regcache.c (supply_register): Change buf argument to const void *. (supply_register_by_name): Likewise. (collect_register): Change buf argument to void *. (collect_register_by_name): Likewise. * gdbserver/regcache.h: Add missing prototypes. * gdbserver/remote-utils.c: Include for inet_ntoa. * gdbserver/server.c (handle_query): New function. (attached): New static variable, moved out of main. (main): Quiet longjmp clobber warnings. * gdbserver/server.h: Add ATTR_NORETURN and ATTR_FORMAT. Update prototypes. * gdbserver/utils.c (error): Remove NORETURN. (fatal): Likewise. --- gdb/ChangeLog | 23 +++++++++++++++++++++++ gdb/gdbserver/Makefile.in | 11 ++++++++--- gdb/gdbserver/config.in | 3 +++ gdb/gdbserver/configure | 2 +- gdb/gdbserver/configure.in | 2 +- gdb/gdbserver/gdbreplay.c | 8 ++++++-- gdb/gdbserver/linux-low.h | 2 +- gdb/gdbserver/regcache.c | 8 ++++---- gdb/gdbserver/regcache.h | 8 ++++++++ gdb/gdbserver/remote-utils.c | 1 + gdb/gdbserver/server.c | 9 ++++++--- gdb/gdbserver/server.h | 30 ++++++++++++++++++++++++------ gdb/gdbserver/utils.c | 4 ++-- 13 files changed, 88 insertions(+), 23 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 068424a471b..3120f1c2f8e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,26 @@ +2002-04-09 Daniel Jacobowitz + + * gdbserver/Makefile.in: Add WARN_CFLAGS. Update configury + dependencies. + * gdbserver/configure.in: Check for + * gdbserver/configure: Regenerate. + * gdbserver/config.in: Regenerate. + * gdbserver/gdbreplay.c: Include needed system headers. + (remote_open): Remove strchr prototype. + * gdbserver/linux-low.h: Correct #ifdef to HAVE_LINUX_USRREGS. + * gdbserver/regcache.c (supply_register): Change buf argument to const void *. + (supply_register_by_name): Likewise. + (collect_register): Change buf argument to void *. + (collect_register_by_name): Likewise. + * gdbserver/regcache.h: Add missing prototypes. + * gdbserver/remote-utils.c: Include for inet_ntoa. + * gdbserver/server.c (handle_query): New function. + (attached): New static variable, moved out of main. + (main): Quiet longjmp clobber warnings. + * gdbserver/server.h: Add ATTR_NORETURN and ATTR_FORMAT. Update prototypes. + * gdbserver/utils.c (error): Remove NORETURN. + (fatal): Likewise. + 2002-04-09 Daniel Jacobowitz * symtab.h (ALL_BLOCK_SYMBOLS): Don't dereference the pointer diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index c553d920d94..076484c7262 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -90,13 +90,15 @@ INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../regformats -I$(INCLUDE_DIR) GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS} #PROFILE_CFLAGS = -pg +WARN_CFLAGS = -Wall + # CFLAGS is specifically reserved for setting from the command line # when running make. I.E. "make CFLAGS=-Wmissing-prototypes". CFLAGS = @CFLAGS@ # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. -INTERNAL_CFLAGS = ${CFLAGS} ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} \ - ${INCLUDE_CFLAGS} ${BFD_CFLAGS} +INTERNAL_CFLAGS = $(WARN_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \ + ${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${BFD_CFLAGS} # LDFLAGS is specifically reserved for setting from the command line # when running make. @@ -195,8 +197,11 @@ maintainer-clean realclean: clean STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb +config.h: config.in config.status + CONFIG_FILES="" $(SHELL) ./config.status + Makefile: Makefile.in config.status - $(SHELL) ./config.status + CONFIG_HEADERS="" $(SHELL) ./config.status config.status: configure configure.srv $(SHELL) ./config.status --recheck diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index e77d5a78a50..9d553f220be 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -16,6 +16,9 @@ /* Define if you have the header file. */ #undef HAVE_SGTTY_H +/* Define if you have the header file. */ +#undef HAVE_STRING_H + /* Define if you have the header file. */ #undef HAVE_SYS_REG_H diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index c08d5c20508..d3e0b64f7e1 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -1105,7 +1105,7 @@ EOF fi -for ac_hdr in sgtty.h termio.h termios.h sys/reg.h +for ac_hdr in sgtty.h termio.h termios.h sys/reg.h string.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 diff --git a/gdb/gdbserver/configure.in b/gdb/gdbserver/configure.in index 744aac206c0..a0bde9be882 100644 --- a/gdb/gdbserver/configure.in +++ b/gdb/gdbserver/configure.in @@ -30,7 +30,7 @@ AC_PROG_INSTALL AC_HEADER_STDC -AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h) +AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h) . ${srcdir}/configure.srv diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index dce4079e3f1..65831b1d762 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -30,6 +30,12 @@ #include #include #include +#include +#include + +#ifdef HAVE_STRING_H +#include +#endif /* Sort of a hack... */ #define EOL (EOF - 1) @@ -83,8 +89,6 @@ remote_close (void) void remote_open (char *name) { - extern char *strchr (); - if (!strchr (name, ':')) { fprintf (stderr, "%s: Must specify tcp connection as host:addr\n", name); diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index 421fa227869..5f06db14eb8 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef HAVE_LINUX_USR_REGISTERS +#ifdef HAVE_LINUX_USRREGS extern int regmap[]; extern int num_regs; int cannot_fetch_register (int regno); diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index bec20bb6fd8..5e3c62f07b3 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -123,25 +123,25 @@ register_data (int n) } void -supply_register (int n, const char *buf) +supply_register (int n, const void *buf) { memcpy (register_data (n), buf, register_size (n)); } void -supply_register_by_name (const char *name, const char *buf) +supply_register_by_name (const char *name, const void *buf) { supply_register (find_regno (name), buf); } void -collect_register (int n, char *buf) +collect_register (int n, void *buf) { memcpy (buf, register_data (n), register_size (n)); } void -collect_register_by_name (const char *name, char *buf) +collect_register_by_name (const char *name, void *buf) { collect_register (find_regno (name), buf); } diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h index 07195b3f44e..e71aee26e60 100644 --- a/gdb/gdbserver/regcache.h +++ b/gdb/gdbserver/regcache.h @@ -46,4 +46,12 @@ int find_regno (const char *name); extern const char **gdbserver_expedite_regs; +void supply_register (int n, const void *buf); + +void supply_register_by_name (const char *name, const void *buf); + +void collect_register (int n, void *buf); + +void collect_register_by_name (const char *name, void *buf); + #endif /* REGCACHE_H */ diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index adf52996094..edfcace90ec 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -35,6 +35,7 @@ #include #include #include +#include int remote_debug = 0; struct ui_file *gdb_stdlog; diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index adaabacdf2f..b567688031b 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -55,6 +55,7 @@ attach_inferior (int pid, char *statusptr, unsigned char *sigptr) } extern int remote_debug; +static int attached; int main (int argc, char *argv[]) @@ -64,9 +65,8 @@ main (int argc, char *argv[]) unsigned char signal; unsigned int len; CORE_ADDR mem_addr; - int bad_attach = 0; - int pid = 0; - int attached = 0; + int bad_attach; + int pid; char *arg_end; if (setjmp (toplevel)) @@ -75,6 +75,9 @@ main (int argc, char *argv[]) exit (1); } + bad_attach = 0; + pid = 0; + attached = 0; if (argc >= 3 && strcmp (argv[2], "--attach") == 0) { if (argc == 4 diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index 7f22041b23d..9de0d7395f9 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -23,20 +23,36 @@ #define SERVER_H #include "config.h" + #include #include #include #include +#include - -/* FIXME: Both of these should be autoconf'd for. */ -#define NORETURN +#ifndef ATTR_NORETURN +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) +#define ATTR_NORETURN __attribute__ ((noreturn)) +#else +#define ATTR_NORETURN /* nothing */ +#endif +#endif + +#ifndef ATTR_FORMAT +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4)) +#define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y))) +#else +#define ATTR_FORMAT(type, x, y) /* nothing */ +#endif +#endif + +/* FIXME: This should probably be autoconf'd for. It's an integer type at + least the size of a (void *). */ typedef long long CORE_ADDR; #include "regcache.h" #include "gdb/signals.h" -#include /* Target-specific functions */ @@ -93,11 +109,13 @@ int target_signal_to_host (enum target_signal oursig); /* Functions from utils.c */ void perror_with_name (char *string); -void error (const char *string,...); -void fatal (const char *string,...); +void error (const char *string,...) ATTR_NORETURN; +void fatal (const char *string,...) ATTR_NORETURN; void warning (const char *string,...); +/* Functions from the register cache definition. */ +void init_registers (void); /* Maximum number of bytes to read/write at once. The value here is chosen to fill up a packet (the headers account for the 32). */ diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c index a8ea9a15f8b..e13eda80d46 100644 --- a/gdb/gdbserver/utils.c +++ b/gdb/gdbserver/utils.c @@ -57,7 +57,7 @@ perror_with_name (char *string) STRING is the error message, used as a fprintf string, and ARG is passed as an argument to it. */ -NORETURN void +void error (const char *string,...) { extern jmp_buf toplevel; @@ -74,7 +74,7 @@ error (const char *string,...) STRING and ARG are passed to fprintf. */ /* VARARGS */ -NORETURN void +void fatal (const char *string,...) { va_list args; -- 2.30.2