Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@arm.com>
To: mckennad@esatclear.ie
Cc: Richard Earnshaw <rearnsha@arm.com>,
	gdb@sources.redhat.com, insight@sources.redhat.com,
	nickc@redhat.com
Subject: Re: ARM Simulator Bug?
Date: Thu, 04 Sep 2003 11:45:00 -0000	[thread overview]
Message-ID: <200309041144.h84Bio518885@pc960.cambridge.arm.com> (raw)
In-Reply-To: Your message of "Wed, 03 Sep 2003 16:19:48 BST." <200309031519.h83FJmX18357@pc960.cambridge.arm.com>

Ok, the executive summary on this is that gdb seems to have done the right 
thing (inserted a Thumb breakpoint at the appropriate point), but the 
simulator is ignoring this by treating it as a nop.  That's not very 
helpful, especially since it's then "nop"ped out a real instruction.

The reason that the behaviour changes when you drop in your link script is 
that it causes a SWI vector to be installed (at least, it does according 
to the primitive logic in the simulator), and hence SWI_vector_installed 
becomes true.

What happens is that the Thumb decoder translates the instruction into an 
ARM BKPT instruction, and it then runs the following ARM code to handle 
that:

	      if (state->is_v5)
		{
		  if (BITS (4, 7) == 0x7)
		    {
		      ARMword value;
		      extern int SWI_vector_installed;

		      /* Hardware is allowed to optionally override this
			 instruction and treat it as a breakpoint.  Since
			 this is a simulator not hardware, we take the position
			 that if a SWI vector was not installed, then an Abort
			 vector was probably not installed either, and so
			 normally this instruction would be ignored, even if an
			 Abort is generated.  This is a bad thing, since GDB
			 uses this instruction for its breakpoints (at least in
			 Thumb mode it does).  So intercept the instruction here
			 and generate a breakpoint SWI instead.  */
		      if (! SWI_vector_installed)
			ARMul_OSHandleSWI (state, SWI_Breakpoint);
		      else
			{
			  /* BKPT - normally this will cause an abort, but on the
			     XScale we must check the DCSR.  */
			  XScale_set_fsr_far (state, ARMul_CP15_R5_MMU_EXCPT, pc);
	                  if (!XScale_debug_moe (state, ARMul_CP14_R10_MOE_BT))
			    break;
			}

		      /* Force the next instruction to be refetched.  */
		      state->NextInstr = RESUME;
		      break;


Now, since SWI_vector_installed is true, we don't call ARMul_OSHandleSWI 
for this case, so the debugger never gets re-entered (normally done 
through SWI_Breakpoint).

I think the code should call ARMul_UndefInstr() if there isn't a specific 
handler for it.  The argument that if there isn't a SWI handler then there 
won't be an abort handler seems specious -- it's not an abort anyway.

This is all a mess.  But I'm not sure right now how best to start 
untangling it.

R.


  reply	other threads:[~2003-09-04 11:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-03 14:57 David Mc Kenna
2003-09-03 15:20 ` Richard Earnshaw
2003-09-04 11:45   ` Richard Earnshaw [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-09-03 10:36 David Mc Kenna
2003-09-03 13:53 ` Richard Earnshaw
2003-09-03  9:13 David Mc Kenna
2003-09-03  9:51 ` Richard Earnshaw
2003-09-02 14:31 David Mc Kenna
2003-09-02 18:17 ` Richard Earnshaw
2003-09-02 11:27 David Mc Kenna
2003-09-02 12:43 ` Richard Earnshaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200309041144.h84Bio518885@pc960.cambridge.arm.com \
    --to=rearnsha@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gdb@sources.redhat.com \
    --cc=insight@sources.redhat.com \
    --cc=mckennad@esatclear.ie \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox