This commit is contained in:
Felix Geisendörfer 2021-03-22 15:17:01 +01:00
parent 6a34d89513
commit 48693a2c50
2 changed files with 3 additions and 12 deletions

View file

@ -1,8 +1,4 @@
# TODO
# Get stack lo from goroutine
# Use the stacktrace API to unwind the stack and get annotations
word_size = 8 # 64bit
word_size = 8 # 64bit only for now
def get_reg(name):
for req in registers().Regs:
@ -143,10 +139,5 @@ def command_stackannotate():
])
print(ascii_table(rows))
#g = getg()
#for f in stacktrace(g.goid, 128, True).Locations:
#print(f)
#break
def main():
dlv_command("config alias stackannotate sa")

View file

@ -46,9 +46,9 @@ The next step is to find the program counters of all the callers of the current
### Real Example
Looking at pretty pictures can be good way to get a high level understanding of the stack, but it has its limits. Sometimes you need to look at the raw bits & bytes in order to get a full understanding. If you're not interested in that, feel free to skip ahead to the next section.
Looking at pretty pictures can be a good way to get a high level understanding of the stack, but it has its limits. Sometimes you need to look at the raw bits & bytes in order to get a full understanding. If you're not interested in that, feel free to skip ahead to the next section.
To take a look at the stack, we'll use [delve](https://github.com/go-delve/delve) which is a wonderful debugger for Go. In order to inspect the stack I wrote a script called [stackannotate.star](./delve/stackannotate.star) that can used to print the annotated stack for a simple [example program](examples/stackannotate/main.go) as can be seen below:
To take a look at the stack, we'll use [delve](https://github.com/go-delve/delve) which is a wonderful debugger for Go. In order to inspect the stack, I wrote a script called [stackannotate.star](./delve/stackannotate.star) that can used to print the annotated stack for a simple [example program](examples/stackannotate/main.go):
```
$ dlv debug ./examples/stackannotate/main.go