X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Futils%2Fpintos;h=58635a9b65f5a08547f97264a77d467cedee673a;hp=4b385cdf87553a07f1d5c1a2667a260b145a416c;hb=9f013d0930202eea99c21083b71098a0df64be0d;hpb=a03618133f7df0954802a470a4bee7674f7aed45 diff --git a/src/utils/pintos b/src/utils/pintos index 4b385cd..58635a9 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -32,6 +32,7 @@ our (@disks); # Extra disk images to pass to simulator. our ($loader_fn); # Bootstrap loader. our (%geometry); # IDE disk geometry. our ($align); # Partition alignment. +our ($gdb_port) = $ENV{"GDB_PORT"} || "1234"; # Port to listen on for GDB parse_command_line (); prepare_scratch_disk (); @@ -113,6 +114,8 @@ sub parse_command_line { $align = "bochs", print STDERR "warning: setting --align=bochs for Bochs support\n" if $sim eq 'bochs' && defined ($align) && $align eq 'none'; + + $kill_on_failure = 0; } # usage($exitcode). @@ -561,9 +564,12 @@ cpu: ips=1000000 megs: $mem log: bochsout.txt panic: action=fatal -user_shortcut: keys=ctrlaltdel +# For older bochs: +#user_shortcut: keys=ctrlaltdel +# For more recent bochs: +keyboard: user_shortcut=ctrl-alt-del EOF - print BOCHSRC "gdbstub: enabled=1\n" if $debug eq 'gdb'; + print BOCHSRC "gdbstub: enabled=1, port=$gdb_port\n" if $debug eq 'gdb'; print BOCHSRC "clock: sync=", $realtime ? 'realtime' : 'none', ", time0=0\n"; print BOCHSRC "ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15\n" @@ -618,18 +624,26 @@ sub run_qemu { if $vga eq 'terminal'; print "warning: qemu doesn't support jitter\n" if defined $jitter; - my (@cmd) = ('qemu'); - push (@cmd, '-no-kqemu'); - push (@cmd, '-hda', $disks[0]) if defined $disks[0]; - push (@cmd, '-hdb', $disks[1]) if defined $disks[1]; - push (@cmd, '-hdc', $disks[2]) if defined $disks[2]; - push (@cmd, '-hdd', $disks[3]) if defined $disks[3]; + my (@cmd) = ('qemu-system-i386'); + push (@cmd, '-device', 'isa-debug-exit'); + + my ($i); + for ($i = 0; $i < 4; $i++) { + if (defined $disks[$i]) { + push (@cmd, '-drive'); + push (@cmd, "file=$disks[$i],format=raw,index=$i,media=disk"); + } + } +# push (@cmd, '-hda', $disks[0]) if defined $disks[0]; +# push (@cmd, '-hdb', $disks[1]) if defined $disks[1]; +# push (@cmd, '-hdc', $disks[2]) if defined $disks[2]; +# push (@cmd, '-hdd', $disks[3]) if defined $disks[3]; push (@cmd, '-m', $mem); push (@cmd, '-net', 'none'); push (@cmd, '-nographic') if $vga eq 'none'; push (@cmd, '-serial', 'stdio') if $serial && $vga ne 'none'; push (@cmd, '-S') if $debug eq 'monitor'; - push (@cmd, '-s', '-S') if $debug eq 'gdb'; + push (@cmd, '-gdb', "tcp::$gdb_port", '-S') if $debug eq 'gdb'; push (@cmd, '-monitor', 'null') if $vga eq 'none' && $debug eq 'none'; run_command (@cmd); } @@ -820,14 +834,14 @@ sub xsystem { for (;;) { if (waitpid ($pid, WNOHANG) != 0) { # Subprocess died. Pass through any remaining data. - print $buf while sysread ($in, $buf, 4096) > 0; + do { print $buf } while sysread ($in, $buf, 4096) > 0; last; } # Read and print out pipe data. my ($len) = length ($buf); - waitpid ($pid, 0), last - if sysread ($in, $buf, 4096, $len) <= 0; + my ($n_read) = sysread ($in, $buf, 4096, $len); + waitpid ($pid, 0), last if !defined ($n_read) || $n_read <= 0; print substr ($buf, $len); # Remove full lines from $buf and scan them for keywords. @@ -852,13 +866,17 @@ sub xsystem { alarm (0); &$cleanup (); - if (WIFSIGNALED ($?) && WTERMSIG ($?) == SIGVTALRM ()) { + if (WIFSIGNALED ($?) && WTERMSIG ($?) == SIGVTALRM_number ()) { seek (STDOUT, 0, 2); print "\nTIMEOUT after $timeout seconds of host CPU time\n"; exit 0; } - return $?; + # Kind of a gross hack, because qemu's isa-debug-exit device + # only allows odd-numbered exit values, so we can't exit + # cleanly with 0. We use exit status 0x63 as an alternate + # "clean" exit status. + return ($? != 0x6300) && $?; } } @@ -907,7 +925,7 @@ sub get_load_average { # Calls setitimer to set a timeout, then execs what was passed to us. sub exec_setitimer { if (defined $timeout) { - if ($ ge 5.8.0) { + if ($^V ge 5.8.0) { eval " use Time::HiRes qw(setitimer ITIMER_VIRTUAL); setitimer (ITIMER_VIRTUAL, $timeout, 0); @@ -923,7 +941,7 @@ sub exec_setitimer { exit (1); } -sub SIGVTALRM { +sub SIGVTALRM_number { use Config; my $i = 0; foreach my $name (split(' ', $Config{sig_name})) {