Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdbarch software_single_step returns VEC (CORE_ADDR) *
Date: Wed, 23 Mar 2016 17:25:00 -0000	[thread overview]
Message-ID: <56F2D1A2.80103@redhat.com> (raw)
In-Reply-To: <1458742206-622-2-git-send-email-yao.qi@linaro.org>

On 03/23/2016 02:10 PM, Yao Qi wrote:

 
> However, breakpoint insertion in arm is a little different, which
> uses arm_insert_single_step_breakpoint, and it updates a global
> variable arm_override_mode, so that arm_pc_is_thumb can get the
> right arm thumb mode even the program is wrong (see
> gdb.arch/thumb-singlestep.exp).  I failed to remove global variable
> arm_override_mode, so have to add a new gdbarch method
> insert_single_step_breakpoint, which is in default
> insert_single_step_breakpoint for all targets except arm.
> 

I think the problem is the ambiguity in arm_breakpoint_from_pc,
and to the fact that we don't "normalize" breakpoint addresses
before passing them down to target_insert_breakpoint. 

Some callers start with an address coming from the user and want
to consult symbol tables / mapping symbols.  Other caller really
want to trust the thumb bit as set in the address.

Note that arm_breakpoint_from_pc uses arm_pc_is_thumb, which is
what consults symbol tables / mapping symbols.

I think the fix would to make arm_breakpoint_from_pc always trust
that the address bit is already encoded correctly, and trust
IS_THUMB_ADDR, similarly to how the gdbserver version does, in
arm_breakpoint_kind_from_pc.

Then, we'd still need to consult the mapping symbols
consultation, or IOW, do something based on arm_pc_is_thumb _before_
target_insert_breakpoint is reached.  That is, call something like
arm_pc_is_thumb and use the result to encode the thumb bit correctly in
the address passed to target_insert_breakpoint.  IOW, "normalize" the
target address, using some gdbarch method, _before_ that address is passed
to the target routines in the first place.

Along the way, several other functions would stop using arm_pc_is_thumb,
but use IS_THUMB_ADDR directly.  E.g., arm_remote_breakpoint_from_pc.

WDYT?


> -# A return value of 1 means that the software_single_step breakpoints
> -# were inserted; 0 means they were not.
> -F:int:software_single_step:struct frame_info *frame:frame
> +# Return a vector of addresses on which the software single step
> +# breakpoints are inserted.  NULL means software single step is not used.

s/are inserted/should be inserted/

> +F:VEC (CORE_ADDR) *:software_single_step:struct frame_info *frame:frame
> +
> +m:void:insert_single_step_breakpoint:struct address_space *aspace, CORE_ADDR pc:aspace, pc::insert_single_step_breakpoint::0
>   
>   # Return non-zero if the processor is executing a delay slot and a
>   # further single-step is needed before the instruction finishes.
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 696105d..5dbcf7a 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -2248,11 +2248,28 @@ maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc)
>     int hw_step = 1;
>   
>     if (execution_direction == EXEC_FORWARD
> -      && gdbarch_software_single_step_p (gdbarch)
> -      && gdbarch_software_single_step (gdbarch, get_current_frame ()))
> +      && gdbarch_software_single_step_p (gdbarch))
>       {
> -      hw_step = 0;
> +      struct frame_info *frame = get_current_frame ();
> +      VEC (CORE_ADDR) * next_pcs;
> +
> +      next_pcs = gdbarch_software_single_step (gdbarch, frame);
> +
> +      if (next_pcs != NULL)
> +	{
> +	  int i;
> +	  CORE_ADDR pc;
> +	  struct address_space *aspace = get_frame_address_space (frame);
> +
> +	  hw_step = 0;
> +
> +	  for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); i++)
> +	    gdbarch_insert_single_step_breakpoint (gdbarch, aspace, pc);
> +
> +	  VEC_free (CORE_ADDR, next_pcs);
> +	}

This pattern of starting from a VEC of addresses, and a frame and
calling gdbarch_insert_single_step_breakpoint on each address
appears multiple times.  Can we put it in a convenience function?

Though the other calls in record-full.c didn't go through
gdbarch_insert_single_step_breakpoint -- why's that?

Otherwise, this is fine with me.   

Thanks,
Pedro Alves


  reply	other threads:[~2016-03-23 17:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-23 14:10 [PATCH 0/2] " Yao Qi
2016-03-23 14:10 ` [PATCH 2/2] Remove gdbarch method displaced_step_hw_singlestep Yao Qi
2016-03-23 17:26   ` Pedro Alves
2016-05-09 11:05     ` Yao Qi
2016-03-23 14:10 ` [PATCH 1/2] gdbarch software_single_step returns VEC (CORE_ADDR) * Yao Qi
2016-03-23 17:25   ` Pedro Alves [this message]
2016-03-30 14:14     ` Yao Qi
2016-04-27 15:19       ` Pedro Alves
2016-04-29 14:48         ` Yao Qi
2016-05-02 10:21           ` Pedro Alves

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=56F2D1A2.80103@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.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