Commit a0c7ab63 authored by jgruber's avatar jgruber Committed by Commit bot

Remove detailed from simple stack trace functionality

This is another point where we add inconsistent behavior between simple and
detailed stack traces. The functionality also does not seem to be used in
chrome anymore when uncaught exceptions are thrown.  Remove it to reduce
maintenance burden.

BUG=624285
R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2141523002
Cr-Commit-Position: refs/heads/master@{#37673}
parent b93cde37
......@@ -553,18 +553,7 @@ Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) {
Handle<Object> stack_trace =
JSReceiver::GetDataProperty(error_object, key_detailed);
if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace);
if (!capture_stack_trace_for_uncaught_exceptions_) return Handle<JSArray>();
// Try to get details from simple stack trace.
Handle<JSArray> detailed_stack_trace =
GetDetailedFromSimpleStackTrace(error_object);
if (!detailed_stack_trace.is_null()) {
// Save the detailed stack since the simple one might be withdrawn later.
JSObject::SetProperty(error_object, key_detailed, detailed_stack_trace,
STRICT).Assert();
}
return detailed_stack_trace;
return Handle<JSArray>();
}
......@@ -747,46 +736,6 @@ int PositionFromStackTrace(Handle<FixedArray> elements, int index) {
}
}
Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace(
Handle<JSObject> error_object) {
Handle<Name> key = factory()->stack_trace_symbol();
Handle<Object> property = JSReceiver::GetDataProperty(error_object, key);
if (!property->IsJSArray()) return Handle<JSArray>();
Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
CaptureStackTraceHelper helper(this,
stack_trace_for_uncaught_exceptions_options_);
int frames_seen = 0;
Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements()));
int elements_limit = Smi::cast(simple_stack_trace->length())->value();
int frame_limit = stack_trace_for_uncaught_exceptions_frame_limit_;
if (frame_limit < 0) frame_limit = (elements_limit - 1) / 4;
Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit);
for (int i = 1; i < elements_limit && frames_seen < frame_limit; i += 4) {
Handle<Object> recv = handle(elements->get(i), this);
Handle<JSFunction> fun =
handle(JSFunction::cast(elements->get(i + 1)), this);
bool is_constructor =
recv->IsJSObject() &&
Handle<JSObject>::cast(recv)->map()->GetConstructor() == *fun;
int position = PositionFromStackTrace(elements, i);
Handle<JSObject> stack_frame =
helper.NewStackFrameObject(fun, position, is_constructor);
FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame);
frames_seen++;
}
stack_trace->set_length(Smi::FromInt(frames_seen));
return stack_trace;
}
Handle<JSArray> Isolate::CaptureCurrentStackTrace(
int frame_limit, StackTrace::StackTraceOptions options) {
CaptureStackTraceHelper helper(this, options);
......
......@@ -17001,40 +17001,6 @@ TEST(CaptureStackTraceForUncaughtException) {
CHECK_EQ(1, report_count);
}
TEST(GetStackTraceForUncaughtExceptionFromSimpleStackTrace) {
report_count = 0;
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
// Create an Error object first.
CompileRunWithOrigin(
"function foo() {\n"
"e=new Error('err');\n"
"};\n"
"function bar() {\n"
" foo();\n"
"};\n"
"var e;",
"origin");
v8::Local<v8::Object> global = env->Global();
Local<Value> trouble =
global->Get(env.local(), v8_str("bar")).ToLocalChecked();
CHECK(trouble->IsFunction());
Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).ToLocalChecked();
// Enable capturing detailed stack trace late, and throw the exception.
// The detailed stack trace should be extracted from the simple stack.
isolate->AddMessageListener(StackTraceForUncaughtExceptionListener);
isolate->SetCaptureStackTraceForUncaughtExceptions(true);
CompileRunWithOrigin("throw e", "origin");
isolate->SetCaptureStackTraceForUncaughtExceptions(false);
isolate->RemoveMessageListeners(StackTraceForUncaughtExceptionListener);
CHECK_EQ(1, report_count);
}
TEST(CaptureStackTraceForUncaughtExceptionAndSetters) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment