MCPcopy Create free account
hub / github.com/apache/brpc / BthreadAllCmd

Class BthreadAllCmd

tools/gdb_bthread_stack.py:147–174  ·  view source on GitHub ↗

print all bthread frames

Source from the content-addressed store, hash-verified

145 gdb.parse_and_eval("$rbp = {}".format(rbp))
146
147class BthreadAllCmd(gdb.Command):
148 """print all bthread frames"""
149 def __init__(self):
150 gdb.Command.__init__(self, "bthread_all", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
151
152 def invoke(self, arg, tty):
153 global status
154 global bthreads
155 if not status:
156 print("Not in bthread debug mode")
157 return
158 for bthread_id in range(len(bthreads)):
159 stack = bthreads[bthread_id]["stack"]
160 if str(stack) == "0x0":
161 print("this bthread has no stack")
162 continue
163 try:
164 context = gdb.parse_and_eval("(*(('bthread::ContextualStack' *){})).context".format(stack))
165 rip = gdb.parse_and_eval("*(uint64_t*)({}+7*8)".format(context))
166 rbp = gdb.parse_and_eval("*(uint64_t*)({}+6*8)".format(context))
167 rsp = gdb.parse_and_eval("{}+8*8".format(context))
168 gdb.parse_and_eval("$rip = {}".format(rip))
169 gdb.parse_and_eval("$rsp = {}".format(rsp))
170 gdb.parse_and_eval("$rbp = {}".format(rbp))
171 print("Bthread {}:".format(bthread_id))
172 gdb.execute('bt')
173 except Exception as e:
174 pass
175
176class BthreadRegsCmd(gdb.Command):
177 """bthread_regs <id>, print bthread registers"""

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected