github.com/eh-steve/goloader@v0.0.0-20240111193454-90ff3cfdae39/debug.go (about)

     1  package goloader
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/eh-steve/goloader/objabi/dataindex"
     7  )
     8  
     9  func dumpPCData(b []byte, prefix string) {
    10  	fmt.Println(prefix, b)
    11  	var pc uintptr
    12  	val := int32(-1)
    13  	var ok bool
    14  	b, ok = step(b, &pc, &val, true)
    15  	for {
    16  		if !ok || len(b) <= 0 {
    17  			fmt.Println(prefix, "step end")
    18  			break
    19  		}
    20  		fmt.Println(prefix, "pc:", pc, "val:", val)
    21  		b, ok = step(b, &pc, &val, false)
    22  	}
    23  }
    24  
    25  func dumpStackMap(f interface{}) {
    26  	finfo := findfunc(getFunctionPtr(f))
    27  	fmt.Println(funcname(finfo))
    28  	stkmap := (*stackmap)(funcdata(finfo, dataindex.FUNCDATA_LocalsPointerMaps))
    29  	fmt.Printf("%v %p\n", stkmap, stkmap)
    30  }