mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
compiler_vm: added libc fatal errors; trace program only on signal
This commit is contained in:
parent
4efa96dbbe
commit
a2e2d15fc7
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 359,
|
||||
BUILD_DATE => "2012-02-05",
|
||||
BUILD_REVISION => 360,
|
||||
BUILD_DATE => "2012-02-09",
|
||||
};
|
||||
|
||||
1;
|
||||
|
@ -698,8 +698,10 @@ print FILE "$nick: [lang:$lang][args:$args][input:$input]\n", pretty($code), "\n
|
||||
|
||||
$output = compile($lang, pretty($code), $args, $input, $USE_LOCAL);
|
||||
|
||||
=cut
|
||||
$output =~ s/^\s+//;
|
||||
$output =~ s/\s+$//;
|
||||
=cut
|
||||
|
||||
if($output =~ m/^\s*$/) {
|
||||
$output = $nooutput
|
||||
@ -725,11 +727,12 @@ if($output =~ m/^\s*$/) {
|
||||
my $right_quote = chr(226) . chr(128) . chr(153);
|
||||
$output =~ s/$left_quote/'/g;
|
||||
$output =~ s/$right_quote/'/g;
|
||||
$output =~ s/\t/ /g;
|
||||
$output =~ s/\s*In function 'main':\s*//g;
|
||||
$output =~ s/warning: unknown conversion type character 'b' in format \[-Wformat\]\s+warning: too many arguments for format \[-Wformat-extra-args\]/info: conversion type character 'b' in format is a candide extension/g;
|
||||
$output =~ s/warning: unknown conversion type character 'b' in format \[-Wformat\]//g;
|
||||
$output =~ s/\s\(core dumped\)/./;
|
||||
$output =~ s/\[\s+/[/g;
|
||||
# $output =~ s/\[\s+/[/g;
|
||||
$output =~ s/ \[enabled by default\]//g;
|
||||
$output =~ s/initializer\s+warning: \(near/initializer (near/g;
|
||||
$output =~ s/note: each undeclared identifier is reported only once for each function it appears in//g;
|
||||
@ -737,11 +740,16 @@ if($output =~ m/^\s*$/) {
|
||||
$output =~ s/", '\\(\d{3})' <repeats \d+ times>,? ?"/\\$1/g;
|
||||
$output =~ s/, '\\(\d{3})' <repeats \d+ times>\s*//g;
|
||||
$output =~ s/(\\000)+/\\0/g;
|
||||
$output =~ s/\\0[^">]+/\\0/g;
|
||||
$output =~ s/\\0[^">']+/\\0/g;
|
||||
$output =~ s/\\0"/"/g;
|
||||
$output =~ s/"\\0/"/g;
|
||||
$output =~ s/\.\.\.>/>/g;
|
||||
$output =~ s/(\\\d{3})+//g;
|
||||
$output =~ s/<\s*included at \/home\/compiler\/>\s*//g;
|
||||
$output =~ s/\s*compilation terminated due to -Wfatal-errors\.//g;
|
||||
$output =~ s/^======= Backtrace.*\[vsyscall\]\s*$//ms;
|
||||
$output =~ s/glibc detected \*\*\* \/home\/compiler\/prog: //;
|
||||
$output =~ s/: \/home\/compiler\/prog terminated//;
|
||||
}
|
||||
|
||||
unless($got_run) {
|
||||
|
@ -33,12 +33,13 @@ sub execute {
|
||||
<$out> and next if $line =~ m/^\(gdb\) No line \d+ in/;
|
||||
next if $line =~ m/^\(gdb\) Continuing/;
|
||||
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\) Breakpoint \d+ at 0x/;
|
||||
next if $line =~ m/^\(gdb\) Note: breakpoint \d+ also set/;
|
||||
next if $line =~ m/^(\(gdb\) )?Starting program/;
|
||||
next if $line =~ m/^(\(gdb\) )*Starting program/;
|
||||
next if $line =~ m/PRETTY_FUNCTION__ =/;
|
||||
next if $line =~ m/libc_start_main/;
|
||||
next if $line =~ m/libc-start.c/;
|
||||
|
||||
if($line =~ m/^\d+: (.*? = .*)/) {
|
||||
print "<$1>\n";
|
||||
@ -77,6 +78,8 @@ sub execute {
|
||||
}
|
||||
|
||||
gdb $in, "break $break\n";
|
||||
gdb $in, "set width 0\n";
|
||||
gdb $in, "set height 0\n";
|
||||
gdb $in, "run\n";
|
||||
next;
|
||||
}
|
||||
@ -85,6 +88,9 @@ sub execute {
|
||||
my $line = <$out>;
|
||||
print "== got: $line\n" if $debug >= 5;
|
||||
if($line =~ m/^\d+\s+return.*?;\s*$/ or $line =~ m/^\d+\s+}\s*$/) {
|
||||
for(my $i = 0; $i < $watching; $i++) {
|
||||
<$out>;
|
||||
}
|
||||
if($got_output == 0) {
|
||||
print "no output, checking locals\n" if $debug >= 5;
|
||||
gdb $in, "print \"Go.\"\ninfo locals\nprint \"Ok.\"\n";
|
||||
@ -162,7 +168,7 @@ sub execute {
|
||||
$return_value = ", returned $1";
|
||||
last;
|
||||
}
|
||||
|
||||
|
||||
next if not length $retval;
|
||||
next if $retval =~ m/^\$\d+ = 0/;
|
||||
|
||||
@ -186,7 +192,7 @@ sub execute {
|
||||
}
|
||||
|
||||
$indent++ if $direction eq "leaving";
|
||||
|
||||
|
||||
print "<$direction [$indent]", ' ' x $indent, "$func$return_value>\n";
|
||||
gdb $in, "cont\n";
|
||||
next;
|
||||
@ -330,6 +336,8 @@ sub execute {
|
||||
if($line =~ m/^Watchpoint \d+ deleted/) {
|
||||
my $ignore = <$out>;
|
||||
print "ignored $ignore\n" if $debug >= 5;
|
||||
$ignore = <$out>;
|
||||
print "ignored $ignore\n" if $debug >= 5;
|
||||
gdb $in, "cont\n";
|
||||
next;
|
||||
}
|
||||
@ -372,7 +380,9 @@ sub execute {
|
||||
next;
|
||||
}
|
||||
|
||||
if($line =~ m/Program received signal/) {
|
||||
if($line =~ m/Program received signal ([^, ]+)/) {
|
||||
my $signal = $1;
|
||||
my $trace_prog_only = 1;
|
||||
my $result = "";
|
||||
my $vars = "";
|
||||
my $varsep = "";
|
||||
@ -381,6 +391,14 @@ sub execute {
|
||||
$got_output = 1;
|
||||
print "$line ";
|
||||
|
||||
print "\ngot signal [$signal]\n" if $debug >= 2;
|
||||
|
||||
if($signal eq "SIGABRT") {
|
||||
$trace_prog_only = 1;
|
||||
}
|
||||
|
||||
my $last_file = "";
|
||||
|
||||
while(my $line = <$out>) {
|
||||
chomp $line;
|
||||
$line =~ s/^\(gdb\)\s+//;
|
||||
@ -390,30 +408,44 @@ sub execute {
|
||||
|
||||
next if $line =~ m/__PRETTY_FUNCTION__ =/;
|
||||
|
||||
my $skip = 0;
|
||||
if($trace_prog_only) {
|
||||
if($line =~ m/.*\s(.*?)\.c:\d+$/) {
|
||||
$last_file = $1;
|
||||
}
|
||||
|
||||
$skip = 1 if not $last_file eq "prog";
|
||||
}
|
||||
|
||||
print "last file: [$last_file], skip: $skip\n" if $debug >= 6;
|
||||
|
||||
if($line =~ s/^(#\d+\s+)?0x[0-9A-Fa-f]+\s//) {
|
||||
$line =~ s/\s+at .*:\d+//;
|
||||
$line =~ s/\s+from \/lib.*//;
|
||||
|
||||
if($line =~ s/^\s*in\s+//) {
|
||||
if(not length $result) {
|
||||
$result .= "in $line ";
|
||||
$result .= "in $line " unless $skip;
|
||||
} else {
|
||||
$result .= "called by $line ";
|
||||
$result .= "called by $line " unless $skip;
|
||||
}
|
||||
gdb $in, "info locals\n";
|
||||
gdb $in, "info locals\n" unless $skip;
|
||||
gdb $in, "print \"Ok.\"";
|
||||
} else {
|
||||
$result = "in $line from ";
|
||||
gdb $in, "info locals\n";
|
||||
$result = "in $line from " unless $skip;
|
||||
gdb $in, "info locals\n" unless $skip;
|
||||
gdb $in, "print \"Ok.\"";
|
||||
}
|
||||
}
|
||||
elsif($line =~ m/^No symbol table info available/) {
|
||||
elsif($line =~ m/^\$\d+ = "Ok."/) {
|
||||
gdb $in, "up\n";
|
||||
}
|
||||
elsif($line =~ s/^\d+\s+//) {
|
||||
next if $line =~ /No such file/;
|
||||
|
||||
$result .= "at statement: $line ";
|
||||
gdb $in, "up\n";
|
||||
$result .= "at statement: $line " unless $skip;
|
||||
# gdb $in, "info locals\n" unless $skip;
|
||||
gdb $in, "print \"Ok.\"";
|
||||
}
|
||||
elsif($line =~ m/([^=]+)=\s+(.*)/) {
|
||||
$vars .= "$varsep$1= $2";
|
||||
@ -472,4 +504,4 @@ sub flushall {
|
||||
}
|
||||
}
|
||||
|
||||
execute("gdb -silent ./prog");
|
||||
execute("LIBC_FATAL_STDERR_=1 gdb -silent ./prog 2>&1");
|
||||
|
Loading…
Reference in New Issue
Block a user