sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.02k stars 449 forks source link

No source file info in elf file #679

Open celephicus opened 11 months ago

celephicus commented 11 months ago

When built with DEBUG defined, the generated elf file does not contain source file info, as verified with avr-objdump -S ..., at least with the AVR Mega328P target. This makes debugging using the elf file restricted to assembly only.

This is because the linker is not supplied with the -g flag. A fix could be as simple as adding -g to LDFLAGS if DEBUG is defined, but I'm not sure of the consequences for other targets.

Arduino.mk Configuration:

Makefile:

Want latest version so use submodule from git.

ARDMK_DIR := $(realpath ../Arduino-Makefile)

BOARD_TAG = nano BOARD_SUB = atmega328old

The makefile gets this wrong.

AVRDUDE_CONF = /etc/avrdude.conf

MONITOR_PORT = /dev/ttyUSB1

ISP_PROG = atmelice_isp

CXXFLAGS += -Wextra -Wno-unused-parameter -Wno-pragmas -Wshadow -Wdouble-promotion -fno-common -funsigned-char -funsigned-bitfields CXXFLAGS += -fpack-struct -fshort-enums -Wundef

Debug switch, if not defined DEBUG_FLAGS ignored and optimisation set to 's'.

DEBUG = 1 DEBUG_FLAGS = -DDEBUG -g3 -Og

include $(ARDMK_DIR)/Arduino.mk