Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Unified Diff: runtime/vm/il_printer.cc

Issue 905363002: Add --print-flow-graph-filter to allow filtering debugging output. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/il_printer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/il_printer.cc
diff --git a/runtime/vm/il_printer.cc b/runtime/vm/il_printer.cc
index c81ac93ec1280d8a67eaba9f26d150cd7e2065d3..6889e3cb496dc88da977fde8bdba5d7d9d73c2c6 100644
--- a/runtime/vm/il_printer.cc
+++ b/runtime/vm/il_printer.cc
@@ -12,7 +12,8 @@
namespace dart {
DEFINE_FLAG(bool, print_environments, false, "Print SSA environments.");
-
+DEFINE_FLAG(charp, print_flow_graph_filter, NULL,
+ "Print only IR of functions with matching names");
void BufferFormatter::Print(const char* format, ...) {
va_list args;
@@ -33,6 +34,52 @@ void BufferFormatter::VPrint(const char* format, va_list args) {
}
+// Checks whether function's name matches the given filter, which is
+// a comma-separated list of strings.
+bool FlowGraphPrinter::PassesFilter(const char* filter,
+ const Function& function) {
+ if (filter == NULL) {
+ return true;
+ }
+
+ char* save_ptr; // Needed for strtok_r.
+ const char* function_name = function.ToFullyQualifiedCString();
+ intptr_t function_name_len = strlen(function_name);
+
+ intptr_t len = strlen(filter) + 1; // Length with \0.
+ char* filter_buffer = new char[len];
+ strncpy(filter_buffer, filter, len); // strtok modifies arg 1.
+ char* token = strtok_r(filter_buffer, ",", &save_ptr);
+ bool found = false;
+ while (token != NULL) {
+ if (strstr(function_name, token) != NULL) {
+ found = true;
+ break;
+ }
+ const intptr_t token_len = strlen(token);
+ if (token[token_len - 1] == '%') {
+ if (function_name_len > token_len) {
+ const char* suffix = function_name +
+ (function_name_len - token_len + 1);
+ if (strncmp(suffix, token, token_len - 1) == 0) {
+ found = true;
+ break;
+ }
+ }
+ }
+ token = strtok_r(NULL, ",", &save_ptr);
+ }
+ delete[] filter_buffer;
+
+ return found;
+}
+
+
+bool FlowGraphPrinter::ShouldPrint(const Function& function) {
+ return PassesFilter(FLAG_print_flow_graph_filter, function);
+}
+
+
void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) {
OS::Print("*** BEGIN CFG\n%s\n", phase);
FlowGraphPrinter printer(*flow_graph);
« no previous file with comments | « runtime/vm/il_printer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698