I'm using the Arduino IDE, the J-Link gdb server and the gdb client from the arm toolchain. Processor is Adafruit Feather-M0.
To use gdb, my executable must include debugging symbols, as produced by the compiler -g option. How do I accomplish this?
I'm using the Arduino IDE, the J-Link gdb server and the gdb client from the arm toolchain. Processor is Adafruit Feather-M0.
To use gdb, my executable must include debugging symbols, as produced by the compiler -g option. How do I accomplish this?
I believe the compilers are already invoked with the -g switch when generating the .elf file. Check the verbose output to be sure...
Reply to reply #1:
Unfortunately that is not true. When I do a "file etc.etc.elf" in the gdb client, it reports no debugging symbols found. Also, I captured the compiler output from the IDE subwindow and searched for the -g option but found none.
I have been searching the forum and the web for an answer but have found none..
The compiler flags are defined in the platform.txt file of each hardware core.
The easiest way to find the active hardware package location is as follows:
You can open platform.txt in a text editor and modify it.
You can also create a file named platform.local.txt and define your own customized properties in that file to make it easy to keep your modifications separate from the stock platform.txt.
You need to restart the Arduino IDE before changes to platform.txt and platform.local.txt will take effect.
Note that every time you update to a new version of Adafruit SAMD Boards, you will need to redo your modifications. You might want to save your platform.local.txt to a safe place so you can just copy it into the folder after updating.
That's odd. I confirmed that the Arduino M0 platforms (MKRZero and M0) DO use a "-g" in the command line. It seems un-Adafruit-like to have removed something like that...
Ah. There should be a "Debug" option in the boards menu now (only for the Adafruit boards)...
Debug Board Option added.
Remove "-g" as a default.
(I don't know why...)
Your advice worked beautifully, many thanks.
For the Adafruit Feather-M0, I found the platform.txt file in ~/.arduino15/packages/adafruit/hardware/samd/ 1.5.3. I copied platform.txt to platform.local.txt in that directory and altered the line for compiler.flags.cpp to include -g3. Then when I did 'file /tmp/arduino_build_892069/gTest.ino.elf' in the gdb client (where that long name happened to be the name of my elf file), it found the symbols.
You're welcome. I'm glad to hear it worked.
I recommend against copying the full contents of platform.txt to platform.local.txt. Only copy the things you want to change to that file. It sounds like you only need compiler.flags.cpp in your platform.local.txt. The reason I recommend this is that Adafruit may make other changes to the file in future releases and your current platform.local.txt would cause the outdated version to be used.
Ah, I just saw westfw's reply. So instead of the slightly hacking platform.local.txt fix, you can simply select Tools > Debug > On in the Arduino IDE. Of course, that gives you -g instead of -g3. If you need -g3 then platform.local.txt is the way to go.