3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

guest-gdb: remove redundant error-checking

This commit is contained in:
Pragmatic Software 2022-01-29 09:50:15 -08:00
parent 55b4ae0c57
commit 07dff29d4a

View File

@ -302,7 +302,6 @@ sub get_backtrace($context) {
foreach my $output (@$console) { foreach my $output (@$console) {
last if $output->{_type} eq RESULT; last if $output->{_type} eq RESULT;
#0 0x0000555555555995 in bar () at prog3.c:18\n
$output->{_text} =~ /in (\w+) (.*) at/; $output->{_text} =~ /in (\w+) (.*) at/;
push @backtrace, { func => $1, args => $2 }; push @backtrace, { func => $1, args => $2 };
} }
@ -375,11 +374,6 @@ sub cmd_gdb($context, $command) {
my $text = ''; my $text = '';
foreach my $output (@$console) { foreach my $output (@$console) {
if ($output->{_class} eq 'error') {
print_gdb_output($context, $output->{msg});
last;
}
last if $output->{_type} eq RESULT; last if $output->{_type} eq RESULT;
$text .= "$output->{_text}\n"; $text .= "$output->{_text}\n";
} }
@ -393,11 +387,6 @@ sub cmd_ptype($context, $args) {
my $text = ''; my $text = '';
foreach my $output (@$console) { foreach my $output (@$console) {
if ($output->{_class} eq 'error') {
print_gdb_output($context, $output->{msg});
last;
}
last if $output->{_type} eq RESULT; last if $output->{_type} eq RESULT;
if ($output->{_text} =~ /type\s*=\s*(.*)/) { if ($output->{_text} =~ /type\s*=\s*(.*)/) {
@ -415,11 +404,6 @@ sub cmd_whatis($context, $args) {
my $console = gdb_send_and_read_console($context, "whatis $args"); my $console = gdb_send_and_read_console($context, "whatis $args");
foreach my $output (@$console) { foreach my $output (@$console) {
if ($output->{_class} eq 'error') {
print_gdb_output($context, $output->{msg});
next;
}
last if $output->{_type} eq RESULT; last if $output->{_type} eq RESULT;
if ($output->{_text} =~ /type\s*=\s*(.*)/) { if ($output->{_text} =~ /type\s*=\s*(.*)/) {
@ -432,11 +416,6 @@ sub cmd_print($context, $args) {
my $console = gdb_send_and_read_console($context, "print $args"); my $console = gdb_send_and_read_console($context, "print $args");
foreach my $output (@$console) { foreach my $output (@$console) {
if ($output->{_class} eq 'error') {
print_gdb_output($context, $output->{msg});
next;
}
last if $output->{_type} eq RESULT; last if $output->{_type} eq RESULT;
if ($output->{_text} =~ /^\$\d+\s*=\s*(.*)/) { if ($output->{_text} =~ /^\$\d+\s*=\s*(.*)/) {
@ -652,10 +631,10 @@ sub run_program($context) {
sub main { sub main {
# first command-line argument can override file to debug # first command-line argument can override file to debug
my $prog = $ARGV[0] // 'prog'; my $prog = $ARGV[0] // './prog';
# start gdb and grab references to its input and output streams # start gdb and grab references to its input and output streams
open2(my $out, my $in, "LIBC_FATAL_STDERR=1 MALLOC_CHECK_=1 gdb -i mi3 -q -nx ./$prog"); open2(my $out, my $in, "LIBC_FATAL_STDERR=1 MALLOC_CHECK_=1 gdb -i mi3 -q -nx $prog");
my $context = { my $context = {
gdb_output => $out, # gdb output stream gdb_output => $out, # gdb output stream