Add error/warning suppression with `suppress_msg` and `unsuppress_msg` commands (#157)
* Add error/warning suppression with `suppress_msg` and `unsuppress_msg` commands * Fixes * Merge docs * Fixes * Remove optional arg from class * Add where to find message codes * Update docs * Requested fixes * Deal with errors on the TCL side instead of C++ side * Update ok file * Add back in C++ side error suppression and have tests for both C++/TCL side suppression * Requested fixes to ChangeLog and unifying suppression in C++/TCL * Requested fixes * Requested test adjustments * Smallfixes * Smallfixes * Another smallfix
This commit is contained in:
parent
cc3b911b6d
commit
fbb4b8c6e6
|
|
@ -31,11 +31,14 @@ is now supported by the the read_saif command.
|
|||
read_saif [-scope scope] filename
|
||||
|
||||
The report_checks -group_count option has been renamed to -group_path_count.
|
||||
The report_checks -endpoing_count option has been renamed to -endpoint_path_count.
|
||||
The report_checks -endpoint_count option has been renamed to -endpoint_path_count.
|
||||
|
||||
The report_checks -field hierarchical_pins field reports hierarical pins between
|
||||
The report_checks -field hierarchical_pins field reports hierarchical pins between
|
||||
a driver and a load in the path report.
|
||||
|
||||
The suppress_msg and unsuppress_msg commands allow suppression/unsuppression of
|
||||
warnings/errors by ID. Message IDs can be found in doc/messages.txt.
|
||||
|
||||
Release 2.5.0 2024/01/17
|
||||
-------------------------
|
||||
|
||||
|
|
|
|||
BIN
doc/OpenSTA.odt
BIN
doc/OpenSTA.odt
Binary file not shown.
BIN
doc/OpenSTA.pdf
BIN
doc/OpenSTA.pdf
Binary file not shown.
|
|
@ -34,11 +34,14 @@ public:
|
|||
class ExceptionMsg : public Exception
|
||||
{
|
||||
public:
|
||||
ExceptionMsg(const char *msg);
|
||||
ExceptionMsg(const char *msg,
|
||||
const bool suppressed);
|
||||
virtual const char *what() const noexcept;
|
||||
virtual bool suppressed() const { return suppressed_; }
|
||||
|
||||
private:
|
||||
string msg_;
|
||||
bool suppressed_;
|
||||
};
|
||||
|
||||
class ExceptionLine : public Exception
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <cstdarg>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "Machine.hh" // __attribute__
|
||||
|
||||
|
|
@ -119,6 +120,11 @@ public:
|
|||
size_t length);
|
||||
static Report *defaultReport() { return default_; }
|
||||
|
||||
// Suppress message by id.
|
||||
void suppressMsgId(int id);
|
||||
void unsuppressMsgId(int id);
|
||||
bool isSuppressed(int id);
|
||||
|
||||
protected:
|
||||
// All sta print functions have an implicit return printed by this function.
|
||||
virtual void printLine(const char *line,
|
||||
|
|
@ -152,6 +158,7 @@ protected:
|
|||
size_t buffer_length_;
|
||||
std::mutex buffer_lock_;
|
||||
static Report *default_;
|
||||
std::set<int> suppressed_msg_ids_;
|
||||
|
||||
friend class Debug;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@
|
|||
fprintf(stderr, "Error: out of memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
catch (ExceptionMsg &excp) {
|
||||
if (!excp.suppressed()) {
|
||||
Tcl_ResetResult(interp);
|
||||
Tcl_AppendResult(interp, "Error: ", excp.what(), nullptr);
|
||||
}
|
||||
return TCL_ERROR;
|
||||
}
|
||||
catch (std::exception &excp) {
|
||||
Tcl_ResetResult(interp);
|
||||
Tcl_AppendResult(interp, "Error: ", excp.what(), nullptr);
|
||||
|
|
|
|||
29
tcl/Util.tcl
29
tcl/Util.tcl
|
|
@ -192,10 +192,13 @@ proc sta_warn { msg_id msg } {
|
|||
proc sta_error { msg_id msg } {
|
||||
variable sdc_file
|
||||
variable sdc_line
|
||||
if { [info exists sdc_file] } {
|
||||
error "Error: [file tail $sdc_file] line $sdc_line, $msg"
|
||||
} else {
|
||||
error "Error: $msg"
|
||||
|
||||
if { ! [is_suppressed $msg_id] } {
|
||||
if { [info exists sdc_file] } {
|
||||
error "Error: [file tail $sdc_file] line $sdc_line, $msg"
|
||||
} else {
|
||||
error "Error: $msg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +210,24 @@ proc sta_warn_error { msg_id warn_error msg } {
|
|||
}
|
||||
}
|
||||
|
||||
define_cmd_args "suppress_msg" msg_ids
|
||||
|
||||
proc suppress_msg { args } {
|
||||
foreach msg_id $args {
|
||||
check_integer "msg_id" $msg_id
|
||||
suppress_msg_id $msg_id
|
||||
}
|
||||
}
|
||||
|
||||
define_cmd_args "unsuppress_msg" msg_ids
|
||||
|
||||
proc unsuppress_msg { args } {
|
||||
foreach msg_id $args {
|
||||
check_integer "msg_id" $msg_id
|
||||
unsuppress_msg_id $msg_id
|
||||
}
|
||||
}
|
||||
|
||||
# Defined by StaTcl.i
|
||||
define_cmd_args "elapsed_run_time" {}
|
||||
define_cmd_args "user_run_time" {}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ record_sta_tests {
|
|||
report_checks_src_attr
|
||||
report_json1
|
||||
report_json2
|
||||
suppress_msg
|
||||
verilog_attribute
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
Warning: suppress_msg.tcl line 18, cmd warn 1
|
||||
caught Error: suppress_msg.tcl line 18, cmd error 1
|
||||
Warning: cmd warn 2
|
||||
caught Error: cmd error 2
|
||||
after error
|
||||
caught
|
||||
caught
|
||||
after error
|
||||
Warning: suppress_msg.tcl line 51, cmd warn 7
|
||||
caught Error: suppress_msg.tcl line 51, cmd error 7
|
||||
Warning: cmd warn 8
|
||||
caught Error: cmd error 8
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# suppress and unsuppress message ids
|
||||
|
||||
# Run sta_warn/sta_error to test TCL side suppression
|
||||
proc sta_cmd { msg } {
|
||||
sta::sta_warn 1 "cmd warn $msg"
|
||||
sta::sta_error 2 "cmd error $msg"
|
||||
puts "after error"
|
||||
}
|
||||
|
||||
# Run report_warn/report_error to test C++ side suppression
|
||||
proc report_cmd { msg } {
|
||||
sta::report_warn 1 "cmd warn $msg"
|
||||
sta::report_error 2 "cmd error $msg"
|
||||
puts "after error"
|
||||
}
|
||||
|
||||
# Ensure that TCL side messages are displayed as usual
|
||||
catch { sta_cmd 1 } error
|
||||
puts "caught $error"
|
||||
|
||||
# Ensure that C++ side messages are displayed as usual
|
||||
catch { report_cmd 2 } error
|
||||
puts "caught $error"
|
||||
|
||||
# Suppress messages
|
||||
suppress_msg 1 2
|
||||
|
||||
# Ensure that TCL side messages are suppressed
|
||||
catch { sta_cmd 3 } error
|
||||
puts "caught $error"
|
||||
|
||||
# Ensure that C++ side messages are suppressed
|
||||
catch { report_cmd 4 } error
|
||||
puts "caught $error"
|
||||
|
||||
# Continue on error to avoid having to catch
|
||||
set sta_continue_on_error 1
|
||||
|
||||
# Ensure that TCL side messages are suppressed
|
||||
# TCL side will make it to "after error"
|
||||
sta_cmd 5
|
||||
|
||||
# Ensure that C++ side messages are suppressed
|
||||
# C++ will not make it to "after error" as the whole cmd is cancelled
|
||||
report_cmd 6
|
||||
|
||||
# Unsuppress messages
|
||||
unsuppress_msg 1 2
|
||||
|
||||
# Ensure that TCL side messages are displayed as usual
|
||||
catch { sta_cmd 7 } error
|
||||
puts "caught $error"
|
||||
|
||||
# Ensure that C++ side messages are displayed as usual
|
||||
catch { report_cmd 8 } error
|
||||
puts "caught $error"
|
||||
|
|
@ -28,9 +28,11 @@ Exception::Exception() :
|
|||
{
|
||||
}
|
||||
|
||||
ExceptionMsg::ExceptionMsg(const char *msg) :
|
||||
ExceptionMsg::ExceptionMsg(const char *msg,
|
||||
const bool suppressed) :
|
||||
Exception(),
|
||||
msg_(msg)
|
||||
msg_(msg),
|
||||
suppressed_(suppressed)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,59 +169,71 @@ Report::printBufferLine()
|
|||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
Report::warn(int /* id */,
|
||||
Report::warn(int id,
|
||||
const char *fmt,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printToBuffer("Warning: ");
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
va_end(args);
|
||||
// Skip suppressed messages.
|
||||
if (!isSuppressed(id)) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printToBuffer("Warning: ");
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Report::vwarn(int /* id */,
|
||||
Report::vwarn(int id,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
printToBuffer("Warning: ");
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
// Skip suppressed messages.
|
||||
if (!isSuppressed(id)) {
|
||||
printToBuffer("Warning: ");
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Report::fileWarn(int /* id */,
|
||||
Report::fileWarn(int id,
|
||||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printToBuffer("Warning: %s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
va_end(args);
|
||||
// Skip suppressed messages.
|
||||
if (!isSuppressed(id)) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printToBuffer("Warning: %s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Report::vfileWarn(int /* id */,
|
||||
Report::vfileWarn(int id,
|
||||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
printToBuffer("Warning: %s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
// Skip suppressed messages.
|
||||
if (!isSuppressed(id)) {
|
||||
printToBuffer("Warning: %s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
printBufferLine();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
Report::error(int /* id */,
|
||||
Report::error(int id,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
|
@ -229,21 +241,21 @@ Report::error(int /* id */,
|
|||
// No prefix msg, no \n.
|
||||
printToBuffer(fmt, args);
|
||||
va_end(args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
throw ExceptionMsg(buffer_, isSuppressed(id));
|
||||
}
|
||||
|
||||
void
|
||||
Report::verror(int /* id */,
|
||||
Report::verror(int id,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
// No prefix msg, no \n.
|
||||
printToBuffer(fmt, args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
throw ExceptionMsg(buffer_, isSuppressed(id));
|
||||
}
|
||||
|
||||
void
|
||||
Report::fileError(int /* id */,
|
||||
Report::fileError(int id,
|
||||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
|
|
@ -255,11 +267,11 @@ Report::fileError(int /* id */,
|
|||
printToBuffer("%s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
va_end(args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
throw ExceptionMsg(buffer_, isSuppressed(id));
|
||||
}
|
||||
|
||||
void
|
||||
Report::vfileError(int /* id */,
|
||||
Report::vfileError(int id,
|
||||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
|
|
@ -268,7 +280,7 @@ Report::vfileError(int /* id */,
|
|||
// No prefix msg, no \n.
|
||||
printToBuffer("%s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
throw ExceptionMsg(buffer_, isSuppressed(id));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
|
@ -304,6 +316,26 @@ Report::fileCritical(int /* id */,
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
Report::suppressMsgId(int id)
|
||||
{
|
||||
suppressed_msg_ids_.insert(id);
|
||||
}
|
||||
|
||||
void
|
||||
Report::unsuppressMsgId(int id)
|
||||
{
|
||||
suppressed_msg_ids_.erase(id);
|
||||
}
|
||||
|
||||
bool
|
||||
Report::isSuppressed(int id)
|
||||
{
|
||||
return suppressed_msg_ids_.find(id) != suppressed_msg_ids_.end();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
Report::logBegin(const char *filename)
|
||||
{
|
||||
|
|
|
|||
18
util/Util.i
18
util/Util.i
|
|
@ -148,6 +148,24 @@ report_line(const char *msg)
|
|||
printf("%s\n", msg);
|
||||
}
|
||||
|
||||
void
|
||||
suppress_msg_id(int id)
|
||||
{
|
||||
Sta::sta()->report()->suppressMsgId(id);
|
||||
}
|
||||
|
||||
void
|
||||
unsuppress_msg_id(int id)
|
||||
{
|
||||
Sta::sta()->report()->unsuppressMsgId(id);
|
||||
}
|
||||
|
||||
int
|
||||
is_suppressed(int id)
|
||||
{
|
||||
return Sta::sta()->report()->isSuppressed(id);
|
||||
}
|
||||
|
||||
void
|
||||
fflush()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue