Add --gdbbt option

This commit is contained in:
Wilson Snyder 2009-10-04 18:04:37 -04:00
parent 546e7c0c1f
commit b883ce95b2
3 changed files with 31 additions and 8 deletions

View File

@ -45,6 +45,7 @@ autoflush STDERR 1;
$Debug = 0;
my $opt_gdb;
my $opt_gdbbt;
# No arguments can't do anything useful. Give help
if ($#ARGV < 0) {
@ -66,20 +67,29 @@ if (! GetOptions (
# "version!" => \&version, # Also passthru'ed
# Switches
"gdb=s" => \$opt_gdb, # Undocumented debugging
"gdbbt!" => \$opt_gdbbt, # Undocumented debugging
# Additional parameters
"<>" => sub {}, # Ignored
)) {
pod2usage(-exitstatus=>2, -verbose=>0);
}
# Determine runtime flags
my $vcmd =(($opt_gdb?"$opt_gdb ":"")
.verilator_bin()
." ".join(' ',@Opt_Verilator_Sw)
);
# Run verilator
run ($vcmd);
# Determine runtime flags and run
if ($opt_gdbbt && !$opt_gdb && $Debug) {
# Run under GDB to get gdbbt
run ("gdb ".verilator_bin()
." --batch --quiet"
." -ex 'run ".join(' ',@Opt_Verilator_Sw)."'"
." -ex 'set width 0'"
." -ex 'bt'"
." -ex 'c'");
die "%Error: --gdbbt looses the exit status; so must assume run went badly...";
} else {
# Normal, non gdb
run (($opt_gdb?"$opt_gdb ":"")
.verilator_bin()
." ".join(' ',@Opt_Verilator_Sw));
}
#----------------------------------------------------------------------
@ -2638,6 +2648,8 @@ License Version 2.0.
=head1 AUTHORS
When possible, please instead report bugs to L<http://www.veripool.org/>.
Wilson Snyder <wsnyder@wsnyder.org>
Major concepts by Paul Wasson and Duane Galbi.

View File

@ -769,6 +769,9 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
else if ( !strcmp (sw, "-gdb") && (i+1)<argc ) {
shift; // Used only in perl shell
}
else if ( !strcmp (sw, "-gdbbt")) {
// Used only in perl shell
}
else if ( !strcmp (sw, "-mod-prefix") && (i+1)<argc ) {
shift; m_modPrefix = argv[i];
}

View File

@ -43,6 +43,7 @@ $Debug = 0;
my $opt_benchmark;
my @opt_tests;
my $opt_gdb;
my $opt_gdbbt;
my $opt_iv;
my $opt_jobs = 1;
my $opt_nc;
@ -60,6 +61,7 @@ if (! GetOptions (
"benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; },
"debug" => \&debug,
"gdb!" => \$opt_gdb,
"gdbbt!" => \$opt_gdbbt,
"help" => \&usage,
"iverilog!" => \$opt_iv,
"j=i" => \$opt_jobs,
@ -417,6 +419,7 @@ sub compile {
$opt_gdb="gdbrun" if defined $opt_gdb;
my @verilator_flags = @{$param{verilator_flags}};
unshift @verilator_flags, "--gdb $opt_gdb" if $opt_gdb;
unshift @verilator_flags, "--gdbbt" if $opt_gdbbt;
unshift @verilator_flags, @Opt_Driver_Verilator_Flags;
unshift @verilator_flags, "--x-assign unique"; # More likely to be buggy
unshift @verilator_flags, "--trace" if $opt_trace;
@ -1106,6 +1109,11 @@ specifies the number of simulation cycles (for tests that support it).
Run verilator under the debugger.
=item --gdbbt
Run verilator under the debugger, only to print backtrace information.
Requires --debug.
=item --help
Displays this message and program version and exits.