2 # Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
9 # Preserve debugging info (which is not ABI-stable under PNaCl).
10 if not env.AllowNonStableBitcode():
13 if env.Bit('bitcode'):
14 # With the PNaCl toolchain, special flags are required to get a build ID.
15 env.Append(LINKFLAGS=['--pnacl-allow-nexe-build-id'])
16 if env.Bit('pnacl_generate_pexe'):
17 env.Append(TRANSLATEFLAGS=['--build-id'])
19 env.Append(LINKFLAGS=['--pnacl-allow-native', '-Wn,--build-id'])
21 env['COMPONENT_STATIC'] = env.Bit('nacl_static_link')
22 env.ComponentLibrary('minidump_test_lib', 'minidump_test_lib.c')
23 nexe = env.ComponentProgram(
24 'minidump_test', 'minidump_test.c',
25 EXTRA_LIBS=['minidump_test_lib', 'minidump_generator',
26 '${NONIRT_LIBS}', '${EXCEPTION_LIBS}', '${PTHREAD_LIBS}'])
28 for crash_in_lib in [0, 1]:
29 for modules_live in [0, 1]:
32 name += '_crash_in_lib'
34 name += '_modules_live'
36 output_dump_file = env.File(name + '.dmp')
38 env.CommandSelLdrTestNacl(
40 [output_dump_file.abspath, str(crash_in_lib), str(modules_live)],
41 declares_exit_status=True,
42 sel_ldr_flags=['-e', # Enable exception handling for catching crash
43 '-a', # Enable file access for writing minidump file
46 env.SideEffect(output_dump_file, nodes[0])
47 breakpad_tools_dir = env.get('BREAKPAD_TOOLS_DIR')
48 if breakpad_tools_dir is not None:
49 # Check that the minidump can be decoded.
50 minidump_dump = breakpad_tools_dir.File('src/processor/minidump_dump')
51 if not os.path.exists(minidump_dump.abspath):
52 raise Exception('minidump_dump not available, '
53 'but breakpad_tools_dir=%s specified' % breakpad_tools_dir)
54 nodes.append(env.AutoDepsCommand(
55 [name + '.dump', name + '.dump_errors'],
56 [minidump_dump, output_dump_file,
57 '>${TARGETS[0]}', '2>${TARGETS[1]}']))
58 # Check that a stack trace can be extracted from the minidump.
59 # TODO(bradnelson): Check the trace is actually right.
60 minidump_stackwalk = breakpad_tools_dir.File(
61 'src/processor/minidump_stackwalk')
62 if not os.path.exists(minidump_dump.abspath):
63 raise Exception('minidump_stackwalk not available, '
64 'but breakpad_tools_dir=%s specified' % breakpad_tools_dir)
65 nodes.append(env.AutoDepsCommand(
66 [name + '.stackwalk', name + '.stackwalk_errors'],
67 [minidump_stackwalk, output_dump_file,
68 '>${TARGETS[0]}', '2>${TARGETS[1]}']))
69 env.AddNodeToTestSuite(
71 ['small_tests', 'exception_tests', 'nonpexe_tests'],
73 # Nexe build IDs are not available under the
74 # sandboxed PNaCl translator.
75 is_broken=(env.Bit('use_sandboxed_translator') or
76 # Nexe build IDs are currently not being generated by
77 # nacl-clang for !linux:
78 # http://code.google.com/p/nativeclient/issues/detail?id=3975
79 (env.Bit('nacl_clang') and not env.Bit('host_linux'))))