Unable to debug native code using GDB Server

1,100 views
Skip to first unread message

iblues

unread,
Jan 13, 2010, 6:45:44 AM1/13/10
to android-ndk
Hi all,

I tried to configure the gdbserver by following the below steps :

Let me elaborate on my setup. I have the device connected onto my
windows machine and a remote linux server for building the code. I
started the gdb server as follows in the adb prompt :

adb> gdbserver localhost:1234 --attach <PID>

Then I did a port forward as follows :

d:\> adb forward tcp:1234 tcp:1234

Running netstat in my windows machine showed the following ::
TCP 127.0.0.1:1234 0.0.0.0:0 LISTENING
1840

Then in Putty, I setting the tunneling as follows :

R1234 -> <IP address of Windows PC>:1234

Putty connects to a Linux build server.

Netstat in Putty shows the following ::

Proto Recv-Q Send-Q Local Address Foreign Address
State Timer

tcp 0 0 127.0.0.1:1234 0.0.0.0:*
LISTEN off (0.00/0/0)

When I open Putty with this tunneling setting and run "arm-eabi-gdb"
and GDB opens properly with (gdb) prompt:

Here , I run the following command:
target remote :1234

and get the following output :
Remote debugging using :1234
putpkt: write failed: Broken pipe.

Please correct me if I am doing any mistake.

Regards,
Syed

David Turner

unread,
Jan 13, 2010, 10:44:47 AM1/13/10
to andro...@googlegroups.com
adb is listening on localhost:1234 on the machine connected to your device, and you setup a network redirection
to <localip>:1234 on the same machine with Putty. This is not going to work because you should instead setup
a redirection to localhost:1234

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
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.




iblues

unread,
Jan 13, 2010, 11:57:13 PM1/13/10
to android-ndk
Thanks David!

The error does not come now. But, now, while executing the target
command,
it fails to load the symbol libraries. It displays the below :

(gdb) target remote :1234
Remote debugging using :1234
Error while mapping shared library sections:
libc.so: No such file or directory.
Error while mapping shared library sections:
libstdc++.so: No such file or directory.
Error while mapping shared library sections:
libm.so: No such file or directory.
Error while mapping shared library sections:
liblog.so: No such file or directory.
Error while mapping shared library sections:
libcutils.so: No such file or directory.
Error while mapping shared library sections:
libz.so: No such file or directory.
Error while mapping shared library sections:
libutils.so: No such file or directory.
...
Error while mapping shared library sections:
libopencore_player.so: No such file or directory.
Error while mapping shared library sections:
libopencore_author.so: No such file or directory.
Error while mapping shared library sections:
libmediaplayerservice.so: No such file or directory.
Reading symbols from /android/out/target/product/generic/symbols/
system/bin/linker...done.
Loaded symbols for /android/out/target/product/generic/symbols/system/
bin/linker
Symbol file not found for libc.so
Symbol file not found for libstdc++.so
Symbol file not found for libm.so
Symbol file not found for liblog.so
Symbol file not found for libcutils.so
Symbol file not found for libz.so
Symbol file not found for libutils.so
...
Symbol file not found for libopencore_player.so
Symbol file not found for libopencore_author.so
Symbol file not found for libmediaplayerservice.so
0x6fe0c53c in ?? ()

In the ADB shell where the GDB server is running, i see the
following ::

gdb: Unable to get location for thread creation breakpoint: requested
event is not supported

I am configuring the mediaserver process for debugging. Even though
the respective so files are present in symbols/system/lib folder, GDB
is not able to link.

Regards.
Syed

> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>

iblues

unread,
Jan 14, 2010, 3:44:33 AM1/14/10
to android-ndk
Hi David,

I resolved this issue too.. Instead of running the arm-eabi-gdb
directly, I ran the gdbclient command (defined in build\envsetup.sh)
as follows :

gdbclient mediaserver :1234 mediaserver

After that, the symbols were able to load properly! I just need to
start putting breakpoints and start debugging.

Thanks for your support! Have a great day..

Regards,
Syed

Chris

unread,
Jan 14, 2010, 7:00:02 AM1/14/10
to android-ndk
Where is build\evsetup.sh? What package does that come with? The NDK?

Chris

unread,
Jan 14, 2010, 7:26:02 AM1/14/10
to android-ndk
Let me clarify my question. I'm assuming that build\envsetup.sh is
part of the PDK? If so, is that a necessary piece to debugging native
code? Why should you need to build the Android platform to debug your
native pieces?

Thanks,
Chris

Umang Saini

unread,
Jan 14, 2010, 7:10:47 AM1/14/10
to andro...@googlegroups.com
Hi Chris,

build\evsetup.sh is part of the Android's full source tree. You'll may get it from http://source.android.com/download

--
Umang



To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

Chris

unread,
Jan 15, 2010, 2:30:54 PM1/15/10
to android-ndk
Thank you. Do you need to actually BUILD the source for the Android OS
in order to use the debugging tools properly?

On Jan 14, 7:10 am, Umang Saini <poloo...@gmail.com> wrote:
> Hi Chris,
>
> build\evsetup.sh is part of the Android's full source tree. You'll may get

> it fromhttp://source.android.com/download
>
> --
> Umang

> > > > > > android-ndk...@googlegroups.com<android-ndk%2Bunsu...@googlegroups.com>


> > <android-ndk%2Bunsubscribe@googlegr oups.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 post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > android-ndk...@googlegroups.com<android-ndk%2Bunsu...@googlegroups.com>

iblues

unread,
Jan 20, 2010, 9:53:45 PM1/20/10
to android-ndk
Hi Chris,

Debugging using GDB uses the symbol information the the shared
library.

If you want to debug only your native code, you need not compile the
entire android source code.
There are so many tutorials in net describing how to debug native
android apps. You can follow the same.

Regards,
Syed Ibrahim

> > > > > > > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>


> > > <android-ndk%2Bunsubscribe@googlegr oups.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 post to this group, send email to andro...@googlegroups.com.
> > > To unsubscribe from this group, send email to

> > > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>

Reply all
Reply to author
Forward
0 new messages