From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19043 invoked by alias); 8 Sep 2010 20:39:57 -0000 Received: (qmail 18999 invoked by uid 22791); 8 Sep 2010 20:39:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_50,KAM_STOCKTIP,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_EG,TW_OC,TW_XS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Sep 2010 20:39:34 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o88KdAtw012006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 Sep 2010 16:39:10 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o88Kd6Lg026406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Sep 2010 16:39:08 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o88Kd6Be009446; Wed, 8 Sep 2010 22:39:06 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o88Kd4I4009445; Wed, 8 Sep 2010 22:39:04 +0200 Date: Wed, 08 Sep 2010 23:42:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org, Daniel Jacobowitz , Joel Brobecker , Eli Zaretskii , Mark Kettenis Subject: Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t Message-ID: <20100908203904.GA8565@host1.dyn.jankratochvil.net> References: <20100901200621.GA11085@caradoc.them.org> <201009012108.56984.pedro@codesourcery.com> <201009020254.47745.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="oyUTqETQ0mS9luUI" Content-Disposition: inline In-Reply-To: <201009020254.47745.pedro@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00191.txt.bz2 --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1845 On Thu, 02 Sep 2010 03:54:47 +0200, Pedro Alves wrote: > The rest of the idea remains. A target_signal_o array to hold > all the possible gdb signals, and a target_signal becomes: > > typedef const struct target_signal_o * target_signal; While trying to clean it up for a check-in I found it as a no-go. The current GDB code assumes zeroed target_signal field is TARGET_SIGNAL_0. Additionally literal `0' is also compatible with such target_signal type. While sure one can try to find such places of implicit zeroed initializations it may more destabilize the GDB codebase than what the code-neutral compile time sanity checking goal should have reached. 5192 resume (currently_stepping (ecs->event_thread), 5193 ecs->event_thread->stop_signal); -> #6 0x000000000069cc5e in resume (step=0, sig=0x0) at infrun.c:1743 (gdb) p sig $9 = (gdb_target_signal_t) 0x0 The struct { } solution [patch 3/9]#2 Change target_signal_t to a struct http://sourceware.org/ml/gdb-patches/2010-08/msg00483.html had (unintentionally?) TARGET_SIGNAL_0 equivalent to a zeroed memory block. Another possibility would be to make it a `(type *) 0L', `(type *) 1L' etc. But in general if TARGET_SIGNAL_EQ() etc. operators are not acceptable I find mostly the compile-time sanity checks as not feasible for plain C. Trying further so hard to avoid all the C obstacles is becoming contraproductive. This part has become a sanity-checking one only. It is no longer a pre-requisite for the (planned) siginfo fix. Attaching the two patches (bare rename + the conversion) FYI. They have a regression at least on fork-child-threads.exp. They are based on: Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t http://sourceware.org/ml/gdb-patches/2010-09/msg00078.html From: Pedro Alves Thanks, Jan --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="sigrename.patch" Content-length: 43932 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -970,7 +970,7 @@ aix_thread_detach (struct target_ops *ops, char *args, int from_tty) static void aix_thread_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal sig) + ptid_t ptid, int step, gdb_target_signal_t sig) { struct thread_info *thread; pthdb_tid_t tid[2]; --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1230,7 +1230,7 @@ amd64_linux_syscall_record (struct regcache *regcache) int amd64_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, - enum target_signal signal) + gdb_target_signal_t signal) { ULONGEST rsp; --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -397,7 +397,7 @@ bsd_uthread_wait (struct target_ops *ops, static void bsd_uthread_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal sig) + ptid_t ptid, int step, gdb_target_signal_t sig) { /* Pass the request to the layer beneath. */ struct target_ops *beneath = find_target_beneath (ops); --- a/gdb/common/gdb_signals.h +++ b/gdb/common/gdb_signals.h @@ -28,29 +28,29 @@ targ_signal SIGNO has an equivalent ``host'' representation. */ /* FIXME: cagney/1999-11-22: The name below was chosen in preference to the shorter target_signal_p() because it is far less ambigious. - In this context ``target_signal'' refers to GDB's internal + In this context ``gdb_target_signal_t'' refers to GDB's internal representation of the target's set of signals while ``host signal'' refers to the target operating system's signal. Confused? */ -extern int target_signal_to_host_p (enum target_signal signo); +extern int target_signal_to_host_p (gdb_target_signal_t signo); -/* Convert between host signal numbers and enum target_signal's. +/* Convert between host signal numbers and gdb_target_signal_t's. target_signal_to_host() returns 0 and prints a warning() on GDB's console if SIGNO has no equivalent host representation. */ /* FIXME: cagney/1999-11-22: Here ``host'' is used incorrectly, it is refering to the target operating system's signal numbering. - Similarly, ``enum target_signal'' is named incorrectly, ``enum + Similarly, ``gdb_target_signal_t'' is named incorrectly, ``enum gdb_signal'' would probably be better as it is refering to GDB's internal representation of a target operating system's signal. */ -extern enum target_signal target_signal_from_host (int); -extern int target_signal_to_host (enum target_signal); +extern gdb_target_signal_t target_signal_from_host (int); +extern int target_signal_to_host (gdb_target_signal_t); /* Return the string for a signal. */ -extern const char *target_signal_to_string (enum target_signal); +extern const char *target_signal_to_string (gdb_target_signal_t); /* Return the name (SIGHUP, etc.) for a signal. */ -extern const char *target_signal_to_name (enum target_signal); +extern const char *target_signal_to_name (gdb_target_signal_t); /* Given a name (SIGHUP, etc.), return its signal. */ -enum target_signal target_signal_from_name (const char *); +gdb_target_signal_t target_signal_from_name (const char *); #endif /* COMMON_GDB_SIGNALS_H */ --- a/gdb/common/signals.c +++ b/gdb/common/signals.c @@ -48,7 +48,8 @@ struct gdbarch; # endif #endif -/* This table must match in order and size the signals in enum target_signal. */ +/* This table must match in order and size the signals in gdb_target_signal_t. + */ static const struct { const char *name; @@ -63,7 +64,7 @@ static const struct { /* Return the string for a signal. */ const char * -target_signal_to_string (enum target_signal sig) +target_signal_to_string (gdb_target_signal_t sig) { if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST) return signals[sig].string; @@ -73,7 +74,7 @@ target_signal_to_string (enum target_signal sig) /* Return the name for a signal. */ const char * -target_signal_to_name (enum target_signal sig) +target_signal_to_name (gdb_target_signal_t sig) { if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST && signals[sig].name != NULL) @@ -85,10 +86,10 @@ target_signal_to_name (enum target_signal sig) } /* Given a name, return its signal. */ -enum target_signal +gdb_target_signal_t target_signal_from_name (const char *name) { - enum target_signal sig; + gdb_target_signal_t sig; /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD" for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more @@ -98,7 +99,7 @@ target_signal_from_name (const char *name) /* This ugly cast brought to you by the native VAX compiler. */ for (sig = TARGET_SIGNAL_HUP; sig < TARGET_SIGNAL_LAST; - sig = (enum target_signal) ((int) sig + 1)) + sig = (gdb_target_signal_t) ((int) sig + 1)) if (signals[sig].name != NULL && strcmp (name, signals[sig].name) == 0) return sig; @@ -110,7 +111,7 @@ target_signal_from_name (const char *name) a file called native-utils.c or unixwaitstatus-utils.c or whatever. */ /* Convert host signal to our signals. */ -enum target_signal +gdb_target_signal_t target_signal_from_host (int hostsig) { /* A switch statement would make sense but would require special kludges @@ -340,12 +341,12 @@ target_signal_from_host (int hostsig) { /* This block of TARGET_SIGNAL_REALTIME value is in order. */ if (33 <= hostsig && hostsig <= 63) - return (enum target_signal) + return (gdb_target_signal_t) (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33); else if (hostsig == 32) return TARGET_SIGNAL_REALTIME_32; else if (64 <= hostsig && hostsig <= 127) - return (enum target_signal) + return (gdb_target_signal_t) (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64); else error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal"); @@ -355,13 +356,13 @@ target_signal_from_host (int hostsig) return TARGET_SIGNAL_UNKNOWN; } -/* Convert a OURSIG (an enum target_signal) to the form used by the +/* Convert a OURSIG (an gdb_target_signal_t) to the form used by the target operating system (refered to as the ``host'') or zero if the equivalent host signal is not available. Set/clear OURSIG_OK accordingly. */ static int -do_target_signal_to_host (enum target_signal oursig, +do_target_signal_to_host (gdb_target_signal_t oursig, int *oursig_ok) { int retsig; @@ -626,7 +627,7 @@ do_target_signal_to_host (enum target_signal oursig, } int -target_signal_to_host_p (enum target_signal oursig) +target_signal_to_host_p (gdb_target_signal_t oursig) { int oursig_ok; do_target_signal_to_host (oursig, &oursig_ok); @@ -634,7 +635,7 @@ target_signal_to_host_p (enum target_signal oursig) } int -target_signal_to_host (enum target_signal oursig) +target_signal_to_host (gdb_target_signal_t oursig) { int oursig_ok; int targ_signo = do_target_signal_to_host (oursig, &oursig_ok); @@ -660,11 +661,11 @@ target_signal_to_host (enum target_signal oursig) lenient and allow 1-15 which should match host signal numbers on most systems. Use of symbolic signal names is strongly encouraged. */ -enum target_signal +gdb_target_signal_t target_signal_from_command (int num) { if (num >= 1 && num <= 15) - return (enum target_signal) num; + return (gdb_target_signal_t) num; error ("Only signals 1-15 are valid as numeric signals.\n\ Use \"info signals\" for a list of symbolic signals."); } @@ -679,12 +680,13 @@ _initialize_signals (void) } int -default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts) +default_target_signal_to_host (struct gdbarch *gdbarch, + gdb_target_signal_t ts) { return target_signal_to_host (ts); } -enum target_signal +gdb_target_signal_t default_target_signal_from_host (struct gdbarch *gdbarch, int signo) { return target_signal_from_host (signo); --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -432,9 +432,9 @@ core_open (char *filename, int from_tty) { /* NOTE: target_signal_from_host() converts a target signal value into gdb's internal signal value. Unfortunately gdb's internal - value is called ``target_signal'' and this function got the + value is called ``gdb_target_signal_t'' and this function got the name ..._from_host(). */ - enum target_signal sig = (core_gdbarch != NULL + gdb_target_signal_t sig = (core_gdbarch != NULL ? gdbarch_target_signal_from_host (core_gdbarch, siggy) : target_signal_from_host (siggy)); --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -89,9 +89,9 @@ extern boolean_t exc_server (mach_msg_header_t *in, mach_msg_header_t *out); static void darwin_stop (ptid_t); static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step, - enum target_signal signal); + gdb_target_signal_t signal); static void darwin_resume (ptid_t ptid, int step, - enum target_signal signal); + gdb_target_signal_t signal); static ptid_t darwin_wait_to (struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options); @@ -767,7 +767,7 @@ darwin_suspend_inferior_threads (struct inferior *inf) } static void -darwin_resume (ptid_t ptid, int step, enum target_signal signal) +darwin_resume (ptid_t ptid, int step, gdb_target_signal_t signal) { struct target_waitstatus status; int pid; @@ -833,7 +833,7 @@ darwin_resume (ptid_t ptid, int step, enum target_signal signal) static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step, - enum target_signal signal) + gdb_target_signal_t signal) { return darwin_resume (ptid, step, signal); } --- a/gdb/defs.h +++ b/gdb/defs.h @@ -64,7 +64,7 @@ #include "gdb_wchar.h" -/* For ``enum target_signal''. */ +/* For ``gdb_target_signal_t''. */ #include "gdb/signals.h" /* Just in case they're not defined in stdio.h. */ --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -150,7 +150,7 @@ find_signalled_thread (struct thread_info *info, void *data) return 0; } -static enum target_signal +static gdb_target_signal_t find_stop_signal (void) { struct thread_info *info = --- a/gdb/fork-child.c +++ b/gdb/fork-child.c @@ -448,7 +448,7 @@ startup_inferior (int ntraps) while (1) { - enum target_signal resume_signal = TARGET_SIGNAL_0; + gdb_target_signal_t resume_signal = TARGET_SIGNAL_0; ptid_t event_ptid; struct target_waitstatus ws; --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3507,7 +3507,7 @@ gdbarch_process_record_signal_p (struct gdbarch *gdbarch) } int -gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum target_signal signal) +gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, gdb_target_signal_t signal) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->process_record_signal != NULL); @@ -3523,7 +3523,7 @@ set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch->process_record_signal = process_record_signal; } -enum target_signal +gdb_target_signal_t gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo) { gdb_assert (gdbarch != NULL); @@ -3541,7 +3541,7 @@ set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch, } int -gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts) +gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdb_target_signal_t ts) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->target_signal_to_host != NULL); --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -880,22 +880,22 @@ extern void set_gdbarch_process_record (struct gdbarch *gdbarch, gdbarch_process extern int gdbarch_process_record_signal_p (struct gdbarch *gdbarch); -typedef int (gdbarch_process_record_signal_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, enum target_signal signal); -extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum target_signal signal); +typedef int (gdbarch_process_record_signal_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, gdb_target_signal_t signal); +extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, gdb_target_signal_t signal); extern void set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch_process_record_signal_ftype *process_record_signal); /* Signal translation: translate inferior's signal (host's) number into GDB's representation. */ -typedef enum target_signal (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo); -extern enum target_signal gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo); +typedef gdb_target_signal_t (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo); +extern gdb_target_signal_t gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo); extern void set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch, gdbarch_target_signal_from_host_ftype *target_signal_from_host); /* Signal translation: translate GDB's signal number into inferior's host signal number. */ -typedef int (gdbarch_target_signal_to_host_ftype) (struct gdbarch *gdbarch, enum target_signal ts); -extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts); +typedef int (gdbarch_target_signal_to_host_ftype) (struct gdbarch *gdbarch, gdb_target_signal_t ts); +extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdb_target_signal_t ts); extern void set_gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdbarch_target_signal_to_host_ftype *target_signal_to_host); /* Extra signal info inspection. --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -748,14 +748,14 @@ M:int:process_record:struct regcache *regcache, CORE_ADDR addr:regcache, addr # Save process state after a signal. # Return -1 if something goes wrong, 0 otherwise. -M:int:process_record_signal:struct regcache *regcache, enum target_signal signal:regcache, signal +M:int:process_record_signal:struct regcache *regcache, gdb_target_signal_t signal:regcache, signal # Signal translation: translate inferior's signal (host's) number into # GDB's representation. -m:enum target_signal:target_signal_from_host:int signo:signo::default_target_signal_from_host::0 +m:gdb_target_signal_t:target_signal_from_host:int signo:signo::default_target_signal_from_host::0 # Signal translation: translate GDB's signal number into inferior's host # signal number. -m:int:target_signal_to_host:enum target_signal ts:ts::default_target_signal_to_host::0 +m:int:target_signal_to_host:gdb_target_signal_t ts:ts::default_target_signal_to_host::0 # Extra signal info inspection. # --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -54,7 +54,7 @@ struct thread_resume thread. If stopping a thread, and this is 0, the target should stop the thread however it best decides to (e.g., SIGSTOP on linux; SuspendThread on win32). This is a host signal value (not - enum target_signal). */ + gdb_target_signal_t). */ int sig; }; @@ -98,7 +98,7 @@ struct target_waitstatus union { int integer; - enum target_signal sig; + gdb_target_signal_t sig; ptid_t related_pid; char *execd_pathname; } --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -72,7 +72,7 @@ static int attaching = 0; static HANDLE current_process_handle = NULL; static DWORD current_process_id = 0; static DWORD main_thread_id = 0; -static enum target_signal last_sig = TARGET_SIGNAL_0; +static gdb_target_signal_t last_sig = TARGET_SIGNAL_0; /* The current debug event from WaitForDebugEvent. */ static DEBUG_EVENT current_event; @@ -802,7 +802,7 @@ static void win32_resume (struct thread_resume *resume_info, size_t n) { DWORD tid; - enum target_signal sig; + gdb_target_signal_t sig; int step; win32_thread_info *th; DWORD continue_status = DBG_CONTINUE; --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -176,7 +176,7 @@ struct thread_info struct target_waitstatus pending_follow; /* Last signal that the inferior received (why it stopped). */ - enum target_signal stop_signal; + gdb_target_signal_t stop_signal; /* Chain containing status of breakpoint(s) the thread stopped at. */ --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -107,7 +107,7 @@ void inf_resume (struct inf *inf); void inf_set_step_thread (struct inf *inf, struct proc *proc); void inf_detach (struct inf *inf); void inf_attach (struct inf *inf, int pid); -void inf_signal (struct inf *inf, enum target_signal sig); +void inf_signal (struct inf *inf, gdb_target_signal_t sig); void inf_continue (struct inf *inf); #define inf_debug(_inf, msg, args...) \ @@ -1318,7 +1318,7 @@ inf_restore_exc_ports (struct inf *inf) signal 0, will continue it. INF is assumed to be in a paused state, and the resume_sc's of INF's threads may be affected. */ void -inf_signal (struct inf *inf, enum target_signal sig) +inf_signal (struct inf *inf, gdb_target_signal_t sig) { error_t err = 0; int host_sig = target_signal_to_host (sig); @@ -1965,7 +1965,7 @@ port_msgs_queued (mach_port_t port) */ static void gnu_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal sig) + ptid_t ptid, int step, gdb_target_signal_t sig) { struct proc *step_thread = 0; int resume_all; --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -238,7 +238,7 @@ static void go32_attach (struct target_ops *ops, char *args, int from_tty); static void go32_detach (struct target_ops *ops, char *args, int from_tty); static void go32_resume (struct target_ops *ops, ptid_t ptid, int step, - enum target_signal siggnal); + gdb_target_signal_t siggnal); static void go32_fetch_registers (struct target_ops *ops, struct regcache *, int regno); static void store_register (const struct regcache *, int regno); @@ -309,7 +309,7 @@ regno_mapping[] = static struct { int go32_sig; - enum target_signal gdb_sig; + gdb_target_signal_t gdb_sig; } sig_map[] = { @@ -343,7 +343,7 @@ sig_map[] = }; static struct { - enum target_signal gdb_sig; + gdb_target_signal_t gdb_sig; int djgpp_excepno; } excepn_map[] = { {TARGET_SIGNAL_0, -1}, @@ -391,7 +391,7 @@ static int resume_signal = -1; static void go32_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal siggnal) + ptid_t ptid, int step, gdb_target_signal_t siggnal) { int i; --- a/gdb/hpux-thread.c +++ b/gdb/hpux-thread.c @@ -169,7 +169,7 @@ hpux_thread_detach (struct target_ops *ops, char *args, int from_tty) static void hpux_thread_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signo) + ptid_t ptid, int step, gdb_target_signal_t signo) { struct cleanup *old_chain; --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -829,7 +829,7 @@ static const unsigned char linux_syscall[] = { 0xcd, 0x80 }; static void i386_linux_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signal) + ptid_t ptid, int step, gdb_target_signal_t signal) { int pid = PIDGET (ptid); --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -463,7 +463,7 @@ i386_linux_intx80_sysenter_record (struct regcache *regcache) int i386_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, - enum target_signal signal) + gdb_target_signal_t signal) { ULONGEST esp; --- a/gdb/i386fbsd-nat.c +++ b/gdb/i386fbsd-nat.c @@ -37,7 +37,7 @@ static void i386fbsd_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signal) + ptid_t ptid, int step, gdb_target_signal_t signal) { pid_t pid = ptid_get_pid (ptid); int request = PT_STEP; --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -350,7 +350,7 @@ inf_ptrace_stop (ptid_t ptid) static void inf_ptrace_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signal) + ptid_t ptid, int step, gdb_target_signal_t signal) { pid_t pid = ptid_get_pid (ptid); int request; --- a/gdb/inf-ttrace.c +++ b/gdb/inf-ttrace.c @@ -867,7 +867,7 @@ inf_ttrace_resume_callback (struct thread_info *info, void *arg) static void inf_ttrace_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signal) + ptid_t ptid, int step, gdb_target_signal_t signal) { int resume_all; ttreq_t request = step ? TT_LWP_SINGLE : TT_LWP_CONTINUE; --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1161,7 +1161,7 @@ go_command (char *line_no, int from_tty) static void signal_command (char *signum_exp, int from_tty) { - enum target_signal oursig; + gdb_target_signal_t oursig; int async_exec = 0; dont_repeat (); /* Too dangerous. */ --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -35,7 +35,7 @@ struct terminal_info; /* For bpstat. */ #include "breakpoint.h" -/* For enum target_signal. */ +/* For gdb_target_signal_t. */ #include "target.h" /* For struct frame_id. */ @@ -143,7 +143,7 @@ extern int sync_execution; extern void clear_proceed_status (void); -extern void proceed (CORE_ADDR, enum target_signal, int); +extern void proceed (CORE_ADDR, gdb_target_signal_t, int); extern int sched_multi; @@ -198,7 +198,7 @@ extern void reopen_exec_file (void); /* The `resume' routine should only be called in special circumstances. Normally, use `proceed', which handles a lot of bookkeeping. */ -extern void resume (int, enum target_signal); +extern void resume (int, gdb_target_signal_t); /* From misc files */ --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -59,7 +59,7 @@ static void signals_info (char *, int); static void handle_command (char *, int); -static void sig_print_info (enum target_signal); +static void sig_print_info (gdb_target_signal_t); static void sig_print_header (void); @@ -85,11 +85,11 @@ static int prepare_to_proceed (int); static void print_exited_reason (int exitstatus); -static void print_signal_exited_reason (enum target_signal siggnal); +static void print_signal_exited_reason (gdb_target_signal_t siggnal); static void print_no_history_reason (void); -static void print_signal_received_reason (enum target_signal siggnal); +static void print_signal_received_reason (gdb_target_signal_t siggnal); static void print_end_stepping_range_reason (void); @@ -1307,7 +1307,7 @@ write_memory_ptid (ptid_t ptid, CORE_ADDR memaddr, const gdb_byte *myaddr, int l } static void -displaced_step_fixup (ptid_t event_ptid, enum target_signal signal) +displaced_step_fixup (ptid_t event_ptid, gdb_target_signal_t signal) { struct cleanup *old_cleanups; struct displaced_step_inferior_state *displaced @@ -1548,7 +1548,7 @@ maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc) STEP nonzero if we should step (zero to continue instead). SIG is the signal to give the inferior (zero for none). */ void -resume (int step, enum target_signal sig) +resume (int step, gdb_target_signal_t sig) { int should_resume = 1; struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); @@ -1905,7 +1905,7 @@ prepare_to_proceed (int step) You should call clear_proceed_status before calling proceed. */ void -proceed (CORE_ADDR addr, enum target_signal siggnal, int step) +proceed (CORE_ADDR addr, gdb_target_signal_t siggnal, int step) { struct regcache *regcache; struct gdbarch *gdbarch; @@ -3605,7 +3605,7 @@ targets should add new threads to the thread list themselves in non-stop mode.") if (new_singlestep_pc != singlestep_pc) { - enum target_signal stop_signal; + gdb_target_signal_t stop_signal; if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread," @@ -5235,7 +5235,7 @@ print_end_stepping_range_reason (void) /* The inferior was terminated by a signal, print why it stopped. */ static void -print_signal_exited_reason (enum target_signal siggnal) +print_signal_exited_reason (gdb_target_signal_t siggnal) { annotate_signalled (); if (ui_out_is_mi_like_p (uiout)) @@ -5285,7 +5285,7 @@ print_exited_reason (int exitstatus) tells us to print about it. */ static void -print_signal_received_reason (enum target_signal siggnal) +print_signal_received_reason (gdb_target_signal_t siggnal) { annotate_signal (); @@ -5646,7 +5646,7 @@ Signal Stop\tPrint\tPass to program\tDescription\n")); } static void -sig_print_info (enum target_signal oursig) +sig_print_info (gdb_target_signal_t oursig) { const char *name = target_signal_to_name (oursig); int name_padding = 13 - strlen (name); @@ -5670,7 +5670,7 @@ handle_command (char *args, int from_tty) char **argv; int digits, wordlen; int sigfirst, signum, siglast; - enum target_signal oursig; + gdb_target_signal_t oursig; int allsigs; int nsigs; unsigned char *sigs; @@ -5790,14 +5790,15 @@ handle_command (char *args, int from_tty) for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++) { - switch ((enum target_signal) signum) + switch ((gdb_target_signal_t) signum) { case TARGET_SIGNAL_TRAP: case TARGET_SIGNAL_INT: if (!allsigs && !sigs[signum]) { if (query (_("%s is used by the debugger.\n\ -Are you sure you want to change it? "), target_signal_to_name ((enum target_signal) signum))) +Are you sure you want to change it? "), + target_signal_to_name ((gdb_target_signal_t) signum))) { sigs[signum] = 1; } @@ -5865,7 +5866,7 @@ xdb_handle_command (char *args, int from_tty) if (argBuf) { int validFlag = 1; - enum target_signal oursig; + gdb_target_signal_t oursig; oursig = target_signal_from_name (argv[0]); memset (argBuf, 0, bufLen); @@ -5916,7 +5917,7 @@ xdb_handle_command (char *args, int from_tty) static void signals_info (char *signum_exp, int from_tty) { - enum target_signal oursig; + gdb_target_signal_t oursig; sig_print_header (); @@ -5938,7 +5939,7 @@ signals_info (char *signum_exp, int from_tty) /* These ugly casts brought to you by the native VAX compiler. */ for (oursig = TARGET_SIGNAL_FIRST; (int) oursig < (int) TARGET_SIGNAL_LAST; - oursig = (enum target_signal) ((int) oursig + 1)) + oursig = (gdb_target_signal_t) ((int) oursig + 1)) { QUIT; @@ -6034,7 +6035,7 @@ siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var) struct inferior_thread_state { - enum target_signal stop_signal; + gdb_target_signal_t stop_signal; CORE_ADDR stop_pc; struct regcache *registers; }; --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1581,7 +1581,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty) } else if (WIFSIGNALED (status)) { - enum target_signal signo; + gdb_target_signal_t signo; target_terminal_ours (); target_mourn_inferior (); @@ -1617,7 +1617,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty) static int get_pending_status (struct lwp_info *lp, int *status) { - enum target_signal signo = TARGET_SIGNAL_0; + gdb_target_signal_t signo = TARGET_SIGNAL_0; /* If we paused threads momentarily, we may have stored pending events in lp->status or lp->waitstatus (see stop_wait_callback), @@ -1863,7 +1863,7 @@ resume_set_callback (struct lwp_info *lp, void *data) static void linux_nat_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signo) + ptid_t ptid, int step, gdb_target_signal_t signo) { sigset_t prev_mask; struct lwp_info *lp; @@ -1908,7 +1908,7 @@ linux_nat_resume (struct target_ops *ops, if (lp->status && WIFSTOPPED (lp->status)) { - enum target_signal saved_signo; + gdb_target_signal_t saved_signo; struct inferior *inf; inf = find_inferior_pid (ptid_get_pid (lp->ptid)); @@ -2268,7 +2268,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, catchpoints. */ if (!stopping) { - enum target_signal signo; + gdb_target_signal_t signo; new_lp->stopped = 0; new_lp->resumed = 1; @@ -3569,7 +3569,7 @@ retry: if (WIFSTOPPED (status)) { - enum target_signal signo = target_signal_from_host (WSTOPSIG (status)); + gdb_target_signal_t signo = target_signal_from_host (WSTOPSIG (status)); struct inferior *inf; inf = find_inferior_pid (ptid_get_pid (lp->ptid)); @@ -4169,7 +4169,7 @@ find_signalled_thread (struct thread_info *info, void *data) return 0; } -static enum target_signal +static gdb_target_signal_t find_stop_signal (void) { struct thread_info *info = @@ -4187,7 +4187,7 @@ find_stop_signal (void) static char * linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid, char *note_data, int *note_size, - enum target_signal stop_signal) + gdb_target_signal_t stop_signal) { unsigned long lwp = ptid_get_lwp (ptid); struct gdbarch *gdbarch = target_gdbarch; @@ -4280,7 +4280,7 @@ struct linux_nat_corefile_thread_data char *note_data; int *note_size; int num_notes; - enum target_signal stop_signal; + gdb_target_signal_t stop_signal; }; /* Called by gdbthread.c once per thread. Records the thread's --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1650,7 +1650,7 @@ thread_db_get_ada_task_ptid (long lwp, long thread) static void thread_db_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signo) + ptid_t ptid, int step, gdb_target_signal_t signo) { struct target_ops *beneath = find_target_beneath (ops); struct thread_db_info *info; --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -928,7 +928,7 @@ monitor_supply_register (struct regcache *regcache, int regno, char *valstr) static void monitor_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal sig) + ptid_t ptid, int step, gdb_target_signal_t sig) { /* Some monitors require a different command when starting a program */ monitor_debug ("MON resume\n"); --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -952,7 +952,7 @@ procfs_remove_hw_breakpoint (struct gdbarch *gdbarch, static void procfs_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signo) + ptid_t ptid, int step, gdb_target_signal_t signo) { int signal_to_pass; procfs_status status; --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -113,7 +113,7 @@ static void procfs_attach (struct target_ops *, char *, int); static void procfs_detach (struct target_ops *, char *, int); static void procfs_resume (struct target_ops *, - ptid_t, int, enum target_signal); + ptid_t, int, gdb_target_signal_t); static void procfs_stop (ptid_t); static void procfs_files_info (struct target_ops *); static void procfs_fetch_registers (struct target_ops *, @@ -4380,7 +4380,7 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr) static void procfs_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signo) + ptid_t ptid, int step, gdb_target_signal_t signo) { procinfo *pi, *thread; int native_signo; @@ -5616,7 +5616,7 @@ procfs_first_available (void) static char * procfs_do_thread_registers (bfd *obfd, ptid_t ptid, char *note_data, int *note_size, - enum target_signal stop_signal) + gdb_target_signal_t stop_signal) { struct regcache *regcache = get_thread_regcache (ptid); gdb_gregset_t gregs; @@ -5667,7 +5667,7 @@ struct procfs_corefile_thread_data { bfd *obfd; char *note_data; int *note_size; - enum target_signal stop_signal; + gdb_target_signal_t stop_signal; }; static int @@ -5697,7 +5697,7 @@ find_signalled_thread (struct thread_info *info, void *data) return 0; } -static enum target_signal +static gdb_target_signal_t find_stop_signal (void) { struct thread_info *info = @@ -5723,7 +5723,7 @@ procfs_make_note_section (bfd *obfd, int *note_size) struct procfs_corefile_thread_data thread_args; gdb_byte *auxv; int auxv_len; - enum target_signal stop_signal; + gdb_target_signal_t stop_signal; if (get_exec_file (0)) { --- a/gdb/record.c +++ b/gdb/record.c @@ -98,7 +98,7 @@ struct record_reg_entry struct record_end_entry { - enum target_signal sigval; + gdb_target_signal_t sigval; ULONGEST insn_num; }; @@ -207,7 +207,7 @@ static struct target_ops record_core_ops; /* The beneath function pointers. */ static struct target_ops *record_beneath_to_resume_ops; static void (*record_beneath_to_resume) (struct target_ops *, ptid_t, int, - enum target_signal); + gdb_target_signal_t); static struct target_ops *record_beneath_to_wait_ops; static ptid_t (*record_beneath_to_wait) (struct target_ops *, ptid_t, struct target_waitstatus *, @@ -578,7 +578,7 @@ record_arch_list_cleanups (void *ignore) record_arch_list, and add it to record_list. */ static int -record_message (struct regcache *regcache, enum target_signal signal) +record_message (struct regcache *regcache, gdb_target_signal_t signal) { int ret; struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -649,7 +649,7 @@ record_message (struct regcache *regcache, enum target_signal signal) struct record_message_args { struct regcache *regcache; - enum target_signal signal; + gdb_target_signal_t signal; }; static int @@ -662,7 +662,7 @@ record_message_wrapper (void *args) static int record_message_wrapper_safe (struct regcache *regcache, - enum target_signal signal) + gdb_target_signal_t signal) { struct record_message_args args; @@ -783,7 +783,7 @@ record_exec_insn (struct regcache *regcache, struct gdbarch *gdbarch, static struct target_ops *tmp_to_resume_ops; static void (*tmp_to_resume) (struct target_ops *, ptid_t, int, - enum target_signal); + gdb_target_signal_t); static struct target_ops *tmp_to_wait_ops; static ptid_t (*tmp_to_wait) (struct target_ops *, ptid_t, struct target_waitstatus *, @@ -1005,7 +1005,7 @@ static int record_resume_step = 0; static void record_resume (struct target_ops *ops, ptid_t ptid, int step, - enum target_signal signal) + gdb_target_signal_t signal) { record_resume_step = step; @@ -1746,7 +1746,7 @@ init_record_ops (void) static void record_core_resume (struct target_ops *ops, ptid_t ptid, int step, - enum target_signal signal) + gdb_target_signal_t signal) { record_resume_step = step; } --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -453,7 +453,7 @@ m32r_close (int quitting) static void m32r_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal sig) + ptid_t ptid, int step, gdb_target_signal_t sig) { unsigned long pc_addr, bp_addr, ab_addr; int ib_breakpoints; --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -1744,7 +1744,7 @@ mips_detach (struct target_ops *ops, char *args, int from_tty) static void mips_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal siggnal) + ptid_t ptid, int step, gdb_target_signal_t siggnal) { int err; @@ -1758,7 +1758,7 @@ mips_resume (struct target_ops *ops, /* Return the signal corresponding to SIG, where SIG is the number which the MIPS protocol uses for the signal. */ -static enum target_signal +static gdb_target_signal_t mips_signal_from_protocol (int sig) { /* We allow a few more signals than the IDT board actually returns, on @@ -1772,7 +1772,7 @@ mips_signal_from_protocol (int sig) from MIPS signal numbers, not host ones. Our internal numbers match the MIPS numbers for the signals the board can return, which are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP. */ - return (enum target_signal) sig; + return (gdb_target_signal_t) sig; } /* Set the register designated by REGNO to the value designated by VALUE. */ --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -119,7 +119,7 @@ struct sim_inferior_data { ptid_t remote_sim_ptid; /* Signal with which to resume. */ - enum target_signal resume_siggnal; + gdb_target_signal_t resume_siggnal; /* Flag which indicates whether resume should step or not. */ int resume_step; @@ -825,7 +825,7 @@ gdbsim_detach (struct target_ops *ops, char *args, int from_tty) struct resume_data { - enum target_signal siggnal; + gdb_target_signal_t siggnal; int step; }; @@ -854,7 +854,7 @@ gdbsim_resume_inferior (struct inferior *inf, void *arg) static void gdbsim_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal siggnal) + ptid_t ptid, int step, gdb_target_signal_t siggnal) { struct resume_data rd; struct sim_inferior_data *sim_data --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4384,7 +4384,7 @@ remote_vcont_probe (struct remote_state *rs) static char * append_resumption (char *p, char *endp, - ptid_t ptid, int step, enum target_signal siggnal) + ptid_t ptid, int step, gdb_target_signal_t siggnal) { struct remote_state *rs = get_remote_state (); @@ -4427,7 +4427,7 @@ append_resumption (char *p, char *endp, moment. */ static int -remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal) +remote_vcont_resume (ptid_t ptid, int step, gdb_target_signal_t siggnal) { struct remote_state *rs = get_remote_state (); char *p; @@ -4495,13 +4495,13 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal) /* Tell the remote machine to resume. */ -static enum target_signal last_sent_signal = TARGET_SIGNAL_0; +static gdb_target_signal_t last_sent_signal = TARGET_SIGNAL_0; static int last_sent_step; static void remote_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal siggnal) + ptid_t ptid, int step, gdb_target_signal_t siggnal) { struct remote_state *rs = get_remote_state (); char *buf; @@ -5155,7 +5155,7 @@ Packet: '%s'\n"), else { event->ws.kind = TARGET_WAITKIND_STOPPED; - event->ws.value.sig = (enum target_signal) + event->ws.value.sig = (gdb_target_signal_t) (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); } break; @@ -5181,7 +5181,7 @@ Packet: '%s'\n"), { /* The remote process exited with a signal. */ event->ws.kind = TARGET_WAITKIND_SIGNALLED; - event->ws.value.sig = (enum target_signal) value; + event->ws.value.sig = (gdb_target_signal_t) value; } /* If no process is specified, assume inferior_ptid. */ --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -348,7 +348,7 @@ sol_thread_detach (struct target_ops *ops, char *args, int from_tty) static void sol_thread_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal signo) + ptid_t ptid, int step, gdb_target_signal_t signo) { struct cleanup *old_chain; struct target_ops *beneath = find_target_beneath (ops); --- a/gdb/target.c +++ b/gdb/target.c @@ -2407,7 +2407,7 @@ target_pid_to_str (ptid_t ptid) } void -target_resume (ptid_t ptid, int step, enum target_signal signal) +target_resume (ptid_t ptid, int step, gdb_target_signal_t signal) { struct target_ops *t; --- a/gdb/target.h +++ b/gdb/target.h @@ -162,7 +162,7 @@ struct target_waitstatus union { int integer; - enum target_signal sig; + gdb_target_signal_t sig; ptid_t related_pid; char *execd_pathname; int syscall_number; @@ -401,7 +401,7 @@ struct target_ops void (*to_post_attach) (int); void (*to_detach) (struct target_ops *ops, char *, int); void (*to_disconnect) (struct target_ops *, char *, int); - void (*to_resume) (struct target_ops *, ptid_t, int, enum target_signal); + void (*to_resume) (struct target_ops *, ptid_t, int, gdb_target_signal_t); ptid_t (*to_wait) (struct target_ops *, ptid_t, struct target_waitstatus *, int); void (*to_fetch_registers) (struct target_ops *, struct regcache *, int); @@ -797,7 +797,7 @@ extern void target_disconnect (char *, int); the target, or TARGET_SIGNAL_0 for no signal. The caller may not pass TARGET_SIGNAL_DEFAULT. */ -extern void target_resume (ptid_t ptid, int step, enum target_signal signal); +extern void target_resume (ptid_t ptid, int step, gdb_target_signal_t signal); /* Wait for process pid to do something. PTID = -1 to wait for any pid to do something. Return pid of child, or -1 in case of error; @@ -1585,13 +1585,13 @@ extern int remote_timeout; extern void store_waitstatus (struct target_waitstatus *, int); /* These are in common/signals.c, but they're only used by gdb. */ -extern enum target_signal default_target_signal_from_host (struct gdbarch *, +extern gdb_target_signal_t default_target_signal_from_host (struct gdbarch *, int); extern int default_target_signal_to_host (struct gdbarch *, - enum target_signal); + gdb_target_signal_t); -/* Convert from a number used in a GDB command to an enum target_signal. */ -extern enum target_signal target_signal_from_command (int); +/* Convert from a number used in a GDB command to an gdb_target_signal_t. */ +extern gdb_target_signal_t target_signal_from_command (int); /* End of files in common/signals.c. */ /* Set the show memory breakpoints mode to show, and installs a cleanup --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -185,7 +185,7 @@ static void cygwin_set_dr (int i, CORE_ADDR addr); static void cygwin_set_dr7 (unsigned long val); static unsigned long cygwin_get_dr6 (void); -static enum target_signal last_sig = TARGET_SIGNAL_0; +static gdb_target_signal_t last_sig = TARGET_SIGNAL_0; /* Set if a signal was received from the debugged process */ /* Thread information structure used to track information that is @@ -258,7 +258,7 @@ static const int *mappings; struct xlate_exception { int them; - enum target_signal us; + gdb_target_signal_t us; }; static const struct xlate_exception @@ -1282,7 +1282,7 @@ fake_create_process (void) static void windows_resume (struct target_ops *ops, - ptid_t ptid, int step, enum target_signal sig) + ptid_t ptid, int step, gdb_target_signal_t sig) { thread_info *th; DWORD continue_status = DBG_CONTINUE; --- a/include/gdb/signals.h +++ b/include/gdb/signals.h @@ -49,12 +49,13 @@ /* For an explanation of what each signal means, see target_signal_to_string. */ -enum target_signal +typedef enum { #define SET(symbol, constant, name, string) \ symbol = constant, #include "gdb/signals.def" #undef SET - }; + } +gdb_target_signal_t; #endif /* #ifndef GDB_SIGNALS_H */ --- a/sim/common/sim-signal.c +++ b/sim/common/sim-signal.c @@ -94,7 +94,7 @@ sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig) #endif } -enum target_signal +gdb_target_signal_t sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL sig) { switch (sig) --- a/sim/common/sim-signal.h +++ b/sim/common/sim-signal.h @@ -46,6 +46,6 @@ typedef enum { } SIM_SIGNAL; int sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL); -enum target_signal sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL); +gdb_target_signal_t sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL); #endif /* SIM_SIGNAL_H */ --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="sigrename-sigasptr.patch" Content-length: 34789 --- a/gdb/common/gdb_signals.h +++ b/gdb/common/gdb_signals.h @@ -53,4 +53,6 @@ extern const char *target_signal_to_name (gdb_target_signal_t); /* Given a name (SIGHUP, etc.), return its signal. */ gdb_target_signal_t target_signal_from_name (const char *); +extern gdb_target_signal_t target_signal_from_number (int signo); + #endif /* COMMON_GDB_SIGNALS_H */ --- a/gdb/common/signals.c +++ b/gdb/common/signals.c @@ -51,34 +51,36 @@ struct gdbarch; /* This table must match in order and size the signals in gdb_target_signal_t. */ -static const struct { - const char *name; - const char *string; - } signals [] = +static const struct target_signal_o signals[] = { -#define SET(symbol, constant, name, string) { name, string }, +#define SET(symbol, constant, name, string) \ + { constant, name, string }, #include "gdb/signals.def" #undef SET }; +#define SET(symbol, constant, name, string) \ + const gdb_target_signal_t symbol = &signals[constant]; +#include "gdb/signals.def" +#undef SET /* Return the string for a signal. */ const char * target_signal_to_string (gdb_target_signal_t sig) { - if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST) - return signals[sig].string; + if (sig >= TARGET_SIGNAL_FIRST && sig <= TARGET_SIGNAL_LAST) + return TARGET_SIGNAL_STRING (sig); else - return signals[TARGET_SIGNAL_UNKNOWN].string; + return TARGET_SIGNAL_STRING (TARGET_SIGNAL_UNKNOWN); } /* Return the name for a signal. */ const char * target_signal_to_name (gdb_target_signal_t sig) { - if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST - && signals[sig].name != NULL) - return signals[sig].name; + if (sig >= TARGET_SIGNAL_FIRST && sig <= TARGET_SIGNAL_LAST + && TARGET_SIGNAL_NAME (sig) != NULL) + return TARGET_SIGNAL_NAME (sig); else /* I think the code which prints this will always print it along with the string, so no need to be verbose (very old comment). */ @@ -97,15 +99,24 @@ target_signal_from_name (const char *name) instead. */ /* This ugly cast brought to you by the native VAX compiler. */ - for (sig = TARGET_SIGNAL_HUP; - sig < TARGET_SIGNAL_LAST; - sig = (gdb_target_signal_t) ((int) sig + 1)) - if (signals[sig].name != NULL - && strcmp (name, signals[sig].name) == 0) + for (sig = TARGET_SIGNAL_HUP; sig < TARGET_SIGNAL_LAST; sig++) + if (TARGET_SIGNAL_NAME (sig) != NULL + && strcmp (name, TARGET_SIGNAL_NAME (sig)) == 0) return sig; return TARGET_SIGNAL_UNKNOWN; } - + +/* Return the gdb_target_signal_t for a gdb signal. */ + +gdb_target_signal_t +target_signal_from_number (int number) +{ + if (number < 0 || number > TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST)) + return TARGET_SIGNAL_UNKNOWN; + else + return &signals[number]; +} + /* The following functions are to help certain targets deal with the signal/waitstatus stuff. They could just as well be in a file called native-utils.c or unixwaitstatus-utils.c or whatever. */ @@ -341,13 +352,13 @@ target_signal_from_host (int hostsig) { /* This block of TARGET_SIGNAL_REALTIME value is in order. */ if (33 <= hostsig && hostsig <= 63) - return (gdb_target_signal_t) - (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33); + return target_signal_from_number + (hostsig - 33 + TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_33)); else if (hostsig == 32) return TARGET_SIGNAL_REALTIME_32; else if (64 <= hostsig && hostsig <= 127) - return (gdb_target_signal_t) - (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64); + return target_signal_from_number + (hostsig - 64 + TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_64)); else error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal"); } @@ -371,81 +382,81 @@ do_target_signal_to_host (gdb_target_signal_t oursig, (void) retsig; *oursig_ok = 1; - switch (oursig) + switch (TARGET_SIGNAL_NUMBER (oursig)) { - case TARGET_SIGNAL_0: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0): return 0; #if defined (SIGHUP) - case TARGET_SIGNAL_HUP: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_HUP): return SIGHUP; #endif #if defined (SIGINT) - case TARGET_SIGNAL_INT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INT): return SIGINT; #endif #if defined (SIGQUIT) - case TARGET_SIGNAL_QUIT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_QUIT): return SIGQUIT; #endif #if defined (SIGILL) - case TARGET_SIGNAL_ILL: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ILL): return SIGILL; #endif #if defined (SIGTRAP) - case TARGET_SIGNAL_TRAP: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TRAP): return SIGTRAP; #endif #if defined (SIGABRT) - case TARGET_SIGNAL_ABRT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ABRT): return SIGABRT; #endif #if defined (SIGEMT) - case TARGET_SIGNAL_EMT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_EMT): return SIGEMT; #endif #if defined (SIGFPE) - case TARGET_SIGNAL_FPE: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_FPE): return SIGFPE; #endif #if defined (SIGKILL) - case TARGET_SIGNAL_KILL: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_KILL): return SIGKILL; #endif #if defined (SIGBUS) - case TARGET_SIGNAL_BUS: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_BUS): return SIGBUS; #endif #if defined (SIGSEGV) - case TARGET_SIGNAL_SEGV: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SEGV): return SIGSEGV; #endif #if defined (SIGSYS) - case TARGET_SIGNAL_SYS: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SYS): return SIGSYS; #endif #if defined (SIGPIPE) - case TARGET_SIGNAL_PIPE: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PIPE): return SIGPIPE; #endif #if defined (SIGALRM) - case TARGET_SIGNAL_ALRM: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ALRM): return SIGALRM; #endif #if defined (SIGTERM) - case TARGET_SIGNAL_TERM: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TERM): return SIGTERM; #endif #if defined (SIGUSR1) - case TARGET_SIGNAL_USR1: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_USR1): return SIGUSR1; #endif #if defined (SIGUSR2) - case TARGET_SIGNAL_USR2: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_USR2): return SIGUSR2; #endif #if defined (SIGCHLD) || defined (SIGCLD) - case TARGET_SIGNAL_CHLD: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CHLD): #if defined (SIGCHLD) return SIGCHLD; #else @@ -453,111 +464,111 @@ do_target_signal_to_host (gdb_target_signal_t oursig, #endif #endif /* SIGCLD or SIGCHLD */ #if defined (SIGPWR) - case TARGET_SIGNAL_PWR: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PWR): return SIGPWR; #endif #if defined (SIGWINCH) - case TARGET_SIGNAL_WINCH: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WINCH): return SIGWINCH; #endif #if defined (SIGURG) - case TARGET_SIGNAL_URG: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_URG): return SIGURG; #endif #if defined (SIGIO) - case TARGET_SIGNAL_IO: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_IO): return SIGIO; #endif #if defined (SIGPOLL) - case TARGET_SIGNAL_POLL: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_POLL): return SIGPOLL; #endif #if defined (SIGSTOP) - case TARGET_SIGNAL_STOP: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_STOP): return SIGSTOP; #endif #if defined (SIGTSTP) - case TARGET_SIGNAL_TSTP: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TSTP): return SIGTSTP; #endif #if defined (SIGCONT) - case TARGET_SIGNAL_CONT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CONT): return SIGCONT; #endif #if defined (SIGTTIN) - case TARGET_SIGNAL_TTIN: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TTIN): return SIGTTIN; #endif #if defined (SIGTTOU) - case TARGET_SIGNAL_TTOU: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TTOU): return SIGTTOU; #endif #if defined (SIGVTALRM) - case TARGET_SIGNAL_VTALRM: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_VTALRM): return SIGVTALRM; #endif #if defined (SIGPROF) - case TARGET_SIGNAL_PROF: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PROF): return SIGPROF; #endif #if defined (SIGXCPU) - case TARGET_SIGNAL_XCPU: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_XCPU): return SIGXCPU; #endif #if defined (SIGXFSZ) - case TARGET_SIGNAL_XFSZ: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_XFSZ): return SIGXFSZ; #endif #if defined (SIGWIND) - case TARGET_SIGNAL_WIND: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WIND): return SIGWIND; #endif #if defined (SIGPHONE) - case TARGET_SIGNAL_PHONE: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PHONE): return SIGPHONE; #endif #if defined (SIGLOST) - case TARGET_SIGNAL_LOST: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LOST): return SIGLOST; #endif #if defined (SIGWAITING) - case TARGET_SIGNAL_WAITING: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WAITING): return SIGWAITING; #endif #if defined (SIGCANCEL) - case TARGET_SIGNAL_CANCEL: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CANCEL): return SIGCANCEL; #endif #if defined (SIGLWP) - case TARGET_SIGNAL_LWP: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LWP): return SIGLWP; #endif #if defined (SIGDANGER) - case TARGET_SIGNAL_DANGER: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_DANGER): return SIGDANGER; #endif #if defined (SIGGRANT) - case TARGET_SIGNAL_GRANT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_GRANT): return SIGGRANT; #endif #if defined (SIGRETRACT) - case TARGET_SIGNAL_RETRACT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_RETRACT): return SIGRETRACT; #endif #if defined (SIGMSG) - case TARGET_SIGNAL_MSG: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_MSG): return SIGMSG; #endif #if defined (SIGSOUND) - case TARGET_SIGNAL_SOUND: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SOUND): return SIGSOUND; #endif #if defined (SIGSAK) - case TARGET_SIGNAL_SAK: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SAK): return SIGSAK; #endif #if defined (SIGPRIO) - case TARGET_SIGNAL_PRIO: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PRIO): return SIGPRIO; #endif @@ -588,7 +599,7 @@ do_target_signal_to_host (gdb_target_signal_t oursig, #endif #if defined (SIGINFO) - case TARGET_SIGNAL_INFO: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INFO): return SIGINFO; #endif @@ -601,7 +612,8 @@ do_target_signal_to_host (gdb_target_signal_t oursig, { /* This block of signals is continuous, and TARGET_SIGNAL_REALTIME_33 is 33 by definition. */ - retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33; + retsig = (TARGET_SIGNAL_NUMBER (oursig) + - TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_33) + 33); } else if (oursig == TARGET_SIGNAL_REALTIME_32) { @@ -614,7 +626,8 @@ do_target_signal_to_host (gdb_target_signal_t oursig, { /* This block of signals is continuous, and TARGET_SIGNAL_REALTIME_64 is 64 by definition. */ - retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64; + retsig = (TARGET_SIGNAL_NUMBER (oursig) + - TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_64) + 64); } if (retsig >= REALTIME_LO && retsig < REALTIME_HI) @@ -665,7 +678,7 @@ gdb_target_signal_t target_signal_from_command (int num) { if (num >= 1 && num <= 15) - return (gdb_target_signal_t) num; + return target_signal_from_number (num); error ("Only signals 1-15 are valid as numeric signals.\n\ Use \"info signals\" for a list of symbolic signals."); } @@ -675,8 +688,17 @@ extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */ void _initialize_signals (void) { - if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0) - internal_error (__FILE__, __LINE__, "failed internal consistency check"); + gdb_target_signal_t sig; + + for (sig = TARGET_SIGNAL_0; sig <= TARGET_SIGNAL_LAST; sig++) + if (sig - TARGET_SIGNAL_0 != TARGET_SIGNAL_NUMBER (sig)) + internal_error (__FILE__, __LINE__, "failed internal consistency check " + "(signals continuity)"); + + if (strcmp (TARGET_SIGNAL_STRING (TARGET_SIGNAL_LAST), + "TARGET_SIGNAL_MAGIC") != 0) + internal_error (__FILE__, __LINE__, "failed internal consistency check" + "(last signal magic)"); } int --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -2266,7 +2266,7 @@ Check if we're already there.\n", || WSTOPSIG (w) == __SIGRTMIN + 1)) || #endif - (pass_signals[target_signal_from_host (WSTOPSIG (w))] + (pass_signals[TARGET_SIGNAL_NUMBER (target_signal_from_host (WSTOPSIG (w)))] && !(WSTOPSIG (w) == SIGSTOP && current_inferior->last_resume_kind == resume_stop)))) { @@ -2421,7 +2421,7 @@ Check if we're already there.\n", fprintf (stderr, "linux_wait ret = %s, %d, %d\n", target_pid_to_str (ptid_of (event_child)), ourstatus->kind, - ourstatus->value.sig); + TARGET_SIGNAL_NUMBER (ourstatus->value.sig)); return ptid_of (event_child); } --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -1240,7 +1240,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, const char **regp; struct regcache *regcache; - sprintf (buf, "T%02x", status->value.sig); + sprintf (buf, "T%02x", TARGET_SIGNAL_NUMBER (status->value.sig)); buf += strlen (buf); regp = gdbserver_expedite_regs; @@ -1339,9 +1339,10 @@ prepare_resume_reply (char *buf, ptid_t ptid, case TARGET_WAITKIND_SIGNALLED: if (multi_process) sprintf (buf, "X%x;process:%x", - status->value.sig, ptid_get_pid (ptid)); + TARGET_SIGNAL_NUMBER (status->value.sig), + ptid_get_pid (ptid)); else - sprintf (buf, "X%02x", status->value.sig); + sprintf (buf, "X%02x", TARGET_SIGNAL_NUMBER (status->value.sig)); break; default: error ("unhandled waitkind"); --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -51,7 +51,7 @@ int debug_threads; /* Enable debugging of h/w breakpoint/watchpoint support. */ int debug_hw_points; -int pass_signals[TARGET_SIGNAL_LAST]; +int pass_signals[TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST)]; jmp_buf toplevel; @@ -398,7 +398,7 @@ handle_general_set (char *own_buf) { if (strncmp ("QPassSignals:", own_buf, strlen ("QPassSignals:")) == 0) { - int numsigs = (int) TARGET_SIGNAL_LAST, i; + int numsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST), i; const char *p = own_buf + strlen ("QPassSignals:"); CORE_ADDR cursig; @@ -1747,12 +1747,15 @@ handle_v_cont (char *own_buf) if (p[0] == 'S' || p[0] == 'C') { - int sig; - sig = strtol (p + 1, &q, 16); + int signo; + gdb_target_signal_t sig; + + signo = strtol (p + 1, &q, 16); if (p == q) goto err; p = q; + sig = target_signal_from_number (signo); if (!target_signal_to_host_p (sig)) goto err; resume_info[i].sig = target_signal_to_host (sig); @@ -2959,8 +2962,8 @@ process_serial_event (void) case 'C': require_running (own_buf); convert_ascii_to_int (own_buf + 1, &sig, 1); - if (target_signal_to_host_p (sig)) - signal = target_signal_to_host (sig); + if (target_signal_to_host_p (target_signal_from_number (sig))) + signal = target_signal_to_host (target_signal_from_number (sig)); else signal = 0; myresume (own_buf, 0, signal); @@ -2968,8 +2971,8 @@ process_serial_event (void) case 'S': require_running (own_buf); convert_ascii_to_int (own_buf + 1, &sig, 1); - if (target_signal_to_host_p (sig)) - signal = target_signal_to_host (sig); + if (target_signal_to_host_p (target_signal_from_number (sig))) + signal = target_signal_to_host (target_signal_from_number (sig)); else signal = 0; myresume (own_buf, 1, signal); --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -240,17 +240,17 @@ extern void start_remote (int from_tty); extern void normal_stop (void); -extern int signal_stop_state (int); +extern int signal_stop_state (gdb_target_signal_t sig); -extern int signal_print_state (int); +extern int signal_print_state (gdb_target_signal_t sig); -extern int signal_pass_state (int); +extern int signal_pass_state (gdb_target_signal_t sig); -extern int signal_stop_update (int, int); +extern int signal_stop_update (gdb_target_signal_t sig, int state); -extern int signal_print_update (int, int); +extern int signal_print_update (gdb_target_signal_t sig, int state); -extern int signal_pass_update (int, int); +extern int signal_pass_update (gdb_target_signal_t sig, int state); extern void get_last_target_status(ptid_t *ptid, struct target_waitstatus *status); --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1583,7 +1583,7 @@ resume (int step, gdb_target_signal_t sig) fprintf_unfiltered (gdb_stdlog, "infrun: resume (step=%d, signal=%d), " "trap_expected=%d\n", - step, sig, tp->trap_expected); + step, TARGET_SIGNAL_NUMBER (sig), tp->trap_expected); /* Normally, by the time we reach `resume', the breakpoints are either removed or inserted, as appropriate. The exception is if we're sitting @@ -1963,7 +1963,8 @@ proceed (CORE_ADDR addr, gdb_target_signal_t siggnal, int step) if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: proceed (addr=%s, signal=%d, step=%d)\n", - paddress (gdbarch, addr), siggnal, step); + paddress (gdbarch, addr), + TARGET_SIGNAL_NUMBER (siggnal), step); /* We're handling a live event, so make sure we're doing live debugging. If we're looking at traceframes while the target is @@ -2047,7 +2048,7 @@ proceed (CORE_ADDR addr, gdb_target_signal_t siggnal, int step) tp->stop_signal = siggnal; /* If this signal should not be seen by program, give it zero. Used for debugging signals. */ - else if (!signal_program[tp->stop_signal]) + else if (! signal_pass_state (tp->stop_signal)) tp->stop_signal = TARGET_SIGNAL_0; annotate_starting (); @@ -3970,11 +3971,11 @@ process_event_stop_test: if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: random signal %d\n", - ecs->event_thread->stop_signal); + TARGET_SIGNAL_NUMBER (ecs->event_thread->stop_signal)); stopped_by_random_signal = 1; - if (signal_print[ecs->event_thread->stop_signal]) + if (signal_print_state (ecs->event_thread->stop_signal)) { printed = 1; target_terminal_ours_for_output (); @@ -3997,7 +3998,7 @@ process_event_stop_test: target_terminal_inferior (); /* Clear the signal if it should not be passed. */ - if (signal_program[ecs->event_thread->stop_signal] == 0) + if (signal_pass_state (ecs->event_thread->stop_signal) == 0) ecs->event_thread->stop_signal = TARGET_SIGNAL_0; if (ecs->event_thread->prev_pc == stop_pc @@ -5184,7 +5185,7 @@ keep_going (struct execution_control_state *ecs) equivalent of a SIGNAL_TRAP to the program being debugged. */ if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP - && !signal_program[ecs->event_thread->stop_signal]) + && ! signal_pass_state (ecs->event_thread->stop_signal)) ecs->event_thread->stop_signal = TARGET_SIGNAL_0; discard_cleanups (old_cleanups); @@ -5594,47 +5595,47 @@ hook_stop_stub (void *cmd) } int -signal_stop_state (int signo) +signal_stop_state (gdb_target_signal_t sig) { - return signal_stop[signo]; + return signal_stop[TARGET_SIGNAL_NUMBER (sig)]; } int -signal_print_state (int signo) +signal_print_state (gdb_target_signal_t sig) { - return signal_print[signo]; + return signal_print[TARGET_SIGNAL_NUMBER (sig)]; } int -signal_pass_state (int signo) +signal_pass_state (gdb_target_signal_t sig) { - return signal_program[signo]; + return signal_program[TARGET_SIGNAL_NUMBER (sig)]; } int -signal_stop_update (int signo, int state) +signal_stop_update (gdb_target_signal_t sig, int state) { - int ret = signal_stop[signo]; + int ret = signal_stop[TARGET_SIGNAL_NUMBER (sig)]; - signal_stop[signo] = state; + signal_stop[TARGET_SIGNAL_NUMBER (sig)] = state; return ret; } int -signal_print_update (int signo, int state) +signal_print_update (gdb_target_signal_t sig, int state) { - int ret = signal_print[signo]; + int ret = signal_print[TARGET_SIGNAL_NUMBER (sig)]; - signal_print[signo] = state; + signal_print[TARGET_SIGNAL_NUMBER (sig)] = state; return ret; } int -signal_pass_update (int signo, int state) +signal_pass_update (gdb_target_signal_t sig, int state) { - int ret = signal_program[signo]; + int ret = signal_program[TARGET_SIGNAL_NUMBER (sig)]; - signal_program[signo] = state; + signal_program[TARGET_SIGNAL_NUMBER (sig)] = state; return ret; } @@ -5656,9 +5657,9 @@ sig_print_info (gdb_target_signal_t oursig) printf_filtered ("%s", name); printf_filtered ("%*.*s ", name_padding, name_padding, " "); - printf_filtered ("%s\t", signal_stop[oursig] ? "Yes" : "No"); - printf_filtered ("%s\t", signal_print[oursig] ? "Yes" : "No"); - printf_filtered ("%s\t\t", signal_program[oursig] ? "Yes" : "No"); + printf_filtered ("%s\t", signal_stop_state (oursig) ? "Yes" : "No"); + printf_filtered ("%s\t", signal_print_state (oursig) ? "Yes" : "No"); + printf_filtered ("%s\t\t", signal_pass_state (oursig) ? "Yes" : "No"); printf_filtered ("%s\n", target_signal_to_string (oursig)); } @@ -5683,7 +5684,7 @@ handle_command (char *args, int from_tty) /* Allocate and zero an array of flags for which signals to handle. */ - nsigs = (int) TARGET_SIGNAL_LAST; + nsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST); sigs = (unsigned char *) alloca (nsigs); memset (sigs, 0, nsigs); @@ -5756,12 +5757,13 @@ handle_command (char *args, int from_tty) using symbolic names anyway, and the common ones like SIGHUP, SIGINT, SIGALRM, etc. will work right anyway. */ - sigfirst = siglast = (int) - target_signal_from_command (atoi (*argv)); + gdb_target_signal_t sig = target_signal_from_command (atoi (*argv)); + + sigfirst = siglast = TARGET_SIGNAL_NUMBER (sig); if ((*argv)[digits] == '-') { - siglast = (int) - target_signal_from_command (atoi ((*argv) + digits + 1)); + sig = target_signal_from_command (atoi ((*argv) + digits + 1)); + siglast = TARGET_SIGNAL_NUMBER (sig); } if (sigfirst > siglast) { @@ -5776,7 +5778,7 @@ handle_command (char *args, int from_tty) oursig = target_signal_from_name (*argv); if (oursig != TARGET_SIGNAL_UNKNOWN) { - sigfirst = siglast = (int) oursig; + sigfirst = siglast = TARGET_SIGNAL_NUMBER (oursig); } else { @@ -5790,15 +5792,15 @@ handle_command (char *args, int from_tty) for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++) { - switch ((gdb_target_signal_t) signum) + switch (signum) { - case TARGET_SIGNAL_TRAP: - case TARGET_SIGNAL_INT: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TRAP): + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INT): if (!allsigs && !sigs[signum]) { if (query (_("%s is used by the debugger.\n\ Are you sure you want to change it? "), - target_signal_to_name ((gdb_target_signal_t) signum))) + target_signal_to_name (target_signal_from_number (signum)))) { sigs[signum] = 1; } @@ -5809,9 +5811,9 @@ Are you sure you want to change it? "), } } break; - case TARGET_SIGNAL_0: - case TARGET_SIGNAL_DEFAULT: - case TARGET_SIGNAL_UNKNOWN: + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0): + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_DEFAULT): + case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_UNKNOWN): /* Make sure that "all" doesn't print these. */ break; default: @@ -5834,7 +5836,7 @@ Are you sure you want to change it? "), sig_print_header (); for (; signum < nsigs; signum++) if (sigs[signum]) - sig_print_info (signum); + sig_print_info (target_signal_from_number (signum)); } break; @@ -5876,21 +5878,21 @@ xdb_handle_command (char *args, int from_tty) { if (strcmp (argv[1], "s") == 0) { - if (!signal_stop[oursig]) + if (! signal_stop_state (oursig)) sprintf (argBuf, "%s %s", argv[0], "stop"); else sprintf (argBuf, "%s %s", argv[0], "nostop"); } else if (strcmp (argv[1], "i") == 0) { - if (!signal_program[oursig]) + if (! signal_pass_state (oursig)) sprintf (argBuf, "%s %s", argv[0], "pass"); else sprintf (argBuf, "%s %s", argv[0], "nopass"); } else if (strcmp (argv[1], "r") == 0) { - if (!signal_print[oursig]) + if (! signal_print_state (oursig)) sprintf (argBuf, "%s %s", argv[0], "print"); else sprintf (argBuf, "%s %s", argv[0], "noprint"); @@ -5937,9 +5939,7 @@ signals_info (char *signum_exp, int from_tty) printf_filtered ("\n"); /* These ugly casts brought to you by the native VAX compiler. */ - for (oursig = TARGET_SIGNAL_FIRST; - (int) oursig < (int) TARGET_SIGNAL_LAST; - oursig = (gdb_target_signal_t) ((int) oursig + 1)) + for (oursig = TARGET_SIGNAL_FIRST; oursig < TARGET_SIGNAL_LAST; oursig++) { QUIT; @@ -6612,7 +6612,7 @@ leave it stopped or free to run as needed."), &setlist, &showlist); - numsigs = (int) TARGET_SIGNAL_LAST; + numsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST); signal_stop = (unsigned char *) xmalloc (sizeof (signal_stop[0]) * numsigs); signal_print = (unsigned char *) xmalloc (sizeof (signal_print[0]) * numsigs); @@ -6627,37 +6627,37 @@ leave it stopped or free to run as needed."), /* Signals caused by debugger's own actions should not be given to the program afterwards. */ - signal_program[TARGET_SIGNAL_TRAP] = 0; - signal_program[TARGET_SIGNAL_INT] = 0; + signal_pass_update (TARGET_SIGNAL_TRAP, 0); + signal_pass_update (TARGET_SIGNAL_INT, 0); /* Signals that are not errors should not normally enter the debugger. */ - signal_stop[TARGET_SIGNAL_ALRM] = 0; - signal_print[TARGET_SIGNAL_ALRM] = 0; - signal_stop[TARGET_SIGNAL_VTALRM] = 0; - signal_print[TARGET_SIGNAL_VTALRM] = 0; - signal_stop[TARGET_SIGNAL_PROF] = 0; - signal_print[TARGET_SIGNAL_PROF] = 0; - signal_stop[TARGET_SIGNAL_CHLD] = 0; - signal_print[TARGET_SIGNAL_CHLD] = 0; - signal_stop[TARGET_SIGNAL_IO] = 0; - signal_print[TARGET_SIGNAL_IO] = 0; - signal_stop[TARGET_SIGNAL_POLL] = 0; - signal_print[TARGET_SIGNAL_POLL] = 0; - signal_stop[TARGET_SIGNAL_URG] = 0; - signal_print[TARGET_SIGNAL_URG] = 0; - signal_stop[TARGET_SIGNAL_WINCH] = 0; - signal_print[TARGET_SIGNAL_WINCH] = 0; + signal_stop_update (TARGET_SIGNAL_ALRM, 0); + signal_print_update (TARGET_SIGNAL_ALRM, 0); + signal_stop_update (TARGET_SIGNAL_VTALRM, 0); + signal_print_update (TARGET_SIGNAL_VTALRM, 0); + signal_stop_update (TARGET_SIGNAL_PROF, 0); + signal_print_update (TARGET_SIGNAL_PROF, 0); + signal_stop_update (TARGET_SIGNAL_CHLD, 0); + signal_print_update (TARGET_SIGNAL_CHLD, 0); + signal_stop_update (TARGET_SIGNAL_IO, 0); + signal_print_update (TARGET_SIGNAL_IO, 0); + signal_stop_update (TARGET_SIGNAL_POLL, 0); + signal_print_update (TARGET_SIGNAL_POLL, 0); + signal_stop_update (TARGET_SIGNAL_URG, 0); + signal_print_update (TARGET_SIGNAL_URG, 0); + signal_stop_update (TARGET_SIGNAL_WINCH, 0); + signal_print_update (TARGET_SIGNAL_WINCH, 0); /* These signals are used internally by user-level thread implementations. (See signal(5) on Solaris.) Like the above signals, a healthy program receives and handles them as part of its normal operation. */ - signal_stop[TARGET_SIGNAL_LWP] = 0; - signal_print[TARGET_SIGNAL_LWP] = 0; - signal_stop[TARGET_SIGNAL_WAITING] = 0; - signal_print[TARGET_SIGNAL_WAITING] = 0; - signal_stop[TARGET_SIGNAL_CANCEL] = 0; - signal_print[TARGET_SIGNAL_CANCEL] = 0; + signal_stop_update (TARGET_SIGNAL_LWP, 0); + signal_print_update (TARGET_SIGNAL_LWP, 0); + signal_stop_update (TARGET_SIGNAL_WAITING, 0); + signal_print_update (TARGET_SIGNAL_WAITING, 0); + signal_stop_update (TARGET_SIGNAL_CANCEL, 0); + signal_print_update (TARGET_SIGNAL_CANCEL, 0); add_setshow_zinteger_cmd ("stop-on-solib-events", class_support, &stop_on_solib_events, _("\ --- a/gdb/record.c +++ b/gdb/record.c @@ -2302,7 +2302,7 @@ record_restore (void) bfdcore_read (core_bfd, osec, &signal, sizeof (signal), &bfd_offset); signal = netorder32 (signal); - rec->u.end.sigval = signal; + rec->u.end.sigval = target_signal_from_number (signal); /* Get insn count. */ bfdcore_read (core_bfd, osec, &count, @@ -2560,7 +2560,8 @@ cmd_record_save (char *args, int from_tty) (unsigned long) sizeof (signal), (unsigned long) sizeof (count)); /* Write signal value. */ - signal = netorder32 (record_list->u.end.sigval); + signal = netorder32 (TARGET_SIGNAL_NUMBER + (record_list->u.end.sigval)); bfdcore_write (obfd, osec, &signal, sizeof (signal), &bfd_offset); --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1557,15 +1557,17 @@ remote_pass_signals (void) if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE) { char *pass_packet, *p; - int numsigs = (int) TARGET_SIGNAL_LAST; + int numsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST); int count = 0, i; gdb_assert (numsigs < 256); for (i = 0; i < numsigs; i++) { - if (signal_stop_state (i) == 0 - && signal_print_state (i) == 0 - && signal_pass_state (i) == 1) + gdb_target_signal_t sig = target_signal_from_number (i); + + if (signal_stop_state (sig) == 0 + && signal_print_state (sig) == 0 + && signal_pass_state (sig) == 1) count++; } pass_packet = xmalloc (count * 3 + strlen ("QPassSignals:") + 1); @@ -1573,9 +1575,11 @@ remote_pass_signals (void) p = pass_packet + strlen (pass_packet); for (i = 0; i < numsigs; i++) { - if (signal_stop_state (i) == 0 - && signal_print_state (i) == 0 - && signal_pass_state (i) == 1) + gdb_target_signal_t sig = target_signal_from_number (i); + + if (signal_stop_state (sig) == 0 + && signal_print_state (sig) == 0 + && signal_pass_state (sig) == 1) { if (i >= 16) *p++ = tohex (i >> 4); @@ -4389,11 +4393,11 @@ append_resumption (char *p, char *endp, struct remote_state *rs = get_remote_state (); if (step && siggnal != TARGET_SIGNAL_0) - p += xsnprintf (p, endp - p, ";S%02x", siggnal); + p += xsnprintf (p, endp - p, ";S%02x", TARGET_SIGNAL_NUMBER (siggnal)); else if (step) p += xsnprintf (p, endp - p, ";s"); else if (siggnal != TARGET_SIGNAL_0) - p += xsnprintf (p, endp - p, ";C%02x", siggnal); + p += xsnprintf (p, endp - p, ";C%02x", TARGET_SIGNAL_NUMBER (siggnal)); else p += xsnprintf (p, endp - p, ";c"); @@ -4495,7 +4499,7 @@ remote_vcont_resume (ptid_t ptid, int step, gdb_target_signal_t siggnal) /* Tell the remote machine to resume. */ -static gdb_target_signal_t last_sent_signal = TARGET_SIGNAL_0; +static gdb_target_signal_t last_sent_signal; static int last_sent_step; @@ -4531,7 +4535,7 @@ remote_resume (struct target_ops *ops, /* We don't pass signals to the target in reverse exec mode. */ if (info_verbose && siggnal != TARGET_SIGNAL_0) warning (" - Can't pass signal %d to target in reverse: ignored.\n", - siggnal); + TARGET_SIGNAL_NUMBER (siggnal)); if (step && remote_protocol_packets[PACKET_bs].support == PACKET_DISABLE) @@ -4544,9 +4548,11 @@ remote_resume (struct target_ops *ops, } else if (siggnal != TARGET_SIGNAL_0) { + int signo = TARGET_SIGNAL_NUMBER (siggnal); + buf[0] = step ? 'S' : 'C'; - buf[1] = tohex (((int) siggnal >> 4) & 0xf); - buf[2] = tohex (((int) siggnal) & 0xf); + buf[1] = tohex ((signo >> 4) & 0xf); + buf[2] = tohex (signo & 0xf); buf[3] = '\0'; } else @@ -5155,8 +5161,9 @@ Packet: '%s'\n"), else { event->ws.kind = TARGET_WAITKIND_STOPPED; - event->ws.value.sig = (gdb_target_signal_t) - (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); + event->ws.value.sig + = target_signal_from_number ((fromhex (buf[1]) << 4) + + fromhex (buf[2])); } break; case 'W': /* Target exited. */ @@ -5181,7 +5188,7 @@ Packet: '%s'\n"), { /* The remote process exited with a signal. */ event->ws.kind = TARGET_WAITKIND_SIGNALLED; - event->ws.value.sig = (gdb_target_signal_t) value; + event->ws.value.sig = target_signal_from_number (value); } /* If no process is specified, assume inferior_ptid. */ @@ -10788,5 +10795,6 @@ Show the remote pathname for \"run\""), NULL, NULL, NULL, target_buf_size = 2048; target_buf = xmalloc (target_buf_size); -} + last_sent_signal = TARGET_SIGNAL_0; +} --- a/include/gdb/signals.h +++ b/include/gdb/signals.h @@ -49,13 +49,31 @@ /* For an explanation of what each signal means, see target_signal_to_string. */ -typedef enum +#define TARGET_SIGNAL_NUMBER(target_signal) (target_signal)->number +#define TARGET_SIGNAL_STRING(target_signal) (target_signal)->string +#define TARGET_SIGNAL_NAME(target_signal) (target_signal)->name +#define TARGET_SIGNAL_NUMBER_CONST(target_signal) target_signal ## _NUMBER + +enum target_signal_number + { +#define SET(symbol, constant, name, string) \ + TARGET_SIGNAL_NUMBER_CONST (symbol) = constant, +#include "gdb/signals.def" +#undef SET + }; + +struct target_signal_o { + enum target_signal_number number; + const char *name; + const char *string; + }; + +typedef const struct target_signal_o *gdb_target_signal_t; + #define SET(symbol, constant, name, string) \ - symbol = constant, + extern const gdb_target_signal_t symbol; #include "gdb/signals.def" #undef SET - } -gdb_target_signal_t; #endif /* #ifndef GDB_SIGNALS_H */ --oyUTqETQ0mS9luUI--