forked from github/verilator
--gdbbt now documented, and uses return-child-results
Use this in first test_c to backtrace if any problems.
This commit is contained in:
parent
0837e39787
commit
233ff1b744
@ -78,15 +78,17 @@ if (! GetOptions (
|
||||
}
|
||||
|
||||
# Determine runtime flags and run
|
||||
if ($opt_gdbbt && !gdb_works()) {
|
||||
warn "-Info: --gdbbt ignored: gdb doesn't seem to be working\n" if $Debug;
|
||||
$opt_gdbbt = 0;
|
||||
}
|
||||
if ($opt_gdbbt && !$opt_gdb && $Debug) {
|
||||
# Run under GDB to get gdbbt
|
||||
run ("gdb ".verilator_bin()
|
||||
." --batch --quiet"
|
||||
." --batch --quiet --return-child-result"
|
||||
." -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...";
|
||||
." -ex 'bt'");
|
||||
} else {
|
||||
# Normal, non gdb
|
||||
run (($opt_gdb?"$opt_gdb ":"")
|
||||
@ -117,9 +119,7 @@ sub verilator_bin {
|
||||
|| ($Debug ? "verilator_bin_dbg" : "verilator_bin"));
|
||||
if (defined($ENV{VERILATOR_ROOT})) {
|
||||
my $dir = $ENV{VERILATOR_ROOT};
|
||||
if (-x "$basename") {
|
||||
$bin = $basename;
|
||||
} elsif (-x "$dir/bin/$basename") { # From a "make install" into VERILATOR_ROOT
|
||||
if (-x "$dir/bin/$basename") { # From a "make install" into VERILATOR_ROOT
|
||||
$bin = "$dir/bin/$basename";
|
||||
} else {
|
||||
$bin = "$dir/$basename"; # From pointing to kit directory
|
||||
@ -134,6 +134,17 @@ sub verilator_bin {
|
||||
#######################################################################
|
||||
# Utilities
|
||||
|
||||
sub gdb_works {
|
||||
$! = undef; # Cleanup -x
|
||||
system("gdb /bin/echo"
|
||||
." --batch-silent --quiet --return-child-result"
|
||||
." -ex 'run -n'" # `echo -n`
|
||||
." -ex 'set width 0'"
|
||||
." -ex 'bt'");
|
||||
my $status = $?;
|
||||
return $status==0;
|
||||
}
|
||||
|
||||
sub run {
|
||||
# Run command, check errors
|
||||
my $command = shift;
|
||||
@ -241,6 +252,7 @@ descriptions in the next sections for more information.
|
||||
--exe Link to create executable
|
||||
-F <file> Parse options from a file, relatively
|
||||
-f <file> Parse options from a file
|
||||
--gdbbt Run Verilator under GDB for backtrace
|
||||
--help Display this help.
|
||||
-I<dir> Directory to search for includes
|
||||
+incdir+<dir> Directory to search for includes
|
||||
@ -528,6 +540,12 @@ Read the specified file, and act as if all text inside it was specified as
|
||||
command line parameters. Any relative paths are relative to the current
|
||||
directory. Note -f is fairly standard across Verilog tools.
|
||||
|
||||
=item --gdbbt
|
||||
|
||||
If --debug is specified, run Verilator underneath a GDB process and print
|
||||
a backtrace on exit. Without --debug or if GDB doesn't seem to work, this
|
||||
flag is ignored.
|
||||
|
||||
=item --help
|
||||
|
||||
Displays this message and program version and exits.
|
||||
|
@ -21,7 +21,8 @@ export VERILATOR_ROOT
|
||||
# Pick up PERL and other variable settings
|
||||
include $(VERILATOR_ROOT)/include/verilated.mk
|
||||
|
||||
DEBUG_ON = --debug --trace-dups
|
||||
DEBUG_QUIET = --debug --debugi 0 --gdbbt --no-dump-tree
|
||||
DEBUG_ON = --debug --trace-dups --gdbbt
|
||||
#DEBUG = $(DEBUG_ON)
|
||||
VALGRIND_ON = $(DEBUG_ON) --gdb "valgrind -v --leak-check=yes"
|
||||
|
||||
@ -33,8 +34,10 @@ test_valgrind: prep_vg compile run
|
||||
VERILATOR_FLAGS = --cc -f $(VERILATOR_ROOT)/test_v/input.vc top.v
|
||||
VERILATOR_FLAGS += --trace
|
||||
|
||||
#prep: Is the very first time we've executed Verilator after building
|
||||
#so we make sure to run with --gdbbt, so if it dumps we'll get a trace.
|
||||
prep:
|
||||
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG) $(VERILATOR_FLAGS)
|
||||
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_QUIET) $(VERILATOR_FLAGS)
|
||||
prep_dbg:
|
||||
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_ON) $(VERILATOR_FLAGS)
|
||||
prep_vg:
|
||||
|
Loading…
Reference in New Issue
Block a user