Skip to content

Commit cd870cc

Browse files
committed
chore(dev): improve remote debugging on T113 by stripping debug symbols from uploaded binary
1 parent 81575a8 commit cd870cc

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"options": {
126126
"cwd": "${config:buildroot_path}"
127127
},
128-
"command": "command ssh root@${config:duetscreen_ip} '/etc/init.d/S21DuetScreenMonitor stop; start-stop-daemon -K -n DuetScreen';scp output/target/usr/bin/DuetScreen root@${config:duetscreen_ip}:/usr/bin/DuetScreen",
128+
"command": "command ssh root@${config:duetscreen_ip} '/etc/init.d/S21DuetScreenMonitor stop; start-stop-daemon -K -n DuetScreen'; cp output/target/usr/bin/DuetScreen output/target/usr/bin/DuetScreen.stripped && output/host/bin/arm-none-linux-gnueabihf-strip output/target/usr/bin/DuetScreen.stripped && scp output/target/usr/bin/DuetScreen.stripped root@${config:duetscreen_ip}:/usr/bin/DuetScreen && rm output/target/usr/bin/DuetScreen.stripped",
129129
"group": {
130130
"kind": "build",
131131
"isDefault": false

CMakeLists.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
5555
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
5656
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
5757
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
58-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g")
59-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g")
58+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
59+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -gline-tables-only")
60+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -gline-tables-only")
61+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
62+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g1")
63+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g1")
64+
endif()
6065
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
61-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
62-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
66+
# Use DWARF 4 for broad GDB compatibility and -g2 (the default for -g) for
67+
# full variable/type info without macro tables (-g3), keeping binary size in check.
68+
# Suppress -gpubnames to avoid the huge .debug_gnu_pub{names,types} sections
69+
# that inflate the binary and slow down GDB loading.
70+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g2 -gdwarf-4 -gno-pubnames")
71+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g2 -gdwarf-4 -gno-pubnames")
6372
endif()
6473

65-
# Reduce debug info size and speed up links in Debug/RelWithDebInfo
74+
# Reduce debug info size and speed up links by using split DWARF or similar features when available.
6675
set(PIPE ON)
6776
option(DUETSCREEN_SPLIT_DWARF "Split DWARF debug info for faster links" OFF)
68-
if(CMAKE_BUILD_TYPE MATCHES "^Debug$|^RelWithDebInfo$")
69-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
70-
# Keep only line tables for fast stepping and use split DWARF if enabled
71-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gline-tables-only")
72-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gline-tables-only")
73-
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
74-
# Minimal debug info level that still allows backtraces
75-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g1")
76-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g1")
77-
endif()
77+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
7878
if(DUETSCREEN_SPLIT_DWARF AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
7979
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gsplit-dwarf")
8080
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf")

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"DUETSCREEN_ENABLE_CONSOLE_SHELL": "ON",
3232
"DUETSCREEN_ENABLE_PROFILING": "ON",
3333
"DUETSCREEN_USE_PCH": "ON",
34-
"DUETSCREEN_SPLIT_DWARF": "ON"
34+
"DUETSCREEN_SPLIT_DWARF": "OFF"
3535
}
3636
},
3737
{

0 commit comments

Comments
 (0)