Created
October 22, 2013 08:49
-
-
Save styxyang/7097293 to your computer and use it in GitHub Desktop.
tcl script to test gdb-like breakpoint function for jos lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set timeout 10; # set timeout to -1 to wait forever | |
set hda "obj/kern/kernel.img" | |
# spawn qemu -nographic -hda $hda -serial "file:jos.out" -monitor null -no-reboot | |
spawn qemu -nographic -hda $hda -monitor null -no-reboot | |
# interact | |
expect { | |
-re "&a equals (.*)\n" { set addr $expect_out(1,string) } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
-re "eip (.*)\n" { | |
set eip $expect_out(1,string) | |
set nexteip [format %x [expr $eip + 7]]; # tcl manipulation | |
} | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
"K> " { send "x $addr\r" } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
"10" { } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
"K> " { send "si\r" } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
"$nexteip" { } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
"K> " { send "c\r" } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
expect { | |
"Finally , a equals 20\r" { } | |
timeout { exec pkill -9 qemu; exit 1 } | |
} | |
# send $expect_out(0,string) | |
exec pkill -9 qemu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment