From c504ca566124d1f097e7fe8a2f9f67c1c59e9ccf Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 14 Jan 2020 01:48:06 -0800 Subject: 5893 --- html/003trace.cc.html | 175 +++++++++++++++++++++++++------------------------- 1 file changed, 88 insertions(+), 87 deletions(-) (limited to 'html/003trace.cc.html') diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 2b5fba00..1aa53854 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -192,7 +192,7 @@ if ('onhashchange' in window) { 131 132 string unescape_newline(string& s) { 133 std::stringstream ss; -134 for (int i = 0; i < SIZE(s); ++i) { +134 for (int i = 0; i < SIZE(s); ++i) { 135 if (s.at(i) == '\n') 136 ss << "\\n"; 137 else @@ -202,7 +202,7 @@ if ('onhashchange' in window) { 141 } 142 143 void dump_trace_line(ostream& s, trace_line& t) { -144 s << std::setw(4) << t.depth << ' ' << t.label << ": " << unescape_newline(t.contents) << '\n'; +144 s << std::setw(2) << t.depth << ' ' << t.label << ": " << unescape_newline(t.contents) << '\n'; 145 } 146 147 //: Starting a new trace line. @@ -245,14 +245,14 @@ if ('onhashchange' in window) { 184 if (!curr_stream) return; 185 string curr_contents = curr_stream->str(); 186 if (!curr_contents.empty()) { -187 past_lines.push_back(trace_line(curr_contents, trim(curr_label), curr_depth)); // preserve indent in contents +187 past_lines.push_back(trace_line(curr_contents, trim(curr_label), curr_depth)); // preserve indent in contents 188 // maybe incrementally dump trace 189 trace_line& t = past_lines.back(); 190 if (should_incrementally_print_trace()) { 191 dump_trace_line(cerr, t); 192 } -193 // Hack: on 'subx --trace --dump', emit only to stderr, not 'last_run'. -194 if (Dump_trace) past_lines.pop_back(); // economize on memory +193 // Hack: on 'bootstrap --trace --dump', emit only to stderr, not 'last_run'. +194 if (Dump_trace) past_lines.pop_back(); // economize on memory 195 // End trace Commit 196 } 197 @@ -381,24 +381,24 @@ if ('onhashchange' in window) { 320 if (!Trace_stream) return false; 321 vector<string> expected_lines = split(expected, "\n"); 322 int curr_expected_line = 0; -323 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) +323 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) 324 ++curr_expected_line; -325 if (curr_expected_line == SIZE(expected_lines)) return true; +325 if (curr_expected_line == SIZE(expected_lines)) return true; 326 string label, contents; 327 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); 328 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 329 if (label != p->label) continue; -330 string t = trim(p->contents); +330 string t = trim(p->contents); 331 if (contents != unescape_newline(t)) continue; 332 ++curr_expected_line; -333 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) +333 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) 334 ++curr_expected_line; -335 if (curr_expected_line == SIZE(expected_lines)) return true; +335 if (curr_expected_line == SIZE(expected_lines)) return true; 336 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); 337 } 338 339 if (line_exists_anywhere(label, contents)) { -340 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; +340 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; 341 DUMP(""); 342 } 343 else { @@ -411,7 +411,7 @@ if ('onhashchange' in window) { 350 351 bool trace_doesnt_contain(string expected) { 352 vector<string> tmp = split_first(expected, ": "); -353 if (SIZE(tmp) == 1) { +353 if (SIZE(tmp) == 1) { 354 raise << expected << ": missing label or contents in trace line\n" << end(); 355 assert(false); 356 } @@ -422,12 +422,12 @@ if ('onhashchange' in window) { 361 return trace_count(label, ""); 362 } 363 -364 int trace_count(string label, string line) { +364 int trace_count(string label, string line) { 365 if (!Trace_stream) return 0; 366 long result = 0; 367 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 368 if (label == p->label) { -369 if (line == "" || trim(line) == trim(p->contents)) +369 if (line == "" || trim(line) == trim(p->contents)) 370 ++result; 371 } 372 } @@ -439,7 +439,7 @@ if ('onhashchange' in window) { 378 long result = 0; 379 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 380 if (label == p->label) { -381 if (starts_with(trim(p->contents), trim(prefix))) +381 if (starts_with(trim(p->contents), trim(prefix))) 382 ++result; 383 } 384 } @@ -451,18 +451,18 @@ if ('onhashchange' in window) { 390 size_t pos = s.find(delim); 391 if (pos == string::npos) { 392 *label = ""; -393 *contents = trim(s); +393 *contents = trim(s); 394 } 395 else { -396 *label = trim(s.substr(0, pos)); -397 *contents = trim(s.substr(pos+SIZE(delim))); +396 *label = trim(s.substr(0, pos)); +397 *contents = trim(s.substr(pos+SIZE(delim))); 398 } 399 } 400 401 bool line_exists_anywhere(const string& label, const string& contents) { 402 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 403 if (label != p->label) continue; -404 if (contents == trim(p->contents)) return true; +404 if (contents == trim(p->contents)) return true; 405 } 406 return false; 407 } @@ -508,79 +508,80 @@ if ('onhashchange' in window) { 447 :(before "End Globals") 448 ofstream Trace_file; 449 :(before "End Commandline Options(*arg)") -450 else if (is_equal(*arg, "--trace")) { +450 else if (is_equal(*arg, "--trace")) { 451 cerr << "saving trace to 'last_run'\n"; 452 Trace_file.open("last_run"); 453 // Add a dummy line up top; otherwise the `browse_trace` tool currently has 454 // no way to expand any lines above an error. 455 Trace_file << " 0 dummy: start\n"; -456 } -457 :(before "End trace Commit") -458 if (Trace_file) { -459 dump_trace_line(Trace_file, t); -460 } -461 :(before "End One-time Setup") -462 atexit(cleanup_main); -463 :(code) -464 void cleanup_main() { -465 if (Trace_file) Trace_file.close(); -466 // End cleanup_main -467 } -468 -469 :(before "End trace_stream Methods") -470 string readable_contents(string label) { -471 string trim(const string& s); // prototype -472 ostringstream output; -473 label = trim(label); -474 for (vector<trace_line>::iterator p = past_lines.begin(); p != past_lines.end(); ++p) -475 if (label.empty() || label == p->label) -476 dump_trace_line(output, *p); -477 return output.str(); -478 } -479 -480 //: Print traces to the screen as they happen. -481 //: Particularly useful when juggling multiple trace streams, like when -482 //: debugging sandboxes. -483 :(before "End Globals") -484 bool Dump_trace = false; -485 :(before "End Commandline Options(*arg)") -486 else if (is_equal(*arg, "--dump")) { -487 Dump_trace = true; -488 } -489 :(before "End Incremental Trace Print Conditions") -490 if (Dump_trace) return true; -491 -492 //: Miscellaneous helpers. -493 -494 :(code) -495 string trim(const string& s) { -496 string::const_iterator first = s.begin(); -497 while (first != s.end() && isspace(*first)) -498 ++first; -499 if (first == s.end()) return ""; -500 -501 string::const_iterator last = --s.end(); -502 while (last != s.begin() && isspace(*last)) -503 --last; -504 ++last; -505 return string(first, last); -506 } -507 -508 :(before "End Includes") -509 #include <vector> -510 using std::vector; -511 #include <list> -512 using std::list; -513 #include <set> -514 using std::set; -515 -516 #include <sstream> -517 using std::istringstream; -518 using std::ostringstream; -519 -520 #include <fstream> -521 using std::ifstream; -522 using std::ofstream; +456 // End --trace Settings +457 } +458 :(before "End trace Commit") +459 if (Trace_file) { +460 dump_trace_line(Trace_file, t); +461 } +462 :(before "End One-time Setup") +463 atexit(cleanup_main); +464 :(code) +465 void cleanup_main() { +466 if (Trace_file) Trace_file.close(); +467 // End cleanup_main +468 } +469 +470 :(before "End trace_stream Methods") +471 string readable_contents(string label) { +472 string trim(const string& s); // prototype +473 ostringstream output; +474 label = trim(label); +475 for (vector<trace_line>::iterator p = past_lines.begin(); p != past_lines.end(); ++p) +476 if (label.empty() || label == p->label) +477 dump_trace_line(output, *p); +478 return output.str(); +479 } +480 +481 //: Print traces to the screen as they happen. +482 //: Particularly useful when juggling multiple trace streams, like when +483 //: debugging sandboxes. +484 :(before "End Globals") +485 bool Dump_trace = false; +486 :(before "End Commandline Options(*arg)") +487 else if (is_equal(*arg, "--dump")) { +488 Dump_trace = true; +489 } +490 :(before "End Incremental Trace Print Conditions") +491 if (Dump_trace) return true; +492 +493 //: Miscellaneous helpers. +494 +495 :(code) +496 string trim(const string& s) { +497 string::const_iterator first = s.begin(); +498 while (first != s.end() && isspace(*first)) +499 ++first; +500 if (first == s.end()) return ""; +501 +502 string::const_iterator last = --s.end(); +503 while (last != s.begin() && isspace(*last)) +504 --last; +505 ++last; +506 return string(first, last); +507 } +508 +509 :(before "End Includes") +510 #include <vector> +511 using std::vector; +512 #include <list> +513 using std::list; +514 #include <set> +515 using std::set; +516 +517 #include <sstream> +518 using std::istringstream; +519 using std::ostringstream; +520 +521 #include <fstream> +522 using std::ifstream; +523 using std::ofstream; -- cgit 1.4.1-2-gfad0