3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00

compiler_vm: updated gdb parsing (still needs refactoring)

This commit is contained in:
Pragmatic Software 2012-01-31 05:32:24 +00:00
parent d56aaeebca
commit 22b43f21bf
2 changed files with 30 additions and 19 deletions

View File

@ -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 => 352, BUILD_REVISION => 353,
BUILD_DATE => "2012-01-29", BUILD_DATE => "2012-01-30",
}; };
1; 1;

View File

@ -31,24 +31,31 @@ sub execute {
next if $line =~ m/^\(gdb\) \$\d+ = "Ok\."/; next if $line =~ m/^\(gdb\) \$\d+ = "Ok\."/;
next if $line =~ m/^(\(gdb\) )?Breakpoint \d+ at 0x/; next if $line =~ m/^(\(gdb\) )?Breakpoint \d+ at 0x/;
next if $line =~ m/^(\(gdb\) )?Starting program/; next if $line =~ m/^(\(gdb\) )?Starting program/;
next if $line =~ m/^\d+: .*? =/;
if($line =~ m/^\d+: (.*? = .*)/) {
print "<$1>\n";
$got_output = 1;
next;
}
if($line =~ m/^Reading symbols from.*done\.$/) { if($line =~ m/^Reading symbols from.*done\.$/) {
print $in "break gdb\n"; print $in "break gdb\n";
#<$out>; #<$out>;
print $in "list main\n"; print $in "list main,9001\n";
print $in "print \"Ok.\"\n"; print $in "print \"Ok.\"\n";
my $break = 0;
while(my $line = <$out>) { while(my $line = <$out>) {
chomp $line; chomp $line;
print "list got: [$line]\n" if $debug >= 4; print "list got: [$line]\n" if $debug >= 4;
if($line =~ m/^(\d+)\s+return 0;/) { if($line =~ m/^(\d+)\s+return 0;/) {
print $in "break $1\n"; $break = $1;
} }
last if $line =~ m/^\(gdb\) \$\d+ = "Ok."/; last if $line =~ m/^\(gdb\) \$\d+ = "Ok."/;
} }
print $in "break $break\n";
print $in "run\n"; print $in "run\n";
next; next;
} }
@ -59,7 +66,18 @@ sub execute {
if($line =~ m/^\d+\s+return 0;$/) { if($line =~ m/^\d+\s+return 0;$/) {
if($got_output == 0) { if($got_output == 0) {
print "no output, checking locals\n" if $debug >= 5; print "no output, checking locals\n" if $debug >= 5;
print $in "info locals\nprint \"Ok.\"\n"; print $in "print \"Go.\"\ninfo locals\nprint \"Ok.\"\n";
while(my $peep = <$out>) {
chomp $peep;
last if $peep =~ m/\(gdb\) \$\d+ = "Go."/;
# fix this
$peep =~ s/^\d+: (.*?) =/$1 =/;
print "<$peep>\n";
$got_output = 1;
}
my $result = ""; my $result = "";
my $vars = ""; my $vars = "";
my $varsep = ""; my $varsep = "";
@ -78,18 +96,11 @@ sub execute {
$result =~ s/\s+$//; $result =~ s/\s+$//;
$vars =~ s/\(gdb\)\s*//g; $vars =~ s/\(gdb\)\s*//g;
$local_vars = "<local variables: $vars>" if length $vars; $local_vars = "<no output: $vars>" if length $vars;
print $in "cont\n";
next;
} else {
print $in "cont\n";
next;
} }
} else {
print $in "cont\n";
next;
} }
print $in "cont\n";
next;
} }
@ -127,7 +138,7 @@ sub execute {
if($cmd eq "watch") { if($cmd eq "watch") {
print $in "display $args\n"; print $in "display $args\n";
#<$out>; <$out>;
$watching++; $watching++;
$ignore_response = 1; $ignore_response = 1;
} }
@ -135,7 +146,7 @@ sub execute {
print $in "$command\nprint \"Ok.\"\n"; print $in "$command\nprint \"Ok.\"\n";
my $next_line = <$out>; my $next_line = <$out>;
chomp $next_line; chomp $next_line;
#print "nextline: $next_line\n"; print "nextline: $next_line\n" if $debug >= 1;
$next_line =~ s/^\(gdb\)\s*\(gdb\)\s+\$\d+ = "Ok."//; $next_line =~ s/^\(gdb\)\s*\(gdb\)\s+\$\d+ = "Ok."//;
$next_line =~ s/^\(gdb\)\s+\$\d+//; $next_line =~ s/^\(gdb\)\s+\$\d+//;