Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lightweight debugging on embedded Linux

I'm developing an application that runs on a small Linux-based SBC (~32MB RAM). Sadly, my app recently became too large to run under GDB anymore. Does anyone know of any good, lightweight debugging methods that I can use in embedded Linux? Even being able to view a thread's stack trace would be extremely helpful.

I should mention that this application is written in C++ and runs multiple threads, so gdbserver is a no-go as it doesn't work with multithreaded apps.

Thanks in advance,

Maha

like image 278
Jason Machacek Avatar asked Dec 01 '09 23:12

Jason Machacek


3 Answers

gdbserver definitely works with multi-threaded applications, I'm working on an embedded project right now with >25 threads and we use gdbserver all the time.

info threads 

lists all the threads in the system

thread <thread number from info threads>  

switches to that thread of execution.

thread apply XXX <command>  

Runs on the thread designated by XXX, which can also be 'all'. So if you want the back trace from all running threads do

thread apply all bt

Once you're in the execution flow of a given threads all your typical commands work as they would in a single threaded process.

like image 176
asm Avatar answered Sep 23 '22 20:09

asm


I've heard of people doing hacks like running the application in an emulator like QEMU and then running GDB (or things like valgrind) on that. It sounds painful, but if it works....

Would you get anywhere with libunwind (to get stack traces) and printf-style logging?

like image 37
Brooks Moses Avatar answered Sep 26 '22 20:09

Brooks Moses


Serial port printing is the most light weight I can think of ~~~ Easily seen in a Host PC, and simple and light weight code inside your app~~

If you do not have a serial port, once we used an GPIO port and simulated a serial port using it. It worked perfectly well, but was a bit slow :-( ~~~

like image 37
Alphaneo Avatar answered Sep 24 '22 20:09

Alphaneo