def gdb_select_thread(_, target): hexfile = test_harness.build_program(['multithreaded.S'], image_type='raw') with EmulatorProcess(hexfile, num_cores=2), DebugConnection() as conn: # Read thread ID conn.expect('qC', 'QC01') # Each line is one thread tests = [ (7, 0xc7733c56), (5, 0xf54adec3), (1, 0x5afaf01e), (2, 0x1964682e), (3, 0x16cc6be1), (8, 0xcbff923), (4, 0x4596de2), (6, 0xcd920ca6), ] # Step all threads through initialization code (5 instructions) for thid in range(len(tests)): # Switch to thread conn.expect('Hg' + str(thid + 1), 'OK') # Read thread ID conn.expect('qC', 'QC0' + str(thid + 1)) for index in range(5): conn.expect('S', 'S05') # Read PC register conn.expect( 'g40', '{:08x}'.format(test_harness.endian_swap((index + 1) * 4))) # Now all threads are at the same instruction: # 00000014 move s0, 1 # Step each thread independently some number of steps and # write a value to register 1 for index, (num_steps, regval) in enumerate(tests): conn.expect('Hg' + str(index + 1), 'OK') # Switch to thread for _ in range(num_steps): conn.expect('S', 'S05') conn.expect('G01,{:08x}'.format(regval), 'OK') # Read back PC and register values for index, (num_steps, regval) in enumerate(tests): conn.expect('Hg' + str(index + 1), 'OK') # Switch to thread conn.expect( 'g40', '{:08x}'.format( test_harness.endian_swap(0x14 + num_steps * 4))) conn.expect('g01', '{:08x}'.format(regval)) # Try to switch to an invalid thread ID conn.expect('Hgfe', '') # Ensure still on thread 8 conn.expect('qC', 'QC08')
def gdb_select_thread(_, target): hexfile = test_harness.build_program(['multithreaded.S'], image_type='raw') with EmulatorProcess(hexfile, num_cores=2), DebugConnection() as conn: # Read thread ID conn.expect('qC', 'QC01') # Each line is one thread tests = [ (7, 0xc7733c56), (5, 0xf54adec3), (1, 0x5afaf01e), (2, 0x1964682e), (3, 0x16cc6be1), (8, 0xcbff923), (4, 0x4596de2), (6, 0xcd920ca6), ] # Step all threads through initialization code (5 instructions) for thid in range(len(tests)): # Switch to thread conn.expect('Hg' + str(thid + 1), 'OK') # Read thread ID conn.expect('qC', 'QC0' + str(thid + 1)) for index in range(5): conn.expect('S', 'S05') # Read PC register conn.expect('g40', '{:08x}'.format( test_harness.endian_swap((index + 1) * 4))) # Now all threads are at the same instruction: # 00000014 move s0, 1 # Step each thread independently some number of steps and # write a value to register 1 for index, (num_steps, regval) in enumerate(tests): conn.expect('Hg' + str(index + 1), 'OK') # Switch to thread for _ in range(num_steps): conn.expect('S', 'S05') conn.expect('G01,{:08x}'.format(regval), 'OK') # Read back PC and register values for index, (num_steps, regval) in enumerate(tests): conn.expect('Hg' + str(index + 1), 'OK') # Switch to thread conn.expect('g40', '{:08x}'.format( test_harness.endian_swap(0x14 + num_steps * 4))) conn.expect('g01', '{:08x}'.format(regval)) # Try to switch to an invalid thread ID conn.expect('Hgfe', '') # Ensure still on thread 8 conn.expect('qC', 'QC08')