This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode


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 (éå)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]