public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, "Maciej W. Rozycki" <macro@imgtec.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode
Date: Wed, 29 Jun 2016 11:56:00 -0000	[thread overview]
Message-ID: <7898dd6b-7898-44e7-104e-fca326c0b1a7@redhat.com> (raw)
In-Reply-To: <CAH=s-PP26yTpNGU46T-J9kvFrg0UK7A=6h9-bJZyOPjE6SJFdg@mail.gmail.com>

On 06/29/2016 09:39 AM, Yao Qi wrote:
> On Wed, Jun 22, 2016 at 8:04 PM, Maciej W. Rozycki <macro@imgtec.com> wrote:
>>

>>  So how does this work for indirect calls, such as ones made via function
>> pointers, with the ARM target?  With dynamic reassignment such a pointer
>> can change at the run time and with mixed code it can point to regular ARM
>> code sometimes and at other times it can point to Thumb code, still within
>> the same execution of a program.  Can't GDB reproduce the same actions?
>> What do GCC/GAS/LD do with function pointer assignments that GDB can't?
> 
> On ARM target, instruction "blx rm" is generated for indirect call, and "rm" has
> the target address, plus ISA bit if needed.  If the target function is ARM code,
> "rm" has the target function address, otherwise, it has the thumb
> target function
> address with LSB set.  I want to make it clear that, although thumb function
> symbol value has LSB set, which only indicates this is a thumb function, the
> function address is still 2-byte aligned.  All these ISA bit set/clear
> is managed
> by LD.

I think the question is what happens at run time, when a function
pointer is set to a thumb function.  Say, with something like this:

typedef void (func_ptr) (void);

void arm_function (void);
void thumb_function (void); // add whatever __attribute__ necessary
                            // for thumb.

func_ptr *ptr;

void foo (void)
{
   ptr = thumb_function;
   ptr ();  // stop here
}

Does "ptr" hold an address with the LSB set at run time, somehow?
I assume it does.

Then, doesn't this in gdb:

 (gdb) print ptr = thumb_function

end up with the same value (LSB set)?  If not, seems like that's a bug.


Note that from the original commit log, one can't tell what
exactly goes wrong in the test that requires skipping it.  It talks
in terms of Maciej's patch, and how some prototype based on that
behaves, and not in terms of what is wrong with the current support, or
if there's something the test is doing that is fundamentally impossible
to do on arm.

Thanks,
Pedro Alves

  reply	other threads:[~2016-06-29 11:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-13 10:12 Yao Qi
2016-06-22 19:05 ` Maciej W. Rozycki
2016-06-29  8:40   ` Yao Qi
2016-06-29 11:56     ` Pedro Alves [this message]
2016-06-29 16:25       ` Yao Qi
2016-06-29 16:31         ` 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=7898dd6b-7898-44e7-104e-fca326c0b1a7@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@imgtec.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).