Commit bc294802 authored by protolambda's avatar protolambda

cmd: clean up debug info during run

parent 3adfef32
...@@ -15,6 +15,14 @@ type StepMatcherFlag struct { ...@@ -15,6 +15,14 @@ type StepMatcherFlag struct {
matcher StepMatcher matcher StepMatcher
} }
func MustStepMatcherFlag(pattern string) *StepMatcherFlag {
out := new(StepMatcherFlag)
if err := out.Set(pattern); err != nil {
panic(err)
}
return out
}
func (m *StepMatcherFlag) Set(value string) error { func (m *StepMatcherFlag) Set(value string) error {
m.repr = value m.repr = value
if value == "" || value == "never" { if value == "" || value == "never" {
......
...@@ -68,6 +68,12 @@ var ( ...@@ -68,6 +68,12 @@ var (
Value: "meta.json", Value: "meta.json",
Required: false, Required: false,
} }
RunInfoAtFlag = &cli.GenericFlag{
Name: "info-at",
Usage: "step pattern to print info at: " + patternHelp,
Value: MustStepMatcherFlag("%1000"),
Required: false,
}
) )
type Proof struct { type Proof struct {
...@@ -212,6 +218,7 @@ func Run(ctx *cli.Context) error { ...@@ -212,6 +218,7 @@ func Run(ctx *cli.Context) error {
stopAt := ctx.Generic(RunStopAtFlag.Name).(*StepMatcherFlag).Matcher() stopAt := ctx.Generic(RunStopAtFlag.Name).(*StepMatcherFlag).Matcher()
proofAt := ctx.Generic(RunProofAtFlag.Name).(*StepMatcherFlag).Matcher() proofAt := ctx.Generic(RunProofAtFlag.Name).(*StepMatcherFlag).Matcher()
snapshotAt := ctx.Generic(RunSnapshotAtFlag.Name).(*StepMatcherFlag).Matcher() snapshotAt := ctx.Generic(RunSnapshotAtFlag.Name).(*StepMatcherFlag).Matcher()
infoAt := ctx.Generic(RunInfoAtFlag.Name).(*StepMatcherFlag).Matcher()
var meta *mipsevm.Metadata var meta *mipsevm.Metadata
if metaPath := ctx.Path(RunMetaFlag.Name); metaPath == "" { if metaPath := ctx.Path(RunMetaFlag.Name); metaPath == "" {
...@@ -241,23 +248,18 @@ func Run(ctx *cli.Context) error { ...@@ -241,23 +248,18 @@ func Run(ctx *cli.Context) error {
for !state.Exited { for !state.Exited {
step := state.Step step := state.Step
//if infoAt(state) { name := meta.LookupSymbol(state.PC)
// s := lookupSymbol(state.PC) if infoAt(state) {
// var sy elf.Symbol
// l.Info("", "insn", state.Memory.GetMemory(state.PC), "pc", state.PC, "symbol", sy.Name)
// // print name
//}
if meta.LookupSymbol(state.PC) == "runtime.notesleep" {
return fmt.Errorf("got stuck in Go sleep at step %d", step)
}
if step%100 == 0 || step > 14_478_400 {
l.Info("processing", l.Info("processing",
"step", step, "step", step,
"pc", mipsevm.HexU32(state.PC), "pc", mipsevm.HexU32(state.PC),
"insn", mipsevm.HexU32(state.Memory.GetMemory(state.PC)), "insn", mipsevm.HexU32(state.Memory.GetMemory(state.PC)),
"name", meta.LookupSymbol(state.PC), "name", name,
) )
} }
if name == "runtime.notesleep" { // don't loop forever when we get stuck because of an unexpected bad program
return fmt.Errorf("got stuck in Go sleep at step %d", step)
}
if stopAt(state) { if stopAt(state) {
break break
...@@ -319,5 +321,6 @@ var RunCommand = &cli.Command{ ...@@ -319,5 +321,6 @@ var RunCommand = &cli.Command{
RunSnapshotFmtFlag, RunSnapshotFmtFlag,
RunStopAtFlag, RunStopAtFlag,
RunMetaFlag, RunMetaFlag,
RunInfoAtFlag,
}, },
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment