Skip to content

Commit d08d4d8

Browse files
committed
Dump functions on circular dependency parser error
Help with: #25545 [email protected] Review URL: https://codereview.chromium.org/1751523003 .
1 parent 55630a5 commit d08d4d8

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

runtime/observatory/tests/service/developer_extension_test.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,4 @@ var tests = [
152152
},
153153
];
154154

155-
main(args) async => runIsolateTests(args, tests, testeeConcurrent:test,
156-
trace_compiler: true);
155+
main(args) async => runIsolateTests(args, tests, testeeConcurrent:test);

runtime/vm/parser.cc

+27-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ DEFINE_FLAG(bool, await_is_keyword, false,
5151
"await and yield are treated as proper keywords in synchronous code.");
5252

5353
DECLARE_FLAG(bool, profile_vm);
54+
DECLARE_FLAG(bool, trace_service);
5455

5556
// Quick access to the current thread, isolate and zone.
5657
#define T (thread())
@@ -2956,6 +2957,22 @@ SequenceNode* Parser::MakeImplicitConstructor(const Function& func) {
29562957
}
29572958

29582959

2960+
// Returns a zone allocated string.
2961+
static char* DumpPendingFunctions(
2962+
Zone* zone,
2963+
const GrowableObjectArray& pending_functions) {
2964+
ASSERT(zone != NULL);
2965+
char* result = OS::SCreate(zone, "Pending Functions:\n");
2966+
for (intptr_t i = 0; i < pending_functions.Length(); i++) {
2967+
const Function& func =
2968+
Function::Handle(zone, Function::RawCast(pending_functions.At(i)));
2969+
const String& fname = String::Handle(zone, func.UserVisibleName());
2970+
result = OS::SCreate(zone, "%s%" Pd ": %s\n", result, i, fname.ToCString());
2971+
}
2972+
return result;
2973+
}
2974+
2975+
29592976
void Parser::CheckRecursiveInvocation() {
29602977
const GrowableObjectArray& pending_functions =
29612978
GrowableObjectArray::Handle(Z, T->pending_functions());
@@ -2964,7 +2981,16 @@ void Parser::CheckRecursiveInvocation() {
29642981
if (pending_functions.At(i) == current_function().raw()) {
29652982
const String& fname =
29662983
String::Handle(Z, current_function().UserVisibleName());
2967-
ReportError("circular dependency for function %s", fname.ToCString());
2984+
if (FLAG_trace_service) {
2985+
const char* pending_function_dump =
2986+
DumpPendingFunctions(Z, pending_functions);
2987+
ASSERT(pending_function_dump != NULL);
2988+
ReportError("circular dependency for function %s\n%s",
2989+
fname.ToCString(),
2990+
pending_function_dump);
2991+
} else {
2992+
ReportError("circular dependency for function %s", fname.ToCString());
2993+
}
29682994
}
29692995
}
29702996
ASSERT(!unregister_pending_function_);

0 commit comments

Comments
 (0)