From 37d53a70958bfe5b1d7946229af9c12f0b865abc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 23 Sep 2018 22:38:16 -0700 Subject: 4512 --- html/subx/003trace.cc.html | 66 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'html/subx/003trace.cc.html') diff --git a/html/subx/003trace.cc.html b/html/subx/003trace.cc.html index 6abc7086..9e3c7c6c 100644 --- a/html/subx/003trace.cc.html +++ b/html/subx/003trace.cc.html @@ -129,10 +129,10 @@ if ('onhashchange' in window) { 70 :(before "End Types") 71 struct trace_line { 72 int depth; // optional field just to help browse traces later - 73 string label; + 73 string label; 74 string contents; - 75 trace_line(string l, string c) :depth(0), label(l), contents(c) {} - 76 trace_line(int d, string l, string c) :depth(d), label(l), contents(c) {} + 75 trace_line(string l, string c) :depth(0), label(l), contents(c) {} + 76 trace_line(int d, string l, string c) :depth(d), label(l), contents(c) {} 77 }; 78 79 //: Support for tracing an entire run. @@ -176,14 +176,14 @@ if ('onhashchange' in window) { 117 trace_stream() :curr_stream(NULL), curr_depth(Max_depth), collect_depth(Max_depth) {} 118 ~trace_stream() { if (curr_stream) delete curr_stream; } 119 -120 ostream& stream(string label) { -121 return stream(Max_depth, label); +120 ostream& stream(string label) { +121 return stream(Max_depth, label); 122 } 123 -124 ostream& stream(int depth, string label) { +124 ostream& stream(int depth, string label) { 125 if (depth > collect_depth) return null_stream; 126 curr_stream = new ostringstream; -127 curr_label = label; +127 curr_label = label; 128 curr_depth = depth; 129 (*curr_stream) << std::hex; 130 return *curr_stream; @@ -199,7 +199,7 @@ if ('onhashchange' in window) { 140 // be sure to call this before messing with curr_stream or curr_label 141 void newline(); 142 // useful for debugging -143 string readable_contents(string label); // empty label = show everything +143 string readable_contents(string label); // empty label = show everything 144 }; 145 146 :(code) @@ -220,12 +220,12 @@ if ('onhashchange' in window) { 161 curr_depth = Max_depth; 162 } 163 -164 string trace_stream::readable_contents(string label) { +164 string trace_stream::readable_contents(string label) { 165 ostringstream output; -166 label = trim(label); +166 label = trim(label); 167 for (vector<trace_line>::iterator p = past_lines.begin(); p != past_lines.end(); ++p) -168 if (label.empty() || label == p->label) { -169 output << std::setw(4) << p->depth << ' ' << p->label << ": " << p->contents << '\n'; +168 if (label.empty() || label == p->label) { +169 output << std::setw(4) << p->depth << ' ' << p->label << ": " << p->contents << '\n'; 170 } 171 return output.str(); 172 } @@ -318,10 +318,10 @@ if ('onhashchange' in window) { 259 } 260 261 #define CHECK_TRACE_COUNT(label, count) \ -262 if (Passed && trace_count(label) != (count)) { \ -263 cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \ -264 cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \ -265 DUMP(label); \ +262 if (Passed && trace_count(label) != (count)) { \ +263 cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \ +264 cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \ +265 DUMP(label); \ 266 Passed = false; \ 267 return; /* Currently we stop at the very first failure. */ \ 268 } @@ -337,10 +337,10 @@ if ('onhashchange' in window) { 278 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) 279 ++curr_expected_line; 280 if (curr_expected_line == SIZE(expected_lines)) return true; -281 string label, contents; +281 string label, contents; 282 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); 283 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -284 if (label != p->label) continue; +284 if (label != p->label) continue; 285 if (contents != trim(p->contents)) continue; 286 ++curr_expected_line; 287 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) @@ -349,19 +349,19 @@ if ('onhashchange' in window) { 290 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); 291 } 292 -293 if (line_exists_anywhere(label, contents)) { -294 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; +293 if (line_exists_anywhere(label, contents)) { +294 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; 295 DUMP(""); 296 } 297 else { 298 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n"; -299 DUMP(label); +299 DUMP(label); 300 } 301 Passed = false; 302 return false; 303 } 304 -305 void split_label_contents(const string& s, string* label, string* contents) { +305 void split_label_contents(const string& s, string* label, string* contents) { 306 static const string delim(": "); 307 size_t pos = s.find(delim); 308 if (pos == string::npos) { @@ -374,23 +374,23 @@ if ('onhashchange' in window) { 315 } 316 } 317 -318 bool line_exists_anywhere(const string& label, const string& contents) { +318 bool line_exists_anywhere(const string& label, const string& contents) { 319 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -320 if (label != p->label) continue; +320 if (label != p->label) continue; 321 if (contents == trim(p->contents)) return true; 322 } 323 return false; 324 } 325 -326 int trace_count(string label) { -327 return trace_count(label, ""); +326 int trace_count(string label) { +327 return trace_count(label, ""); 328 } 329 -330 int trace_count(string label, string line) { +330 int trace_count(string label, string line) { 331 if (!Trace_stream) return 0; 332 long result = 0; 333 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -334 if (label == p->label) { +334 if (label == p->label) { 335 if (line == "" || trim(line) == trim(p->contents)) 336 ++result; 337 } @@ -398,11 +398,11 @@ if ('onhashchange' in window) { 339 return result; 340 } 341 -342 int trace_count_prefix(string label, string prefix) { +342 int trace_count_prefix(string label, string prefix) { 343 if (!Trace_stream) return 0; 344 long result = 0; 345 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -346 if (label == p->label) { +346 if (label == p->label) { 347 if (starts_with(trim(p->contents), trim(prefix))) 348 ++result; 349 } @@ -410,14 +410,14 @@ if ('onhashchange' in window) { 351 return result; 352 } 353 -354 bool trace_doesnt_contain(string label, string line) { -355 return trace_count(label, line) == 0; +354 bool trace_doesnt_contain(string label, string line) { +355 return trace_count(label, line) == 0; 356 } 357 358 bool trace_doesnt_contain(string expected) { 359 vector<string> tmp = split_first(expected, ": "); 360 if (SIZE(tmp) == 1) { -361 raise << expected << ": missing label or contents in trace line\n" << end(); +361 raise << expected << ": missing label or contents in trace line\n" << end(); 362 assert(false); 363 } 364 return trace_doesnt_contain(tmp.at(0), tmp.at(1)); -- cgit 1.4.1-2-gfad0