CallsiteAssembly decodes the callsite trailing/leading bytes depending on the value of the `leading` argument. The resulting string contains the decoded x86 machine opcodes in Intel assembler syntax.
(proc windows.Handle, leading bool)
| 145 | // The resulting string contains the decoded x86 machine |
| 146 | // opcodes in Intel assembler syntax. |
| 147 | func (f *Frame) CallsiteAssembly(proc windows.Handle, leading bool) string { |
| 148 | if f.Addr.InSystemRange() { |
| 149 | return "" |
| 150 | } |
| 151 | |
| 152 | size := uint(512) |
| 153 | base := f.Addr.Uintptr() |
| 154 | if leading { |
| 155 | base -= uintptr(size) |
| 156 | } |
| 157 | |
| 158 | buf := va.ReadArea(proc, base, size, size, false) |
| 159 | if len(buf) == 0 || va.Zeroed(buf) { |
| 160 | return "" |
| 161 | } |
| 162 | |
| 163 | var b strings.Builder |
| 164 | |
| 165 | for i := 0; i < len(buf); { |
| 166 | ins, err := x86asm.Decode(buf[i:], 64) |
| 167 | if err != nil { |
| 168 | return b.String() |
| 169 | } |
| 170 | b.WriteString(x86asm.IntelSyntax(ins, f.Addr.Uint64(), nil)) |
| 171 | b.WriteRune('|') |
| 172 | i += ins.Len |
| 173 | } |
| 174 | |
| 175 | return b.String() |
| 176 | } |
| 177 | |
| 178 | // Callstack is a sequence of stack frames |
| 179 | // representing function executions. |