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

Unified Diff: src/isolate.cc

Issue 2450253002: Improve exception printing for debug (Closed)
Patch Set: Address commends Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 8702ee758c4a5ef513007b1fb9838f7e5ba09240..9759ba084158676861c2f4f8d42021e1bf15c671 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1072,6 +1072,30 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
if (FLAG_print_all_exceptions) {
printf("=========================================================\n");
printf("Exception thrown:\n");
+ if (location) {
+ Handle<Script> script = location->script();
+ Handle<Object> name = Script::GetNameOrSourceURL(script);
+ printf("at ");
+ if (name->IsString() && String::cast(*name)->length() > 0)
+ String::cast(*name)->PrintOn(stdout);
+ else
+ printf("<anonymous>");
+// Script::GetLineNumber and Script::GetColumnNumber can allocate on the heap to
+// initialize the line_ends array, so be careful when calling them.
+#ifdef DEBUG
+ if (AllowHeapAllocation::IsAllowed()) {
+#else
+ if (false) {
+#endif
+ printf(", %d:%d - %d:%d\n",
+ Script::GetLineNumber(script, location->start_pos()) + 1,
+ Script::GetColumnNumber(script, location->start_pos()),
+ Script::GetLineNumber(script, location->end_pos()) + 1,
+ Script::GetColumnNumber(script, location->end_pos()));
+ } else {
+ printf(", line %d\n", script->GetLineNumber(location->start_pos()) + 1);
+ }
+ }
exception->Print();
printf("Stack Trace:\n");
PrintStack(stdout);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698