Skip to content

Instantly share code, notes, and snippets.

@Ankur008
Created October 30, 2017 06:35
Show Gist options
  • Save Ankur008/4c982d33187fc2ddf04896b11ee11e6e to your computer and use it in GitHub Desktop.
Save Ankur008/4c982d33187fc2ddf04896b11ee11e6e to your computer and use it in GitHub Desktop.
func verbose(t *Term, ctx callContext, args string) error {
state, err := t.client.Next()
if args=="first" {
//fmt.Println("calling cont")
customCont(t,ctx,args)
}else{
printFileLine(t, state.CurrentThread.File, state.CurrentThread.Line, true)
}
currentLine:= state.CurrentThread.Line
//fmt.Println("Current line initial",currentLine)
nextBreatPointLine:= getNextBreakPointLine(t,ctx,args,state.CurrentThread.Line)
for currentLine<nextBreatPointLine {
currentLine = customNext(t,ctx,args)
//fmt.Println("Current Line ",currentLine)
}
return err
}
func getNextBreakPointLine(t *Term, ctx callContext, args string, line int ) int {
breakPoints, err := t.client.ListBreakpoints()
fmt.Println(err)
/*if err != nil {
return nil
}
*/
sort.Sort(ByID(breakPoints))
var isNextBreakPointLine int
isNextBreakPointLine= 0
for _, bp := range breakPoints {
if bp.ID>1 {
if line<BreakpointLine(bp) {
isNextBreakPointLine=BreakpointLine(bp)
break
}
}
}
return isNextBreakPointLine
}
func customNext(t *Term, ctx callContext, args string) int {
if err := scopePrefixSwitch(t, ctx); err != nil {
return 0
}
state, err := t.client.Next()
if err != nil {
printfileNoState(t)
return 0
}
//printcontext(t, state)
customContinueUntilCompleteNext(t, state, "next")
locals(t,ctx,args)
return state.CurrentThread.Line
}
func customCont(t *Term, ctx callContext, args string) error {
stateChan := t.client.Continue()
var state *api.DebuggerState
for state = range stateChan {
if state.Err != nil {
printfileNoState(t)
return state.Err
}
//printcontext(t, state)
}
printFileLine(t, state.CurrentThread.File, state.CurrentThread.Line, true)
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment