Changeset c0c0bd5 for tools


Ignore:
Timestamp:
Apr 15, 2021, 2:58:49 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
84cd72d
Parents:
76c94bf
Message:

Attempt to make gdb utils more robust by pretending threads just entered the context switch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gdb/utils-gdb.py

    r76c94bf rc0c0bd5  
    480480                context = thread['context']
    481481
     482
     483
     484                # must be at frame 0 to set pc register
     485                gdb.execute('select-frame 0')
     486                if gdb.selected_frame().architecture().name() != 'i386:x86-64':
     487                        print('gdb debugging only supported for i386:x86-64 for now')
     488                        return
     489
     490                # gdb seems to handle things much better if we pretend we just entered the context switch
     491                # pretend the pc is __cfactx_switch and adjust the sp, base pointer doesn't need to change
    482492                # lookup for sp,fp and uSwitch
    483                 xsp = context['SP'] + 48
     493                xsp = context['SP'] + 40 # 40 = 5 64bit registers : %r15, %r14, %r13, %r12, %rbx WARNING: x64 specific
    484494                xfp = context['FP']
    485495
    486496                # convert string so we can strip out the address
    487497                try:
    488                         xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address + 28)
     498                        xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address)
    489499                except:
    490500                        print("here")
    491501                        return
    492 
    493                 # must be at frame 0 to set pc register
    494                 gdb.execute('select-frame 0')
    495502
    496503                # push sp, fp, pc into a global stack
     
    503510
    504511                # update registers for new task
    505                 print('switching to ')
     512                # print('switching to {} ({}) : [{}, {}, {}]'.format(thread['self_cor']['name'].string(), str(thread), str(xsp), str(xfp), str(xpc)))
     513                print('switching to thread {} ({})'.format(str(thread), thread['self_cor']['name'].string()))
    506514                gdb.execute('set $rsp={}'.format(xsp))
    507515                gdb.execute('set $rbp={}'.format(xfp))
     
    552560
    553561                argv = parse(arg)
    554                 print(argv)
    555562                if argv[0].isdigit():
    556563                        cname = " ".join(argv[1:]) if len(argv) > 1 else None
Note: See TracChangeset for help on using the changeset viewer.