# Command-line options.
our ($sim); # Simulator: bochs, qemu, or gsx.
our ($debug) = "none"; # Debugger: none, monitor, or gdb.
+our ($checkbochs) = 0; # Use checkbochs race detector?
+our ($checkbochs_logfile) # Log file for checkbochs.
+ = "checkbochs.log";
our ($mem) = 4; # Physical RAM in MB.
our ($serial_out) = 1; # Send output to serial port?
our ($vga); # VGA output: window, terminal, or none.
"monitor" => sub { set_debug ("monitor") },
"gdb" => sub { set_debug ("gdb") },
+ "checkbochs" => \$checkbochs,
+ "logfile=s" => \$checkbochs_logfile,
+
"m|memory=i" => \$mem,
"j|jitter=i" => sub { set_jitter (@_) },
"r|realtime" => sub { set_realtime () },
--gsx Use VMware GSX Server 3.x as simulator
Debugger selection:
--no-debug (default) No debugger
- --monitor Debug with simulator's monitor
- --gdb Debug with gdb
+ --monitor Debug with simulator's monitor (Bochs or qemu only)
+ --gdb Debug with gdb (Bochs or qemu only)
+Race detector (Bochs only; may be combined with debugger):
+ --no-checkbochs (default) Do not use race detector
+ --checkbochs Use race detector
+ --logfile=FILE Set checkbochs log file (default: checkbochs.log)
Display options: (default is both VGA and serial)
-v, --no-vga No VGA display
-s, --no-serial No serial output
# Runs Bochs.
sub run_bochs {
- # Select Bochs binary based on the chosen debugger.
- my ($bin);
- if ($debug eq 'none') {
- $bin = 'bochs';
- } elsif ($debug eq 'monitor') {
- $bin = 'bochs-dbg';
- } elsif ($debug eq 'gdb') {
- $bin = 'bochs-gdb';
- }
+ # Select Bochs binary based on checkbochs and debugger settings.
+ my ($bin) = $checkbochs ? 'checkbochs' : 'bochs';
+ $bin .= '-dbg' if $debug eq 'monitor';
+ $bin .= '-gdb' if $debug eq 'gdb';
# Write bochsrc.txt configuration file.
open (BOCHSRC, ">", "bochsrc.txt") or die "bochsrc.txt: create: $!\n";
} else {
print BOCHSRC "display_library: term\n";
}
+ print BOCHSRC "logfile: $checkbochs_logfile\n" if $checkbochs;
close (BOCHSRC);
# Compose Bochs command line.
if $vga eq 'terminal';
print "warning: qemu doesn't support jitter\n"
if defined $jitter;
+ print "warning: qemu doesn't support race detection\n"
+ if $checkbochs;
my (@cmd) = ('qemu');
for my $iface (0...3) {
my ($option) = ('-hda', '-hdb', '-hdc', '-hdd')[$iface];
gsx_unsup ("--no-vga") if $vga eq 'none';
gsx_unsup ("--terminal") if $vga eq 'terminal';
gsx_unsup ("--jitter") if defined $jitter;
+ gsx_unsup ("--checkbochs") if $checkbochs;
unlink ("pintos.out");
# Interrupts $pid and dies with a timeout error message.
sub timeout {
my ($pid) = @_;
- relay_signal ($pid, "INT");
+ kill "INT", $pid;
+ waitpid ($pid, 0);
+ seek (STDOUT, 0, 2);
my ($load_avg) = `uptime` =~ /(load average:.*)$/i;
- print "TIMEOUT after $timeout seconds";
+ print "\nTIMEOUT after $timeout seconds";
print " - $load_avg" if defined $load_avg;
print "\n";
- exit (2);
+ exit 0;
}