The featured image of this blog post has been created by Cryteria, CC BY 3.0, Link

Gdb, the GNU debugger, is probably the most used open source debugger for embedded systems. The AVR version of gdb on the Mac is unfortunately not very cooperative. If you try to read an elf file, you get the following funny message (reminding us of HAL9000):

I’m sorry, Dave, I can’t do that. Symbol format `elf32-avr’ unknown.

But with the right homebrew formula one can teach gdb some new tricks …

EDIT: The problem has been solved by the homebrew maintainers.

Actually, the version I am referring to is the one that one can install using homebrew. There are also other versions around, e.g., older Arduino versions contained avr-gdb. And also PlatformIO contains one version of avr-gdb. The PlatformIO version of avr-gdb can read elf files, but it tells you that its Python support is limited.

The problem with the current “official” homebrew versions seems to be that the compiler used to produce the binary is the clang compiler, the standard macOS compiler, which at some points is less forgiving than gcc. Apparently, an implicit declaration of strncmp led to the problem. Including string.h in elf-bfd.h solves the problem as reported at Sourceware Bugzilla. Unfortunately, the patch did not make it into the most recent version 10.2 of gdb. However, one can easily adapt a homebrew formula, which I did. With

    brew update
    brew install felias-fogg/arduino/avr-gdb

you get (after waiting some time) a working version of avr-gdb (even version 10.2 instead of 10.1!). Most probably, the new formula will be adapted soon by the maintainers of the osx-cross maintainer.

EDIT: Indeed, you can use the ordinary brew formula again.