Commit 43512e6c authored by Luuk van Dijk's avatar Luuk van Dijk

runtime: fix gdb support for goroutines.

in gdb, 'info goroutines' and 'goroutine <n> <cmd> were crashing
because the 'g' and 'm' structures had changed a bit.

R=rsc
CC=golang-dev
https://golang.org/cl/4289077
parent 6b335712
...@@ -215,6 +215,8 @@ class IfacePrinter: ...@@ -215,6 +215,8 @@ class IfacePrinter:
return 'string' return 'string'
def to_string(self): def to_string(self):
if self.val['data'] == 0:
return 0x0
try: try:
dtype = iface_dtype(self.val) dtype = iface_dtype(self.val)
except: except:
...@@ -308,15 +310,11 @@ class GoroutinesCmd(gdb.Command): ...@@ -308,15 +310,11 @@ class GoroutinesCmd(gdb.Command):
for ptr in linked_list(gdb.parse_and_eval("'runtime.allg'"), 'alllink'): for ptr in linked_list(gdb.parse_and_eval("'runtime.allg'"), 'alllink'):
if ptr['status'] == 6: # 'gdead' if ptr['status'] == 6: # 'gdead'
continue continue
m = ptr['m']
s = ' ' s = ' '
if m: if ptr['m']:
pc = m['sched']['pc'].cast(vp)
sp = m['sched']['sp'].cast(vp)
s = '*' s = '*'
else: pc = ptr['sched']['pc'].cast(vp)
pc = ptr['sched']['pc'].cast(vp) sp = ptr['sched']['sp'].cast(vp)
sp = ptr['sched']['sp'].cast(vp)
blk = gdb.block_for_pc(long((pc))) blk = gdb.block_for_pc(long((pc)))
print s, ptr['goid'], "%8s" % sts[long((ptr['status']))], blk.function print s, ptr['goid'], "%8s" % sts[long((ptr['status']))], blk.function
...@@ -326,7 +324,7 @@ def find_goroutine(goid): ...@@ -326,7 +324,7 @@ def find_goroutine(goid):
if ptr['status'] == 6: # 'gdead' if ptr['status'] == 6: # 'gdead'
continue continue
if ptr['goid'] == goid: if ptr['goid'] == goid:
return [(ptr['m'] or ptr)['sched'][x].cast(vp) for x in 'pc', 'sp'] return [ptr['sched'][x].cast(vp) for x in 'pc', 'sp']
return None, None return None, None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment