From aba25aab19c1d7c579e2381e4f5b6bdfd1110660 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 20 Sep 2010 09:21:29 -0400 Subject: [PATCH] On core dump, print debug suggestions. --- Changes | 2 ++ bin/verilator | 9 +++++++++ src/V3Options.cpp | 2 ++ test_regress/t/t_debug_sigsegv_bad.pl | 21 +++++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100755 test_regress/t/t_debug_sigsegv_bad.pl diff --git a/Changes b/Changes index de7113b6c..966ff15b4 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Increase define recursions before error. [Paul Liu] +**** On core dump, print debug suggestions. + * Verilator 3.803 2010/07/10 *** Fix preprocessor preservation of newlines across macro substitutions. diff --git a/bin/verilator b/bin/verilator index b87e5e941..cdecb91b5 100755 --- a/bin/verilator +++ b/bin/verilator @@ -137,6 +137,15 @@ sub run { warn "%Error: export VERILATOR_ROOT=".($ENV{VERILATOR_ROOT}||"")."\n"; warn "%Error: $command\n"; } + if ($status & 255) { + if (($status & 255) == 8 || ($status & 255) == 11) { # SIGFPA or SIGSEGV + warn "%Error: Verilator internal fault, sorry. Consider trying --debug --gdbbt\n" if !$Debug; + } elsif (($status & 255) == 6) { # SIGABRT + warn "%Error: Verilator aborted. Consider trying --debug --gdbbt\n" if !$Debug; + } else { + warn "%Error: Verilator threw signal $status. Consider trying --debug --gdbbt\n" if !$Debug; + } + } die "%Error: Command Failed $command\n"; } } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 01d8a5a96..64f2a3b49 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -614,7 +614,9 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) { else if ( onoff (sw, "-coverage-underscore", flag/*ref*/) ){ m_coverageUnderscore = flag; } else if ( onoff (sw, "-coverage-user", flag/*ref*/) ){ m_coverageUser = flag; } else if ( onoff (sw, "-covsp", flag/*ref*/) ) { } // TBD + else if ( !strcmp (sw, "-debug-abort") ) { abort(); } // Undocumented, see also --debug-core-dump else if ( onoff (sw, "-debug-check", flag/*ref*/) ){ m_debugCheck = flag; } + else if ( !strcmp (sw, "-debug-core-dump") ) { char* zp=NULL; *zp=0; } // Undocumented, see also --debug-abort else if ( onoff (sw, "-dump-tree", flag/*ref*/) ) { m_dumpTree = flag; } else if ( onoff (sw, "-exe", flag/*ref*/) ) { m_exe = flag; } else if ( onoff (sw, "-ignc", flag/*ref*/) ) { m_ignc = flag; } diff --git a/test_regress/t/t_debug_sigsegv_bad.pl b/test_regress/t/t_debug_sigsegv_bad.pl new file mode 100755 index 000000000..7e15d231e --- /dev/null +++ b/test_regress/t/t_debug_sigsegv_bad.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you can +# redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. + +$Self->{vlt} or $Self->skip("Verilator only test"); + +compile ( + v_flags2 => ["--debug-core-dump"], + fails=>$Self->{v3}, + expect=> +'%Error: Verilator internal fault, sorry. Consider trying --debug --gdbbt +%Error: Command Failed.*', + ); + +ok(1); +1;