Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <alves.ped@gmail.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] use gdbarch_addr_bits_remove for entry point address
Date: Fri, 23 Nov 2012 19:58:00 -0000	[thread overview]
Message-ID: <50AFD573.1090601@gmail.com> (raw)
In-Reply-To: <1353404184-22073-1-git-send-email-yao@codesourcery.com>

On 11/20/2012 09:36 AM, Yao Qi wrote:

> This patch attempts to clear the lsb of the entry address, which might
> be set by compiler for thumb code.
> 
> This patch does something similar to this one,
> 
>   RFC: Handle ISA bits for the entry point
>   http://sourceware.org/ml/gdb-patches/2009-07/msg00682.html
> 
> Regression tested on arm-none-linux-gnueabi.  Is it OK?
> 
> gdb:
> 
> 2012-11-20  Daniel Jacobowitz  <dan@codesourcery.com>
> 	    Kazu Hirata  <kazu@codesourcery.com>
> 	    Yao Qi  <yao@codesourcery.com>
> 
> 	* objfiles.c (init_entry_point_info): Use gdbarch_addr_bits_remove.
> 	* solib-svr4.c (exec_entry_point): Likewise.
> 	* symfile.c (generic_load): Call gdbarch_addr_bits_remove on
> 	the entry address.
> ---
>  gdb/objfiles.c   |    5 +++++
>  gdb/solib-svr4.c |    5 ++++-
>  gdb/symfile.c    |    1 +
>  3 files changed, 10 insertions(+), 1 deletions(-)
> 
> diff --git a/gdb/objfiles.c b/gdb/objfiles.c
> index a1db8c6..3374c68 100644
> --- a/gdb/objfiles.c
> +++ b/gdb/objfiles.c
> @@ -353,6 +353,11 @@ init_entry_point_info (struct objfile *objfile)
>        /* Examination of non-executable.o files.  Short-circuit this stuff.  */
>        objfile->ei.entry_point_p = 0;
>      }
> +
> +  if (objfile->ei.entry_point_p)
> +    objfile->ei.entry_point
> +      = gdbarch_addr_bits_remove (objfile->gdbarch,
> +				  objfile->ei.entry_point);
>  }

If this is needed here, then it would look to me that  gdbarch_convert_from_func_ptr_addr
would be needed too.  See the function right below  init_entry_point_info:

/* If there is a valid and known entry point, function fills *ENTRY_P with it
   and returns non-zero; otherwise it returns zero.  */

int
entry_point_address_query (CORE_ADDR *entry_p)
{
  struct gdbarch *gdbarch;
  CORE_ADDR entry_point;

  if (symfile_objfile == NULL || !symfile_objfile->ei.entry_point_p)
    return 0;

  gdbarch = get_objfile_arch (symfile_objfile);

  entry_point = symfile_objfile->ei.entry_point;

  /* Make certain that the address points at real code, and not a
     function descriptor.  */
  entry_point = gdbarch_convert_from_func_ptr_addr (gdbarch, entry_point,
						    &current_target);

  /* Remove any ISA markers, so that this matches entries in the
     symbol table.  */
  entry_point = gdbarch_addr_bits_remove (gdbarch, entry_point);

  *entry_p = entry_point;
  return 1;
}

So you if put the gdbarch_addr_bits_remove call in init_entry_point_info,
ISTM the same call in entry_point_address_query is no longer necessary.  And
that it'd be better to move gdbarch_convert_from_func_ptr_addr too, I'd think (and I
don't know if there's an order they should be called in; moving both preserves the order).
Maybe there are yet other callers that could have gdbarch_addr_bits_remove calls
removed as redundant too, I haven't checked.

-- 
Pedro Alves


  reply	other threads:[~2012-11-23 19:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20  9:36 Yao Qi
2012-11-23 19:58 ` Pedro Alves [this message]
2012-11-24 11:14   ` Yao Qi
2012-11-26 11:57     ` Pedro Alves
2012-11-27  8:12       ` Yao Qi
2012-12-13 12:05     ` crash/regression with ia64 targets (was: "Re: [PATCH] use gdbarch_addr_bits_remove for entry point address") Joel Brobecker
2012-12-13 14:13       ` crash/regression with ia64 targets Yao Qi
2012-12-14 15:33         ` Joel Brobecker
2012-12-13 18:36       ` Pedro Alves
2012-12-14 15:14         ` Joel Brobecker
2012-12-15 13:12           ` checked in: " Joel Brobecker
2012-12-14 15:15       ` Tom Tromey
2012-12-14 15:33         ` Joel Brobecker
2012-12-15 13:14           ` Joel Brobecker

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=50AFD573.1090601@gmail.com \
    --to=alves.ped@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.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