From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Jacobowitz To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa] gdbserver 2/n - signals Date: Thu, 19 Jul 2001 14:52:00 -0000 Message-id: <20010719145237.A28070@nevyn.them.org> References: <20010719120143.A19963@nevyn.them.org> <3B574A5D.6030403@cygnus.com> <20010719141742.A25968@nevyn.them.org> <3B5755C9.8070003@cygnus.com> X-SW-Source: 2001-07/msg00488.html On Thu, Jul 19, 2001 at 05:48:57PM -0400, Andrew Cagney wrote: > > > > I was going to use that, except for a few small problems: > > - wasted space, a couple of functions and the large name table. > > I'm not really bothered by this one. > > - warning() and internal_error() calls, which gdbserver doesn't > > provide. > > > > Perhaps re-using it despite those minor hurdles would be wiser. I'll > > tweak the patch. > > > The compiler/linker should be able to eliminate the unused code (can > GCC?). Adding warning() and internal_error() wouldn't hurt. Only if you're using -ffunction-sections. Otherwise you're stuck with the whole object file. At least, I think so... This better? -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer 2001-07-19 Daniel Jacobowitz * gdbserver/server.c (main): Call target_signal_to_host_p and target_signal_to_host on signals received from the remote. * gdbserver/remote-utils.c (prepare_resume_reply): Call target_signal_from_host on signals sent to the remote. * gdbserver/Makefile.in: Add signals.o, built from the parent directory. 2001-07-19 Daniel Jacobowitz * gdb.texinfo (Protocol): Mention that signal numbers are defined by the target_signal enum. Index: gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.44 diff -u -r1.44 gdb.texinfo --- gdb.texinfo 2001/07/06 04:07:29 1.44 +++ gdb.texinfo 2001/07/19 18:56:55 @@ -10211,8 +10211,8 @@ receive any of the below as a reply. In the case of the @samp{C}, @samp{c}, @samp{S} and @samp{s} packets, that reply is only returned when the target halts. In the below the exact meaning of @samp{signal -number} is poorly defined. In general one of the UNIX signal numbering -conventions is used. +number} is defined by the type @code{enum target_signal}. For the most +common signals this corresponds to the UNIX signal numbering conventions. @multitable @columnfractions .4 .6 Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/Makefile.in,v retrieving revision 1.3 diff -u -r1.3 Makefile.in --- Makefile.in 2001/03/06 08:21:43 1.3 +++ Makefile.in 2001/07/19 21:41:43 @@ -137,7 +137,7 @@ SOURCES = $(SFILES) $(ALLDEPFILES) TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS} -OBS = utils.o $(GDBSERVER_DEPFILES) server.o remote-utils.o +OBS = utils.o $(GDBSERVER_DEPFILES) server.o remote-utils.o signals.o # Prevent Sun make from putting in the machine type. Setting # TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1. @@ -247,5 +247,7 @@ low-sun3.o : $(srcdir)/low-sun3.c $(srcdir)/server.h low-hppabsd.o : $(srcdir)/low-hppabsd.c $(srcdir)/server.h utils.o : ${srcdir}/utils.c ${srcdir}/server.h +signals.o : ${srcdir}/../signals.c + ${CC} -c ${INTERNAL_CFLAGS} $< # This is the end of "Makefile.in". Index: remote-utils.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v retrieving revision 1.7 diff -u -r1.7 remote-utils.c --- remote-utils.c 2001/07/12 21:04:35 1.7 +++ remote-utils.c 2001/07/19 21:41:47 @@ -459,17 +459,15 @@ void prepare_resume_reply (char *buf, char status, unsigned char signo) { - int nib; + int nib, sig; *buf++ = status; - /* FIXME! Should be converting this signal number (numbered - according to the signal numbering of the system we are running on) - to the signal numbers used by the gdb protocol (see enum target_signal - in gdb/target.h). */ - nib = ((signo & 0xf0) >> 4); + sig = (int)target_signal_from_host (signo); + + nib = ((sig & 0xf0) >> 4); *buf++ = tohex (nib); - nib = signo & 0x0f; + nib = sig & 0x0f; *buf++ = tohex (nib); if (status == 'T') Index: server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.3 diff -u -r1.3 server.c --- server.c 2001/03/06 08:21:44 1.3 +++ server.c 2001/07/19 21:41:47 @@ -130,13 +133,21 @@ break; case 'C': convert_ascii_to_int (own_buf + 1, &sig, 1); - myresume (0, sig); + if (target_signal_to_host_p (sig)) + signal = target_signal_to_host (sig); + else + signal = 0; + myresume (0, signal); signal = mywait (&status); prepare_resume_reply (own_buf, status, signal); break; case 'S': convert_ascii_to_int (own_buf + 1, &sig, 1); - myresume (1, sig); + if (target_signal_to_host_p (sig)) + signal = target_signal_to_host (sig); + else + signal = 0; + myresume (1, signal); signal = mywait (&status); prepare_resume_reply (own_buf, status, signal); break; Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/utils.c,v retrieving revision 1.4 diff -u -r1.4 utils.c --- utils.c 2001/03/06 08:21:44 1.4 +++ utils.c 2001/07/19 21:41:47 @@ -53,6 +53,21 @@ error ("%s.", combined); } +/* Print a warning message. + The first argument STRING is the warning message, used as a fprintf string, + and the remaining args are passed as arguments to it. + The primary difference between warnings and errors is that a warning + does not force the return to command level. */ +void +warning (const char *string,...) +{ + va_list args; + va_start (args, string); + fflush (stdout); + vfprintf (stderr, string, args); + fprintf (stderr, "\n"); +} + /* Print an error message and return to command level. STRING is the error message, used as a fprintf string, and ARG is passed as an argument to it. */ @@ -84,4 +99,16 @@ fprintf (stderr, "\n"); va_end (args); exit (1); +} + +void +internal_error (const char *file, int line, const char *string, ...) +{ + va_list args; + va_start (args, string); + fprintf (stderr, "gdb internal error (%s:%d): ", file, line); + vfprintf (stderr, string, args); + fprintf (stderr, "\n"); + va_end (args); + exit (1); }