This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/committed] sim: delete duplicate SIGINT handling


Many of the simulators change the SIGINT handler.
E.g., moxie/interp.c:

  sigsave = signal (SIGINT, interrupt);

However, this is unnecessary.
remote-sim.h already provides an API for asynchronously stopping
a sim; and both gdb and the drivers (run.c and nrun.c at least,
I didn't check the others) install a SIGINT handler which
calls this method.

URL: https://sourceware.org/bugzilla/show_bug.cgi?id=16450
Reported-by: Tom Tromey <tromey@redhat.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 sim/h8300/ChangeLog      |  7 +++++++
 sim/h8300/compile.c      | 14 --------------
 sim/mcore/ChangeLog      |  6 ++++++
 sim/mcore/interp.c       | 10 ----------
 sim/microblaze/ChangeLog |  6 ++++++
 sim/microblaze/interp.c  | 10 ----------
 sim/moxie/ChangeLog      |  6 ++++++
 sim/moxie/interp.c       | 10 ----------
 sim/sh/ChangeLog         |  6 ++++++
 sim/sh/interp.c          | 13 -------------
 10 files changed, 31 insertions(+), 57 deletions(-)

diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index 4760745..38280e8 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,3 +1,10 @@
+2014-02-17  Mike Frysinger  <vapier@gentoo.org>
+
+	PR gdb/16450
+	* compile.c (control_c_sim_desc): Delete.
+	(control_c): Likewise.
+	(sim_resume): Delete signal(SIGINT) handling.
+
 2013-09-23  Alan Modra  <amodra@gmail.com>
 
 	* configure: Regenerate.
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 13d5cae..2c7316c 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -1859,15 +1859,6 @@ init_pointers (SIM_DESC sd)
     }
 }
 
-/* Grotty global variable for use by control_c signal handler.  */
-static SIM_DESC control_c_sim_desc;
-
-static void
-control_c (int sig)
-{
-  sim_engine_set_run_state (control_c_sim_desc, sim_stopped, SIGINT);
-}
-
 int
 sim_stop (SIM_DESC sd)
 {
@@ -1901,7 +1892,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
   int cycles = 0;
   int insts = 0;
   int tick_start = get_now ();
-  void (*prev) ();
   int poll_count = 0;
   int res;
   int tmp;
@@ -1917,9 +1907,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
 
   init_pointers (sd);
 
-  control_c_sim_desc = sd;
-  prev = signal (SIGINT, control_c);
-
   if (step)
     {
       sim_engine_set_run_state (sd, sim_stopped, SIGTRAP);
@@ -4604,7 +4591,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
     h8_set_exr (sd, (trace<<7) | intMask);
 
   h8_set_mask (sd, oldmask);
-  signal (SIGINT, prev);
 }
 
 int
diff --git a/sim/mcore/ChangeLog b/sim/mcore/ChangeLog
index 0208dc3..a034cde 100644
--- a/sim/mcore/ChangeLog
+++ b/sim/mcore/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-17  Mike Frysinger  <vapier@gentoo.org>
+
+	PR gdb/16450
+	* interp.c (interrupt): Delete.
+	(sim_resume): Delete signal(SIGINT) handling.
+
 2013-09-23  Alan Modra  <amodra@gmail.com>
 
 	* configure: Regenerate.
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index 310f361..72c59f7 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -472,12 +472,6 @@ set_initial_gprs ()
   cpu.gr[PARM4] = cpu.gr[0];
 }
 
-static void
-interrupt ()
-{
-  cpu.asregs.exception = SIGINT;
-}
-
 /* Functions so that trapped open/close don't interfere with the
    parent's functions.  We say that we can't close the descriptors
    that we didn't open.  exit() and cleanup() get in trouble here,
@@ -762,7 +756,6 @@ sim_resume (sd, step, siggnal)
   word ibuf;
   word pc;
   unsigned short inst;
-  void (* sigsave)();
   int memops;
   int bonus_cycles;
   int insts;
@@ -770,7 +763,6 @@ sim_resume (sd, step, siggnal)
   int cycs;
   word WLhash;
 
-  sigsave = signal (SIGINT, interrupt);
   cpu.asregs.exception = step ? SIGTRAP: 0;
   pc = cpu.asregs.pc;
 
@@ -1709,8 +1701,6 @@ sim_resume (sd, step, siggnal)
   cpu.asregs.cycles += insts;		/* and each takes a cycle */
   cpu.asregs.cycles += bonus_cycles;	/* and extra cycles for branches */
   cpu.asregs.cycles += memops * memcycles;	/* and memop cycle delays */
-  
-  signal (SIGINT, sigsave);
 }
 
 
diff --git a/sim/microblaze/ChangeLog b/sim/microblaze/ChangeLog
index 7a3c774..fe6add2 100644
--- a/sim/microblaze/ChangeLog
+++ b/sim/microblaze/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-17  Mike Frysinger  <vapier@gentoo.org>
+
+	PR gdb/16450
+	* interp.c (interrupt): Delete.
+	(sim_resume): Delete signal(SIGINT) handling.
+
 2013-09-23  Alan Modra  <amodra@gmail.com>
 
 	* configure: Regenerate.
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 9e9ed1f..4907b73 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -368,12 +368,6 @@ set_initial_gprs ()
 
 }
 
-static void
-interrupt ()
-{
-  CPU.exception = SIGINT;
-}
-
 /* Functions so that trapped open/close don't interfere with the
    parent's functions.  We say that we can't close the descriptors
    that we didn't open.  exit() and cleanup() get in trouble here,
@@ -515,7 +509,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
   int needfetch;
   word inst;
   enum microblaze_instr op;
-  void (*sigsave)();
   int memops;
   int bonus_cycles;
   int insts;
@@ -532,7 +525,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
   short num_delay_slot; /* UNUSED except as reqd parameter */
   enum microblaze_instr_type insn_type;
 
-  sigsave = signal (SIGINT, interrupt);
   CPU.exception = step ? SIGTRAP : 0;
 
   memops = 0;
@@ -697,8 +689,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
   CPU.cycles += insts;		/* and each takes a cycle */
   CPU.cycles += bonus_cycles;	/* and extra cycles for branches */
   CPU.cycles += memops; 	/* and memop cycle delays */
-
-  signal (SIGINT, sigsave);
 }
 
 
diff --git a/sim/moxie/ChangeLog b/sim/moxie/ChangeLog
index 8ddd163..95daaef 100644
--- a/sim/moxie/ChangeLog
+++ b/sim/moxie/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-17  Mike Frysinger  <vapier@gentoo.org>
+
+	PR gdb/16450
+	* interp.c (interrupt): Delete.
+	(sim_resume): Delete signal(SIGINT) handling.
+
 2013-09-23  Alan Modra  <amodra@gmail.com>
 
 	* configure: Regenerate.
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index 314da4a..63dc8fc 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -157,12 +157,6 @@ set_initial_gprs ()
     cpu.asregs.sregs[i] = 0;
 }
 
-static void
-interrupt ()
-{
-  cpu.asregs.exception = SIGINT;
-}
-
 /* Write a 1 byte value to memory.  */
 
 static void INLINE 
@@ -258,11 +252,9 @@ sim_resume (sd, step, siggnal)
   word pc, opc;
   unsigned long long insts;
   unsigned short inst;
-  void (* sigsave)();
   sim_cpu *scpu = STATE_CPU (sd, 0); /* FIXME */
   address_word cia = CIA_GET (scpu);
 
-  sigsave = signal (SIGINT, interrupt);
   cpu.asregs.exception = step ? SIGTRAP: 0;
   pc = cpu.asregs.regs[PC_REGNO];
   insts = cpu.asregs.insts;
@@ -1022,8 +1014,6 @@ sim_resume (sd, step, siggnal)
   /* Hide away the things we've cached while executing.  */
   cpu.asregs.regs[PC_REGNO] = pc;
   cpu.asregs.insts += insts;		/* instructions done ... */
-
-  signal (SIGINT, sigsave);
 }
 
 int
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index bb57ca1..8c1b09b 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-17  Mike Frysinger  <vapier@gentoo.org>
+
+	PR gdb/16450
+	* interp.c (control_c): Delete.
+	(sim_resume): Delete signal(SIGINT) handling.
+
 2013-09-23  Alan Modra  <amodra@gmail.com>
 
 	* configure: Regenerate.
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index fa77e5f..5689511 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1261,16 +1261,6 @@ trap (i, regs, insn_ptr, memory, maskl, maskw, endianw)
   return 0;
 }
 
-void
-control_c (sig, code, scp, addr)
-     int sig;
-     int code;
-     char *scp;
-     char *addr;
-{
-  raise_exception (SIGINT);
-}
-
 static int
 div1 (R, iRn2, iRn1/*, T*/)
      int *R;
@@ -1979,7 +1969,6 @@ sim_resume (sd, step, siggnal)
   register int endianw = global_endianw;
 
   int tick_start = get_now ();
-  void (*prev) ();
   void (*prev_fpe) ();
 
   register unsigned short *jump_table = sh_jump_table;
@@ -1996,7 +1985,6 @@ sim_resume (sd, step, siggnal)
   register unsigned char *memory;
   register unsigned int sbit = ((unsigned int) 1 << 31);
 
-  prev = signal (SIGINT, control_c);
   prev_fpe = signal (SIGFPE, SIG_IGN);
 
   init_pointers ();
@@ -2134,7 +2122,6 @@ sim_resume (sd, step, siggnal)
     }
 
   signal (SIGFPE, prev_fpe);
-  signal (SIGINT, prev);
 }
 
 int
-- 
1.8.5.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]