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

Unified Diff: runtime/vm/exceptions.cc

Issue 328663008: Add support to trace warnings in TraceBuffer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/exceptions.h ('k') | runtime/vm/exceptions_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
===================================================================
--- runtime/vm/exceptions.cc (revision 37297)
+++ runtime/vm/exceptions.cc (working copy)
@@ -750,16 +750,18 @@
ASSERT(caller_frame != NULL);
ASSERT(FLAG_warn_on_javascript_compatibility);
if (FLAG_silent_warnings) return;
- const Code& caller_code = Code::Handle(caller_frame->LookupDartCode());
+ Isolate* isolate = Isolate::Current();
+ const Code& caller_code = Code::Handle(isolate,
+ caller_frame->LookupDartCode());
ASSERT(!caller_code.IsNull());
const uword caller_pc = caller_frame->pc();
const intptr_t token_pos = caller_code.GetTokenIndexOfPC(caller_pc);
- const Function& caller = Function::Handle(caller_code.function());
- const Script& script = Script::Handle(caller.script());
+ const Function& caller = Function::Handle(isolate, caller_code.function());
+ const Script& script = Script::Handle(isolate, caller.script());
va_list args;
va_start(args, format);
- const Error& error = Error::Handle(
- LanguageError::NewFormattedV(Error::Handle(), // No previous error.
+ const Error& error = Error::Handle(isolate,
+ LanguageError::NewFormattedV(Error::Handle(isolate), // No prev error.
script, token_pos, LanguageError::kWarning,
Heap::kNew, format, args));
va_end(args);
@@ -767,13 +769,54 @@
ThrowJavascriptCompatibilityError(error.ToErrorCString());
} else {
OS::Print("javascript compatibility warning: %s", error.ToErrorCString());
+ va_start(args, format);
+ TraceJSWarningV(script, token_pos, format, args);
+ va_end(args);
}
const Stacktrace& stacktrace =
- Stacktrace::Handle(Exceptions::CurrentStacktrace());
+ Stacktrace::Handle(isolate, Exceptions::CurrentStacktrace());
intptr_t idx = 0;
OS::Print("%s",
stacktrace.ToCStringInternal(&idx,
FLAG_stacktrace_depth_on_warning));
}
+
+void Exceptions::TraceJSWarningF(const Script& script, intptr_t token_pos,
+ const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ TraceJSWarningV(script, token_pos, format, args);
+ va_end(args);
+}
+
+
+void Exceptions::TraceJSWarningV(const Script& script, intptr_t token_pos,
+ const char* format, va_list args) {
+ const int64_t micros = OS::GetCurrentTimeMicros();
+ Isolate* isolate = Isolate::Current();
+ TraceBuffer* trace_buffer = isolate->trace_buffer();
+ if (trace_buffer == NULL) {
+ TraceBuffer::Init(isolate);
+ trace_buffer = isolate->trace_buffer();
+ }
+ JSONStream js;
+ {
+ JSONObject trace_warning(&js);
+ trace_warning.AddProperty("type", "JSCompatibilityWarning");
+ trace_warning.AddProperty("script", script);
+ trace_warning.AddProperty("tokenPos", token_pos);
+ va_list args_copy;
+ va_copy(args_copy, args);
+ const intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy);
+ va_end(args_copy);
+ char* msg = reinterpret_cast<char*>(malloc(len + 1));
+ va_copy(args_copy, args);
+ OS::VSNPrint(msg, len + 1, format, args_copy);
+ va_end(args_copy);
+ trace_warning.AddProperty("message", msg);
+ }
+ trace_buffer->Trace(micros, js.ToCString(), true); // Already escaped.
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/exceptions.h ('k') | runtime/vm/exceptions_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698