Changes in tools/gdb/utils-gdb.py [6abcb4d:d8b17e2]
- File:
-
- 1 edited
-
tools/gdb/utils-gdb.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/gdb/utils-gdb.py
r6abcb4d rd8b17e2 23 23 gdb.execute('handle SIGUSR1 nostop noprint pass') 24 24 25 CfaTypes = collections.namedtuple('CfaTypes', 'cluster_ptr processor_ptr thread_ptr int_ptr thread_state yield_state')25 CfaTypes = collections.namedtuple('CfaTypes', 'cluster_ptr processor_ptr thread_ptr int_ptr thread_state') 26 26 27 27 class ThreadInfo: … … 52 52 # GDB types for various structures/types in CFA 53 53 return CfaTypes(cluster_ptr = gdb.lookup_type('struct cluster').pointer(), 54 processor_ptr = gdb.lookup_type('struct processor').pointer(), 55 thread_ptr = gdb.lookup_type('struct $thread').pointer(), 56 int_ptr = gdb.lookup_type('int').pointer(), 57 thread_state = gdb.lookup_type('enum __Coroutine_State'), 58 yield_state = gdb.lookup_type('enum __Preemption_Reason')) 54 processor_ptr = gdb.lookup_type('struct processor').pointer(), 55 thread_ptr = gdb.lookup_type('struct $thread').pointer(), 56 int_ptr = gdb.lookup_type('int').pointer(), 57 thread_state = gdb.lookup_type('enum __Coroutine_State')) 59 58 60 59 def get_addr(addr): … … 372 371 def print_thread(self, thread, tid, marked): 373 372 cfa_t = get_cfa_types() 374 ys = str(thread['preempted'].cast(cfa_t.yield_state)) 375 if ys == '_X15__NO_PREEMPTIONKM19__Preemption_Reason_1': 376 state = str(thread['state'].cast(cfa_t.thread_state)) 377 elif ys == '_X18__ALARM_PREEMPTIONKM19__Preemption_Reason_1': 378 state = 'preempted' 379 elif ys == '_X19__MANUAL_PREEMPTIONKM19__Preemption_Reason_1': 380 state = 'yield' 381 elif ys == '_X17__POLL_PREEMPTIONKM19__Preemption_Reason_1': 382 state = 'poll' 383 else: 384 print("error: thread {} in undefined preemption state {}".format(thread, ys)) 385 state = 'error' 386 self.print_formatted(marked, tid, thread['self_cor']['name'].string(), state, str(thread)) 373 self.print_formatted(marked, tid, thread['self_cor']['name'].string(), str(thread['state'].cast(cfa_t.thread_state)), str(thread)) 387 374 388 375 def print_threads_by_cluster(self, cluster, print_system = False): … … 493 480 context = thread['context'] 494 481 495 482 # lookup for sp,fp and uSwitch 483 xsp = context['SP'] + 48 484 xfp = context['FP'] 485 486 # convert string so we can strip out the address 487 try: 488 xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address + 28) 489 except: 490 print("here") 491 return 496 492 497 493 # must be at frame 0 to set pc register 498 494 gdb.execute('select-frame 0') 499 if gdb.selected_frame().architecture().name() != 'i386:x86-64':500 print('gdb debugging only supported for i386:x86-64 for now')501 return502 503 # gdb seems to handle things much better if we pretend we just entered the context switch504 # pretend the pc is __cfactx_switch and adjust the sp, base pointer doesn't need to change505 # lookup for sp,fp and uSwitch506 xsp = context['SP'] + 40 # 40 = 5 64bit registers : %r15, %r14, %r13, %r12, %rbx WARNING: x64 specific507 xfp = context['FP']508 509 # convert string so we can strip out the address510 try:511 xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address)512 except:513 print("here")514 return515 495 516 496 # push sp, fp, pc into a global stack … … 523 503 524 504 # update registers for new task 525 # print('switching to {} ({}) : [{}, {}, {}]'.format(thread['self_cor']['name'].string(), str(thread), str(xsp), str(xfp), str(xpc))) 526 print('switching to thread {} ({})'.format(str(thread), thread['self_cor']['name'].string())) 505 print('switching to ') 527 506 gdb.execute('set $rsp={}'.format(xsp)) 528 507 gdb.execute('set $rbp={}'.format(xfp)) … … 573 552 574 553 argv = parse(arg) 554 print(argv) 575 555 if argv[0].isdigit(): 576 556 cname = " ".join(argv[1:]) if len(argv) > 1 else None
Note:
See TracChangeset
for help on using the changeset viewer.