Index: sdk/lib/_internal/compiler/implementation/helpers/trace.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/helpers/trace.dart b/sdk/lib/_internal/compiler/implementation/helpers/trace.dart |
index 42c122acbec772dccad77b19f59a8f9a505508a0..b592972b36a923ba6f8464de0114d271dd16ddcc 100644 |
--- a/sdk/lib/_internal/compiler/implementation/helpers/trace.dart |
+++ b/sdk/lib/_internal/compiler/implementation/helpers/trace.dart |
@@ -13,8 +13,16 @@ part of dart2js.helpers; |
* returns [:true:] on the stack trace text. This can be used to filter the |
* printed stack traces based on their content. For instance only print stack |
* traces that contain specific paths. |
+ * |
karlklose
2014/06/02 09:39:38
I prefer changes to the helpers in separate CLs.
|
+ * If [limit] is provided, the stack trace is limited to [limit] entries. |
+ * |
+ * If [throwOnPrint] is `true`, [message] will be thrown after the stack trace |
+ * has been printed. Together with [condition] this can be used to discover |
+ * unknown call-sites in tests by filtering known call-sites and throwning |
+ * otherwise. |
*/ |
-void trace(String message, {bool condition(String stackTrace), int limit}) { |
+void trace(String message, {bool condition(String stackTrace), int limit, |
+ bool throwOnPrint: false}) { |
try { |
throw ''; |
} catch (e, s) { |
@@ -24,13 +32,16 @@ void trace(String message, {bool condition(String stackTrace), int limit}) { |
if (!condition(stackTrace)) return; |
} |
print('$message\n$stackTrace'); |
+ if (throwOnPrint) throw message; |
} |
} |
void traceAndReport(Compiler compiler, Spannable node, String message, |
- {bool condition(String stackTrace), int limit}) { |
+ {bool condition(String stackTrace), int limit, |
+ bool throwOnPrint: false}) { |
- trace(message, condition: (String stackTrace) { |
+ trace(message, limit: limit, throwOnPrint: throwOnPrint, |
+ condition: (String stackTrace) { |
bool result = condition != null ? condition(stackTrace) : true; |
if (result) { |
reportHere(compiler, node, message); |