Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [MIPS sim patch] sim_monitor cleanup
@ 2001-02-18 19:27 Ben Elliston
  2001-02-19 11:12 ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Elliston @ 2001-02-18 19:27 UTC (permalink / raw)
  To: cagney, cgd; +Cc: gdb-patches, bje

The following patch gives `sim_monitor' a return type of `int' and
returns meaningful result codes that the caller can use to decide on
appropriate error handling.

Okay to commit?


2001-02-19  Ben Elliston  <bje@redhat.com>

	* sim-main.h (sim_monitor): Return an int.
	* interp.c (sim_monitor): Add return values.
	(signal_exception): Handle error conditions from sim_monitor.

Index: interp.c
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/mips/interp.c,v
retrieving revision 1.196.10.7
diff -u -c -r1.196.10.7 interp.c
*** interp.c	2001/02/16 02:01:42	1.196.10.7
--- interp.c	2001/02/19 03:08:39
***************
*** 1252,1258 ****
  
  
  /* Simple monitor interface (currently setup for the IDT and PMON monitors) */
! void
  sim_monitor (SIM_DESC sd,
  	     sim_cpu *cpu,
  	     address_word cia,
--- 1252,1258 ----
  
  
  /* Simple monitor interface (currently setup for the IDT and PMON monitors) */
! int
  sim_monitor (SIM_DESC sd,
  	     sim_cpu *cpu,
  	     address_word cia,
***************
*** 1482,1492 ****
        }
  
      default:
!       sim_io_error (sd, "TODO: sim_monitor(%d) : PC = 0x%s\n",
! 		    reason, pr_addr(cia));
!       break;
    }
!   return;
  }
  
  /* Store a word into memory.  */
--- 1482,1491 ----
        }
  
      default:
!       /* Unknown reason.  */
!       return 1;
    }
!   return 0;
  }
  
  /* Store a word into memory.  */
