Commit 64f4d051 authored by George Hotz's avatar George Hotz

support saving the target

parent a37c36e5
......@@ -18,10 +18,14 @@ func WriteCheckpoint(ram map[uint32](uint32), fn string, step int) {
func main() {
root := ""
target := -1
if len(os.Args) > 1 {
blockNumber, _ := strconv.Atoi(os.Args[1])
root = fmt.Sprintf("/tmp/cannon/%d_%d", 0, blockNumber)
}
if len(os.Args) > 2 {
target = strconv.Atoi(os.Args[2])
}
// step 1, generate the checkpoints every million steps using unicorn
ram := make(map[uint32](uint32))
......@@ -29,7 +33,7 @@ func main() {
lastStep := 0
mu := GetHookedUnicorn(root, ram, func(step int, mu uc.Unicorn, ram map[uint32](uint32)) {
// this can be raised to 10,000,000 if the files are too large
if step%10000000 == 0 {
if step%10000000 == 0 || (target != -1 && step == target) {
SyncRegs(mu, ram)
fn := fmt.Sprintf("%s/checkpoint_%d.json", root, step)
WriteCheckpoint(ram, fn, step)
......
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