enter bthread debug mode
| 227 | print(bthreads[bthread_id]) |
| 228 | |
| 229 | class BthreadBeginCmd(gdb.Command): |
| 230 | """enter bthread debug mode""" |
| 231 | def __init__(self): |
| 232 | gdb.Command.__init__(self, "bthread_begin", gdb.COMMAND_STACK, gdb.COMPLETE_NONE) |
| 233 | |
| 234 | def invoke(self, arg, tty): |
| 235 | global status |
| 236 | if status: |
| 237 | print("Already in bthread debug mode, do not switch thread before exec 'bthread_end' !!!") |
| 238 | return |
| 239 | active_bthreads = get_bthread_num() |
| 240 | scanned_bthreads = active_bthreads |
| 241 | if arg: |
| 242 | num_arg = int(arg) |
| 243 | if num_arg < active_bthreads: |
| 244 | scanned_bthreads = num_arg |
| 245 | else: |
| 246 | print("requested bthreads {} more than actived, will display {} bthreads".format(num_arg, scanned_bthreads)) |
| 247 | print("Active bthreads: {}, will display {} bthreads".format(active_bthreads, scanned_bthreads)) |
| 248 | get_all_bthreads(scanned_bthreads) |
| 249 | gdb.parse_and_eval("$saved_rip = $rip") |
| 250 | gdb.parse_and_eval("$saved_rsp = $rsp") |
| 251 | gdb.parse_and_eval("$saved_rbp = $rbp") |
| 252 | status = True |
| 253 | print("Enter bthread debug mode, do not switch thread before exec 'bthread_end' !!!") |
| 254 | |
| 255 | class BthreadRegRestoreCmd(gdb.Command): |
| 256 | """restore registers""" |