Changeset 213718 in webkit


Ignore:
Timestamp:
Mar 10, 2017 11:01:57 AM (7 years ago)
Author:
mark.lam@apple.com
Message:

[Re-landing] Implement a StackTrace utility object that can capture stack traces for debugging.
https://bugs.webkit.org/show_bug.cgi?id=169454

Reviewed by Michael Saboff.

The underlying implementation is hoisted right out of Assertions.cpp from the
implementations of WTFPrintBacktrace().

The reason we need this StackTrace object is because during heap debugging, we
sometimes want to capture the stack trace that allocated the objects of interest.
Dumping the stack trace directly to stdout (using WTFReportBacktrace()) may
perturb the execution profile sufficiently that an issue may not reproduce,
while alternatively, just capturing the stack trace and deferring printing it
till we actually need it later perturbs the execution profile less.

In addition, just capturing the stack traces (instead of printing them
immediately at each capture site) allows us to avoid polluting stdout with tons
of stack traces that may be irrelevant.

For now, we only capture the native stack trace. We'll leave capturing and
integrating the JS stack trace as an exercise for the future if we need it then.

Here's an example of how to use this StackTrace utility:

Capture a stack trace of the top 10 frames.
std::unique_ptr<StackTrace> trace(StackTrace::captureStackTrace(10));
Print the trace.
dataLog(*trace);

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • tools/StackTrace.cpp: Added.

(JSC::StackTrace::instanceSize):
(JSC::StackTrace::captureStackTrace):
(JSC::StackTrace::dump):

  • tools/StackTrace.h: Added.

(JSC::StackTrace::size):
(JSC::StackTrace::StackTrace):

Location:
trunk/Source/JavaScriptCore
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r213714 r213718  
    925925    tools/JSDollarVMPrototype.cpp
    926926    tools/SigillCrashAnalyzer.cpp
     927    tools/StackTrace.cpp
    927928    tools/VMInspector.cpp
    928929
  • trunk/Source/JavaScriptCore/ChangeLog

    r213714 r213718  
     12017-03-10  Mark Lam  <mark.lam@apple.com>
     2
     3        [Re-landing] Implement a StackTrace utility object that can capture stack traces for debugging.
     4        https://bugs.webkit.org/show_bug.cgi?id=169454
     5
     6        Reviewed by Michael Saboff.
     7
     8        The underlying implementation is hoisted right out of Assertions.cpp from the
     9        implementations of WTFPrintBacktrace().
     10
     11        The reason we need this StackTrace object is because during heap debugging, we
     12        sometimes want to capture the stack trace that allocated the objects of interest.
     13        Dumping the stack trace directly to stdout (using WTFReportBacktrace()) may
     14        perturb the execution profile sufficiently that an issue may not reproduce,
     15        while alternatively, just capturing the stack trace and deferring printing it
     16        till we actually need it later perturbs the execution profile less.
     17
     18        In addition, just capturing the stack traces (instead of printing them
     19        immediately at each capture site) allows us to avoid polluting stdout with tons
     20        of stack traces that may be irrelevant.
     21
     22        For now, we only capture the native stack trace.  We'll leave capturing and
     23        integrating the JS stack trace as an exercise for the future if we need it then.
     24
     25        Here's an example of how to use this StackTrace utility:
     26
     27            // Capture a stack trace of the top 10 frames.
     28            std::unique_ptr<StackTrace> trace(StackTrace::captureStackTrace(10));
     29            // Print the trace.
     30            dataLog(*trace);
     31
     32        * CMakeLists.txt:
     33        * JavaScriptCore.xcodeproj/project.pbxproj:
     34        * tools/StackTrace.cpp: Added.
     35        (JSC::StackTrace::instanceSize):
     36        (JSC::StackTrace::captureStackTrace):
     37        (JSC::StackTrace::dump):
     38        * tools/StackTrace.h: Added.
     39        (JSC::StackTrace::size):
     40        (JSC::StackTrace::StackTrace):
     41
    1422017-03-04  Filip Pizlo  <fpizlo@apple.com>
    243
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r213714 r213718  
    23722372                FE1BD0241E72053800134BC9 /* HeapVerifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1BD0221E72052F00134BC9 /* HeapVerifier.cpp */; };
    23732373                FE1BD0251E72053800134BC9 /* HeapVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1BD0231E72052F00134BC9 /* HeapVerifier.h */; };
     2374                FE1BD02B1E721B4C00134BC9 /* StackTrace.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1BD02A1E721B3700134BC9 /* StackTrace.h */; };
     2375                FE1BD02C1E721B5100134BC9 /* StackTrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1BD0291E721B3700134BC9 /* StackTrace.cpp */; };
    23742376                FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1C0FFC1B193E9800B53FCA /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23752377                FE1C0FFF1B194FD100B53FCA /* Exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1C0FFE1B194FD100B53FCA /* Exception.cpp */; };
     
    49584960                FE1BD0221E72052F00134BC9 /* HeapVerifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapVerifier.cpp; sourceTree = "<group>"; };
    49594961                FE1BD0231E72052F00134BC9 /* HeapVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapVerifier.h; sourceTree = "<group>"; };
     4962                FE1BD0291E721B3700134BC9 /* StackTrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackTrace.cpp; sourceTree = "<group>"; };
     4963                FE1BD02A1E721B3700134BC9 /* StackTrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackTrace.h; sourceTree = "<group>"; };
    49604964                FE1C0FFC1B193E9800B53FCA /* Exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exception.h; sourceTree = "<group>"; };
    49614965                FE1C0FFE1B194FD100B53FCA /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = "<group>"; };
     
    69566960                                FE3022D01E3D739600BAC493 /* SigillCrashAnalyzer.cpp */,
    69576961                                FE3022D11E3D739600BAC493 /* SigillCrashAnalyzer.h */,
     6962                                FE1BD0291E721B3700134BC9 /* StackTrace.cpp */,
     6963                                FE1BD02A1E721B3700134BC9 /* StackTrace.h */,
    69586964                                86B5826A14D35D5100A9C306 /* TieredMMapArray.h */,
    69596965                                FE3022D41E42856700BAC493 /* VMInspector.cpp */,
     
    87608766                                0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */,
    87618767                                0FB14E1F18124ACE009B6B4D /* JITInlineCacheGenerator.h in Headers */,
     8768                                FE1BD02B1E721B4C00134BC9 /* StackTrace.h in Headers */,
    87628769                                86CC85A10EE79A4700288682 /* JITInlines.h in Headers */,
    87638770                                FE3A06BE1C11041200390FDD /* JITLeftShiftGenerator.h in Headers */,
     
    1020110208                                0FDB2CE7174830A2007B3C1B /* DFGWorklist.cpp in Sources */,
    1020210209                                0FE050171AA9091100D33B33 /* DirectArguments.cpp in Sources */,
     10210                                FE1BD02C1E721B5100134BC9 /* StackTrace.cpp in Sources */,
    1020310211                                0FE050151AA9091100D33B33 /* DirectArgumentsOffset.cpp in Sources */,
    1020410212                                0F2EBBAB1DEDF95000990369 /* DirectEvalCodeCache.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.