This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: "Maciej W. Rozycki" <macro at imgtec dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 29 Jun 2016 17:31:18 +0100
- Subject: Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode
- Authentication-results: sourceware.org; auth=none
- References: <1465812702-22061-1-git-send-email-yao dot qi at linaro dot org> <alpine dot DEB dot 2 dot 00 dot 1606210234110 dot 7182 at tp dot orcam dot me dot uk> <CAH=s-PP26yTpNGU46T-J9kvFrg0UK7A=6h9-bJZyOPjE6SJFdg at mail dot gmail dot com> <7898dd6b-7898-44e7-104e-fca326c0b1a7 at redhat dot com> <CAH=s-PPL_sNLmGroc01Y7i0ch8Th0s56z=gGVUdYEDdZLqQk6w at mail dot gmail dot com>
On 06/29/2016 05:25 PM, Yao Qi wrote:
> On Wed, Jun 29, 2016 at 12:55 PM, Pedro Alves <palves@redhat.com> wrote:
>>
>> 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.
>
> Yes, 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.
>>
>
> ptr doesn't have LSB set, because the value of symbol "thumb_function"
> doesn't have LSB set in GDB.
>
>> 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.
>
> The test has nothing wrong, but current approach, added by Maciej, can't
> be extended for ARM thumb mode, as a result of my investigation and
> prototype. In current approach, we propagate ISA bit of address into symbols
> and line tables, and that works for MIPS. In ARM, the LSB of address
> only indicates that instruction set will be changed to thumb, and
> function is still
> 2-byte aligned. For example, thumb_function's address is 0x00010510, and
> it really starts from there. We only set LSB of address, or set it to
> 0x00010511,
> when it is the target address of branch with changing mode from arm to thumb.
> Set LSB of address in other places make no sense to ARM.
Agreed.
>
> I also find that gdb.base/func-ptrs.exp fails on ppc64, due to the function
> descriptor. GDB should assign function descriptor to the pointer rather than
> the function address. I am thinking maybe we can use a different approach
> for arm and ppc64, that is, when we do function pointer assignment, use a
> gdbarch method to adjust the result, on arm, if the result is the entry of a
> thumb function, set its LSB; on ppc64, if the result is the entry of a function,
> set it to the address of function descriptor. However, I don't know where is
> the best place (in expression evaluation?) to adjust the result of function
> pointer assignment.
Off hand, I'd think somewhere around value_assign / value_cast / value_cast_pointers.
Thanks,
Pedro Alves