mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 21:39:27 +01:00
compiler_vm: updated to run properly on Linux; untested on Cygwin
This commit is contained in:
parent
be8c03ba27
commit
c8bc14183b
@ -13,8 +13,8 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 292,
|
BUILD_REVISION => 298,
|
||||||
BUILD_DATE => "2011-01-31",
|
BUILD_DATE => "2011-02-01",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -28,6 +28,7 @@ sub vm_stop {
|
|||||||
my $pid = shift @_;
|
my $pid = shift @_;
|
||||||
return if not defined $pid;
|
return if not defined $pid;
|
||||||
kill 'TERM', $pid;
|
kill 'TERM', $pid;
|
||||||
|
waitpid($pid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub vm_start {
|
sub vm_start {
|
||||||
@ -38,7 +39,9 @@ sub vm_start {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($pid == 0) {
|
if($pid == 0) {
|
||||||
exec('"/cygdrive/c/Program Files (x86)\QemuManager\qemu\qemu-system-x86_64.exe" -L "C:\Program Files (x86)\QemuManager\qemu" -M "pc" -m 512 -cpu "qemu64" -vga cirrus -drive "file=C:\Program Files (x86)\QemuManager\images\Test.qcow2,index=0,media=disk" -enable-kqemu -kernel-kqemu -net none -localtime -serial "tcp:127.0.0.1:4444,server,nowait" -monitor "tcp:127.0.0.1:4445,server,nowait" -kernel-kqemu -loadvm 1 -nographic');
|
my $command = 'qemu-system-x86_64 -M pc -hda /home/compiler/compiler-vm-image -m 128 -monitor tcp:127.0.0.1:4445,server,nowait -serial tcp:127.0.0.1:4444,server,nowait -boot c -loadvm 2 -nographic';
|
||||||
|
my @command_list = split / /, $command;
|
||||||
|
exec(@command_list);
|
||||||
} else {
|
} else {
|
||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
@ -58,7 +61,7 @@ sub execute {
|
|||||||
my $pid = open(my $fh, '-|', "$cmdline 2>&1");
|
my $pid = open(my $fh, '-|', "$cmdline 2>&1");
|
||||||
|
|
||||||
local $SIG{ALRM} = sub { print "Time out\n"; kill 'TERM', $pid; die "Timed-out\n"; };
|
local $SIG{ALRM} = sub { print "Time out\n"; kill 'TERM', $pid; die "Timed-out\n"; };
|
||||||
alarm(6);
|
alarm(5);
|
||||||
|
|
||||||
while(my $line = <$fh>) {
|
while(my $line = <$fh>) {
|
||||||
$result .= $line;
|
$result .= $line;
|
||||||
|
@ -73,7 +73,7 @@ sub compile {
|
|||||||
$pid = open2($compiler_output, $compiler, './compiler_vm_server.pl') || die "repl failed: $@\n";
|
$pid = open2($compiler_output, $compiler, './compiler_vm_server.pl') || die "repl failed: $@\n";
|
||||||
print "Started compiler, pid: $pid\n";
|
print "Started compiler, pid: $pid\n";
|
||||||
} else {
|
} else {
|
||||||
$compiler = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => '4444', Proto => 'tcp', Type => 'SOCK_STREAM');
|
$compiler = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => '4444', Proto => 'tcp', Type => SOCK_STREAM);
|
||||||
die "Could not create socket: $!" unless $compiler;
|
die "Could not create socket: $!" unless $compiler;
|
||||||
$compiler_output = $compiler;
|
$compiler_output = $compiler;
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,17 @@ sub debug_program {
|
|||||||
next if $line =~ /in main\s*\(/;
|
next if $line =~ /in main\s*\(/;
|
||||||
|
|
||||||
$line =~ s/\s*0x[0-9a-fA-F]+\s*//;
|
$line =~ s/\s*0x[0-9a-fA-F]+\s*//;
|
||||||
$result .= "$line ";
|
$line =~ s/\s+at .*:\d+//;
|
||||||
|
|
||||||
|
if($line !~ m/^\s*in\s+/) {
|
||||||
|
$result = "in $line from ";
|
||||||
|
} else {
|
||||||
|
$result .= "$line at ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif($line =~ s/^\d+//) {
|
elsif($line =~ s/^\d+//) {
|
||||||
|
next if $line =~ /No such file/;
|
||||||
|
|
||||||
$result .= "at " if not length $result;
|
$result .= "at " if not length $result;
|
||||||
$result .= "statement: $line";
|
$result .= "statement: $line";
|
||||||
last;
|
last;
|
||||||
|
@ -1 +1 @@
|
|||||||
"/cygdrive/c/Program Files (x86)\QemuManager\qemu\qemu-system-x86_64.exe" -L "C:\Program Files (x86)\QemuManager\qemu" -M "pc" -m 512 -cpu "qemu64" -vga cirrus -drive "file=C:\Program Files (x86)\QemuManager\images\Test.qcow2,index=0,media=disk" -enable-kqemu -kernel-kqemu -net none -localtime -serial "tcp:127.0.0.1:4444,server,nowait" -monitor "tcp:127.0.0.1:4445,server,nowait" -kernel-kqemu -loadvm 1
|
qemu-system-x86_64 -M pc -hda /home/compiler/compiler-vm-image -m 128 -monitor "tcp:127.0.0.1:4445,server,nowait" -serial "tcp:127.0.0.1:4444,server,nowait" -boot c -loadvm 2
|
||||||
|
@ -1 +1 @@
|
|||||||
"/cygdrive/c/Program Files (x86)\QemuManager\qemu\qemu-system-x86_64.exe" -L "C:\Program Files (x86)\QemuManager\qemu" -M "pc" -m 512 -cpu "qemu64" -vga cirrus -drive "file=C:\Program Files (x86)\QemuManager\images\Test.qcow2,index=0,media=disk" -enable-kqemu -net nic,vlan=0,macaddr=52-54-00-F0-EC-8D,model=rtl8139 -net user,vlan=0 -localtime -serial "tcp:127.0.0.1:4444,server,nowait" -monitor "tcp:127.0.0.1:4445,server,nowait" -loadvm 1
|
qemu-system-x86_64 -M pc -hda /home/compiler/compiler-vm-image -m 128 -monitor "tcp:127.0.0.1:4445,server,nowait" -serial "tcp:127.0.0.1:4444,server,nowait" -net nic,vlan=0 -net user,vlan=0,hostname=compiler -boot c -loadvm 2
|
||||||
|
Loading…
Reference in New Issue
Block a user