Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [ping]: [PATCH] Fix that different function breakpoints are set at same pc address  (PR gdb/12703)
Date: Tue, 27 Sep 2011 12:53:00 -0000	[thread overview]
Message-ID: <4E81A8FC.3070905@codesourcery.com> (raw)
In-Reply-To: <4E04692F.3030500@codesourcery.com>

On 06/24/2011 06:38 PM, Yao Qi wrote:
>> > I agree with Yao when he says in the PR that there seems to be
>> > some other root cause for the bug.  Shouldn't
>> > thumb_instruction_changes_pc have caught that "b.n" ?
>> > 
>> > 00008160 <fault_isr>:
>> >     8160:    e7fe          b.n    8160 <fault_isr>
>> >     ...
>> > 
>> > 00008164 <reset_isr>:
>> >     8164:    4a05          ldr    r2, [pc, #20]    ; (817c <reset_isr+0x18>)
>> > 
> thumb_instruction_changes_pc can handle "b.n".  AFAICS, the problem is
> in thumb_analyze_prologue.  In thumb_analyze_prologue, there are a lot
> if/else branches, like below,
> 
>       else if ((insn & 0xe000) == 0xe000)  // <-- [1]
> 	{
>           ....
> 	  else if (thumb2_instruction_changes_pc (insn, inst2))
> 	    {
> 	      /* Don't scan past anything that might change control flow.  */
> 	      break;
> 	    }
> 	  else
> 	    {
> 	      /* The optimizer might shove anything into the prologue,
> 		 so we just skip what we don't recognize.  */
> 	      unrecognized_pc = start;
> 	    }
> 
> 	  start += 2;
> 	}
>       else if (thumb_instruction_changes_pc (insn))
> 	{
> 	  /* Don't scan past anything that might change control flow.  */
> 	  break;
> 	}
> 
> The instruction "b.n 8160" is 0xe7fe, so condition check [1] is true,
> and thumb_instruction_changes_pc is unreachable.  This is cause of this
> problem, I doubt.
> 
> 
> The line of code [1] is discussed in this patch
> 
>   [rfa] ARM prologue parsing support for Thumb-2 instructions
>   http://sourceware.org/ml/gdb-patches/2010-10/msg00132.html
> 
> IIUC, condition check [1] is for 32-bit Thumb-2 instructions (I may be
> wrong, of course).  I have an untested patch.
> 

When talking with Terry Guo on HelloGCC workshop last Saturday in
Beijing, it reminds me that I still have a patch pending there, and
forget to ping it.

  http://sourceware.org/ml/gdb-patches/2011-06/msg00370.html

I regression tested this patch on armv7l-unknown-linux-gnueabi with
{-mthumb, -marm}, no new fails.  OK for mainline?

> 	gdb/
> 	* arm-tdep.c (thumb_analyze_prologue): Check condition for 32-bit
> 	Thumb-2 instructions. 
> 
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index 2dd8c9e..7f5a0e1 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -832,8 +832,9 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
>  	  constant = read_memory_unsigned_integer (loc, 4, byte_order);
>  	  regs[bits (insn, 8, 10)] = pv_constant (constant);
>  	}
> -      else if ((insn & 0xe000) == 0xe000)
> +      else if ((insn & 0xe000) == 0xe000 && (insn & 0x1800) != 0)
>  	{
> +	  /* 32-bit Thumb-2 instructions.  */
>  	  unsigned short inst2;
>  
>  	  inst2 = read_memory_unsigned_integer (start + 2, 2,

-- 
Yao (齐尧)


  reply	other threads:[~2011-09-27 10:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-24  2:31 Terry Guo
2011-06-24  3:55 ` Yao Qi
2011-06-24  8:59   ` Pedro Alves
2011-06-24 10:39     ` Yao Qi
2011-09-27 12:53       ` Yao Qi [this message]
2011-10-09 15:06         ` [ping 2]: " Yao Qi
2011-10-10 14:47       ` [PATCH] Fix that different function breakpoints are set@same " Ulrich Weigand
2011-10-12  0:47         ` Yao Qi
2011-10-12 11:58           ` Ulrich Weigand
2011-10-13  8:19             ` [committed] : " Yao Qi

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=4E81A8FC.3070905@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /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