Skip to content

Commit 3c7b364

Browse files
committed
Add Delve script to dump buffers (for debugging)
1 parent 44b8f0b commit 3c7b364

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

contrib/dump-bufs.star

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Delve (https://github.com/go-delve/delve) script to dump all GeeseFS file buffer states
2+
def main():
3+
# Like inodes = eval(None, "fs.inodes").Variable in the Flusher goroutine
4+
inodes = None
5+
for g in goroutines().Goroutines:
6+
s = stacktrace(g.ID, 100)
7+
i = 0
8+
for l in s.Locations:
9+
if l.Location.Function.Name_.endswith('.Flusher'):
10+
inodes = eval({ "GoroutineID": g.ID, "Frame": i }, "fs.inodes").Variable
11+
break
12+
i = i+1
13+
if not inodes:
14+
return
15+
for id in inodes.Value:
16+
inode = inodes.Value[id]
17+
if len(inode.buffers) > 0:
18+
print(inode.Name)
19+
for buf in inode.buffers:
20+
print(buf.offset, " ", buf.length, " ", buf.state, " ", buf.loading, " ", buf.zero, " ", buf.recency, " ", buf.dirtyID, " ", buf.data != None)

0 commit comments

Comments
 (0)