From a005ccb0e21e2ab91edc1e97979e38382010b9cc Mon Sep 17 00:00:00 2001 From: James Cherry Date: Wed, 30 Dec 2020 19:51:50 -0800 Subject: [PATCH] Report::printLine. no more \n's in print stmts --- include/sta/Report.hh | 16 ++++++++++------ liberty/TableModel.cc | 12 ++++++------ sdf/ReportAnnotation.cc | 2 +- search/Search.cc | 6 +++--- search/TagGroup.cc | 2 +- util/Debug.cc | 4 ++-- util/Report.cc | 38 +++++++++++++++++++------------------- 7 files changed, 42 insertions(+), 38 deletions(-) diff --git a/include/sta/Report.hh b/include/sta/Report.hh index 0a62fab5..239d647c 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -38,12 +38,9 @@ public: Report(); virtual ~Report(); - // Primitive to print output. - // Return the number of characters written. - virtual size_t printString(const char *buffer, - size_t length); // Print line with return. - virtual void reportLine(const char *fmt, ...); + virtual void reportLine(const char *fmt, ...) + __attribute__((format (printf, 2, 3))); virtual void reportLineString(const char *line); virtual void reportLine(const string &line); @@ -114,9 +111,16 @@ public: virtual const char *redirectStringEnd(); virtual void setTclInterp(Tcl_Interp *) {} + // Primitive to print output. + // Return the number of characters written. + // public for use by ReportTcl encapsulated channel functions. + virtual size_t printString(const char *buffer, + size_t length); static Report *defaultReport() { return default_; } protected: + virtual void printLine(const char *line, + size_t length); // Primitive to print output on the console. // Return the number of characters written. virtual size_t printConsole(const char *buffer, @@ -129,7 +133,7 @@ protected: ...); void printToBufferAppend(const char *fmt, va_list args); - void printBuffer(); + void printBufferLine(); void redirectStringPrint(const char *buffer, size_t length); diff --git a/liberty/TableModel.cc b/liberty/TableModel.cc index 5fbbac58..c3deb1e5 100644 --- a/liberty/TableModel.cc +++ b/liberty/TableModel.cc @@ -845,14 +845,14 @@ Table1::report(const Units *units, line += unit1->asString(axis1_->axisValue(index1), digits); line += " "; } - report->reportLine(line.c_str()); + report->reportLine(line); line.clear(); for (size_t index1 = 0; index1 < axis1_->size(); index1++) { line += table_unit->asString(tableValue(index1), digits); line += " "; } - report->reportLine(line.c_str()); + report->reportLine(line); } //////////////////////////////////////////////////////////////// @@ -1036,7 +1036,7 @@ Table2::report(const Units *units, line += unit2->asString(axis2_->axisValue(index2), digits); line += " "; } - report->reportLine(line.c_str()); + report->reportLine(line); for (size_t index1 = 0; index1 < axis1_->size(); index1++) { line = unit1->asString(axis1_->axisValue(index1), digits); @@ -1045,7 +1045,7 @@ Table2::report(const Units *units, line += table_unit->asString(tableValue(index1, index2), digits); line += " "; } - report->reportLine(line.c_str()); + report->reportLine(line); } } @@ -1300,7 +1300,7 @@ Table3::report(const Units *units, line += unit3->asString(axis3_->axisValue(index3), digits); line += " "; } - report->reportLine(line.c_str()); + report->reportLine(line); for (size_t index2 = 0; index2 < axis2_->size(); index2++) { line = unit2->asString(axis2_->axisValue(index2),digits); @@ -1309,7 +1309,7 @@ Table3::report(const Units *units, line += table_unit->asString(tableValue(index1, index2, index3), digits); line += " "; } - report->reportLine(line.c_str()); + report->reportLine(line); } } } diff --git a/sdf/ReportAnnotation.cc b/sdf/ReportAnnotation.cc index 44508712..4ce6718d 100644 --- a/sdf/ReportAnnotation.cc +++ b/sdf/ReportAnnotation.cc @@ -467,7 +467,7 @@ ReportAnnotated::reportArcs(const char *header, PinSet &pins) { report_->reportLine(""); - report_->reportLine(header); + report_->reportLineString(header); PinSeq sorted_pins; sortPinSet(&pins, network_, sorted_pins); int i = 0; diff --git a/search/Search.cc b/search/Search.cc index d876e1bf..771a8d87 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -2784,7 +2784,7 @@ Search::reportTagGroups() const for (TagGroupIndex i = 0; i < tag_group_next_; i++) { TagGroup *tag_group = tag_groups_[i]; if (tag_group) { - report_->reportLine("Group %4u hash = %4u (%4u)", + report_->reportLine("Group %4u hash = %4lu (%4lu)", i, tag_group->hash(), tag_group->hash() % tag_group_set_->capacity()); @@ -2792,7 +2792,7 @@ Search::reportTagGroups() const } } size_t long_hash = tag_group_set_->longestBucketHash(); - report_->reportLine("Longest hash bucket length %lu hash=%lu", + report_->reportLine("Longest hash bucket length %d hash=%lu", tag_group_set_->bucketLength(long_hash), long_hash); } @@ -2816,7 +2816,7 @@ Search::reportArrivalCountHistogram() const for (size_t arrival_count = 0; arrival_count < vertex_counts.size(); arrival_count++) { int vertex_count = vertex_counts[arrival_count]; if (vertex_count > 0) - report_->reportLine("%6d %6d", arrival_count, vertex_count); + report_->reportLine("%6lu %6d", arrival_count, vertex_count); } } diff --git a/search/TagGroup.cc b/search/TagGroup.cc index de387c4c..2028479d 100644 --- a/search/TagGroup.cc +++ b/search/TagGroup.cc @@ -106,7 +106,7 @@ void TagGroup::report(const StaState *sta) const { Report *report = sta->report(); - report->reportLine("Group %u hash = %u", index_, hash_); + report->reportLine("Group %u hash = %lu", index_, hash_); arrivalMapReport(arrival_map_, sta); } diff --git a/util/Debug.cc b/util/Debug.cc index 554b494c..0bd81ead 100644 --- a/util/Debug.cc +++ b/util/Debug.cc @@ -112,8 +112,8 @@ Debug::reportLine(const char *what, report_->printToBuffer(what); report_->printToBufferAppend(": "); report_->printToBufferAppend(fmt, args); - report_->printToBufferAppend("\n"); - report_->printBuffer(); + report_->printBufferLine(); + va_end(args); } } // namespace diff --git a/util/Report.cc b/util/Report.cc index bebdcbe1..cde8b023 100644 --- a/util/Report.cc +++ b/util/Report.cc @@ -44,6 +44,14 @@ Report::~Report() delete [] buffer_; } +void +Report::printLine(const char *line, + size_t length) +{ + printString(line, length); + printString("\n", 1); +} + size_t Report::printString(const char *buffer, size_t length) @@ -69,23 +77,20 @@ Report::reportLine(const char *fmt, ...) va_start(args, fmt); std::unique_lock lock(buffer_lock_); printToBuffer(fmt, args); - printString(buffer_, buffer_length_); - printString("\n", 1); + printBufferLine(); va_end(args); } void Report::reportLineString(const char *line) { - printString(line, strlen(line)); - printString("\n", 1); + printLine(line, strlen(line)); } void Report::reportLine(const string &line) { - printString(line.c_str(), line.length()); - printString("\n", 1); + printLine(line.c_str(), line.length()); } //////////////////////////////////////////////////////////////// @@ -137,9 +142,9 @@ Report::printToBufferAppend(const char *fmt, } void -Report::printBuffer() +Report::printBufferLine() { - printString(buffer_, buffer_length_); + printLine(buffer_, buffer_length_); } //////////////////////////////////////////////////////////////// @@ -153,8 +158,7 @@ Report::warn(int /* id */, va_start(args, fmt); printToBuffer("Warning: "); printToBufferAppend(fmt, args); - printToBufferAppend("\n"); - printBuffer(); + printBufferLine(); va_end(args); } @@ -165,8 +169,7 @@ Report::vwarn(int /* id */, { printToBuffer("Warning: "); printToBufferAppend(fmt, args); - printToBufferAppend("\n"); - printBuffer(); + printBufferLine(); } void @@ -180,8 +183,7 @@ Report::fileWarn(int /* id */, va_start(args, fmt); printToBuffer("Warning: %s line %d, ", filename, line); printToBufferAppend(fmt, args); - printToBufferAppend("\n"); - printBuffer(); + printBufferLine(); va_end(args); } @@ -194,8 +196,7 @@ Report::vfileWarn(int /* id */, { printToBuffer("Warning: %s line %d, ", filename, line); printToBufferAppend(fmt, args); - printToBufferAppend("\n"); - printBuffer(); + printBufferLine(); } //////////////////////////////////////////////////////////////// @@ -262,8 +263,7 @@ Report::critical(int /* id */, va_start(args, fmt); printToBuffer("Critical: "); printToBufferAppend(fmt, args); - printToBufferAppend("\n"); - printBuffer(); + printBufferLine(); va_end(args); } @@ -278,7 +278,7 @@ Report::fileCritical(int /* id */, va_start(args, fmt); printToBuffer("Critical: %s line %d, ", filename, line, fmt, args); printToBufferAppend(fmt, args); - printToBufferAppend("\n"); + printBufferLine(); va_end(args); exit(1); }