In ELF files, this preserves all note sections in the output. only-keep-debug Strip a file, removing contents of any sections that would not be tripped by - strip-debug and leaving the debugging sections intact. This will create a new ELF object with just the symbol table. My-object can be either an executable or a shared object (.so) file. The debug symbol file is created by running this command (taken from gcc documentation) First run objcopy to extract the symbol table and build the debug symbol file, then strip the object file. The recipe for this is the same on both the library and executables. Extracting debug symbols from linked objects This article is divided in two sections: first, onhow to automatize the creation of the debug package, then on how to load the symbol tables into gdb. This is just one of the solutions, maybe it is not always applicable, but why not? This way code can installed, tested and used as usual and symbols only moved on board when needed. GDB can read symbol tables from other files, so one solution is to build the package as usual, perhaps with non-optimizing flags (-O0) and with debug symbols (-g) and then split them in executable and debug symbol files. While the production package is around 5Mb compressed, the unstripped version is around 70Mb and we only have 50Mb of flash space available.ĮLF objects are composed of sections that include code (.text), data (.bss and. In my actual project, the whole binary package is composed of many executable and many shared libraries. For example, installing the unstripped executables can be impossible. So native debugging is your only choice.īut embedded hardware is often resources constrained. Sometimes it may be useful to structure your project so that it can be debugged with emulators, mocks and simulated devices on a PC it is a wise choice because emulators and mocks speed up debugging and developing when other parts (especially hardware and firmware) are not ready yet.īut this is not always possible, especially when you are debugging a piece of code that works with specific hardware that can’t be emulated in software or is not available on your development box.įigure it: you have a specific chip on a i2c bus, and of course, it can’t be connected on any other hardware. To proper debug them in GDB, you need compile symbols, otherwise you’ll not be able to understand what a stack trace means. Executables and libraries compiled in Debug mode are big, bloated and slow. When working with a big project on a resource constrained embedded hardware, it might be difficult to debug it properly on the target board. Creating and using debug symbol tables with CMake and GDB Introduction
0 Comments
Leave a Reply. |