debugger

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dispatcher = func(i *dvm.DVM_Interpreter, funcLine string) bool {

	debug := GetDebugger()

	curr_rec := i.State.Monitor_recursion
	function := i.EntryPoint
	lineIP := i.IP

	debug.AddTrace(function, lineIP)
	debug.UpdateLocals(i.Locals)

	stopExecution := func() {
		debug.freezer <- true
		for {

			if freeze := <-debug.freezer; !freeze {
				break
			}

			time.Sleep(time.Millisecond)
		}
	}

	updateRec := func(prev, curr *int64) {
		*prev = *curr
	}

	displayUpdateAndWait := func(msg, line string, ip uint64, p, c *int64) {

		if msg != "" {
			log.Info("%s %v\t%v\n", msg, ip, formatLine(line))
		} else {
			log.Info(" %v\t%v\n", ip, formatLine(line))
		}
		updateRec(p, c)
		stopExecution()
	}

	for {
		switch debug.event {
		case run:
			if ok := debug.isBreakpointValid(function, lineIP); ok {
				reachedBP := fmt.Sprintf("Breakpoint reached in function '%s' at the line:\n", function)
				displayUpdateAndWait(reachedBP, funcLine, lineIP, &prev_rec, &curr_rec)
			}
		case stepi:
			displayUpdateAndWait("", funcLine, lineIP, &prev_rec, &curr_rec)
		case next:
			if curr_rec <= prev_rec {
				displayUpdateAndWait("", funcLine, lineIP, &prev_rec, &curr_rec)
			}
		case ret:
			if curr_rec < prev_rec {
				displayUpdateAndWait("", funcLine, lineIP, &prev_rec, &curr_rec)
			}
		case freeze:
			stopExecution()
		case invalid:
			fallthrough
		case quit:
			log.Info("Debugger: Force quit!!!\n")
			close(debug.freezer)
			return true
		}

		return false

	}
	panic("You should never run this line!!!")
}

Functions

This section is empty.

Types

type Debugger

type Debugger struct {
	// contains filtered or unexported fields
}

func GetDebugger

func GetDebugger() *Debugger

func (*Debugger) AddTrace

func (debug *Debugger) AddTrace(function string, line uint64)

func (*Debugger) CreateBreakpoint

func (debug *Debugger) CreateBreakpoint(function string, line, condition uint64)

func (*Debugger) ListBreakpoint

func (debug *Debugger) ListBreakpoint() string

func (*Debugger) Next

func (debug *Debugger) Next()

func (*Debugger) PrintLocals

func (debug *Debugger) PrintLocals()

func (*Debugger) PrintTraces

func (debug *Debugger) PrintTraces()

func (*Debugger) Quit

func (debug *Debugger) Quit()

func (*Debugger) Reset

func (debug *Debugger) Reset()

func (*Debugger) ResetLocals

func (debug *Debugger) ResetLocals()

func (*Debugger) Return

func (debug *Debugger) Return()

func (*Debugger) Run

func (debug *Debugger) Run()

func (*Debugger) StepInside

func (debug *Debugger) StepInside()

func (*Debugger) Stop

func (debug *Debugger) Stop()

func (*Debugger) UpdateLocals

func (debug *Debugger) UpdateLocals(locals map[string]dvm.Variable)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL