Open
Conversation
By default LTO (Link Time Optimization) of AVR GCC is enabled. On
atmega328p this remove most of the debugging data from the ELF file.
As a result avr-gdb can not be used fully.
For example lets take the simple Hello World application:
#include <Arduino.h>
void setup() {
Serial1.begin(9600);
}
void loop() {
Serial1.print("Hello World\n");
}
following output shows that nither Print.c nither the test_app.cpp
are writen in the ELF file as a referance to the source code for
debugging porpose (the code is compiled with -g):
$ avr-objdump -x build-a-star328PB/test_app.elf | grep df
00000000 l df *ABS* 00000000 malloc.c
00000000 l df *ABS* 00000000
00000000 l df *ABS* 00000000 _clear_bss.o
00000000 l df *ABS* 00000000
00000000 l df *ABS* 00000000 realloc.c
00000000 l df *ABS* 00000000 _udivmodsi4.o
00000000 l df *ABS* 00000000 _exit.o
As a result this ELF file can not be used by GDB. It can not find the
source code of the currently executed code.
When we disable the LTO the output is:
$ avr-objdump -x build-a-star328PB/test_app.elf | grep df
00000000 l df *ABS* 00000000 test_app.cpp
00000000 l df *ABS* 00000000 Print.cpp
00000000 l df *ABS* 00000000 HardwareSerial.cpp
00000000 l df *ABS* 00000000 _clear_bss.o
00000000 l df *ABS* 00000000 main.cpp
00000000 l df *ABS* 00000000 wiring.c
00000000 l df *ABS* 00000000 new.cpp
00000000 l df *ABS* 00000000 _udivmodsi4.o
00000000 l df *ABS* 00000000 _exit.o
00000000 l df *ABS* 00000000
Now all source files are depicted by the ELF file. As a result avr-gdb
can use this ELF file for debugging. It depict the current source line.
Also the size of the .text section (Flash memory) is not optimiezed.
With LTO the simple Helloe World take 20264 bytes (.text). While the
build without LTO generate 3860 bytes (.text) for atmega328p.
This patch allow disabling of LTO by setting LTO=n. While keeping
LTO on by default.
Signed-off-by: Ivo Shopov <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By default LTO (Link Time Optimization) of AVR GCC is enabled. On
atmega328p this remove most of the debugging data from the ELF file.
As a result avr-gdb can not be used fully.
For example lets take the simple Hello World application:
following output shows that nither Print.c nither the test_app.cpp
are writen in the ELF file as a referance to the source code for
debugging porpose (the code is compiled with -g):
As a result this ELF file can not be used by GDB. It can not find the
source code of the currently executed code.
When we disable the LTO the output is:
Now all source files are depicted by the ELF file. As a result avr-gdb
can use this ELF file for debugging. It depict the current source line.
Also the size of the .text section (Flash memory) is not optimiezed.
With LTO the simple Helloe World take 20264 bytes (.text). While the
build without LTO generate 3860 bytes (.text) for atmega328p.
This patch allow disabling of LTO by setting LTO=n. While keeping
LTO on by default.
Signed-off-by: Ivo Shopov [email protected]