Skip to content

Commit a985320

Browse files
committed
Support all as parameter in gdb goroutine commands.
For example, can use `goroutine all bt` to dump all goroutines infomation.
1 parent b56e247 commit a985320

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/runtime/runtime-gdb.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,20 @@ def __init__(self):
518518
gdb.Command.__init__(self, "goroutine", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
519519

520520
def invoke(self, arg, _from_tty):
521-
goid, cmd = arg.split(None, 1)
522-
goid = gdb.parse_and_eval(goid)
523-
pc, sp = find_goroutine(int(goid))
521+
goid_str, cmd = arg.split(None, 1)
522+
goids = []
523+
524+
if goid_str == 'all':
525+
for ptr in SliceValue(gdb.parse_and_eval("'runtime.allgs'")):
526+
goids.append(int(ptr['goid']))
527+
else:
528+
goids = [int(gdb.parse_and_eval(goid_str))]
529+
530+
for goid in goids:
531+
self._invoke(goid, cmd)
532+
533+
def _invoke(self, goid, cmd):
534+
pc, sp = find_goroutine(goid)
524535
if not pc:
525536
print("No such goroutine: ", goid)
526537
return

0 commit comments

Comments
 (0)