Skip to contentSkip to conversation

Debug with gdbserver

DISCUSSION Darren Hart 3 participants 10 messages Aug 1, 2012

lore
Share & tools
lore
#0 lore raw

I am trying to debug a userpsace application that misbehaves under poky-tiny. My current approach is use gdbserver on the target and attach to the offending process, then connect to it on the client using the yocto-built native gdb for the target.

I can easily add gdbserver to the target image, and can successfully connect it to the process:

# From the target (qemux86) root shell:

# dropbearkey -t rsa -f ./rsa
# dropbear -r ./rsa
# DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ')
# gdbserver 127.0.0.1:1234 --attach $DBPID

Now on the host machine (amd64) I want to:

$ gdb????
(gdb) target extended-remote 127.0.0.1:1234

Which package do I need to build to get the appropriate gdb for the host to remote debug processes on the target?

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#1 lore raw
Quoted 14 lines · Darren Hart

I am trying to debug a userpsace application that misbehaves under poky-tiny. My current approach is use gdbserver on the target and attach to the offending process, then connect to it on the client using the yocto-built native gdb for the target.

I can easily add gdbserver to the target image, and can successfully connect it to the process:

# From the target (qemux86) root shell:

# dropbearkey -t rsa -f ./rsa
# dropbear -r ./rsa
# DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ')
# gdbserver 127.0.0.1:1234 --attach $DBPID
Quoted 6 lines

Now on the host machine (amd64) I want to:

$ gdb????
(gdb) target extended-remote 127.0.0.1:1234

Which package do I need to build to get the appropriate gdb for the host to remote debug processes on the target?

bake cross-gdb for your arch and use it same way as above

Quoted 8 lines
Signature · 7 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
#2 lore raw
Quoted 17 lines · Khem Raj
Quoted 14 lines · Darren Hart

I am trying to debug a userpsace application that misbehaves under poky-tiny. My current approach is use gdbserver on the target and attach to the offending process, then connect to it on the client using the yocto-built native gdb for the target.

I can easily add gdbserver to the target image, and can successfully connect it to the process:

# From the target (qemux86) root shell:

# dropbearkey -t rsa -f ./rsa
# dropbear -r ./rsa
# DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ')
# gdbserver 127.0.0.1:1234 --attach $DBPID
Quoted 8 lines
Quoted 6 lines

Now on the host machine (amd64) I want to:

$ gdb????
(gdb) target extended-remote 127.0.0.1:1234

Which package do I need to build to get the appropriate gdb for the host to remote debug processes on the target?

bake cross-gdb for your arch and use it same way as above

ERROR: Nothing PROVIDES 'cross-gdb'

gdb-cross maybe?

Ah that gets a lot farther... and then do_compile fails.

| libgdb.a(python.o): In function `gdbpy_target_wide_charset':
| python.c:(.text+0x1c7): undefined reference to `PyUnicodeUCS4_Decode'

And a lot more similar to that. I'm doing this on poky-tiny (so a minimal target libc... shouldn't impact native bits though right?

Will beat on it some more in the morning.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#3 lore raw
Quoted 24 lines · Darren Hart
Quoted 21 lines · Khem Raj
Quoted 18 lines · Darren Hart

I am trying to debug a userpsace application that misbehaves under poky-tiny. My current approach is use gdbserver on the target and attach to the offending process, then connect to it on the client using the yocto-built native gdb for the target.

I can easily add gdbserver to the target image, and can successfully connect it to the process:

# From the target (qemux86) root shell:

# dropbearkey -t rsa -f ./rsa
# dropbear -r ./rsa
# DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ')
# gdbserver 127.0.0.1:1234 --attach $DBPID

Now on the host machine (amd64) I want to:

$ gdb????
(gdb) target extended-remote 127.0.0.1:1234
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Which package do I need to build to get the appropriate gdb for the host to remote debug processes on the target?

bake cross-gdb for your arch and use it same way as above

ERROR: Nothing PROVIDES 'cross-gdb'

gdb-cross maybe?

I meant cross gdb not the exact recipe name :)

Quoted 7 lines

Ah that gets a lot farther... and then do_compile fails.

