Skip to content

Commit

Permalink
error/warn IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Dec 14, 2020
1 parent e0c4799 commit 78d29c8
Show file tree
Hide file tree
Showing 52 changed files with 496 additions and 461 deletions.
2 changes: 1 addition & 1 deletion dcalc/ArnoldiDelayCalc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ void arnoldi1::calculate_poles_res(delay_work *D,double rdrive)
dsave = d[0];
d[0] += rdrive*ctot;
if (!tridiagEV(order,d,e,p,v))
internalError("arnoldi delay calc failed.\n");
criticalError(204, "arnoldi delay calc failed.");
d[0] = dsave;

for (h=0;h<order;h++) {
Expand Down
2 changes: 1 addition & 1 deletion dcalc/DmpCeff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ DmpCeffDelayCalc::gateDelay(const LibertyCell *drvr_cell,
if (drvr_parasitic
&& !unsuppored_model_warned_) {
unsuppored_model_warned_ = true;
report_->warn("cell %s delay model not supported on SPF parasitics by DMP delay calculator\n",
report_->warn(1, "cell %s delay model not supported on SPF parasitics by DMP delay calculator",
drvr_cell->name());
}
}
Expand Down
2 changes: 1 addition & 1 deletion dcalc/GraphDelayCalc1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ GraphDelayCalc1::findPortIndex(LibertyCell *cell,
return index;
index++;
}
internalError("port not found in cell");
report_->critical(207, "port not found in cell");
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions doc/ApiChanges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

This file summarizes STA API changes for each release.

Release 2.1.1 2020/12/13
Report::error, Report::warn functions now take a unique message ID as a first argument.
InternalError has been renamed Report::cricical.

Release 2.1.0 2020/04/05

All public headers files have been moved to include/sta.
Expand Down
8 changes: 4 additions & 4 deletions graph/Graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ Graph::arcDelayAnnotated(Edge *edge,
if (arc_delay_annotated_.size()) {
size_t index = (edge->arcDelays() + arc->index()) * ap_count_ + ap_index;
if (index >= arc_delay_annotated_.size())
internalError("arc_delay_annotated array bounds exceeded");
report_->critical(208, "arc_delay_annotated array bounds exceeded");
return arc_delay_annotated_[index];
}
else
Expand All @@ -756,7 +756,7 @@ Graph::setArcDelayAnnotated(Edge *edge,
{
size_t index = (edge->arcDelays() + arc->index()) * ap_count_ + ap_index;
if (index >= arc_delay_annotated_.size())
internalError("arc_delay_annotated array bounds exceeded");
report_->critical(209, "arc_delay_annotated array bounds exceeded");
arc_delay_annotated_[index] = annotated;
}

Expand All @@ -768,7 +768,7 @@ Graph::wireDelayAnnotated(Edge *edge,
size_t index = (edge->arcDelays() + TimingArcSet::wireArcIndex(rf)) * ap_count_
+ ap_index;
if (index >= arc_delay_annotated_.size())
internalError("arc_delay_annotated array bounds exceeded");
report_->critical(210, "arc_delay_annotated array bounds exceeded");
return arc_delay_annotated_[index];
}

Expand All @@ -781,7 +781,7 @@ Graph::setWireDelayAnnotated(Edge *edge,
size_t index = (edge->arcDelays() + TimingArcSet::wireArcIndex(rf)) * ap_count_
+ ap_index;
if (index >= arc_delay_annotated_.size())
internalError("arc_delay_annotated array bounds exceeded");
report_->critical(228, "arc_delay_annotated array bounds exceeded");
arc_delay_annotated_[index] = annotated;
}

Expand Down
13 changes: 6 additions & 7 deletions include/sta/ArrayTable.hh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ArrayTable<TYPE>::pushBlock(ArrayBlock<TYPE> *block)
{
blocks_[blocks_size_++] = block;
if (blocks_size_ >= block_id_max)
internalError("max array table block count exceeded.");
criticalError(223, "max array table block count exceeded.");
if (blocks_size_ == blocks_capacity_) {
size_t new_capacity = blocks_capacity_ * 1.5;
ArrayBlock<TYPE>** new_blocks = new ArrayBlock<TYPE>*[new_capacity];
Expand Down Expand Up @@ -177,12 +177,11 @@ TYPE &
ArrayTable<TYPE>::ref(ObjectId id) const
{
if (id == object_id_null)
internalError("null ObjectId reference is undefined.");
else {
BlockIdx blk_idx = id >> idx_bits;
ObjectIdx obj_idx = id & idx_mask_;
return blocks_[blk_idx]->ref(obj_idx);
}
criticalError(222, "null ObjectId reference is undefined.");

BlockIdx blk_idx = id >> idx_bits;
ObjectIdx obj_idx = id & idx_mask_;
return blocks_[blk_idx]->ref(obj_idx);
}

template <class TYPE>
Expand Down
30 changes: 8 additions & 22 deletions include/sta/Error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <exception>
#include "DisallowCopyAssign.hh"
#include "Report.hh"

namespace sta {

Expand All @@ -41,28 +42,6 @@ protected:
int line_;
};

class InternalError : public ExceptionLine
{
public:
InternalError(const char *filename,
int line,
const char *msg);
virtual const char *what() const noexcept;

protected:
const char *msg_;
};

// Report an error condition that should not be possible.
// The default handler prints msg to stderr and exits.
// The msg should NOT include a period or return, as these
// are added by InternalError::asString().
#define internalError(msg) \
throw sta::InternalError(__FILE__, __LINE__, msg)

#define internalErrorNoThrow(msg) \
printf("Internal Error: %s:%d %s\n", __FILE__, __LINE__, msg)

// Failure opening filename for reading.
class FileNotReadable : public Exception
{
Expand All @@ -85,4 +64,11 @@ protected:
const char *filename_;
};

// Report an error condition that should not be possible.
// The default handler prints msg to stderr and exits.
// The msg should NOT include a period or return.
// For only in those cases where a Report object is not available.
#define criticalError(id,msg) \
Report::defaultReport()->fileCritical(id, __FILE__, __LINE__, msg)

} // namespace
2 changes: 1 addition & 1 deletion include/sta/MinMaxValues.hh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public:
if (exists)
return values_[mm_index];
else
internalError("uninitialized value reference");
criticalError(226, "uninitialized value reference");
}

void
Expand Down
4 changes: 2 additions & 2 deletions include/sta/ObjectTable.hh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ObjectTable<TYPE>::makeBlock()
TableBlock<TYPE> *block = new TableBlock<TYPE>(block_index, this);
blocks_.push_back(block);
if (blocks_.size() >= block_id_max)
internalError("max object table block count exceeded.");
criticalError(224, "max object table block count exceeded.");
// ObjectId zero is reserved for object_id_null.
int last = (block_index > 0) ? 0 : 1;
for (int i = block_object_count - 1; i >= last; i--) {
Expand Down Expand Up @@ -134,7 +134,7 @@ TYPE &
ObjectTable<TYPE>::ref(ObjectId id) const
{
if (id == object_id_null)
internalError("null ObjectId reference is undefined.");
criticalError(225, "null ObjectId reference is undefined.");
else {
BlockIdx blk_idx = id >> idx_bits;
ObjectIdx obj_idx = id & idx_mask_;
Expand Down
40 changes: 24 additions & 16 deletions include/sta/Report.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,35 @@ public:
__attribute__((format (printf, 2, 3)));
virtual void vprintError(const char *fmt, va_list args);

// Report error.
virtual void error(const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
virtual void verror(const char *fmt, va_list args);
// Report error in a file.
virtual void fileError(const char *filename, int line, const char *fmt, ...)
__attribute__((format (printf, 4, 5)));
virtual void vfileError(const char *filename, int line, const char *fmt,
va_list args);

// Print to warning stream (same as error stream).
virtual void printWarn(const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
virtual void vprintWarn(const char *fmt, va_list args);
// Report warning.
virtual void warn(const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
virtual void vwarn(const char *fmt, va_list args);
virtual void warn(int id, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
// Report warning in a file.
virtual void fileWarn(const char *filename, int line, const char *fmt, ...)
__attribute__((format (printf, 4, 5)));
virtual void vfileWarn(const char *filename, int line, const char *fmt,
virtual void fileWarn(int id, const char *filename, int line, const char *fmt, ...)
__attribute__((format (printf, 5, 6)));
virtual void vfileWarn(int id, const char *filename, int line, const char *fmt,
va_list args);

// Critical.
// Report error condition that should not be possible or that prevents execution.
// The default handler prints msg to stderr and exits.
virtual void critical(int id, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
virtual void fileCritical(int id, const char *filename, int line, const char *fmt, ...)
__attribute__((format (printf, 5, 6)));

virtual void error(int id, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
// Report error in a file.
virtual void fileError(int id, const char *filename, int line, const char *fmt, ...)
__attribute__((format (printf, 5, 6)));
virtual void vfileError(int id, const char *filename, int line, const char *fmt,
va_list args);

// Log output to filename until logEnd is called.
virtual void logBegin(const char *filename);
virtual void logEnd();
Expand All @@ -96,6 +101,8 @@ public:
virtual const char *redirectStringEnd();
virtual void setTclInterp(Tcl_Interp *) {}

static Report *defaultReport() { return default_; }

protected:
// Primitive to print output on the console.
// Return the number of characters written.
Expand All @@ -116,6 +123,7 @@ protected:
// Length of string in buffer.
size_t buffer_length_;
std::mutex buffer_lock_;
static Report *default_;

private:
DISALLOW_COPY_AND_ASSIGN(Report);
Expand Down
4 changes: 2 additions & 2 deletions liberty/InternalPower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ InternalPowerModel::findAxisValues(float in_slew,
axis_value3 = axisValue(model_->axis3(), in_slew, load_cap);
break;
default:
internalError("unsupported table order");
criticalError(229, "unsupported table order");
}
}

Expand All @@ -201,7 +201,7 @@ InternalPowerModel::axisValue(TableAxis *axis,
else if (var == TableAxisVariable::total_output_net_capacitance)
return load_cap;
else {
internalError("unsupported table axes");
criticalError(230, "unsupported table axes");
return 0.0;
}
}
Expand Down
24 changes: 12 additions & 12 deletions liberty/Liberty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ LibertyLibrary::degradeWireSlew(const LibertyCell *cell,
else if (var1 == TableAxisVariable::connect_delay)
return model->findValue(this, cell, pvt, wire_delay, 0.0, 0.0);
else {
internalError("unsupported slew degradation table axes");
criticalError(231, "unsupported slew degradation table axes");
return 0.0;
}
}
Expand All @@ -341,12 +341,12 @@ LibertyLibrary::degradeWireSlew(const LibertyCell *cell,
&& var2 == TableAxisVariable::output_pin_transition)
return model->findValue(this, cell, pvt, wire_delay, in_slew, 0.0);
else {
internalError("unsupported slew degradation table axes");
criticalError(232, "unsupported slew degradation table axes");
return 0.0;
}
}
default:
internalError("unsupported slew degradation table order");
criticalError(233, "unsupported slew degradation table order");
return 0.0;
}
}
Expand Down Expand Up @@ -376,7 +376,7 @@ LibertyLibrary::checkSlewDegradationAxes(Table *table)
&& var2 == TableAxisVariable::output_pin_transition);
}
default:
internalError("unsupported slew degradation table axes");
criticalError(234, "unsupported slew degradation table axes");
return 0.0;
}
}
Expand Down Expand Up @@ -726,7 +726,7 @@ LibertyLibrary::makeCornerMap(LibertyCell *cell1,
port1->setCornerPort(port2, ap_index);
}
else
report->warn("cell %s/%s port %s not found in cell %s/%s.\n",
report->warn(2, "cell %s/%s port %s not found in cell %s/%s.",
cell1->library()->name(),
cell1->name(),
port_name,
Expand All @@ -749,7 +749,7 @@ LibertyLibrary::makeCornerMap(LibertyCell *cell1,
}
}
else
report->warn("cell %s/%s %s -> %s timing group %s not found in cell %s/%s.\n",
report->warn(3, "cell %s/%s %s -> %s timing group %s not found in cell %s/%s.",
cell1->library()->name(),
cell1->name(),
arc_set1->from()->name(),
Expand Down Expand Up @@ -1126,7 +1126,7 @@ LibertyCell::addTimingArcSet(TimingArcSet *arc_set)
{
int set_index = timing_arc_sets_.size();
if (set_index > timing_arc_set_index_max)
internalError("timing arc set max index exceeded");
criticalError(235, "timing arc set max index exceeded");
timing_arc_sets_.push_back(arc_set);

LibertyPort *from = arc_set->from();
Expand Down Expand Up @@ -1277,7 +1277,7 @@ LibertyCell::makeTimingArcMap(Report *)
if (match != arc_set) {
// Unfortunately these errors are common in some brain damaged
// libraries.
// report->warn("cell %s/%s has duplicate %s -> %s %s timing groups.\n",
// report->warn("cell %s/%s has duplicate %s -> %s %s timing groups.",
// library_->name(),
// name_,
// match->from()->name(),
Expand All @@ -1292,7 +1292,7 @@ LibertyCell::makeTimingArcMap(Report *)
timing_arc_sets_.resize(j);

if (timing_arc_set_map_.size() != timing_arc_sets_.size())
internalError("timing arc count mismatch\n");
criticalError(205, "timing arc count mismatch");
}

void
Expand Down Expand Up @@ -1638,7 +1638,7 @@ LibertyCell::makeLatchEnables(Report *report,
RiseFall *en_rf = latch_enable->enableTransition();
RiseFall *check_rf = check_arc->fromTrans()->asRiseFall();
if (check_rf == en_rf) {
report->warn("cell %s/%s %s -> %s latch enable %s_edge timing arc is inconsistent with %s -> %s setup_%s check.\n",
report->warn(4, "cell %s/%s %s -> %s latch enable %s_edge timing arc is inconsistent with %s -> %s setup_%s check.",
library_->name(),
name_,
en->name(),
Expand All @@ -1653,15 +1653,15 @@ LibertyCell::makeLatchEnables(Report *report,
TimingSense en_sense = en_func->portTimingSense(en);
if (en_sense == TimingSense::positive_unate
&& en_rf != RiseFall::rise())
report->warn("cell %s/%s %s -> %s latch enable %s_edge is inconsistent with latch group enable function positive sense.\n",
report->warn(5, "cell %s/%s %s -> %s latch enable %s_edge is inconsistent with latch group enable function positive sense.",
library_->name(),
name_,
en->name(),
q->name(),
en_rf == RiseFall::rise()?"rising":"falling");
else if (en_sense == TimingSense::negative_unate
&& en_rf != RiseFall::fall())
report->warn("cell %s/%s %s -> %s latch enable %s_edge is inconsistent with latch group enable function negative sense.\n",
report->warn(6, "cell %s/%s %s -> %s latch enable %s_edge is inconsistent with latch group enable function negative sense.",
library_->name(),
name_,
en->name(),
Expand Down
4 changes: 2 additions & 2 deletions liberty/LibertyExpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ LibExprParser::makeFuncExprPort(const char *port_name)
if (port)
expr = FuncExpr::makePort(port);
else
report_->error("%s references unknown port %s.\n",
report_->error(7, "%s references unknown port %s.",
error_msg_, port_name);
stringDelete(port_name);
return expr;
Expand Down Expand Up @@ -166,7 +166,7 @@ LibExprParser::tokenAppend(char ch)
void
LibExprParser::parseError(const char *msg)
{
report_->printError("%s %s.\n", error_msg_, msg);
report_->error(206, "%s %s.", error_msg_, msg);
}

} // namespace
Expand Down
Loading

0 comments on commit 78d29c8

Please sign in to comment.