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: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat 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:25:47 +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>
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.
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.
--
Yao (éå)