| libgdb.a(python.o): In function `gdbpy_target_wide_charset':
| python.c:(.text+0x1c7): undefined reference to `PyUnicodeUCS4_Decode'

And a lot more similar to that. I'm doing this on poky-tiny (so a minimal target libc... shouldn't impact native bits though right?

shouldn't it seems you need python native

Quoted 8 lines

Will beat on it some more in the morning.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#4 lore raw
In reply to Darren Hart
Quoted 33 lines · Darren Hart
Quoted 17 lines · Khem Raj
Quoted 14 lines · Darren Hart

I am trying to debug a userpsace application that misbehaves under poky-tiny. My current approach is use gdbserver on the target and attach to the offending process, then connect to it on the client using the yocto-built native gdb for the target.

I can easily add gdbserver to the target image, and can successfully connect it to the process:

# From the target (qemux86) root shell:

# dropbearkey -t rsa -f ./rsa
# dropbear -r ./rsa
# DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ')
# gdbserver 127.0.0.1:1234 --attach $DBPID
Quoted 8 lines
Quoted 6 lines

Now on the host machine (amd64) I want to:

$ gdb????
(gdb) target extended-remote 127.0.0.1:1234

Which package do I need to build to get the appropriate gdb for the host to remote debug processes on the target?

bake cross-gdb for your arch and use it same way as above

ERROR: Nothing PROVIDES 'cross-gdb'

gdb-cross maybe?

Quoted 7 lines

Ah that gets a lot farther... and then do_compile fails.

| libgdb.a(python.o): In function `gdbpy_target_wide_charset':
| python.c:(.text+0x1c7): undefined reference to `PyUnicodeUCS4_Decode'

And a lot more similar to that. I'm doing this on poky-tiny (so a minimal target libc... shouldn't impact native bits though right?

http://patchwork.openembedded.org/patch/33345/

Cheers,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 40 lines · Martin Jansa
Quoted 39 lines · Darren Hart
Quoted 18 lines · Khem Raj
Quoted 14 lines · Darren Hart

I am trying to debug a userpsace application that misbehaves under poky-tiny. My current approach is use gdbserver on the target and attach to the offending process, then connect to it on the client using the yocto-built native gdb for the target.

I can easily add gdbserver to the target image, and can successfully connect it to the process:

# From the target (qemux86) root shell: # dropbearkey -t rsa -f ./rsa # dropbear -r ./rsa # DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ') # gdbserver 127.0.0.1:1234 --attach $DBPID

Quoted 7 lines
Quoted 5 lines

Now on the host machine (amd64) I want to: $ gdb???? (gdb) target extended-remote 127.0.0.1:1234

Which package do I need to build to get the appropriate gdb for the host to remote debug processes on the target?

bake cross-gdb for your arch and use it same way as above

ERROR: Nothing PROVIDES 'cross-gdb'

gdb-cross maybe?

Ah that gets a lot farther... and then do_compile fails.

| libgdb.a(python.o): In function gdbpy_target_wide_charset': | python.c:(.text+0x1c7): undefined reference to PyUnicodeUCS4_Decode'

Quoted 5 lines
Quoted 3 lines

And a lot more similar to that. I'm doing this on poky-tiny (so a minimal target libc... shouldn't impact native bits though right?

http://patchwork.openembedded.org/patch/33345/

Excellent, that gets things building.

Now I'm trying to use it and getting a timeout. I'm investigating, but if anyone has run into this already and can save me the time, I'd appreciate it.

I start qemu with:

$ qemu -kernel
/build/poky/master/qemux86_SZ60LW/tmp/deploy/images/bzImage-qemux86.bin
- -initrd
/build/poky/master/qemux86_SZ60LW/tmp/deploy/images/core-image-minimal-qemux86.cpio.gz
- -nographic -append "console=ttyS0 root=/dev/ram0" -redir tcp:1234::1234

Then run the following on the target:

# dropbearkey -t rsa -f ./rsa
# dropbear -r ./rsa
# DBPID=$(ps | grep dropbear | head -n1 | cut -f4 -d ' ')
# gdbserver 127.0.0.1:1234 --attach $DBPID
...
Attached; pid = 41
Listening on port 1234

