Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 import struct | 6 import struct |
| 7 import subprocess | 7 import subprocess |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 import xml.etree.ElementTree | 10 import xml.etree.ElementTree |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 ('es', 'I'), | 82 ('es', 'I'), |
| 83 ('fs', 'I'), | 83 ('fs', 'I'), |
| 84 ('gs', 'I'), | 84 ('gs', 'I'), |
| 85 ] | 85 ] |
| 86 | 86 |
| 87 | 87 |
| 88 ARM_REG_DEFS = ([('r%d' % regno, 'I') for regno in xrange(16)] | 88 ARM_REG_DEFS = ([('r%d' % regno, 'I') for regno in xrange(16)] |
| 89 + [('cpsr', 'I')]) | 89 + [('cpsr', 'I')]) |
| 90 | 90 |
| 91 | 91 |
| 92 MIPS_REG_DEFS = [ | |
| 93 ('zero', 'I'), | |
| 94 ('at', 'I'), | |
| 95 ('v0', 'I'), | |
| 96 ('v1', 'I'), | |
| 97 ('a0', 'I'), | |
| 98 ('a1', 'I'), | |
| 99 ('a2', 'I'), | |
| 100 ('a3', 'I'), | |
| 101 ('t0', 'I'), | |
| 102 ('t1', 'I'), | |
| 103 ('t2', 'I'), | |
| 104 ('t3', 'I'), | |
| 105 ('t4', 'I'), | |
| 106 ('t5', 'I'), | |
| 107 ('t6', 'I'), | |
| 108 ('t7', 'I'), | |
| 109 ('s0', 'I'), | |
| 110 ('s1', 'I'), | |
| 111 ('s2', 'I'), | |
| 112 ('s3', 'I'), | |
| 113 ('s4', 'I'), | |
| 114 ('s5', 'I'), | |
| 115 ('s6', 'I'), | |
| 116 ('s7', 'I'), | |
| 117 ('t8', 'I'), | |
| 118 ('t9', 'I'), | |
| 119 ('k0', 'I'), | |
| 120 ('k1', 'I'), | |
| 121 ('global_ptr', 'I'), | |
| 122 ('stack_ptr', 'I'), | |
| 123 ('frame_ptr', 'I'), | |
| 124 ('return_addr', 'I'), | |
| 125 ('prog_ctr', 'I'), | |
| 126 ] | |
| 127 | |
| 128 | |
| 92 REG_DEFS = { | 129 REG_DEFS = { |
| 93 'x86-32': X86_32_REG_DEFS, | 130 'x86-32': X86_32_REG_DEFS, |
| 94 'x86-64': X86_64_REG_DEFS, | 131 'x86-64': X86_64_REG_DEFS, |
| 95 'arm': ARM_REG_DEFS, | 132 'arm': ARM_REG_DEFS, |
| 133 'mips32': MIPS_REG_DEFS, | |
| 96 } | 134 } |
| 97 | 135 |
| 98 | 136 |
| 99 SP_REG = { | 137 SP_REG = { |
| 100 'x86-32': 'esp', | 138 'x86-32': 'esp', |
| 101 'x86-64': 'rsp', | 139 'x86-64': 'rsp', |
| 102 'arm': 'r13', | 140 'arm': 'r13', |
| 141 'mips32': 'stack_ptr', | |
| 103 } | 142 } |
| 104 | 143 |
| 105 | 144 |
| 106 IP_REG = { | 145 IP_REG = { |
| 107 'x86-32': 'eip', | 146 'x86-32': 'eip', |
| 108 'x86-64': 'rip', | 147 'x86-64': 'rip', |
| 109 'arm': 'r15', | 148 'arm': 'r15', |
| 149 'mips32': 'prog_ctr', | |
| 110 } | 150 } |
| 111 | 151 |
| 112 | 152 |
| 113 X86_TRAP_FLAG = 1 << 8 | 153 X86_TRAP_FLAG = 1 << 8 |
| 114 | 154 |
| 115 # RESET_X86_FLAGS_VALUE is what ASM_WITH_REGS() resets the x86 flags | 155 # RESET_X86_FLAGS_VALUE is what ASM_WITH_REGS() resets the x86 flags |
| 116 # to. Copied from tests/common/register_set.h. | 156 # to. Copied from tests/common/register_set.h. |
| 117 RESET_X86_FLAGS_VALUE = (1 << 2) | (1 << 6) | 157 RESET_X86_FLAGS_VALUE = (1 << 2) | (1 << 6) |
| 118 KNOWN_X86_FLAGS_MASK = (1<<0) | (1<<2) | (1<<6) | (1<<7) | (1<<11) | (1<<8) | 158 KNOWN_X86_FLAGS_MASK = (1<<0) | (1<<2) | (1<<6) | (1<<7) | (1<<11) | (1<<8) |
| 119 | 159 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 def ReadMemory(connection, address, size): | 254 def ReadMemory(connection, address, size): |
| 215 reply = connection.RspRequest('m%x,%x' % (address, size)) | 255 reply = connection.RspRequest('m%x,%x' % (address, size)) |
| 216 assert not reply.startswith('E'), reply | 256 assert not reply.startswith('E'), reply |
| 217 return DecodeHex(reply) | 257 return DecodeHex(reply) |
| 218 | 258 |
| 219 | 259 |
| 220 def ReadUint32(connection, address): | 260 def ReadUint32(connection, address): |
| 221 return struct.unpack('I', ReadMemory(connection, address, 4))[0] | 261 return struct.unpack('I', ReadMemory(connection, address, 4))[0] |
| 222 | 262 |
| 223 | 263 |
| 264 def SingleSteppingWorks(ARCH): | |
|
Mark Seaborn
2013/12/26 23:23:43
Local variables should be lower case (upper case i
petarj
2013/12/27 12:59:43
Done, thanks.
| |
| 265 # Single-stepping is not yet supported on ARM and MIPS. | |
| 266 # TODO(eaeltsin): | |
| 267 # http://code.google.com/p/nativeclient/issues/detail?id=2911 | |
| 268 return ARCH in ('x86-32', 'x86-64') | |
| 269 | |
| 270 | |
| 224 class DebugStubTest(unittest.TestCase): | 271 class DebugStubTest(unittest.TestCase): |
| 225 | 272 |
| 226 def test_initial_breakpoint(self): | 273 def test_initial_breakpoint(self): |
| 227 # Any arguments to the nexe would work here because we are only | 274 # Any arguments to the nexe would work here because we are only |
| 228 # testing that we get a breakpoint at the _start entry point. | 275 # testing that we get a breakpoint at the _start entry point. |
| 229 with LaunchDebugStub('test_getting_registers') as connection: | 276 with LaunchDebugStub('test_getting_registers') as connection: |
| 230 reply = connection.RspRequest('?') | 277 reply = connection.RspRequest('?') |
| 231 AssertReplySignal(reply, NACL_SIGTRAP) | 278 AssertReplySignal(reply, NACL_SIGTRAP) |
| 232 | 279 |
| 233 def CheckTargetXml(self, connection): | 280 def CheckTargetXml(self, connection): |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 self.assertEquals(registers['r8'], 0x80000009) | 328 self.assertEquals(registers['r8'], 0x80000009) |
| 282 # Skip r9 because it is not supposed to be settable or readable | 329 # Skip r9 because it is not supposed to be settable or readable |
| 283 # by untrusted code. | 330 # by untrusted code. |
| 284 self.assertEquals(registers['r10'], 0xa000000b) | 331 self.assertEquals(registers['r10'], 0xa000000b) |
| 285 self.assertEquals(registers['r11'], 0xb000000c) | 332 self.assertEquals(registers['r11'], 0xb000000c) |
| 286 self.assertEquals(registers['r12'], 0xc000000d) | 333 self.assertEquals(registers['r12'], 0xc000000d) |
| 287 self.assertEquals(registers['r13'], 0x12345678) | 334 self.assertEquals(registers['r13'], 0x12345678) |
| 288 self.assertEquals(registers['r14'], 0xe000000f) | 335 self.assertEquals(registers['r14'], 0xe000000f) |
| 289 self.assertEquals(registers['cpsr'] & ARM_USER_CPSR_FLAGS_MASK, | 336 self.assertEquals(registers['cpsr'] & ARM_USER_CPSR_FLAGS_MASK, |
| 290 (1 << 29) | (1 << 27)) | 337 (1 << 29) | (1 << 27)) |
| 338 elif ARCH == 'mips32': | |
| 339 # We skip zero register because it cannot be set. | |
| 340 self.assertEquals(registers['at'], 0x11000220) | |
| 341 self.assertEquals(registers['v0'], 0x22000330) | |
| 342 self.assertEquals(registers['v1'], 0x33000440) | |
| 343 self.assertEquals(registers['a0'], 0x44000550) | |
| 344 self.assertEquals(registers['a1'], 0x55000660) | |
| 345 self.assertEquals(registers['a2'], 0x66000770) | |
| 346 self.assertEquals(registers['a3'], 0x77000880) | |
| 347 self.assertEquals(registers['t0'], 0x88000990) | |
| 348 self.assertEquals(registers['t1'], 0x99000aa0) | |
| 349 self.assertEquals(registers['t2'], 0xaa000bb0) | |
| 350 self.assertEquals(registers['t3'], 0xbb000cc0) | |
| 351 self.assertEquals(registers['t4'], 0xcc000dd0) | |
| 352 self.assertEquals(registers['t5'], 0xdd000ee0) | |
| 353 self.assertEquals(registers['t6'], 0x0ffffff0) | |
| 354 self.assertEquals(registers['t7'], 0x3fffffff) | |
| 355 # Skip t8 because it cannot be set by untrusted code. | |
| 356 self.assertEquals(registers['s0'], 0x11100222) | |
| 357 self.assertEquals(registers['s1'], 0x22200333) | |
| 358 self.assertEquals(registers['s2'], 0x33300444) | |
| 359 self.assertEquals(registers['s3'], 0x44400555) | |
| 360 self.assertEquals(registers['s4'], 0x55500666) | |
| 361 self.assertEquals(registers['s5'], 0x66600777) | |
| 362 self.assertEquals(registers['s6'], 0x77700888) | |
| 363 self.assertEquals(registers['s7'], 0x88800999) | |
| 364 self.assertEquals(registers['t9'], 0xaaa00bbb) | |
| 365 # Skip k0 and k1 registers, since they can be changed by kernel. | |
| 366 self.assertEquals(registers['global_ptr'], 0xddd00eee) | |
| 367 self.assertEquals(registers['stack_ptr'], 0x2ee00fff) | |
| 368 self.assertEquals(registers['frame_ptr'], 0xfff00000) | |
| 369 self.assertEquals(registers['return_addr'], 0x0a0a0a0a) | |
| 291 else: | 370 else: |
| 292 raise AssertionError('Unknown architecture') | 371 raise AssertionError('Unknown architecture') |
| 293 | 372 |
| 294 expected_fault_addr = GetSymbols()['fault_addr'] | 373 expected_fault_addr = GetSymbols()['fault_addr'] |
| 295 if ARCH == 'x86-64': | 374 if ARCH == 'x86-64': |
| 296 expected_fault_addr += registers['r15'] | 375 expected_fault_addr += registers['r15'] |
| 297 self.assertEquals(registers[IP_REG[ARCH]], expected_fault_addr) | 376 self.assertEquals(registers[IP_REG[ARCH]], expected_fault_addr) |
| 298 | 377 |
| 299 # Test that we can write registers. | 378 # Test that we can write registers. |
| 300 def CheckWriteRegisters(self, connection): | 379 def CheckWriteRegisters(self, connection): |
| 301 if ARCH == 'x86-32': | 380 if ARCH == 'x86-32': |
| 302 reg_name = 'edx' | 381 reg_name = 'edx' |
| 303 elif ARCH == 'x86-64': | 382 elif ARCH == 'x86-64': |
| 304 reg_name = 'rdx' | 383 reg_name = 'rdx' |
| 305 elif ARCH == 'arm': | 384 elif ARCH == 'arm': |
| 306 reg_name = 'r0' | 385 reg_name = 'r0' |
| 386 elif ARCH == 'mips32': | |
| 387 reg_name = 'a0' | |
| 307 else: | 388 else: |
| 308 raise AssertionError('Unknown architecture') | 389 raise AssertionError('Unknown architecture') |
| 309 | 390 |
| 310 # Read registers. | 391 # Read registers. |
| 311 regs = DecodeRegs(connection.RspRequest('g')) | 392 regs = DecodeRegs(connection.RspRequest('g')) |
| 312 | 393 |
| 313 # Change a register. | 394 # Change a register. |
| 314 regs[reg_name] += 1 | 395 regs[reg_name] += 1 |
| 315 new_value = regs[reg_name] | 396 new_value = regs[reg_name] |
| 316 | 397 |
| 317 # Write registers. | 398 # Write registers. |
| 318 self.assertEquals(connection.RspRequest('G' + EncodeRegs(regs)), 'OK') | 399 self.assertEquals(connection.RspRequest('G' + EncodeRegs(regs)), 'OK') |
| 319 | 400 |
| 320 # Read registers. Check for a new value. | 401 # Read registers. Check for a new value. |
| 321 regs = DecodeRegs(connection.RspRequest('g')) | 402 regs = DecodeRegs(connection.RspRequest('g')) |
| 322 self.assertEquals(regs[reg_name], new_value) | 403 self.assertEquals(regs[reg_name], new_value) |
| 323 | 404 |
| 324 # TODO: Resume execution and check that changing the registers really | 405 # TODO: Resume execution and check that changing the registers really |
| 325 # influenced the program's execution. This would require changing | 406 # influenced the program's execution. This would require changing |
| 326 # debugger_test.c. | 407 # debugger_test.c. |
| 327 | 408 |
| 328 def CheckReadOnlyRegisters(self, connection): | 409 def CheckReadOnlyRegisters(self, connection): |
| 329 if ARCH == 'x86-32': | 410 if ARCH == 'x86-32': |
| 330 sample_read_only_regs = ['cs', 'ds'] | 411 sample_read_only_regs = ['cs', 'ds'] |
| 331 elif ARCH == 'x86-64': | 412 elif ARCH == 'x86-64': |
| 332 sample_read_only_regs = ['r15', 'cs', 'ds'] | 413 sample_read_only_regs = ['r15', 'cs', 'ds'] |
| 333 elif ARCH == 'arm': | 414 elif ARCH == 'arm': |
| 334 sample_read_only_regs = [] | 415 sample_read_only_regs = [] |
| 416 elif ARCH == 'mips32': | |
| 417 sample_read_only_regs = ['zero'] | |
| 335 else: | 418 else: |
| 336 raise AssertionError('Unknown architecture') | 419 raise AssertionError('Unknown architecture') |
| 337 | 420 |
| 338 for reg_name in sample_read_only_regs: | 421 for reg_name in sample_read_only_regs: |
| 339 # Read registers. | 422 # Read registers. |
| 340 regs = DecodeRegs(connection.RspRequest('g')) | 423 regs = DecodeRegs(connection.RspRequest('g')) |
| 341 | 424 |
| 342 # Change a register. | 425 # Change a register. |
| 343 old_value = regs[reg_name] | 426 old_value = regs[reg_name] |
| 344 regs[reg_name] += 1 | 427 regs[reg_name] += 1 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 360 mem_addr = 0xffff | 443 mem_addr = 0xffff |
| 361 resut = connection.RspRequest('m%x,%x' % (mem_addr, 1)) | 444 resut = connection.RspRequest('m%x,%x' % (mem_addr, 1)) |
| 362 self.assertEquals(result, 'E03') | 445 self.assertEquals(result, 'E03') |
| 363 | 446 |
| 364 # Run tests on debugger_test.c binary. | 447 # Run tests on debugger_test.c binary. |
| 365 def test_debugger_test(self): | 448 def test_debugger_test(self): |
| 366 with LaunchDebugStub('test_getting_registers') as connection: | 449 with LaunchDebugStub('test_getting_registers') as connection: |
| 367 # Tell the process to continue, because it starts at the | 450 # Tell the process to continue, because it starts at the |
| 368 # breakpoint set at its start address. | 451 # breakpoint set at its start address. |
| 369 reply = connection.RspRequest('c') | 452 reply = connection.RspRequest('c') |
| 370 if ARCH == 'arm': | 453 if ARCH == 'arm' or ARCH == 'mips32': |
| 371 # The process should have stopped on a BKPT instruction. | 454 # The process should have stopped on a BKPT instruction. |
| 372 AssertReplySignal(reply, NACL_SIGTRAP) | 455 AssertReplySignal(reply, NACL_SIGTRAP) |
| 373 else: | 456 else: |
| 374 # The process should have stopped on a HLT instruction. | 457 # The process should have stopped on a HLT instruction. |
| 375 AssertReplySignal(reply, NACL_SIGSEGV) | 458 AssertReplySignal(reply, NACL_SIGSEGV) |
| 376 | 459 |
| 377 self.CheckTargetXml(connection) | 460 self.CheckTargetXml(connection) |
| 378 self.CheckReadRegisters(connection) | 461 self.CheckReadRegisters(connection) |
| 379 self.CheckWriteRegisters(connection) | 462 self.CheckWriteRegisters(connection) |
| 380 self.CheckReadOnlyRegisters(connection) | 463 self.CheckReadOnlyRegisters(connection) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 reply = connection.RspRequest(step_command) | 527 reply = connection.RspRequest(step_command) |
| 445 AssertReplySignal(reply, NACL_SIGTRAP) | 528 AssertReplySignal(reply, NACL_SIGTRAP) |
| 446 self.assertEquals(ParseThreadStopReply(reply)['thread_id'], thread_id) | 529 self.assertEquals(ParseThreadStopReply(reply)['thread_id'], thread_id) |
| 447 ip += size | 530 ip += size |
| 448 regs = DecodeRegs(connection.RspRequest('g')) | 531 regs = DecodeRegs(connection.RspRequest('g')) |
| 449 self.assertEqual(regs[IP_REG[ARCH]], ip) | 532 self.assertEqual(regs[IP_REG[ARCH]], ip) |
| 450 # The trap flag should be reported as unset. | 533 # The trap flag should be reported as unset. |
| 451 self.assertEqual(regs['eflags'] & X86_TRAP_FLAG, 0) | 534 self.assertEqual(regs['eflags'] & X86_TRAP_FLAG, 0) |
| 452 | 535 |
| 453 def test_single_step(self): | 536 def test_single_step(self): |
| 454 if ARCH == 'arm': | 537 if not SingleSteppingWorks(ARCH): |
| 455 # Skip this test because single-stepping is not supported on ARM. | |
| 456 # TODO(eaeltsin): | |
| 457 # http://code.google.com/p/nativeclient/issues/detail?id=2911 | |
| 458 return | 538 return |
| 459 with LaunchDebugStub('test_single_step') as connection: | 539 with LaunchDebugStub('test_single_step') as connection: |
| 460 # We expect test_single_step() to stop at a HLT instruction. | 540 # We expect test_single_step() to stop at a HLT instruction. |
| 461 reply = connection.RspRequest('c') | 541 reply = connection.RspRequest('c') |
| 462 AssertReplySignal(reply, NACL_SIGSEGV) | 542 AssertReplySignal(reply, NACL_SIGSEGV) |
| 463 tid = ParseThreadStopReply(reply)['thread_id'] | 543 tid = ParseThreadStopReply(reply)['thread_id'] |
| 464 # Skip past the single-byte HLT instruction. | 544 # Skip past the single-byte HLT instruction. |
| 465 regs = DecodeRegs(connection.RspRequest('g')) | 545 regs = DecodeRegs(connection.RspRequest('g')) |
| 466 regs[IP_REG[ARCH]] += 1 | 546 regs[IP_REG[ARCH]] += 1 |
| 467 AssertEquals(connection.RspRequest('G' + EncodeRegs(regs)), 'OK') | 547 AssertEquals(connection.RspRequest('G' + EncodeRegs(regs)), 'OK') |
| 468 | 548 |
| 469 self.CheckSingleStep(connection, 's', tid) | 549 self.CheckSingleStep(connection, 's', tid) |
| 470 # Check that we can continue after single-stepping. | 550 # Check that we can continue after single-stepping. |
| 471 reply = connection.RspRequest('c') | 551 reply = connection.RspRequest('c') |
| 472 self.assertEquals(reply, 'W00') | 552 self.assertEquals(reply, 'W00') |
| 473 | 553 |
| 474 def test_vCont(self): | 554 def test_vCont(self): |
| 475 # Basically repeat test_single_step, but using vCont commands. | 555 # Basically repeat test_single_step, but using vCont commands. |
| 476 if ARCH == 'arm': | 556 if not SingleSteppingWorks(ARCH): |
| 477 # Skip this test because single-stepping is not supported on ARM. | |
| 478 # TODO(eaeltsin): | |
| 479 # http://code.google.com/p/nativeclient/issues/detail?id=2911 | |
| 480 return | 557 return |
| 481 with LaunchDebugStub('test_single_step') as connection: | 558 with LaunchDebugStub('test_single_step') as connection: |
| 482 # Test if vCont is supported. | 559 # Test if vCont is supported. |
| 483 reply = connection.RspRequest('vCont?') | 560 reply = connection.RspRequest('vCont?') |
| 484 self.assertEqual(reply, 'vCont;s;S;c;C') | 561 self.assertEqual(reply, 'vCont;s;S;c;C') |
| 485 | 562 |
| 486 # Continue using vCont. | 563 # Continue using vCont. |
| 487 # We expect test_single_step() to stop at a HLT instruction. | 564 # We expect test_single_step() to stop at a HLT instruction. |
| 488 reply = connection.RspRequest('vCont;c') | 565 reply = connection.RspRequest('vCont;c') |
| 489 AssertReplySignal(reply, NACL_SIGSEGV) | 566 AssertReplySignal(reply, NACL_SIGSEGV) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 508 | 585 |
| 509 # Try to single-step wrong thread. | 586 # Try to single-step wrong thread. |
| 510 reply = connection.RspRequest('vCont;s:%x' % (tid + 2)) | 587 reply = connection.RspRequest('vCont;s:%x' % (tid + 2)) |
| 511 self.assertTrue(reply.startswith('E')) | 588 self.assertTrue(reply.startswith('E')) |
| 512 | 589 |
| 513 # Try to single-step all threads. | 590 # Try to single-step all threads. |
| 514 reply = connection.RspRequest('vCont;s') | 591 reply = connection.RspRequest('vCont;s') |
| 515 self.assertTrue(reply.startswith('E')) | 592 self.assertTrue(reply.startswith('E')) |
| 516 | 593 |
| 517 def test_interrupt(self): | 594 def test_interrupt(self): |
| 518 if ARCH == 'arm': | 595 if not SingleSteppingWorks(ARCH): |
| 519 # Skip this test because single-stepping is not supported on ARM. | |
| 520 # TODO(eaeltsin): | |
| 521 # http://code.google.com/p/nativeclient/issues/detail?id=2911 | |
| 522 return | 596 return |
| 523 func_addr = GetSymbols()['test_interrupt'] | 597 func_addr = GetSymbols()['test_interrupt'] |
| 524 with LaunchDebugStub('test_interrupt') as connection: | 598 with LaunchDebugStub('test_interrupt') as connection: |
| 525 # Single stepping inside syscalls doesn't work. So we need to reach | 599 # Single stepping inside syscalls doesn't work. So we need to reach |
| 526 # a point where interrupt will not catch the program inside syscall. | 600 # a point where interrupt will not catch the program inside syscall. |
| 527 reply = connection.RspRequest('Z0,%x,0' % func_addr) | 601 reply = connection.RspRequest('Z0,%x,0' % func_addr) |
| 528 self.assertEquals(reply, 'OK') | 602 self.assertEquals(reply, 'OK') |
| 529 reply = connection.RspRequest('c') | 603 reply = connection.RspRequest('c') |
| 530 AssertReplySignal(reply, NACL_SIGTRAP) | 604 AssertReplySignal(reply, NACL_SIGTRAP) |
| 531 reply = connection.RspRequest('z0,%x,0' % func_addr) | 605 reply = connection.RspRequest('z0,%x,0' % func_addr) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 regs = DecodeRegs(connection.RspRequest('g')) | 714 regs = DecodeRegs(connection.RspRequest('g')) |
| 641 if ARCH in ('x86-32', 'x86-64'): | 715 if ARCH in ('x86-32', 'x86-64'): |
| 642 AssertReplySignal(stop_reply, NACL_SIGSEGV) | 716 AssertReplySignal(stop_reply, NACL_SIGSEGV) |
| 643 # Skip past the single-byte HLT instruction. | 717 # Skip past the single-byte HLT instruction. |
| 644 regs[IP_REG[ARCH]] += 1 | 718 regs[IP_REG[ARCH]] += 1 |
| 645 elif ARCH == 'arm': | 719 elif ARCH == 'arm': |
| 646 AssertReplySignal(stop_reply, NACL_SIGTRAP) | 720 AssertReplySignal(stop_reply, NACL_SIGTRAP) |
| 647 bundle_size = 16 | 721 bundle_size = 16 |
| 648 assert regs['r15'] % bundle_size == 0, regs['r15'] | 722 assert regs['r15'] % bundle_size == 0, regs['r15'] |
| 649 regs['r15'] += bundle_size | 723 regs['r15'] += bundle_size |
| 724 elif ARCH == 'mips32': | |
| 725 AssertReplySignal(stop_reply, NACL_SIGTRAP) | |
| 726 bundle_size = 16 | |
| 727 assert regs['prog_ctr'] % bundle_size == 0, regs['prog_ctr'] | |
| 728 regs['prog_ctr'] += bundle_size | |
| 650 else: | 729 else: |
| 651 raise AssertionError('Unknown architecture') | 730 raise AssertionError('Unknown architecture') |
| 652 AssertEquals(connection.RspRequest('G' + EncodeRegs(regs)), 'OK') | 731 AssertEquals(connection.RspRequest('G' + EncodeRegs(regs)), 'OK') |
| 653 | 732 |
| 654 def WaitForTestThreadsToStart(self, connection, symbols): | 733 def WaitForTestThreadsToStart(self, connection, symbols): |
| 655 # Wait until: | 734 # Wait until: |
| 656 # * The main thread starts to modify g_main_thread_var. | 735 # * The main thread starts to modify g_main_thread_var. |
| 657 # * The child thread executes a breakpoint. | 736 # * The child thread executes a breakpoint. |
| 658 old_value = ReadUint32(connection, symbols['g_main_thread_var']) | 737 old_value = ReadUint32(connection, symbols['g_main_thread_var']) |
| 659 while True: | 738 while True: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 global NM_TOOL | 813 global NM_TOOL |
| 735 global SEL_LDR_COMMAND | 814 global SEL_LDR_COMMAND |
| 736 ARCH = args.pop(0) | 815 ARCH = args.pop(0) |
| 737 NM_TOOL = args.pop(0) | 816 NM_TOOL = args.pop(0) |
| 738 SEL_LDR_COMMAND = args | 817 SEL_LDR_COMMAND = args |
| 739 unittest.main() | 818 unittest.main() |
| 740 | 819 |
| 741 | 820 |
| 742 if __name__ == '__main__': | 821 if __name__ == '__main__': |
| 743 Main() | 822 Main() |
| OLD | NEW |