我有一个函数,它在我的go文件中给我一个gdb backtrace,如:
func backtrace(){... fmt.Println ("backtrace details")}
我希望将此函数输出公开给qml。我怎么能这样做?
编辑:
func backtrace(){
output,_:=debug.Send("stack-list-frames")
pay:=output["payload"]
payAssert:=pay.(map[string]interface{})
stack:=payAssert["stack"]
stackAssert:=stack.([]interface{})
nbreFct:=len(stackAssert)
for i:=0; i<=nbreFct-1 ; i++{
stackSepare:=stackAssert[i]
stackSepareAssert:=stackSepare.(map[string]interface{})
frame:=stackSepareAssert["frame"]
frameAssert:=frame.(map[string]interface{})
index := strconv.Itoa(i)
fmt.Println("Frame : ", index)
//list variables by frame
output_variables,_ := debug.Send("stack-list-variables","--thread","1","--frame",index,"--simple-values")
map_variables := output_variables["payload"]
m_variables := map_variables.(map[string]interface{})
variables := m_variables["variables"]
fmt.Println("Variables : ", variables)
fun:=frameAssert["func"]
line:=frameAssert["line"]
level:=frameAssert["level"]
fmt.Println("level : ",level,"function : ",fun ," line : ",line)
}
}
如何改进代码输出以将输出公开给qml?