clean up -g handling
This commit is contained in:
Родитель
fcd39b851e
Коммит
53c7b04119
15
emcc
15
emcc
|
@ -819,6 +819,7 @@ try:
|
|||
|
||||
opt_level = 0
|
||||
debug_level = 0
|
||||
requested_debug = ''
|
||||
profiling = False
|
||||
emit_symbol_map = False
|
||||
js_opts = None
|
||||
|
@ -948,11 +949,8 @@ try:
|
|||
elif newargs[i].startswith('-g'):
|
||||
requested_level = newargs[i][2:] or '3'
|
||||
debug_level = validate_arg_level(requested_level, 4, 'Invalid debug level: ' + newargs[i])
|
||||
if newargs[i] != '-g':
|
||||
if debug_level >= 4:
|
||||
newargs[i] = '-g' # we'll need this to get LLVM debug info
|
||||
else:
|
||||
newargs[i] = ''
|
||||
requested_debug = newargs[i]
|
||||
newargs[i] = ''
|
||||
elif newargs[i] == '-profiling':
|
||||
debug_level = 2
|
||||
profiling = True
|
||||
|
@ -1091,7 +1089,7 @@ try:
|
|||
|
||||
if js_opts is None: js_opts = opt_level >= 2
|
||||
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
|
||||
if opt_level == 0: debug_level = 4
|
||||
if opt_level == 0: debug_level = max(3, debug_level)
|
||||
if memory_init_file is None: memory_init_file = opt_level >= 2
|
||||
|
||||
if llvm_lto is None and bind:
|
||||
|
@ -1456,6 +1454,11 @@ try:
|
|||
if has_dash_c: return unsuffixed(input_file) + default_object_extension
|
||||
return in_temp(unsuffixed(uniquename(input_file)) + default_object_extension)
|
||||
|
||||
# Request LLVM debug info if explicitly specified, or building bitcode with -g, or if building a source all the way to JS with -g
|
||||
if debug_level >= 4 or ((final_suffix not in JS_CONTAINING_SUFFIXES or (has_source_inputs and final_suffix in JS_CONTAINING_SUFFIXES)) and requested_debug == '-g'):
|
||||
newargs.append('-g') # preserve LLVM debug info
|
||||
debug_level = 4
|
||||
|
||||
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
|
||||
for i, input_file in input_files:
|
||||
file_ending = filename_type_ending(input_file)
|
||||
|
|
|
@ -6474,38 +6474,6 @@ def process(filename):
|
|||
# This test *should* fail, by throwing this exception
|
||||
assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e)
|
||||
|
||||
def test_debug(self):
|
||||
if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
|
||||
if self.emcc_args is not None:
|
||||
if '-O1' in self.emcc_args or '-O2' in self.emcc_args or '-O3' in self.emcc_args: return self.skip('optimizations remove LLVM debug info')
|
||||
|
||||
src = '''
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
void checker(int x) {
|
||||
x += 20;
|
||||
assert(x < 15); // this is line 7!
|
||||
}
|
||||
|
||||
int main() {
|
||||
checker(10);
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
try:
|
||||
self.do_run(src, '*nothingatall*', assert_returncode=None)
|
||||
except Exception, e:
|
||||
# This test *should* fail
|
||||
assert 'Assertion failed: x < 15' in str(e), str(e)
|
||||
|
||||
lines = open('src.cpp.o.js', 'r').readlines()
|
||||
lines = filter(lambda line: '___assert_fail(' in line or '___assert_func(' in line, lines)
|
||||
found_line_num = any(('//@line 7 "' in line) for line in lines)
|
||||
found_filename = any(('src.cpp"\n' in line) for line in lines)
|
||||
assert found_line_num, 'Must have debug info with the line number'
|
||||
assert found_filename, 'Must have debug info with the filename'
|
||||
|
||||
def test_source_map(self):
|
||||
if Settings.USE_TYPED_ARRAYS != 2: return self.skip("doesn't pass without typed arrays")
|
||||
if NODE_JS not in JS_ENGINES: return self.skip('sourcemapper requires Node to run')
|
||||
|
|
|
@ -3928,18 +3928,47 @@ main(const int argc, const char * const * const argv)
|
|||
test(['-o', 'c.html'], True)
|
||||
test(['-c'], False)
|
||||
|
||||
def dash_g_bc(self):
|
||||
def get_size(name):
|
||||
return len(open(name).read())
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-o', 'a_.bc']).communicate()
|
||||
sizes = { '_': get_size('a_.bc') }
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-g', '-o', 'ag.bc']).communicate()
|
||||
sizes['g'] = get_size('ag.bc')
|
||||
for i in range(0, 5):
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-g' + str(i), '-o', 'a' + str(i) + '.bc']).communicate()
|
||||
sizes[i] = get_size('a' + str(i) + '.bc')
|
||||
print sizes
|
||||
assert sizes['_'] == sizes[0] == sizes[1] == sizes[2] == sizes[3], 'no debug or <4 debug, means no llvm debug info'
|
||||
assert sizes['g'] == sizes[4], '-g or -g4 means llvm debug info'
|
||||
assert sizes['_'] < sizes['g'], 'llvm debug info has positive size'
|
||||
def test_dash_g(self):
|
||||
open('src.c', 'w').write('''
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
void checker(int x) {
|
||||
x += 20;
|
||||
assert(x < 15); // this is line 7!
|
||||
}
|
||||
|
||||
int main() {
|
||||
checker(10);
|
||||
return 0;
|
||||
}
|
||||
''')
|
||||
|
||||
Popen([PYTHON, EMCC, 'src.c', '-g']).communicate()
|
||||
|
||||
lines = open('a.out.js', 'r').readlines()
|
||||
lines = filter(lambda line: '___assert_fail(' in line or '___assert_func(' in line, lines)
|
||||
found_line_num = any(('//@line 7 "' in line) for line in lines)
|
||||
found_filename = any(('src.c"\n' in line) for line in lines)
|
||||
assert found_line_num, 'Must have debug info with the line number'
|
||||
assert found_filename, 'Must have debug info with the filename'
|
||||
|
||||
def test_dash_g_bc(self):
|
||||
def test(opts):
|
||||
print opts
|
||||
def get_size(name):
|
||||
return len(open(name).read())
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-o', 'a_.bc'] + opts).communicate()
|
||||
sizes = { '_': get_size('a_.bc') }
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-g', '-o', 'ag.bc'] + opts).communicate()
|
||||
sizes['g'] = get_size('ag.bc')
|
||||
for i in range(0, 5):
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-g' + str(i), '-o', 'a' + str(i) + '.bc'] + opts).communicate()
|
||||
sizes[i] = get_size('a' + str(i) + '.bc')
|
||||
print ' ', sizes
|
||||
assert sizes['_'] == sizes[0] == sizes[1] == sizes[2] == sizes[3], 'no debug or <4 debug, means no llvm debug info'
|
||||
assert sizes['g'] == sizes[4], '-g or -g4 means llvm debug info'
|
||||
assert sizes['_'] < sizes['g'], 'llvm debug info has positive size'
|
||||
test([])
|
||||
test(['-O1'])
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче