Can't get GDB to connect to my device

3,491 views
Skip to first unread message

Grant

unread,
Aug 25, 2010, 9:50:44 PM8/25/10
to android-ndk
For some reason I can't connect the debugger to my device.

I've compiled the program for debugging (setup the manifest's
application tag with the attribute 'android:debuggable="true"' and
added '-D _DEBUG' to LOCAL_CFLAGS). On the device I've set it to debug
my application in the Dev tools and told it to wait for the debugger
at the start of the app. On my pc (WinXP) I've called 'adb start-
server' and then run 'ddms.bat' (which connects fine and I can see the
app with a red "bug" icon next to the name once I start it).

The program sits there with the "Waiting For Debugger" message but
when I try to run 'ndk-gdb' from my project directory, I get the
following:

petersg@q6600b /cygdrive/d/projects/phonedev/<project>/main-dev/
android
$ $ANDROID_NDK/ndk-gdb --adb=$ANDROID_SDK/tools/adb.exe
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf-
linux".
/cygdrive/d/projects/phonedev/<project>/main-dev/android/obj/local/
armeabi/gdb
.setup:5: Error in sourced command file:
Remote communication error: Connection reset by peer.
(gdb)

This has been annoying me for almost a day now and haven't been able
to make any real headway into the problem.

Thanks,
Grant

alan

unread,
Aug 26, 2010, 4:37:54 AM8/26/10
to android-ndk
which device are you using?

David Turner

unread,
Aug 27, 2010, 8:14:51 AM8/27/10
to andro...@googlegroups.com
this is weird, it looks like it's invoking the gdb binary with incorrect arguments.
what is the output of ndk-gdb if you use the --verbose option ?


--
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.


Grant

unread,
Aug 29, 2010, 8:54:50 PM8/29/10
to android-ndk
Sorry about the late reply, haven't been in the office until now,

Here's what I get from the --verbose option

Android NDK installation path: /cygdrive/d/Android/android-ndk-r4b
Using specific adb command: D:\Android\android-sdk-windows/tools/
adb.exe
ADB version found: Android Debug Bridge version 1.0.26
Using final ADB command: 'D:\Android\android-sdk-windows/tools/
adb.exe'
Using auto-detected project path: .
Found package name: com.mycompany.project
Found debuggable flag: true
ABIs targetted by application: armeabi
Device API Level: 8
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found device gdbserver: /data/data/com.mycompany.project/lib/gdbserver
Using gdb setup init: /cygdrive/d/projects/phonedev/<project>/main-dev/
android/libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/d/Android/android-ndk-r4b/build/
prebuilt/windows/arm-eabi-4.4.0/bin/arm-eabi-
Using app out directory: /cygdrive/d/projects/phonedev/<project>/main-
dev/android/obj/local/armeabi
Found data directory: '/data/data/com.mycompany.project'
Found first launchable activity: ProjectActivity
Launching activity: com.mycompany.project/ProjectActivity
##### NEW COMMAND
D:\Android\android-sdk-windows/tools/adb.exe shell am start -n
com.mycompany.project/ProjectActivity
Starting: Intent { cmp=com.mycompany.project/ProjectActivity }

Error type 3

Error: Activity class {com.mycompany.project/ProjectActivity} does not
exist.

##### NEW COMMAND
D:\Android\android-sdk-windows/tools/adb.exe shell sleep 1
Found running PID: 1759
Launched gdbserver succesfully.
Setup network redirection
##### NEW COMMAND
##### NEW COMMAND
D:\Android\android-sdk-windows/tools/adb.exe shell run-as
com.mycompany.project lib/gdbserver +debug-socket --attach 1759
D:\Android\android-sdk-windows/tools/adb.exe forward tcp:5039
localfilesystem:/data/data/com.mycompany.project/debug-socket
[1] Segmentation fault run-as com.mycom...

##### NEW COMMAND
D:\Android\android-sdk-windows/tools/adb.exe pull /system/bin/
app_process D:/projects/phonedev/<project>/main-dev/android/obj/local/
armeabi/app_process
354 KB/s (0 bytes in 5680.000s)
Pulled from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf-
linux".
/cygdrive/d/projects/phonedev/<project>/main-dev/android/obj/local/
armeabi/gdb.setup:5: Error in sourced command file:
Remote communication error: Connection reset by peer.
(gdb)


I get the same results if I run this with the "wait for debugger"
option enabled or have an infinite loop with the native code, i.e. it
doesn't seem to depend on the state of the app.

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

Rutton

unread,
Aug 31, 2010, 8:57:23 AM8/31/10
to android-ndk
I also get that error "Connection reset by peer" with debugging on the
simulator quite often, but after invoking ndk-gdb a couple of times,
debugging works sometimes.

Is there any rough ETA, when wonky debugging (with this error) and
disfunctional debugging of multi-threaded apps (especially for OpenGL-
native) will be fixed?

Rutton

unread,
Aug 31, 2010, 1:45:01 PM8/31/10
to android-ndk
Hello folks,

On 30 Aug., 02:54, Grant <gpeters...@gmail.com> wrote:

> > > Remote communication error: Connection reset by peer.
> > > (gdb)

What seem to help me, is to insert a
sleep 2
command in ndk-gdb just before the last line, when gdb gets start.
My success-rate (without connection reset by peer) has been
tremendously
increased since then.

But my gdb woes with multithreaded programs ( Program terminated with
signal SIGTRAP, Trace/breakpoint trap. )
is still there.

Cheers,
Rutton.

Rutton

unread,
Aug 31, 2010, 5:39:19 PM8/31/10
to android-ndk
I would guess, what happens if ndk-gdk fails with "Remote
communication error".
The script ndk-gdk executes gdbserver on the target host (eventually
the emulator)
and then redirects a local debug-port for gdb to gdbserver on the
target.
gdb wants to use that local port, but the redirected port on adb isn't
ready because
likely gdbserver isn't ready yet. And adb can do the only thing
possible and drop the
connection.
This happened for me with a big app (as there is a big lib included,
that needs
loaded first).

Cheers,
Rutton.
Reply all
Reply to author
Forward
0 new messages