Difference between revisions of "GDB"
From ArmadeusWiki
(add libthread_db.so hint) |
(→Links) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 27: | Line 27: | ||
<pre class="host"> | <pre class="host"> | ||
[]$ arm-linux-gdb program | []$ arm-linux-gdb program | ||
− | (gdb) set solib-absolute-prefix ./buildroot/ | + | (gdb) set solib-absolute-prefix ./buildroot/output/build/staging_dir/ |
(gdb) target remote 192.168.0.10:2345 | (gdb) target remote 192.168.0.10:2345 | ||
</pre> | </pre> | ||
Line 64: | Line 64: | ||
$ make | $ make | ||
</pre> | </pre> | ||
− | Then you can either reflash your rootfs, or copy ''$ARMADEUS_ROOTFS_DIR/bin/gdb'' to your board, to a SD or to a NFS export. | + | Then you can either reflash your rootfs, or copy ''$ARMADEUS_ROOTFS_DIR/usr/bin/gdb'' to your board, to a SD or to a NFS export. |
* After installation, launch gdb on your APF: | * After installation, launch gdb on your APF: | ||
Line 80: | Line 80: | ||
==Troubleshots== | ==Troubleshots== | ||
− | If you see that kind of error message when using gdb: | + | ===pthread debugging=== |
+ | * If you see that kind of error message when using gdb: | ||
<pre class="apf"> | <pre class="apf"> | ||
dlopen failed on 'libthread_db.so.1' - File not found | dlopen failed on 'libthread_db.so.1' - File not found | ||
Line 88: | Line 89: | ||
''libthread_db.so'' (db == debug) is a library that is needed when you want to debug programs using pthread. You will have to reconfigure the uClibc to get it build: | ''libthread_db.so'' (db == debug) is a library that is needed when you want to debug programs using pthread. You will have to reconfigure the uClibc to get it build: | ||
<pre class="host"> | <pre class="host"> | ||
− | $ make | + | $ make uclibc-menuconfig |
</pre> | </pre> | ||
<pre class="config"> | <pre class="config"> | ||
Line 97: | Line 98: | ||
... | ... | ||
</pre> | </pre> | ||
− | Save your uClibc config and make it standard for next build: | + | |
+ | * Save your uClibc config and make it standard for next build: | ||
<pre class="host"> | <pre class="host"> | ||
− | $ cp buildroot/ | + | $ cp buildroot/output/toolchain/uClibc-0.9.30.3/.config buildroot/target/device/armadeus/apfXX/uClibc.config.arm |
</pre> | </pre> | ||
− | Then rebuild all the toolchain ('''this will erase your local modifications !!''') | + | * Then rebuild all the toolchain ('''this will erase your local modifications !!''') |
<pre class="host"> | <pre class="host"> | ||
− | $ rm -rf buildroot/ | + | $ rm -rf buildroot/output |
− | + | ||
− | + | ||
$ make | $ make | ||
</pre> | </pre> | ||
==Links== | ==Links== | ||
− | * [ | + | * [https://www.sourceware.org/gdb/current/onlinedocs/gdb/index.html Debugging with GDB manual] |
* http://www.kegel.com/linux/gdbserver.html | * http://www.kegel.com/linux/gdbserver.html | ||
* [http://www.linux-france.org/article/memo/node119.html Déboguage avec gdb] | * [http://www.linux-france.org/article/memo/node119.html Déboguage avec gdb] |
Latest revision as of 11:40, 3 June 2016
On this page you will find all you need to debug your userspace applications running on your Armadeus board.
Note: First of all, be sure to have installed the Toolchain on your Host. |
Contents
Compile your program with debug symbols
- Use -g option of gcc:
$ make shell_env $ . armadeus_env.sh $ export PATH=$PATH:$ARMADEUS_TOOLCHAIN_PATH $ arm-linux-gcc -g -o hello hello.c
- If you have a Makefile for your project, you probably have a CFLAGS variable, so add it -g. Ex:
CFLAGS=-W -Wall -g
Debugging a program running on your APF remotely from your Host (through Ethernet)
- On the target launch your program like that:
# gdbserver 192.168.0.2:2345 program [args]
192.168.0.2 is the IP address of your Host and 2345 the port number to use (examples).
- On your Host launch:
[]$ arm-linux-gdb program (gdb) set solib-absolute-prefix ./buildroot/output/build/staging_dir/ (gdb) target remote 192.168.0.10:2345
192.168.0.10 is the address of your target
Note: Only continue / c can be used to start the program, because it is already running when you launch GDB on your host. |
(gdb) break main (gdb) continue ... (gdb) next ...
- If the program is already running, gdbserver can attach itself to the process, if you give him its PID
# ps ... get process PID # gdbserver 192.168.0.2:2345 --attach PID
Note: Core dump analysis doesn't seem to work in this use case (ie on the Host with arm-linux-gdb) !! |
Debugging directly on your APF (may require more memory)
- You have to build gdb for the target:
$ make menuconfig
Toolchain ---> *** Gdb Options *** [*] Build gdb debugger for the Target
$ make
Then you can either reflash your rootfs, or copy $ARMADEUS_ROOTFS_DIR/usr/bin/gdb to your board, to a SD or to a NFS export.
- After installation, launch gdb on your APF:
# gdb your_prog
If you need argument passing:
# gdb --args your_prog your_args
To debug a Core dump:
# gdb your_prog -c your_core_file
Troubleshots
pthread debugging
- If you see that kind of error message when using gdb:
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
Don't worry ! ;-)
libthread_db.so (db == debug) is a library that is needed when you want to debug programs using pthread. You will have to reconfigure the uClibc to get it build:
$ make uclibc-menuconfig
General Library Settings ---> ... [*] POSIX Threading Support [*] Build pthreads debugging support ...
- Save your uClibc config and make it standard for next build:
$ cp buildroot/output/toolchain/uClibc-0.9.30.3/.config buildroot/target/device/armadeus/apfXX/uClibc.config.arm
- Then rebuild all the toolchain (this will erase your local modifications !!)
$ rm -rf buildroot/output $ make