From b7e037a3b77beb4597cd19b6691a4179dfcb0c5e Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 29 Apr 2018 12:51:04 +0100 Subject: [PATCH] o debugger - sketched in ctrl-c handling --- debugger/debugger.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/debugger/debugger.go b/debugger/debugger.go index dec0e93f..a03ad2a3 100644 --- a/debugger/debugger.go +++ b/debugger/debugger.go @@ -5,6 +5,7 @@ import ( "headlessVCS/hardware" "headlessVCS/hardware/cpu" "os" + "os/signal" "strings" ) @@ -52,9 +53,24 @@ func (dbg *Debugger) Start(filename string) error { func (dbg *Debugger) inputLoop() error { var err error var result *cpu.InstructionResult + breakpoint := true next := true + ctrlC := make(chan os.Signal) + signal.Notify(ctrlC, os.Interrupt) + go func() { + for dbg.running { + <-ctrlC + if dbg.runUntilBreak == true { + dbg.runUntilBreak = false + } else { + // TODO: interrupt os.Stdin.Read() + dbg.running = false + } + } + }() + dbg.running = true for dbg.running { if breakpoint {