Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [preliminary patch] sim/h8300/compile.c: abort when abort is called.
@ 2003-06-24  8:14 Kazu Hirata
  2003-06-24 16:18 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Kazu Hirata @ 2003-06-24  8:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: msnyder, rsandifo, aoliva, vinschen, dvenkat

Hi,

Attached is a patch to teach the h8300 simulator to abort when abort
is called.  Without this, I get spurious XPASS when testing gcc.
Although the patched simulator works, my gut feeling is telling me
that there should be a better way to do this.  Any thought?

By the way, the last h8300-side function that causes the simulator to
abort is _kill() in newlib/libc/sys/h8300hms/misc.c, which in turn
issues sleep instruction.

Kazu Hirata

2003-06-24  Kazu Hirata  <kazu@cs.umass.edu>

	* compile.c (sim_resume): Abort when sleep instruction is used
	without the magic number.

Index: compile.c
===================================================================
RCS file: /cvs/src/src/sim/h8300/compile.c,v
retrieving revision 1.31
diff -u -r1.31 compile.c
--- compile.c	19 Jun 2003 02:14:14 -0000	1.31
+++ compile.c	24 Jun 2003 07:40:12 -0000
@@ -3577,8 +3577,7 @@
 	    }
 	  else
 	    {
-	      /* Treat it as a sigtrap.  */
-	      sim_engine_set_run_state (sd, sim_stopped, SIGTRAP);
+	      abort ();
 	    }
 	  goto end;
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [preliminary patch] sim/h8300/compile.c: abort when abort is called.
  2003-06-24  8:14 [preliminary patch] sim/h8300/compile.c: abort when abort is called Kazu Hirata
@ 2003-06-24 16:18 ` Andrew Cagney
  2003-06-24 23:03   ` Michael Snyder
  2003-06-24 23:04   ` Michael Snyder
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Cagney @ 2003-06-24 16:18 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: gdb-patches, msnyder, rsandifo, aoliva, vinschen, dvenkat

> Hi,
> 
> Attached is a patch to teach the h8300 simulator to abort when abort
> is called.  Without this, I get spurious XPASS when testing gcc.
> Although the patched simulator works, my gut feeling is telling me
> that there should be a better way to do this.  Any thought?

Yes.  Generally speaking, the simulators should not call abort.  Instead 
they should, some how, stop the simulation and return to the caller. 
That statement looks to be trying to do just that.  I think MichaelS 
recently changed sim/common to, for the h8300 do a correct exit.

2003-06-04  Michael Snyder  <msnyder@redhat.com>

         * common/run.c (main): Remove SIM_H8300 ifdef.
         (usage): Ditto.
         * common/sim-options.c (STANDARD_OPTIONS): Add SIM_H8300SX.
         (standard_options): Add '-x' for h8/300sx.
         (standard_option_handler): Add case for SIM_H8300SX.

suggest studying that code.

Andrew


> Kazu Hirata
> 
> 2003-06-24  Kazu Hirata  <kazu@cs.umass.edu>
> 
> 	* compile.c (sim_resume): Abort when sleep instruction is used
> 	without the magic number.
> 
> Index: compile.c
> ===================================================================
> RCS file: /cvs/src/src/sim/h8300/compile.c,v
> retrieving revision 1.31
> diff -u -r1.31 compile.c
> --- compile.c	19 Jun 2003 02:14:14 -0000	1.31
> +++ compile.c	24 Jun 2003 07:40:12 -0000
> @@ -3577,8 +3577,7 @@
>  	    }
>  	  else
>  	    {
> -	      /* Treat it as a sigtrap.  */
> -	      sim_engine_set_run_state (sd, sim_stopped, SIGTRAP);
> +	      abort ();
>  	    }
>  	  goto end;
>  
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [preliminary patch] sim/h8300/compile.c: abort when abort is called.
  2003-06-24 16:18 ` Andrew Cagney
