-
Notifications
You must be signed in to change notification settings - Fork 19
/
input.go
50 lines (46 loc) · 1.05 KB
/
input.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func inputContinue(pid int) bool {
sub := false
scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("\n(C)ontinue, (S)tep, set (B)reakpoint or (Q)uit? > ")
for {
scanner.Scan()
input := scanner.Text()
switch strings.ToUpper(input) {
case "C":
return true
case "S":
return false
case "B":
fmt.Printf(" Enter line number in %s: > ", targetfile)
sub = true
case "Q":
os.Exit(0)
default:
if sub {
line, _ = strconv.Atoi(input)
breakpointSet, originalCode = setBreak(pid, targetfile, line)
return true
}
fmt.Printf("Unexpected input %s\n", input)
fmt.Printf("\n(C)ontinue, (S)tep, set (B)reakpoint or (Q)uit? > ")
}
}
}
func setBreak(pid int, filename string, line int) (bool, []byte) {
var err error
pc, _, err = symTable.LineToPC(filename, line)
if err != nil {
fmt.Printf("Can't find breakpoint for %s, %d\n", filename, line)
return false, []byte{}
}
// fmt.Printf("Stopping at %X\n", pc)
return true, replaceCode(pid, pc, []byte{0xCC})
}