Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Do not include Error.captureStackTrace in the trace
Browse files Browse the repository at this point in the history
BUG=v8:5342

Review-Url: https://codereview.chromium.org/2307783002
Cr-Commit-Position: refs/heads/master@{#39124}
  • Loading branch information
schuay authored and Commit bot committed Sep 2, 2016
1 parent 3d617c1 commit 64c518d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/builtins/builtins-error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ BUILTIN(ErrorCaptureStackTrace) {
}
Handle<JSObject> object = Handle<JSObject>::cast(object_obj);
Handle<Object> caller = args.atOrUndefined(isolate, 2);
FrameSkipMode mode = caller->IsJSFunction() ? SKIP_UNTIL_SEEN : SKIP_NONE;
FrameSkipMode mode = caller->IsJSFunction() ? SKIP_UNTIL_SEEN : SKIP_FIRST;

// Collect the stack trace.

Expand Down
9 changes: 0 additions & 9 deletions src/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,8 @@ class StackTraceHelper {
mode_(mode),
caller_(caller),
skip_next_frame_(true) {
// The caller parameter can be used to skip a specific set of frames in the
// stack trace. It can be:
// * null, when called from a standard error constructor. We unconditionally
// skip the top frame, which is always a builtin-exit frame for the error
// constructor builtin.
// * a JSFunction, when called by the user from Error.captureStackTrace().
// We skip each frame until encountering the caller function.
// * For any other value, all frames are included in the trace.
switch (mode_) {
case SKIP_FIRST:
DCHECK(caller_.is_null());
skip_next_frame_ = true;
break;
case SKIP_UNTIL_SEEN:
Expand Down
7 changes: 7 additions & 0 deletions test/mjsunit/regress/regress-5342.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var o = {}
Error.captureStackTrace(o);
assertEquals(-1, o.stack.indexOf("captureStackTrace"));

0 comments on commit 64c518d

Please sign in to comment.