2 # Copyright (c) 2012 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.
10 if 'TRUSTED_ENV' not in env:
13 if env.UnderWindowsCoverage():
16 if env.Bit('target_arm') or env.Bit('target_mips32'):
17 if env.UsingEmulator():
18 # nacl-gdb is built with ARM support but not MIPS support.
19 if env.Bit('target_mips32'):
21 nacl_x86_toolchain_dir = env.GetToolchainDir(target_arch='x86',
24 nacl_gdb_path = os.path.join(nacl_x86_toolchain_dir, 'bin', 'i686-nacl-gdb')
25 env.Replace(GDB=nacl_gdb_path)
27 # Use the system's ARM/MIPS GDB because the NaCl toolchain does not
28 # include a copy of GDB built to run on ARM/MIPS.
29 env.Replace(GDB='gdb')
30 # Unlike nacl-gdb, the system version of GDB does not support the
32 if env.Bit('tests_use_irt'):
35 # Disable finalization (which would strip debug metadata), but allow
36 # the sandbox translator where it makes sense.
37 if not env.AllowNonStableBitcode(allow_sb_translator=True):
40 # We need -O0 to make stepping predictable and read local variables/function
41 # arguments that may otherwise be optimized out.
42 env.Append(CCFLAGS=['-O0', '-g', '-fno-omit-frame-pointer'])
43 # We need to disable PNaCl's link time optimizations so that functions
44 # do not get inlined, so that we can set breakpoints on these
45 # functions. Also make translation optimizaton level -O0.
46 if env.Bit('bitcode'):
47 env.Append(LINKFLAGS=['-O0'])
48 env.Append(TRANSLATEFLAGS=['-O0'])
50 sel_ldr_command = env.AddBootstrap(env.GetSelLdr(), ['-v'])
52 # Run sel_ldr through qemu-arm. Add "-Q" to disable the platform
53 # qualification tests because they fail under qemu-arm.
54 sel_ldr_command = [env.GetEmulator()] + sel_ldr_command + ['-Q']
56 test_args = ['--gdb', env['GDB'],
57 '--output_dir', env.subst('${TARGET_ROOT}/test_results')]
58 if env.Bit('tests_use_irt'):
59 test_args += ['--irt', env.GetIrtNexe()]
60 if not env.Bit('nacl_static_link'):
61 test_args += ['--ld_so', env.File('${NACL_SDK_LIB}/runnable-ld.so'),
62 '--library_path', env['NACL_SDK_LIB']]
63 test_args += ['--'] + sel_ldr_command
65 extra_deps = [env.File('gdb_test.py')]
67 test_suites = ['medium_tests', 'gdb_tests']
69 gdb_test_guest = env.ComponentProgram(
70 'gdb_test_guest', 'gdb_test_guest.c',
71 EXTRA_LIBS=['${NONIRT_LIBS}'])
72 gdb_test_guest = env.GetTranslatedNexe(gdb_test_guest)
74 # GDB treats multithreaded programs specially. Provide distinct nexe for
75 # multithreaded tests to isolate multiple threads-specific issues.
76 gdb_test_guest_thread = env.ComponentProgram(
77 'gdb_test_guest_thread', 'gdb_test_guest_thread.c',
78 EXTRA_LIBS=['${PTHREAD_LIBS}', '${NONIRT_LIBS}'])
79 gdb_test_guest_thread = env.GetTranslatedNexe(gdb_test_guest_thread)
82 # TempFileArguments: gdb_test_guest-based tests below accept a
83 # temporary file argument, and we encapsulate this here for brevity /
84 # to avoid code duplication.
85 def TempFileArguments():
86 temp_path = env.MakeEmptyFile(prefix='nacl_gdb_test_')
87 return ','.join(['-f', temp_path])
90 def AddGdbTest(name, is_broken=False, is_thread_test=False):
92 script_args = ['--nexe', gdb_test_guest_thread]
94 script_args = ['--nexe', gdb_test_guest,
95 '--nexe_args', TempFileArguments()]
96 node = env.CommandTest('%s.out' % name,
97 extra_deps=extra_deps,
98 command=(['${PYTHON}', env.File('%s.py' % name)]
101 # Don't run the host Python through qemu-arm.
102 direct_emulation=False)
103 env.TestBindsFixedTcpPort(node)
104 env.AddNodeToTestSuite(node, test_suites, 'run_gdb_%s_test' % name,
105 is_broken=(is_broken or env.Bit('no_gdb_tests')))
108 AddGdbTest('complete')
110 AddGdbTest('disconnect')
111 AddGdbTest('invalid_memory')
113 AddGdbTest('remote_get')
115 # Single-stepping does work reliably with ARM and MIPS in qemu due to the code
116 # cache not being flushable.
117 AddGdbTest('stepi_after_break', is_broken=env.UsingEmulator())
119 # This fails on ARM+PNaCl. The set_global_var function appears to be
120 # getting the wrong argument value (68K vs 1), so the value of
121 # global_var doesn't match the expected value.
122 # TODO(mseaborn): Investigate and enable this test.
123 # http://code.google.com/p/nativeclient/issues/detail?id=3252
124 AddGdbTest('print_symbol',
125 is_broken=((env.Bit('bitcode') and env.Bit('target_arm'))
126 or env.UsingEmulator()))
128 # This fails on ARM+PNaCl because it gets an
129 # unexpected value for a function argument from
130 # the stack backtrace.
131 # TODO(mseaborn): Investigate and enable this test.
132 # http://code.google.com/p/nativeclient/issues/detail?id=3252
133 AddGdbTest('stack_trace',
134 is_broken=env.Bit('bitcode') and env.Bit('target_arm'))
136 AddGdbTest('step_from_func_start', is_broken=env.UsingEmulator())
138 # This fails on MIPS, since GDB for MIPS executes inferior calls on stack
139 # (call dummy location in MIPS GDB is set as ON_STACK method). Since the stack
140 # is not executable under NaCl, this makes inferior call impossible to execute.
141 AddGdbTest('call_from_gdb', is_broken=env.Bit('target_mips32'))
143 # This fails on ARM/MIPS+PNaCl because it is reading
144 # local_var before it has been initialised.
145 # TODO(mseaborn): Investigate and enable this test.
146 # http://code.google.com/p/nativeclient/issues/detail?id=3252
147 AddGdbTest('change_variable',
148 is_broken=((env.Bit('bitcode') and env.Bit('target_arm')) or
149 env.Bit('target_mips32') or
150 env.UsingEmulator()))
152 if not env.Bit('nacl_static_link'):
153 AddGdbTest('execute_nacl_manifest_twice')
155 # This test hangs under qemu-arm because thread suspension doesn't
157 AddGdbTest('break_continue_thread', is_thread_test=True,
158 is_broken=env.UsingEmulator())
160 AddGdbTest('syscall_thread', is_thread_test=True)
162 # We don't run this test on non-x86 architectures or PNaCl since it
163 # contains inline assembly.
164 if env.Bit('target_x86') and not env.Bit('bitcode'):