Skip to content

Compare: Stack Trace API

Showing with 1,200 additions and 87 deletions.
  1. +7 −0 API-stability.md
  2. 0 arm_debugging_with_the_simulator.md → ARM-Debugging.md
  3. +5 −1 Becoming-a-committer.md
  4. +11 −0 Blink-layout-tests.md
  5. +45 −0 Building-from-Source.md
  6. +76 −0 Building-with-GN.md
  7. +22 −15 Building-with-Gyp.md
  8. +4 −5 Checking-out-source.md
  9. +1 −0 Code-of-conduct.md
  10. +2 −4 v8_committers_responsibility.md → Committer's-responsibility.md
  11. +16 −16 Contributing.md
  12. +14 −1 D8-on-Android.md
  13. +86 −0 Design-Elements.md
  14. +339 −0 Embedder's-Guide.md
  15. +6 −0 Example-code.md
  16. +118 −0 Experiments-with-Strengthening-JavaScript.md
  17. +76 −0 Feature-Launch-Process.md
  18. 0 gdb_jit_interface.md → GDB-JIT-Interface.md
  19. +38 −0 Getting-Started-with-Embedding.md
  20. +3 −0 Handling-of-Ports.md
  21. +8 −1 Home.md
  22. +1 −0 Interpreter.md
  23. +13 −0 Introduction.md
  24. +25 −6 Merging-&-Patching.md
  25. 0 profiling_chromium_with_v8.md → Profiling-Chromium-with-v8.md
  26. +4 −0 Reporting-security-bugs.md
  27. +0 −2 runtime_functions.md → Runtime-functions.md
  28. +2 −2 Stack-Trace-API.md
  29. +26 −2 Testing.md
  30. +39 −0 Tracing-V8.md
  31. +13 −9 Triaging-issues.md
  32. +32 −0 TurboFan.md
  33. +1 −0 Using-D8.md
  34. +1 −8 using_git.md → Using-Git.md
  35. +61 −0 Using-V8’s-internal-profiler.md
  36. +64 −0 V8-Linux-perf-Integration.md
  37. +3 −1 v8_profiler.md → V8-Profiler.md
  38. +38 −8 _Sidebar.md
  39. 0 i18n_support.md → i18n-support.md
  40. BIN images/gcstats_traceviewer.png
  41. BIN images/intro_contexts.png
  42. BIN images/local_persist_handles_review.png
  43. BIN images/mandelbrot_chrome_speed.png
  44. BIN images/map_trans_a.png
  45. BIN images/map_trans_b.png
  46. BIN images/map_trans_c.png
  47. BIN images/runtimestats_traceviewer.png
  48. +0 −6 javascript.md
4 changes: 2 additions & 2 deletions Stack-Trace-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The stack trace mechanism used for built-in errors is implemented using a genera
Error.captureStackTrace(error, constructorOpt)
```

adds a stack property to the given `error` object that will yield the stack trace at the time captureStackTrace was called. The reason for not just returning the formatted stack trace directly is that this way we can postpone the formatting of the stack trace until the stack property is accessed and avoid formatting completely if it never is.
adds a stack property to the given `error` object that will yield the stack trace at the time captureStackTrace was called. Stack traces collected through `Error.captureStackTrace` are immediately collected, formatted, and attached to the given `error` object.

The optional `constructorOpt` parameter allows you to pass in a function value. When collecting the stack trace all frames above the topmost call to this function, including that call, will be left out of the stack trace. This can be useful to hide implementation details that won't be useful to the user. The usual way of defining a custom error that captures a stack trace would be:

Expand All @@ -65,7 +65,7 @@ For efficiency stack traces are not formatted when they are captured but on dema
Error.prepareStackTrace(error, structuredStackTrace)
```

and using whatever this call returns as the value of the `stack` property. If you assign a different function value to `Error.prepareStackTrace` that function will be used to format stack traces. It will be passed the error object that it is preparing a stack trace for and a structured representation of the stack. User stack trace formatters are free to format the stack trace however they want and even return non-string values. It is safe to retain references to the structured stack trace object after a call to prepareStackTrace completes so that it is also a valid return value. Note that the custom prepareStackTrace function is immediately called at the point when the error object is created (e.g. with `new Error()`).
and using whatever this call returns as the value of the `stack` property. If you assign a different function value to `Error.prepareStackTrace` that function will be used to format stack traces. It will be passed the error object that it is preparing a stack trace for and a structured representation of the stack. User stack trace formatters are free to format the stack trace however they want and even return non-string values. It is safe to retain references to the structured stack trace object after a call to prepareStackTrace completes so that it is also a valid return value. Note that the custom prepareStackTrace function is only called once the stack property of `Error` object is accessed.

The structured stack trace is an Array of CallSite objects, each of which represents a stack frame. A CallSite object defines the following methods

Expand Down