Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit b11fd68

Browse files
Implement debug symbol extraction for Linux and Android
1 parent 62d9824 commit b11fd68

File tree

7 files changed

+100
-1
lines changed

7 files changed

+100
-1
lines changed

config/android.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
'lib_suffix': '',
3434
'ext_suffix': '',
3535
'exe_suffix': '',
36+
'debug_info_suffix': '.dbg',
3637
},
3738

3839
'cflags':

config/ios.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
'exe_suffix': '',
4949
'lib_suffix': '.dylib',
5050
'ext_suffix': '.so',
51+
'debug_info_suffix': '.dsym',
5152
},
5253

5354
'defines':

config/linux.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'lib_suffix': '.so',
1414
'ext_suffix': '.so',
1515
'exe_suffix': '',
16+
'debug_info_suffix': '.dbg',
1617

1718
'c++_std': '<!(echo ${CXX_STD:-gnu++03})',
1819
},

config/mac.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'exe_suffix': '',
3939
'lib_suffix': '.dylib',
4040
'ext_suffix': '.so',
41+
'debug_info_suffix': '.dsym',
4142
},
4243

4344
'target_conditions':

config/win32.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
'lib_suffix': '.dll',
2121
'ext_suffix': '.dll',
2222
'exe_suffix': '.exe',
23+
'debug_info_suffix': '',
2324
},
2425

2526
# Don't assume a Cygwin environment when invoking actions

livecode.gyp

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,86 @@
9090
],
9191
},
9292

93+
{
94+
'target_name': 'debug-symbols',
95+
'type': 'none',
96+
97+
'dependencies':
98+
[
99+
'LiveCode-all',
100+
],
101+
102+
'conditions':
103+
[
104+
[
105+
'OS == "linux" or OS == "android"',
106+
{
107+
'variables':
108+
{
109+
'debug_symbol_files':
110+
[
111+
'>!@(["sh", "-c", "echo $@ | xargs -n1 | sed -e \\\"s/$/>(debug_info_suffix)/g\\\"", "echo", \'>@(dist_files)\'])',
112+
],
113+
},
114+
115+
'actions':
116+
[
117+
{
118+
'action_name': 'extract-debug-symbols',
119+
'message': 'Extracting debug symbols',
120+
121+
'inputs':
122+
[
123+
'>@(dist_files)',
124+
'./tools/extract-debug-symbols.sh',
125+
],
126+
127+
'outputs':
128+
[
129+
'<@(debug_symbol_files)',
130+
],
131+
132+
'action':
133+
[
134+
'./tools/extract-debug-symbols.sh',
135+
'>(debug_info_suffix)',
136+
'<@(_inputs)',
137+
],
138+
},
139+
],
140+
141+
'all_dependent_settings':
142+
{
143+
'variables':
144+
{
145+
'dist_aux_files': [ '<@(debug_symbol_files)' ],
146+
},
147+
},
148+
}
149+
],
150+
],
151+
},
152+
93153
{
94154
'target_name': 'binzip-copy',
95155
'type': 'none',
96156

157+
'variables':
158+
{
159+
'dist_files': [],
160+
'dist_aux_files': [],
161+
},
162+
97163
'dependencies':
98164
[
99165
'LiveCode-all',
166+
'debug-symbols',
100167
],
101168

102169
'copies':
103170
[{
104171
'destination': '<(output_dir)',
105-
'files': [ '>@(dist_files)' ],
172+
'files': [ '>@(dist_files)', '>@(dist_aux_files)', ],
106173
}],
107174
},
108175
],

tools/extract-debug-symbols.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
suffix="$1"
6+
shift
7+
inputs="$@"
8+
9+
for input in $inputs ; do
10+
output="${input}${suffix}"
11+
12+
# Extract a copy of the debugging information
13+
objcopy --only-keep-debug "$input" "$output"
14+
15+
# If this file is a dynamic library, don't do a full strip or we'll
16+
# destroy it (no symbols => can't link to it)
17+
if [[ "$(objdump -f $input)" =~ "DYNAMIC" ]] ; then
18+
strip --preserve-dates --strip-debug "$input"
19+
else
20+
strip --preserve-dates --strip-debug --strip-unneeded "$input"
21+
fi
22+
23+
# Add a hint for the debugger so it can find the debug info
24+
objcopy --remove-section=.gnu_debuglink "$input"
25+
objcopy --preserve-dates --add-gnu-debuglink="$output" "$input"
26+
done
27+

0 commit comments

Comments
 (0)