mirror of
https://github.com/verilator/verilator.git
synced 2025-04-16 01:26:54 +00:00
--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
|
# 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) {
|
if ($opt_gdbbt && !$opt_gdb && $Debug) {
|
||||||
# Run under GDB to get gdbbt
|
# Run under GDB to get gdbbt
|
||||||
run ("gdb ".verilator_bin()
|
run ("gdb ".verilator_bin()
|
||||||
." --batch --quiet"
|
." --batch --quiet --return-child-result"
|
||||||
." -ex 'run ".join(' ',@Opt_Verilator_Sw)."'"
|
." -ex 'run ".join(' ',@Opt_Verilator_Sw)."'"
|
||||||
." -ex 'set width 0'"
|
." -ex 'set width 0'"
|
||||||
." -ex 'bt'"
|
." -ex 'bt'");
|
||||||
." -ex 'c'");
|
|
||||||
die "%Error: --gdbbt looses the exit status; so must assume run went badly...";
|
|
||||||
} else {
|
} else {
|
||||||
# Normal, non gdb
|
# Normal, non gdb
|
||||||
run (($opt_gdb?"$opt_gdb ":"")
|
run (($opt_gdb?"$opt_gdb ":"")
|
||||||
@ -117,9 +119,7 @@ sub verilator_bin {
|
|||||||
|| ($Debug ? "verilator_bin_dbg" : "verilator_bin"));
|
|| ($Debug ? "verilator_bin_dbg" : "verilator_bin"));
|
||||||
if (defined($ENV{VERILATOR_ROOT})) {
|
if (defined($ENV{VERILATOR_ROOT})) {
|
||||||
my $dir = $ENV{VERILATOR_ROOT};
|
my $dir = $ENV{VERILATOR_ROOT};
|
||||||
if (-x "$basename") {
|
if (-x "$dir/bin/$basename") { # From a "make install" into VERILATOR_ROOT
|
||||||
$bin = $basename;
|
|
||||||
} elsif (-x "$dir/bin/$basename") { # From a "make install" into VERILATOR_ROOT
|
|
||||||
$bin = "$dir/bin/$basename";
|
$bin = "$dir/bin/$basename";
|
||||||
} else {
|
} else {
|
||||||
$bin = "$dir/$basename"; # From pointing to kit directory
|
$bin = "$dir/$basename"; # From pointing to kit directory
|
||||||
@ -134,6 +134,17 @@ sub verilator_bin {
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
# Utilities
|
# 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 {
|
sub run {
|
||||||
# Run command, check errors
|
# Run command, check errors
|
||||||
my $command = shift;
|
my $command = shift;
|
||||||
@ -241,6 +252,7 @@ descriptions in the next sections for more information.
|
|||||||
--exe Link to create executable
|
--exe Link to create executable
|
||||||
-F <file> Parse options from a file, relatively
|
-F <file> Parse options from a file, relatively
|
||||||
-f <file> Parse options from a file
|
-f <file> Parse options from a file
|
||||||
|
--gdbbt Run Verilator under GDB for backtrace
|
||||||
--help Display this help.
|
--help Display this help.
|
||||||
-I<dir> Directory to search for includes
|
-I<dir> Directory to search for includes
|
||||||
+incdir+<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
|
command line parameters. Any relative paths are relative to the current
|
||||||
directory. Note -f is fairly standard across Verilog tools.
|
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
|
=item --help
|
||||||
|
|
||||||
Displays this message and program version and exits.
|
Displays this message and program version and exits.
|
||||||
|
@ -21,7 +21,8 @@ export VERILATOR_ROOT
|
|||||||
# Pick up PERL and other variable settings
|
# Pick up PERL and other variable settings
|
||||||
include $(VERILATOR_ROOT)/include/verilated.mk
|
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)
|
#DEBUG = $(DEBUG_ON)
|
||||||
VALGRIND_ON = $(DEBUG_ON) --gdb "valgrind -v --leak-check=yes"
|
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 = --cc -f $(VERILATOR_ROOT)/test_v/input.vc top.v
|
||||||
VERILATOR_FLAGS += --trace
|
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:
|
prep:
|
||||||
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG) $(VERILATOR_FLAGS)
|
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_QUIET) $(VERILATOR_FLAGS)
|
||||||
prep_dbg:
|
prep_dbg:
|
||||||
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_ON) $(VERILATOR_FLAGS)
|
$(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_ON) $(VERILATOR_FLAGS)
|
||||||
prep_vg:
|
prep_vg:
|
||||||
|
Loading…
Reference in New Issue
Block a user