@ 2003-06-24 23:03   ` Michael Snyder
  2003-06-25 21:39     ` Kazu Hirata
  2003-06-24 23:04   ` Michael Snyder
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2003-06-24 23:03 UTC (permalink / raw)
  To: Andrew Cagney
  Cc: Kazu Hirata, gdb-patches, rsandifo, aoliva, vinschen, dvenkat

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

Andrew Cagney wrote:
>> Hi,
>>
>> Attached is a patch to teach the h8300 simulator to abort when abort
>> is called.  Without this, I get spurious XPASS when testing gcc.
>> Although the patched simulator works, my gut feeling is telling me
>> that there should be a better way to do this.  Any thought?
> 
> 
> Yes.  Generally speaking, the simulators should not call abort.  Instead 
> they should, some how, stop the simulation and return to the caller. 
> That statement looks to be trying to do just that.  I think MichaelS 
> recently changed sim/common to, for the h8300 do a correct exit.

Yeah, and I didn't think about the stop signal, but it seems
like we're ready to do that too.  Kazu, try this, and with your
approval I'll check it in.


[-- Attachment #2: signals --]
[-- Type: text/plain, Size: 1826 bytes --]

2003-06-24  Michael Snyder  <msnyder@redhat.com>

	* sim-main.h (SIM_WIFSTOPPED, SIM_WSTOPSIG): Define.
	* compile.c (sim_resume): Use the above to return stop signal.

Index: sim-main.h
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/h8sx/sim-main.h,v
retrieving revision 1.13
diff -p -r1.13 sim-main.h
*** sim-main.h	2003/06/18 11:51:39	1.13
--- sim-main.h	2003/06/24 22:13:22
*************** struct sim_state {
*** 164,170 ****
  /* Local version of macros for decoding exit status.  
     (included here rather than try to find target version of wait.h)
  */
! #define SIM_WIFEXITED(V) (((V) & 0xff) == 0)
! #define SIM_WEXITSTATUS(V) ((V) >> 8)
  
  #endif /* SIM_MAIN_H */
--- 164,172 ----
  /* Local version of macros for decoding exit status.  
     (included here rather than try to find target version of wait.h)
  */
! #define SIM_WIFEXITED(V)	(((V) & 0xff) == 0)
! #define SIM_WIFSTOPPED(V)	(!SIM_WIFEXITED (V))
! #define SIM_WEXITSTATUS(V)	(((V) >> 8) & 0xff)
! #define SIM_WSTOPSIG(V)		((V) & 0x7f)
  
  #endif /* SIM_MAIN_H */
Index: compile.c
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/h8sx/compile.c,v
retrieving revision 1.84
diff -p -r1.84 compile.c
*** compile.c	2003/06/19 04:18:52	1.84
--- compile.c	2003/06/24 22:13:22
*************** sim_resume (SIM_DESC sd, int step, int s
*** 3575,3580 ****
--- 3575,3586 ----
  	      sim_engine_set_run_state (sd, sim_exited, 
  					SIM_WEXITSTATUS (h8_get_reg (sd, 0)));
  	    }
+ 	  else if (SIM_WIFSTOPPED (h8_get_reg (sd, 0)))
+ 	    {
+ 	      /* Pass the stop signal up to gdb.  */
+ 	      sim_engine_set_run_state (sd, sim_stopped, 
+ 					SIM_WSTOPSIG (h8_get_reg (sd, 0)));
+ 	    }
  	  else
  	    {
  	      /* Treat it as a sigtrap.  */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [preliminary patch] sim/h8300/compile.c: abort when abort is called.
  2003-06-24 16:18 ` Andrew Cagney
  2003-06-24 23:03   ` Michael Snyder
@ 2003-06-24 23:04   ` Michael Snyder
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2003-06-24 23:04 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew,

Re: sim and abort/SIGABRT, I discovered something interesting when
I fixed the h8 simulator so that it would return SIGABRT to gdb.
Thanks to these lines in remote-sim.c,


     case sim_stopped:
       switch (sigrc)
	{
         case SIGABRT:
           quit ();
           break;
         case SIGINT:
         case SIGTRAP:
         default:
           status->kind = TARGET_WAITKIND_STOPPED;

instead of saying "program stopped with signal SIGABRT",
gdb says "Quit." and detaches from the target.

Have you any idea why it's doing that?

Michael


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [preliminary patch] sim/h8300/compile.c: abort when abort is called.
  2003-06-24 23:03   ` Michael Snyder
@ 2003-06-25 21:39     ` Kazu Hirata
  2003-07-02 19:06       ` Michael Snyder
  0 siblings, 1 reply; 6+ messages in thread
From: Kazu Hirata @ 2003-06-25 21:39 UTC (permalink / raw)
  To: msnyder; +Cc: ac131313, gdb-patches, rsandifo, aoliva, vinschen, dvenkat

Hi Michael,

> Yeah, and I didn't think about the stop signal, but it seems
> like we're ready to do that too.  Kazu, try this, and with your
> approval I'll check it in.

Thanks!  This patch works.  If I use abort(), I get "program stopped
with signal 6", which is correct.  Without this patch, I get "program
stopped with signal 5."

p.s.
Actually, even without this, your patch to nrun.c seems to be enough
for running gcc testsuite.

Kazu Hirata


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [preliminary patch] sim/h8300/compile.c: abort when abort is called.
  2003-06-25 21:39     ` Kazu Hirata
@ 2003-07-02 19:06       ` Michael Snyder
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2003-07-02 19:06 UTC (permalink / raw)
  To: Kazu Hirata; +Cc: ac131313, gdb-patches, rsandifo, aoliva, vinschen, dvenkat

Kazu Hirata wrote:
> Hi Michael,
> 
> 
>>Yeah, and I didn't think about the stop signal, but it seems
>>like we're ready to do that too.  Kazu, try this, and with your
>>approval I'll check it in.
> 
> 
> Thanks!  This patch works.  If I use abort(), I get "program stopped
> with signal 6", which is correct.  Without this patch, I get "program
> stopped with signal 5."

OK, committed.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-07-02 19:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-24  8:14 [preliminary patch] sim/h8300/compile.c: abort when abort is called Kazu Hirata
2003-06-24 16:18 ` Andrew Cagney
2003-06-24 23:03   ` Michael Snyder
2003-06-25 21:39     ` Kazu Hirata
2003-07-02 19:06       ` Michael Snyder
2003-06-24 23:04   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox