本文整理汇总了Golang中github.com/sirnewton01/gdblib.GDB类的典型用法代码示例。如果您正苦于以下问题:Golang GDB类的具体用法?Golang GDB怎么用?Golang GDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GDB类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addVariableHandlers
func addVariableHandlers(mygdb *gdblib.GDB) {
http.HandleFunc("/handle/variable/create", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.VarCreateParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.VarCreate(parms)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/variable/delete", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.VarDeleteParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
err = mygdb.VarDelete(parms)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/variable/listchildren", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.VarListChildrenParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.VarListChildren(parms)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
}
示例2: addBreakpointHandlers
func addBreakpointHandlers(mygdb *gdblib.GDB) {
http.HandleFunc("/handle/breakpoint/list", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
result, err := mygdb.BreakList()
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/breakpoint/insert", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.BreakInsertParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.BreakInsert(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/breakpoint/enable", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.BreakEnableParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
err = mygdb.BreakEnable(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/breakpoint/disable", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.BreakDisableParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
err = mygdb.BreakDisable(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
}
示例3: addFrameHandlers
func addFrameHandlers(mygdb *gdblib.GDB) {
http.HandleFunc("/handle/frame/stackinfo", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
result, err := mygdb.StackInfoFrame()
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/frame/stacklist", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.StackListFramesParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.StackListFrames(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/frame/variableslist", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.StackListVariablesParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.StackListVariables(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/file/get", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := make(map[string]string)
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
path := parms["File"]
if path == "" {
w.WriteHeader(400)
w.Write([]byte("No path provided"))
return
//.........这里部分代码省略.........
示例4: addExecHandlers
func addExecHandlers(mygdb *gdblib.GDB) {
http.HandleFunc("/handle/exec/next", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ExecNextParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err == nil {
err = mygdb.ExecNext(parms)
}
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/exec/step", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ExecStepParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err == nil {
err = mygdb.ExecStep(parms)
}
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/exec/continue", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ExecContinueParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err == nil {
err = mygdb.ExecContinue(parms)
}
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/exec/run", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ExecRunParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err == nil {
err = mygdb.ExecRun(parms)
}
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/exec/args", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ExecArgsParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err == nil {
err = mygdb.ExecArgs(parms)
}
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(200)
}))
http.HandleFunc("/handle/exec/interrupt", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ExecInterruptParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
mygdb.ExecInterrupt(parms)
if err != nil {
//.........这里部分代码省略.........
示例5: addThreadHandlers
func addThreadHandlers(mygdb *gdblib.GDB) {
http.HandleFunc("/handle/thread/listids", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
result, err := mygdb.ThreadListIds()
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/thread/select", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ThreadSelectParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.ThreadSelect(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
http.HandleFunc("/handle/thread/info", wrapHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
parms := gdblib.ThreadInfoParms{}
decoder := json.NewDecoder(r.Body)
err := decoder.Decode(&parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
result, err := mygdb.ThreadInfo(parms)
if err != nil {
w.WriteHeader(400)
w.Write([]byte(err.Error()))
return
}
resultBytes, err := json.Marshal(result)
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(200)
w.Write(resultBytes)
}
}))
}