How to debug/display Thumb instructions on GDB of Android NDK?

1,207 views
Skip to first unread message

Samuel

unread,
May 21, 2012, 10:34:21 PM5/21/12
to andro...@googlegroups.com
Hello,

I use gdb's "x" command, for example:

   x/20i *0xb0006800

It displays wrong ARM instructions, because the data of this memory area are Thumb instructions.

But I can't display Thumb instructions on NDK GDB, how to enable Thumb instructions debug on Android NDK GDB?

Sam

Mārtiņš Možeiko

unread,
May 21, 2012, 11:24:41 PM5/21/12
to andro...@googlegroups.com
Have you tried looking in GDB manual?
http://sourceware.org/gdb/current/onlinedocs/gdb/ARM.html

--
Mārtiņš Možeiko
> --
> You received this message because you are subscribed to the Google Groups
> "android-ndk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-ndk/-/rhKGPooHtVwJ.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-ndk...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-ndk?hl=en.

Samuel

unread,
May 22, 2012, 1:57:31 AM5/22/12
to andro...@googlegroups.com
Daer Mārtiņš Možeiko,

Thank you for your reply.

Did Sourceware's GDB can connect the GDB Server which prebuilt and provided by Android NDK?

Sam

On Tuesday, May 22, 2012 11:24:41 AM UTC+8, Mārtiņš Možeiko wrote:
Have you tried looking in GDB manual?
http://sourceware.org/gdb/current/onlinedocs/gdb/ARM.html

--
Mārtiņš Možeiko


On Mon, May 21, 2012 at 7:34 PM, Samuel <s...@samuel.pro> wrote:
> Hello,
>
> I use gdb's "x" command, for example:
>
>    x/20i *0xb0006800
>
> It displays wrong ARM instructions, because the data of this memory area are
> Thumb instructions.
>
> But I can't display Thumb instructions on NDK GDB, how to enable
> Thumb instructions debug on Android NDK GDB?
>
> Sam
>
> --
> You received this message because you are subscribed to the Google Groups
> "android-ndk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-ndk/-/rhKGPooHtVwJ.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to

David Turner

unread,
May 22, 2012, 3:51:55 AM5/22/12
to andro...@googlegroups.com
On ARM, the low order bit of an function address is used to determine if the corresponding code is 32-bit ARM (set to 0), or 16-bit Thumb (set to 1).

In other words:

  x/20i *0xb0006800    -> will display 20 32-bit ARM instructions starting at address 0xb0006800
  x/20i *0xb0006801    -> will display 20 16-bit Thumb instructions starting at address 0xb0006800

Only the lower bit value changes.

I'm surprised this isn't in the ARM-specific portion of the GDB manual.

Hope this helps


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/rhKGPooHtVwJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

Mārtiņš Možeiko

unread,
May 22, 2012, 10:11:14 PM5/22/12
to andro...@googlegroups.com
"Sourceware's GDB" is THE gdb It is homepage of GDB. Android uses GDB,
so manual from "Sourceware" works for any GDB. There is nothing
special needed to connect with something.

--
Martins Mozeiko
>> > android-ndk...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/android-ndk?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "android-ndk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-ndk/-/Zl4s0ePM89MJ.
>
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-ndk...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-ndk?hl=en.



--
Mārtiņš Možeiko

邓尧

unread,
May 22, 2012, 10:45:50 PM5/22/12
to andro...@googlegroups.com
I built my own gdb-7.4. then set fallback mode with command:
    set arm fallback-mode thumb
It seems that the gdb provided by android-ndk doesn't support this command. Personally, I prefer "disassemble" command to check instructions:
    disassemble 0xb0006800,+40

Thanks
Yao

--
Reply all
Reply to author
Forward
0 new messages