OLD | NEW |
1 # -*- python -*- | 1 # -*- python -*- |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import json | 6 import json |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import re | 9 import re |
10 import socket | 10 import socket |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 'GDB reported stop reason %r but we expected %r (full info is %r)' | 240 'GDB reported stop reason %r but we expected %r (full info is %r)' |
241 % (stop_info.get('reason'), expected_stop_reason, stop_info)) | 241 % (stop_info.get('reason'), expected_stop_reason, stop_info)) |
242 | 242 |
243 def Quit(self): | 243 def Quit(self): |
244 status, items = self._GetResultRecord(self._SendRequest('-gdb-exit')) | 244 status, items = self._GetResultRecord(self._SendRequest('-gdb-exit')) |
245 AssertEquals(status, '^exit') | 245 AssertEquals(status, '^exit') |
246 | 246 |
247 def Eval(self, expression): | 247 def Eval(self, expression): |
248 return self.Command('-data-evaluate-expression ' + expression)['value'] | 248 return self.Command('-data-evaluate-expression ' + expression)['value'] |
249 | 249 |
| 250 def LoadManifestFile(self): |
| 251 assert self._manifest_file is not None |
| 252 # gdb uses bash-like escaping which removes slashes from Windows paths. |
| 253 self.Command('nacl-manifest ' + FilenameToUnix(self._manifest_file)) |
| 254 |
250 def Connect(self): | 255 def Connect(self): |
251 self._GetResponse() | 256 self._GetResponse() |
252 if self._options.irt is not None: | 257 if self._options.irt is not None: |
253 self.Command('nacl-irt ' + FilenameToUnix(self._options.irt)) | 258 self.Command('nacl-irt ' + FilenameToUnix(self._options.irt)) |
254 if self._options.ld_so is not None: | 259 if self._options.ld_so is not None: |
255 # gdb uses bash-like escaping which removes slashes from Windows paths. | 260 self._manifest_file = GenerateManifest(self._options.output_dir, |
256 manifest_file = GenerateManifest(self._options.output_dir, | 261 self._options.nexe, |
257 self._options.nexe, | 262 self._options.ld_so, |
258 self._options.ld_so, | 263 self._name) |
259 self._name) | 264 self.LoadManifestFile() |
260 self.Command('nacl-manifest ' + FilenameToUnix(manifest_file)) | |
261 self.Command('set breakpoint pending on') | 265 self.Command('set breakpoint pending on') |
262 else: | 266 else: |
263 self.Command('file ' + FilenameToUnix(self._options.nexe)) | 267 self.Command('file ' + FilenameToUnix(self._options.nexe)) |
264 self.Command('target remote :4014') | 268 self.Command('target remote :4014') |
265 | 269 |
266 | 270 |
267 def RunTest(test_func, test_name): | 271 def RunTest(test_func, test_name): |
268 parser = optparse.OptionParser() | 272 parser = optparse.OptionParser() |
269 parser.add_option('--output_dir', help='Output directory for log files') | 273 parser.add_option('--output_dir', help='Output directory for log files') |
270 parser.add_option('--gdb', help='Filename of GDB') | 274 parser.add_option('--gdb', help='Filename of GDB') |
271 parser.add_option('--irt', help='Filename of irt.nexe (optional)') | 275 parser.add_option('--irt', help='Filename of irt.nexe (optional)') |
272 parser.add_option('--ld_so', help='Filename of dynamic linker (optional)') | 276 parser.add_option('--ld_so', help='Filename of dynamic linker (optional)') |
273 parser.add_option('--library_path', | 277 parser.add_option('--library_path', |
274 help='Directory containing dynamic libraries, ' | 278 help='Directory containing dynamic libraries, ' |
275 'if using dynamic linking (optional)') | 279 'if using dynamic linking (optional)') |
276 parser.add_option('--nexe', help='Filename of main NaCl executable') | 280 parser.add_option('--nexe', help='Filename of main NaCl executable') |
277 options, sel_ldr_command = parser.parse_args() | 281 options, sel_ldr_command = parser.parse_args() |
278 | 282 |
279 sel_ldr = LaunchSelLdr(sel_ldr_command, options, test_name) | 283 sel_ldr = LaunchSelLdr(sel_ldr_command, options, test_name) |
280 try: | 284 try: |
281 with Gdb(options, test_name) as gdb: | 285 with Gdb(options, test_name) as gdb: |
282 gdb.Connect() | 286 gdb.Connect() |
283 test_func(gdb) | 287 test_func(gdb) |
284 finally: | 288 finally: |
285 KillProcess(sel_ldr) | 289 KillProcess(sel_ldr) |
OLD | NEW |