***************
*** 1840,1846 ****
            perform this magic. */
         if ((instruction & RSVD_INSTRUCTION_MASK) == RSVD_INSTRUCTION)
  	 {
! 	   sim_monitor (SD, CPU, cia, ((instruction >> RSVD_INSTRUCTION_ARG_SHIFT) & RSVD_INSTRUCTION_ARG_MASK) );
  	   /* NOTE: This assumes that a branch-and-link style
  	      instruction was used to enter the vector (which is the
  	      case with the current IDT monitor). */
--- 1839,1848 ----
            perform this magic. */
         if ((instruction & RSVD_INSTRUCTION_MASK) == RSVD_INSTRUCTION)
  	 {
! 	   int reason = (instruction >> RSVD_INSTRUCTION_ARG_SHIFT) & RSVD_INSTRUCTION_ARG_MASK;
! 	   if (sim_monitor (SD, CPU, cia, reason))
! 	     sim_io_error (sd, "TODO sim_monitor: reason = %d, pc = 0x%s\n", reason, pr_addr (cia));
! 
  	   /* NOTE: This assumes that a branch-and-link style
  	      instruction was used to enter the vector (which is the
  	      case with the current IDT monitor). */

Index: sim-main.h
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/mips/sim-main.h,v
retrieving revision 1.86.10.4
diff -u -c -r1.86.10.4 sim-main.h
*** sim-main.h	2001/02/16 00:32:04	1.86.10.4
--- sim-main.h	2001/02/19 03:17:49
***************
*** 773,779 ****
  #define DecodeCoproc(instruction) \
  decode_coproc (SD, CPU, cia, (instruction))
  
! void sim_monitor (SIM_DESC sd, sim_cpu *cpu, address_word cia, unsigned int arg);
    
  
  
--- 773,779 ----
  #define DecodeCoproc(instruction) \
  decode_coproc (SD, CPU, cia, (instruction))
  
! int sim_monitor (SIM_DESC sd, sim_cpu *cpu, address_word cia, unsigned int arg);


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

* Re: [MIPS sim patch] sim_monitor cleanup
  2001-02-18 19:27 [MIPS sim patch] sim_monitor cleanup Ben Elliston
@ 2001-02-19 11:12 ` Andrew Cagney
  2001-02-19 12:12   ` Ben Elliston
  2001-02-19 14:37   ` Ben Elliston
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cagney @ 2001-02-19 11:12 UTC (permalink / raw)
  To: Ben Elliston; +Cc: cagney, cgd, gdb-patches

Ben Elliston wrote:
> 
> The following patch gives `sim_monitor' a return type of `int' and
> returns meaningful result codes that the caller can use to decide on
> appropriate error handling.

Almost.  I'm fine with the theory just not the implementation.  Reading:

!          int reason = (instruction >> RSVD_INSTRUCTION_ARG_SHIFT) &
RSVD_INSTRUCTION_ARG_MASK;
!          if (sim_monitor (SD, CPU, cia, reason))
!            sim_io_error (sd, "TODO sim_monitor: reason = %d, pc =
0x%s\n", reason, pr_addr (cia));

just looks wierd.

Could sim_monitor() return zero or negative to indicate fail (both are
more common conventions) and perhaphs change ``TODO'' to something more
meanginful :-)

	Andrew


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

* Re: [MIPS sim patch] sim_monitor cleanup
  2001-02-19 11:12 ` Andrew Cagney
@ 2001-02-19 12:12   ` Ben Elliston
  2001-02-19 13:17     ` Andrew Cagney
  2001-02-19 14:37   ` Ben Elliston
  1 sibling, 1 reply; 5+ messages in thread
From: Ben Elliston @ 2001-02-19 12:12 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: cgd, gdb-patches

>>>>> "Andrew" == Andrew Cagney <ac131313@cygnus.com> writes:

  Andrew> Almost.  I'm fine with the theory just not the implementation.  Reading:

  Andrew> !          int reason = (instruction >> RSVD_INSTRUCTION_ARG_SHIFT) &
  Andrew> RSVD_INSTRUCTION_ARG_MASK;
  Andrew> !          if (sim_monitor (SD, CPU, cia, reason))
  Andrew> !            sim_io_error (sd, "TODO sim_monitor: reason = %d, pc =
  Andrew> 0x%s\n", reason, pr_addr (cia));

  Andrew> just looks wierd.

  Andrew> Could sim_monitor() return zero or negative to indicate fail (both are
  Andrew> more common conventions) and perhaphs change ``TODO'' to something more
  Andrew> meanginful :-)

Done.  I've negated the sense of sim_monitor()'s result and the error
message now reads:

  "sim_monitor: unhandled reason = %d, pc = 0x%s\n", reason, pr_addr (cia)

Okay to commit?

Ben


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

* Re: [MIPS sim patch] sim_monitor cleanup
  2001-02-19 12:12   ` Ben Elliston
@ 2001-02-19 13:17     ` Andrew Cagney
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2001-02-19 13:17 UTC (permalink / raw)
  To: Ben Elliston; +Cc: cgd, gdb-patches

Ben Elliston wrote:
> 
> >>>>> "Andrew" == Andrew Cagney <ac131313@cygnus.com> writes:
> 
>   Andrew> Almost.  I'm fine with the theory just not the implementation.  Reading:
> 
>   Andrew> !          int reason = (instruction >> RSVD_INSTRUCTION_ARG_SHIFT) &
>   Andrew> RSVD_INSTRUCTION_ARG_MASK;
>   Andrew> !          if (sim_monitor (SD, CPU, cia, reason))
>   Andrew> !            sim_io_error (sd, "TODO sim_monitor: reason = %d, pc =
>   Andrew> 0x%s\n", reason, pr_addr (cia));
> 
>   Andrew> just looks wierd.
> 
>   Andrew> Could sim_monitor() return zero or negative to indicate fail (both are
>   Andrew> more common conventions) and perhaphs change ``TODO'' to something more
>   Andrew> meanginful :-)
> 
> Done.  I've negated the sense of sim_monitor()'s result and the error
> message now reads:
> 
>   "sim_monitor: unhandled reason = %d, pc = 0x%s\n", reason, pr_addr (cia)
> 
> Okay to commit?

Yes.
	Andrew


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

* Re: [MIPS sim patch] sim_monitor cleanup
  2001-02-19 11:12 ` Andrew Cagney
  2001-02-19 12:12   ` Ben Elliston
@ 2001-02-19 14:37   ` Ben Elliston
  1 sibling, 0 replies; 5+ messages in thread
From: Ben Elliston @ 2001-02-19 14:37 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: cagney, cgd, gdb-patches

Checked in.  Thanks, Andrew.

Ben


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

end of thread, other threads:[~2001-02-19 14:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-18 19:27 [MIPS sim patch] sim_monitor cleanup Ben Elliston
2001-02-19 11:12 ` Andrew Cagney
2001-02-19 12:12   ` Ben Elliston
2001-02-19 13:17     ` Andrew Cagney
2001-02-19 14:37   ` Ben Elliston

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