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

Side by Side Diff: src/messages.cc

Issue 2961003: Allow to capture stack trace for uncaught exceptions (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright 2006-2008 the V8 project authors. All rights reserved. 2 // Copyright 2006-2008 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 void MessageHandler::ReportMessage(const char* msg) { 60 void MessageHandler::ReportMessage(const char* msg) {
61 PrintF("%s\n", msg); 61 PrintF("%s\n", msg);
62 } 62 }
63 63
64 64
65 Handle<Object> MessageHandler::MakeMessageObject( 65 Handle<Object> MessageHandler::MakeMessageObject(
66 const char* type, 66 const char* type,
67 MessageLocation* loc, 67 MessageLocation* loc,
68 Vector< Handle<Object> > args, 68 Vector< Handle<Object> > args,
69 Handle<String> stack_trace) { 69 Handle<String> stack_trace,
70 Handle<JSArray> stack_frames) {
70 // Build error message object 71 // Build error message object
71 v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom. 72 v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom.
72 Handle<Object> type_str = Factory::LookupAsciiSymbol(type); 73 Handle<Object> type_str = Factory::LookupAsciiSymbol(type);
73 Handle<Object> array = Factory::NewJSArray(args.length()); 74 Handle<Object> array = Factory::NewJSArray(args.length());
74 for (int i = 0; i < args.length(); i++) 75 for (int i = 0; i < args.length(); i++)
75 SetElement(Handle<JSArray>::cast(array), i, args[i]); 76 SetElement(Handle<JSArray>::cast(array), i, args[i]);
76 77
77 Handle<JSFunction> fun(Top::global_context()->make_message_fun()); 78 Handle<JSFunction> fun(Top::global_context()->make_message_fun());
78 int start, end; 79 int start, end;
79 Handle<Object> script; 80 Handle<Object> script;
80 if (loc) { 81 if (loc) {
81 start = loc->start_pos(); 82 start = loc->start_pos();
82 end = loc->end_pos(); 83 end = loc->end_pos();
83 script = GetScriptWrapper(loc->script()); 84 script = GetScriptWrapper(loc->script());
84 } else { 85 } else {
85 start = end = 0; 86 start = end = 0;
86 script = Factory::undefined_value(); 87 script = Factory::undefined_value();
87 } 88 }
88 Handle<Object> start_handle(Smi::FromInt(start)); 89 Handle<Object> start_handle(Smi::FromInt(start));
89 Handle<Object> end_handle(Smi::FromInt(end)); 90 Handle<Object> end_handle(Smi::FromInt(end));
90 Handle<Object> stack_trace_val = stack_trace.is_null() 91 Handle<Object> stack_trace_val = stack_trace.is_null()
91 ? Factory::undefined_value() 92 ? Factory::undefined_value()
92 : Handle<Object>::cast(stack_trace); 93 : Handle<Object>::cast(stack_trace);
93 const int argc = 6; 94 Handle<Object> stack_frames_val = stack_frames.is_null()
95 ? Factory::undefined_value()
96 : Handle<Object>::cast(stack_frames);
97 const int argc = 7;
94 Object** argv[argc] = { type_str.location(), 98 Object** argv[argc] = { type_str.location(),
95 array.location(), 99 array.location(),
96 start_handle.location(), 100 start_handle.location(),
97 end_handle.location(), 101 end_handle.location(),
98 script.location(), 102 script.location(),
99 stack_trace_val.location() }; 103 stack_trace_val.location(),
104 stack_frames_val.location() };
100 105
101 // Setup a catch handler to catch exceptions in creating the message. This 106 // Setup a catch handler to catch exceptions in creating the message. This
102 // handler is non-verbose to avoid calling MakeMessage recursively in case of 107 // handler is non-verbose to avoid calling MakeMessage recursively in case of
103 // an exception. 108 // an exception.
104 v8::TryCatch catcher; 109 v8::TryCatch catcher;
105 catcher.SetVerbose(false); 110 catcher.SetVerbose(false);
106 catcher.SetCaptureMessage(false); 111 catcher.SetCaptureMessage(false);
107 112
108 // Format the message. 113 // Format the message.
109 bool caught_exception = false; 114 bool caught_exception = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 174 }
170 175
171 176
172 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 177 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
173 HandleScope scope; 178 HandleScope scope;
174 return GetMessage(data)->ToCString(DISALLOW_NULLS); 179 return GetMessage(data)->ToCString(DISALLOW_NULLS);
175 } 180 }
176 181
177 182
178 } } // namespace v8::internal 183 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698