I'm using avr-gdb and simulavr to debug code for an atmega328 microcontroller. My elf file foo.elf depends on a static library bar.a. I've set Debug as the cmake_build_type in bar.a's CMakeLists.txt
When I call simulavr to create the simulation, I get:
$ simulavr --device=atmega328 --cpufrequency=16000000UL -g -f src/arduinoGridmpc.elf
Waiting on port 1212 for gdb client to connect...
Which is as it should be. Then I go on to launch avr-gdb in a new shell:
$ avr-gdb -p 1212
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
--- snip ---
(gdb) file src/foo.elf
Reading symbols from src/foo.elf...done.
(gdb) target remote localhost:1212
Remote debugging using localhost:1212
0x00000000 in __vectors ()
(gdb) load
Loading section .text, size 0xcf6a lma 0x0
Remote connection closed
if I check the simulavr shell:
Waiting on port 1212 for gdb client to connect...
Connection opened by host 127.0.0.1, port -6010.
FATAL: file cmd/gdbserver.cpp: line 326: try to write in flash after last valid address!
If I set the cmake_build_type of my static library bar.a to Release or RelWithDebInfo and recompile, everything runs smoothly, and I get the following from simulavr:
Connection opened by host 127.0.0.1, port -5990.
and from avr-gdb:
(gdb) file src/foo.elf
Reading symbols from src/foo.elf...done.
(gdb) target remote localhost:1212
Remote debugging using localhost:1212
0x00000000 in __vectors ()
(gdb) load
Loading section .text, size 0x2dac lma 0x0
Loading section .data, size 0x42 lma 0x2dac
Start address 0x0, load size 11758
Transfer rate: 395 KB/sec, 904 bytes/write.
(gdb) cont
Continuing.
What could lead to the very different result? Why does the simulavr simulator crash when my static library is in Debug mode? These questions (1,2,3) are similar but not quite the same as mine. Further, they have not received an answer.
I checked, and the build type of foo.elf doesn't matter, so it shouldn't be a problem of mixing build types.
Thank you for any insights!
User contributions licensed under CC BY-SA 3.0