Then from the host:

$ nmap localhost
...
1234/tcp open  hotline
....
$ i586-poky-linux-gdb
GNU gdb (GDB) 7.4.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux --target=i586-poky-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target extended-remote 127.0.0.1:1234
Remote debugging using 127.0.0.1:1234
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Remote communication error.  Target disconnected.: Connection reset by
peer.

- --
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJQGVfEAAoJEKbMaAwKp364Ug8H/0yXaF/jqZdrl3XEnM0mT4Ef gvTIEQ4yAr015Ra2TV9kTUEqb0tnKR1chfZDveEmlBf84ZUsnArFvUseaCMQ1sz6 0lG5iAdeY6Cpo4UKPmpxgLCCMo3nEUIULvA4XrsTakvEgUH4DhssmgEOTOi/aaQ3 Fc9YtpUvXjC63eyRNqYk5sEMWzEVMSxbRHUegllGrsK+eeacEYoA1/TFFiK0c6lH cLL/mZsnbzPFh9a1SteR1D9YC7tmrooGyaWBz/zZ8UYNfTlP5JfsQA/GZHc6wmWn h6Ml9l9DdnNQxXX8Ff6nyEYgc1714u8OEl/Wno6wwJdCh9U9OvxfRC5KxMKkMWg= =yC5/
-----END PGP SIGNATURE-----

#6 lore raw
Quoted 1 line · Darren Hart

(gdb) target extended-remote 127.0.0.1:1234

this should be ip of target which in your case is qemu prolly something like 192.168.7.2 or somesuch

#7 lore raw
Quoted 6 lines · Khem Raj
Quoted 1 line · Darren Hart

(gdb) target extended-remote 127.0.0.1:1234

this should be ip of target which in your case is qemu prolly something like 192.168.7.2 or somesuch

I was trying to use the "redir" feature of qemu which supposedly allows you to connect to 1234 on the host instead. After looking at this for a bit and not making any progress, I setup tun/tap networking with qemu and easily connected using the target IP as you mention above. I'd like to understand why redir didn't work - as debugging without a full network on the client would be nice - but for now, I'm moving along.

Thanks,

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#8 lore raw
Quoted 10 lines · Darren Hart
Quoted 6 lines · Khem Raj
Quoted 1 line · Darren Hart

(gdb) target extended-remote 127.0.0.1:1234

this should be ip of target which in your case is qemu prolly something like 192.168.7.2 or somesuch

Quoted 7 lines

I was trying to use the "redir" feature of qemu which supposedly allows you to connect to 1234 on the host instead. After looking at this for a bit and not making any progress, I setup tun/tap networking with qemu and easily connected using the target IP as you mention above. I'd like to understand why redir didn't work - as debugging without a full network on the client would be nice - but for now, I'm moving along.

well redir is visible to qemu gdb stub not to the software stack that qemu is running in your case. although you can use that to debug kernel using qemu. Pass -s option and qemu will boot kernel using gdb stub and you can debug the kernel from address 0 kind of JTAG debugger for poor :)

Quoted 7 lines

Thanks,

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#9 lore raw
Quoted 21 lines · Khem Raj
Quoted 10 lines · Darren Hart
Quoted 6 lines · Khem Raj
Quoted 1 line · Darren Hart

(gdb) target extended-remote 127.0.0.1:1234

this should be ip of target which in your case is qemu prolly something like 192.168.7.2 or somesuch

Quoted 7 lines

I was trying to use the "redir" feature of qemu which supposedly allows you to connect to 1234 on the host instead. After looking at this for a bit and not making any progress, I setup tun/tap networking with qemu and easily connected using the target IP as you mention above. I'd like to understand why redir didn't work - as debugging without a full network on the client would be nice - but for now, I'm moving along.

Quoted 4 lines

well redir is visible to qemu gdb stub not to the software stack that qemu is running in your case. although you can use that to debug kernel using qemu. Pass -s option and qemu will boot kernel using gdb stub and you can debug the kernel from address 0 kind of JTAG debugger for poor :)

Oh. Duh. :-)

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel