haikuwebkit/Source/WTF/wtf/StackTrace.cpp

155 lines
4.9 KiB
C++
Raw Permalink Normal View History

[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
* Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
Use pragma once in WTF https://bugs.webkit.org/show_bug.cgi?id=190527 Reviewed by Chris Dumez. Source/WTF: We also need to consistently include wtf headers from within wtf so we can build wtf without symbol redefinition errors from including the copy in Source and the copy in the build directory. * wtf/ASCIICType.h: * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/Atomics.h: * wtf/AutomaticThread.cpp: * wtf/AutomaticThread.h: * wtf/BackwardsGraph.h: * wtf/Bag.h: * wtf/BagToHashMap.h: * wtf/BitVector.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Box.h: * wtf/BubbleSort.h: * wtf/BumpPointerAllocator.h: * wtf/ByteOrder.h: * wtf/CPUTime.cpp: * wtf/CallbackAggregator.h: * wtf/CheckedArithmetic.h: * wtf/CheckedBoolean.h: * wtf/ClockType.cpp: * wtf/ClockType.h: * wtf/CommaPrinter.h: * wtf/CompilationThread.cpp: * wtf/CompilationThread.h: * wtf/Compiler.h: * wtf/ConcurrentPtrHashSet.cpp: * wtf/ConcurrentVector.h: * wtf/Condition.h: * wtf/CountingLock.cpp: * wtf/CrossThreadTaskHandler.cpp: * wtf/CryptographicUtilities.cpp: * wtf/CryptographicUtilities.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/CryptographicallyRandomNumber.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DataLog.h: * wtf/DateMath.cpp: * wtf/DateMath.h: * wtf/DecimalNumber.cpp: * wtf/DecimalNumber.h: * wtf/Deque.h: * wtf/DisallowCType.h: * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/FastBitVector.cpp: * wtf/FastMalloc.cpp: * wtf/FastMalloc.h: * wtf/FeatureDefines.h: * wtf/FilePrintStream.cpp: * wtf/FilePrintStream.h: * wtf/FlipBytes.h: * wtf/FunctionDispatcher.cpp: * wtf/FunctionDispatcher.h: * wtf/GetPtr.h: * wtf/Gigacage.cpp: * wtf/GlobalVersion.cpp: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.cpp: * wtf/GregorianDateTime.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashMethod.h: * wtf/HashSet.h: * wtf/HashTable.cpp: * wtf/HashTraits.h: * wtf/Indenter.h: * wtf/IndexSparseSet.h: * wtf/InlineASM.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/JSONValues.cpp: * wtf/JSValueMalloc.cpp: * wtf/LEBDecoder.h: * wtf/Language.cpp: * wtf/ListDump.h: * wtf/Lock.cpp: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockedPrintStream.cpp: * wtf/Locker.h: * wtf/MD5.cpp: * wtf/MD5.h: * wtf/MainThread.cpp: * wtf/MainThread.h: * wtf/MallocPtr.h: * wtf/MathExtras.h: * wtf/MediaTime.cpp: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.cpp: * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: * wtf/MetaAllocator.h: * wtf/MetaAllocatorHandle.h: * wtf/MonotonicTime.cpp: * wtf/MonotonicTime.h: * wtf/NakedPtr.h: * wtf/NoLock.h: * wtf/NoTailCalls.h: * wtf/Noncopyable.h: * wtf/NumberOfCores.cpp: * wtf/NumberOfCores.h: * wtf/OSAllocator.h: * wtf/OSAllocatorPosix.cpp: * wtf/OSRandomSource.cpp: * wtf/OSRandomSource.h: * wtf/ObjcRuntimeExtras.h: * wtf/OrderMaker.h: * wtf/PackedIntVector.h: * wtf/PageAllocation.h: * wtf/PageBlock.cpp: * wtf/PageBlock.h: * wtf/PageReservation.h: * wtf/ParallelHelperPool.cpp: * wtf/ParallelHelperPool.h: * wtf/ParallelJobs.h: * wtf/ParallelJobsLibdispatch.h: * wtf/ParallelVectorIterator.h: * wtf/ParkingLot.cpp: * wtf/ParkingLot.h: * wtf/Platform.h: * wtf/PointerComparison.h: * wtf/Poisoned.cpp: * wtf/PrintStream.cpp: * wtf/PrintStream.h: * wtf/ProcessID.h: * wtf/ProcessPrivilege.cpp: * wtf/RAMSize.cpp: * wtf/RAMSize.h: * wtf/RandomDevice.cpp: * wtf/RandomNumber.cpp: * wtf/RandomNumber.h: * wtf/RandomNumberSeed.h: * wtf/RangeSet.h: * wtf/RawPointer.h: * wtf/ReadWriteLock.cpp: * wtf/RedBlackTree.h: * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefCountedLeakCounter.cpp: * wtf/RefCountedLeakCounter.h: * wtf/RefCounter.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/RunLoop.cpp: * wtf/RunLoop.h: * wtf/RunLoopTimer.h: * wtf/RunLoopTimerCF.cpp: * wtf/SHA1.cpp: * wtf/SHA1.h: * wtf/SaturatedArithmetic.h: (saturatedSubtraction): * wtf/SchedulePair.h: * wtf/SchedulePairCF.cpp: * wtf/SchedulePairMac.mm: * wtf/ScopedLambda.h: * wtf/Seconds.cpp: * wtf/Seconds.h: * wtf/SegmentedVector.h: * wtf/SentinelLinkedList.h: * wtf/SharedTask.h: * wtf/SimpleStats.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SixCharacterHash.cpp: * wtf/SixCharacterHash.h: * wtf/SmallPtrSet.h: * wtf/Spectrum.h: * wtf/StackBounds.cpp: * wtf/StackBounds.h: * wtf/StackStats.cpp: * wtf/StackStats.h: * wtf/StackTrace.cpp: * wtf/StdLibExtras.h: * wtf/StreamBuffer.h: * wtf/StringHashDumpContext.h: * wtf/StringPrintStream.cpp: * wtf/StringPrintStream.h: * wtf/ThreadGroup.cpp: * wtf/ThreadMessage.cpp: * wtf/ThreadSpecific.h: * wtf/Threading.cpp: * wtf/Threading.h: * wtf/ThreadingPrimitives.h: * wtf/ThreadingPthreads.cpp: * wtf/TimeWithDynamicClockType.cpp: * wtf/TimeWithDynamicClockType.h: * wtf/TimingScope.cpp: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/TriState.h: * wtf/TypeCasts.h: * wtf/UUID.cpp: * wtf/UnionFind.h: * wtf/VMTags.h: * wtf/ValueCheck.h: * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.cpp: * wtf/WallTime.h: * wtf/WeakPtr.h: * wtf/WeakRandom.h: * wtf/WordLock.cpp: * wtf/WordLock.h: * wtf/WorkQueue.cpp: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: * wtf/cf/LanguageCF.cpp: * wtf/cf/RunLoopCF.cpp: * wtf/cocoa/Entitlements.mm: * wtf/cocoa/MachSendRight.cpp: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/MemoryFootprintCocoa.cpp: * wtf/cocoa/WorkQueueCocoa.cpp: * wtf/dtoa.cpp: * wtf/dtoa.h: * wtf/ios/WebCoreThread.cpp: * wtf/ios/WebCoreThread.h: * wtf/mac/AppKitCompatibilityDeclarations.h: * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: * wtf/mbmalloc.cpp: * wtf/persistence/PersistentCoders.cpp: * wtf/persistence/PersistentDecoder.cpp: * wtf/persistence/PersistentEncoder.cpp: * wtf/spi/cf/CFBundleSPI.h: * wtf/spi/darwin/CommonCryptoSPI.h: * wtf/text/ASCIIFastPath.h: * wtf/text/ASCIILiteral.cpp: * wtf/text/AtomicString.cpp: * wtf/text/AtomicString.h: * wtf/text/AtomicStringHash.h: * wtf/text/AtomicStringImpl.cpp: * wtf/text/AtomicStringImpl.h: * wtf/text/AtomicStringTable.cpp: * wtf/text/AtomicStringTable.h: * wtf/text/Base64.cpp: * wtf/text/CString.cpp: * wtf/text/CString.h: * wtf/text/ConversionMode.h: * wtf/text/ExternalStringImpl.cpp: * wtf/text/IntegerToStringConversion.h: * wtf/text/LChar.h: * wtf/text/LineEnding.cpp: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.cpp: * wtf/text/StringBuilder.h: * wtf/text/StringBuilderJSON.cpp: * wtf/text/StringCommon.h: * wtf/text/StringConcatenate.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.cpp: * wtf/text/StringImpl.h: * wtf/text/StringOperators.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: * wtf/text/SymbolImpl.cpp: * wtf/text/SymbolRegistry.cpp: * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.cpp: * wtf/text/TextBreakIterator.h: * wtf/text/TextBreakIteratorInternalICU.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.cpp: * wtf/text/UniquedStringImpl.h: * wtf/text/WTFString.cpp: * wtf/text/WTFString.h: * wtf/text/cocoa/StringCocoa.mm: * wtf/text/cocoa/StringViewCocoa.mm: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: * wtf/text/icu/UTextProvider.cpp: * wtf/text/icu/UTextProvider.h: * wtf/text/icu/UTextProviderLatin1.cpp: * wtf/text/icu/UTextProviderLatin1.h: * wtf/text/icu/UTextProviderUTF16.cpp: * wtf/text/icu/UTextProviderUTF16.h: * wtf/threads/BinarySemaphore.cpp: * wtf/threads/BinarySemaphore.h: * wtf/threads/Signals.cpp: * wtf/unicode/CharacterNames.h: * wtf/unicode/Collator.h: * wtf/unicode/CollatorDefault.cpp: * wtf/unicode/UTF8.cpp: * wtf/unicode/UTF8.h: Tools: Put WorkQueue in namespace DRT so it does not conflict with WTF::WorkQueue. * DumpRenderTree/TestRunner.cpp: (TestRunner::queueLoadHTMLString): (TestRunner::queueLoadAlternateHTMLString): (TestRunner::queueBackNavigation): (TestRunner::queueForwardNavigation): (TestRunner::queueLoadingScript): (TestRunner::queueNonLoadingScript): (TestRunner::queueReload): * DumpRenderTree/WorkQueue.cpp: (WorkQueue::singleton): Deleted. (WorkQueue::WorkQueue): Deleted. (WorkQueue::queue): Deleted. (WorkQueue::dequeue): Deleted. (WorkQueue::count): Deleted. (WorkQueue::clear): Deleted. (WorkQueue::processWork): Deleted. * DumpRenderTree/WorkQueue.h: (WorkQueue::setFrozen): Deleted. * DumpRenderTree/WorkQueueItem.h: * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): * DumpRenderTree/mac/FrameLoadDelegate.mm: (-[FrameLoadDelegate processWork:]): (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]): * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): * DumpRenderTree/win/DumpRenderTree.cpp: (runTest): * DumpRenderTree/win/FrameLoadDelegate.cpp: (FrameLoadDelegate::processWork): (FrameLoadDelegate::locationChangeDone): * DumpRenderTree/win/TestRunnerWin.cpp: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): Canonical link: https://commits.webkit.org/205473@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237099 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-15 14:24:49 +00:00
#include <wtf/StackTrace.h>
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
#include <wtf/Assertions.h>
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
#include <wtf/PrintStream.h>
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
#if HAVE(BACKTRACE_SYMBOLS) || HAVE(BACKTRACE)
#include <execinfo.h>
#endif
#if HAVE(DLADDR)
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
#include <cxxabi.h>
#include <dlfcn.h>
#endif
#if OS(WINDOWS)
#include <windows.h>
#include <wtf/win/DbgHelperWin.h>
#endif
void WTFGetBacktrace(void** stack, int* size)
{
#if HAVE(BACKTRACE)
*size = backtrace(stack, *size);
#elif OS(WINDOWS)
[clang-tidy] Run modernize-use-nullptr over WTF https://bugs.webkit.org/show_bug.cgi?id=211628 Reviewed by Yusuke Suzuki. Use the fix option in clang-tidy to ensure nullptr is being used across WTF. * wtf/Assertions.cpp: * wtf/BumpPointerAllocator.h: (WTF::BumpPointerPool::BumpPointerPool): (WTF::BumpPointerPool::create): (WTF::BumpPointerAllocator::BumpPointerAllocator): * wtf/DataLog.cpp: (WTF::setDataFile): * wtf/DateMath.cpp: (WTF::parseES5DatePortion): (WTF::parseES5TimePortion): * wtf/FastMalloc.cpp: (WTF::fastZeroedMalloc): (WTF::fastStrDup): (WTF::tryFastZeroedMalloc): (WTF::isFastMallocEnabled): (WTF::fastMallocGoodSize): (WTF::fastAlignedMalloc): (WTF::tryFastAlignedMalloc): (WTF::fastAlignedFree): (WTF::tryFastMalloc): (WTF::fastMalloc): (WTF::tryFastCalloc): (WTF::fastCalloc): (WTF::fastFree): (WTF::fastRealloc): (WTF::tryFastRealloc): (WTF::releaseFastMallocFreeMemory): (WTF::releaseFastMallocFreeMemoryForThisThread): (WTF::fastMallocStatistics): (WTF::fastMallocSize): (WTF::fastCommitAlignedMemory): (WTF::fastDecommitAlignedMemory): (WTF::fastEnableMiniMode): (WTF::fastDisableScavenger): (WTF::fastMallocDumpMallocStats): (WTF::AvoidRecordingScope::avoidRecordingCount): (WTF::AvoidRecordingScope::AvoidRecordingScope): (WTF::AvoidRecordingScope::~AvoidRecordingScope): (WTF::MallocCallTracker::MallocSiteData::MallocSiteData): (WTF::MallocCallTracker::singleton): (WTF::MallocCallTracker::MallocCallTracker): (WTF::MallocCallTracker::recordMalloc): (WTF::MallocCallTracker::recordRealloc): (WTF::MallocCallTracker::recordFree): (WTF::MallocCallTracker::dumpStats): * wtf/HashTable.h: (WTF::KeyTraits>::inlineLookup): (WTF::KeyTraits>::lookupForWriting): (WTF::KeyTraits>::fullLookupForWriting): (WTF::KeyTraits>::add): * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::findAndRemoveFreeSpace): * wtf/ParallelJobsGeneric.cpp: * wtf/RandomDevice.cpp: (WTF::RandomDevice::cryptographicallyRandomValues): * wtf/RawPointer.h: (WTF::RawPointer::RawPointer): * wtf/RedBlackTree.h: * wtf/SHA1.cpp: (WTF::SHA1::hexDigest): * wtf/SchedulePair.h: (WTF::SchedulePair::SchedulePair): * wtf/StackTrace.cpp: (WTFGetBacktrace): (WTF::StackTrace::dump const): * wtf/StringExtras.h: (strnstr): * wtf/Variant.h: * wtf/Vector.h: (WTF::VectorBufferBase::deallocateBuffer): (WTF::VectorBufferBase::releaseBuffer): (WTF::VectorBufferBase::VectorBufferBase): * wtf/cf/CFURLExtras.cpp: (WTF::createCFURLFromBuffer): (WTF::getURLBytes): * wtf/cf/CFURLExtras.h: * wtf/cf/FileSystemCF.cpp: (WTF::FileSystem::pathAsURL): * wtf/dtoa/double-conversion.cc: * wtf/dtoa/utils.h: (WTF::double_conversion::BufferReference::BufferReference): * wtf/text/CString.cpp: (WTF::CString::mutableData): * wtf/text/CString.h: * wtf/text/StringBuffer.h: (WTF::StringBuffer::release): * wtf/text/StringImpl.cpp: (WTF::StringImpl::createUninitializedInternal): (WTF::StringImpl::reallocateInternal): * wtf/text/StringImpl.h: (WTF::StringImpl::constructInternal<LChar>): (WTF::StringImpl::constructInternal<UChar>): (WTF::StringImpl::characters<LChar> const): (WTF::StringImpl::characters<UChar> const): (WTF::find): (WTF::reverseFindLineTerminator): (WTF::reverseFind): (WTF::equalIgnoringNullity): (WTF::codePointCompare): (WTF::isSpaceOrNewline): (WTF::lengthOfNullTerminatedString): (WTF::StringImplShape::StringImplShape): (WTF::StringImpl::isolatedCopy const): (WTF::StringImpl::isAllASCII const): (WTF::StringImpl::isAllLatin1 const): (WTF::isAllSpecialCharacters): (WTF::isSpecialCharacter const): (WTF::StringImpl::StringImpl): (WTF::StringImpl::create8BitIfPossible): (WTF::StringImpl::createSubstringSharingImpl): (WTF::StringImpl::createFromLiteral): (WTF::StringImpl::tryCreateUninitialized): (WTF::StringImpl::adopt): (WTF::StringImpl::cost const): (WTF::StringImpl::costDuringGC): (WTF::StringImpl::setIsAtom): (WTF::StringImpl::setHash const): (WTF::StringImpl::ref): (WTF::StringImpl::deref): (WTF::StringImpl::copyCharacters): (WTF::StringImpl::at const): (WTF::StringImpl::allocationSize): (WTF::StringImpl::maxInternalLength): (WTF::StringImpl::tailOffset): (WTF::StringImpl::requiresCopy const): (WTF::StringImpl::tailPointer const): (WTF::StringImpl::tailPointer): (WTF::StringImpl::substringBuffer const): (WTF::StringImpl::substringBuffer): (WTF::StringImpl::assertHashIsCorrect const): (WTF::StringImpl::StaticStringImpl::StaticStringImpl): (WTF::StringImpl::StaticStringImpl::operator StringImpl&): (WTF::equalIgnoringASCIICase): (WTF::startsWithLettersIgnoringASCIICase): (WTF::equalLettersIgnoringASCIICase): * wtf/text/TextBreakIterator.cpp: (WTF::initializeIterator): (WTF::setContextAwareTextForIterator): (WTF::openLineBreakIterator): * wtf/text/TextBreakIterator.h: (WTF::LazyLineBreakIterator::get): * wtf/text/WTFString.cpp: (WTF::charactersToFloat): * wtf/text/cf/StringImplCF.cpp: (WTF::StringWrapperCFAllocator::allocate): (WTF::StringWrapperCFAllocator::create): (WTF::StringImpl::createCFString): * wtf/text/icu/UTextProviderLatin1.cpp: (WTF::uTextLatin1Clone): (WTF::openLatin1ContextAwareUTextProvider): * wtf/text/icu/UTextProviderUTF16.cpp: (WTF::openUTF16ContextAwareUTextProvider): * wtf/win/FileSystemWin.cpp: (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::storageDirectory): (WTF::FileSystemImpl::openTemporaryFile): (WTF::FileSystemImpl::openFile): (WTF::FileSystemImpl::writeToFile): (WTF::FileSystemImpl::readFromFile): (WTF::FileSystemImpl::deleteNonEmptyDirectory): * wtf/win/LanguageWin.cpp: (WTF::localeInfo): * wtf/win/MainThreadWin.cpp: (WTF::initializeMainThreadPlatform): * wtf/win/OSAllocatorWin.cpp: (WTF::OSAllocator::reserveUncommitted): (WTF::OSAllocator::reserveAndCommit): * wtf/win/RunLoopWin.cpp: (WTF::RunLoop::run): (WTF::RunLoop::iterate): (WTF::RunLoop::RunLoop): (WTF::RunLoop::cycle): (WTF::RunLoop::TimerBase::start): * wtf/win/ThreadingWin.cpp: (WTF::Thread::establishHandle): Canonical link: https://commits.webkit.org/224543@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261393 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-08 17:31:54 +00:00
*size = RtlCaptureStackBackTrace(0, *size, stack, nullptr);
#else
UNUSED_PARAM(stack);
*size = 0;
#endif
}
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
namespace WTF {
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
ALWAYS_INLINE size_t StackTrace::instanceSize(int capacity)
{
ASSERT(capacity >= 1);
return sizeof(StackTrace) + (capacity - 1) * sizeof(void*);
}
std::unique_ptr<StackTrace> StackTrace::captureStackTrace(int maxFrames, int framesToSkip)
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
{
maxFrames = std::max(1, maxFrames);
size_t sizeToAllocate = instanceSize(maxFrames);
std::unique_ptr<StackTrace> trace(new (NotNull, fastMalloc(sizeToAllocate)) StackTrace());
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
Introduce ExceptionScope::assertNoException() and releaseAssertNoException(). https://bugs.webkit.org/show_bug.cgi?id=171776 Reviewed by Keith Miller. Source/JavaScriptCore: Instead of ASSERT(!scope.exception()), we can now do scope.assertNoException(). Ditto for RELEASE_ASSERT and scope.releaseAssertNoException(). The advantage of using ExceptionScope::assertNoException() and releaseAssertNoException() is that if the assertion fails, these utility functions will print the stack trace for where the unexpected exception is detected as well as where the unexpected exception was thrown from. This makes it much easier to debug the source of unhandled exceptions. * debugger/Debugger.cpp: (JSC::Debugger::pauseIfNeeded): * dfg/DFGOperations.cpp: * interpreter/Interpreter.cpp: (JSC::eval): (JSC::notifyDebuggerOfUnwinding): (JSC::Interpreter::executeProgram): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::prepareForRepeatCall): (JSC::Interpreter::execute): (JSC::Interpreter::debug): * interpreter/ShadowChicken.cpp: (JSC::ShadowChicken::functionsOnStack): * jsc.cpp: (GlobalObject::moduleLoaderResolve): (GlobalObject::moduleLoaderFetch): (functionGenerateHeapSnapshot): (functionSamplingProfilerStackTraces): (box): (runWithScripts): * runtime/AbstractModuleRecord.cpp: (JSC::AbstractModuleRecord::finishCreation): * runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::tryInitializeSpeciesWatchpoint): * runtime/Completion.cpp: (JSC::rejectPromise): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::sanitizedToString): * runtime/ExceptionHelpers.cpp: (JSC::createError): * runtime/ExceptionScope.cpp: (JSC::ExceptionScope::unexpectedExceptionMessage): * runtime/ExceptionScope.h: (JSC::ExceptionScope::assertNoException): (JSC::ExceptionScope::releaseAssertNoException): (JSC::ExceptionScope::unexpectedExceptionMessage): * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments<Type>::defineOwnProperty): * runtime/IntlCollator.cpp: (JSC::IntlCollator::createCollator): (JSC::IntlCollator::resolvedOptions): * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::resolvedOptions): (JSC::IntlDateTimeFormat::format): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::createNumberFormat): (JSC::IntlNumberFormat::resolvedOptions): * runtime/JSCJSValue.cpp: (JSC::JSValue::putToPrimitiveByIndex): * runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::genericTypedArrayViewProtoFuncIncludes): (JSC::genericTypedArrayViewProtoFuncIndexOf): (JSC::genericTypedArrayViewProtoFuncLastIndexOf): (JSC::genericTypedArrayViewPrivateFuncSubarrayCreate): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncHostPromiseRejectionTracker): * runtime/JSModuleEnvironment.cpp: (JSC::JSModuleEnvironment::getOwnPropertySlot): * runtime/JSModuleLoader.cpp: (JSC::JSModuleLoader::finishCreation): * runtime/JSModuleNamespaceObject.cpp: (JSC::JSModuleNamespaceObject::finishCreation): * runtime/JSONObject.cpp: (JSC::Stringifier::toJSON): * runtime/JSObject.cpp: (JSC::JSObject::ordinaryToPrimitive): * runtime/JSPropertyNameEnumerator.h: (JSC::propertyNameEnumerator): * runtime/ObjectConstructor.cpp: (JSC::objectConstructorGetOwnPropertyDescriptors): (JSC::objectConstructorDefineProperty): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncHasOwnProperty): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ReflectObject.cpp: (JSC::reflectObjectDefineProperty): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::nameFromCallee): * runtime/StringPrototype.cpp: (JSC::stringProtoFuncRepeatCharacter): * runtime/TemplateRegistry.cpp: (JSC::TemplateRegistry::getTemplateObject): * runtime/VM.cpp: (JSC::VM::throwException): * runtime/VM.h: (JSC::VM::nativeStackTraceOfLastThrow): (JSC::VM::clearException): * wasm/WasmB3IRGenerator.cpp: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::create): Source/WebCore: No new tests because there's no behavior change in functionality. We're only refactoring the code to use the new assertion utility function. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::installReplacement): * bindings/js/JSCryptoKeySerializationJWK.cpp: (WebCore::getJSArrayFromJSON): (WebCore::getStringFromJSON): (WebCore::getBooleanFromJSON): * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::whenDefined): * bindings/js/JSDOMExceptionHandling.cpp: (WebCore::propagateExceptionSlowPath): (WebCore::throwNotSupportedError): (WebCore::throwInvalidStateError): (WebCore::throwSecurityError): (WebCore::throwDOMSyntaxError): (WebCore::throwDataCloneError): (WebCore::throwIndexSizeError): (WebCore::throwTypeMismatchError): * bindings/js/JSDOMGlobalObject.cpp: (WebCore::makeThisTypeErrorForBuiltins): (WebCore::makeGetterTypeErrorForBuiltins): * bindings/js/JSDOMGlobalObjectTask.cpp: * bindings/js/JSDOMPromise.h: (WebCore::callPromiseFunction): * bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowMicrotaskCallback::call): * bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState::~JSMainThreadExecState): * bindings/js/ReadableStreamDefaultController.cpp: (WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked): * bindings/js/ReadableStreamDefaultController.h: (WebCore::ReadableStreamDefaultController::enqueue): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readTerminal): * bindings/scripts/CodeGeneratorJS.pm: (GenerateSerializerFunction): * bindings/scripts/test/JS/JSTestNode.cpp: (WebCore::JSTestNode::serialize): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObj::serialize): * bindings/scripts/test/JS/JSTestSerialization.cpp: (WebCore::JSTestSerialization::serialize): * bindings/scripts/test/JS/JSTestSerializationInherit.cpp: (WebCore::JSTestSerializationInherit::serialize): * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp: (WebCore::JSTestSerializationInheritFinal::serialize): * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::getTypeFlags): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): (WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange): (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Source/WTF: 1. Add an option to skip some number of top frames when capturing the StackTrace. 2. Add an option to use an indentation string when dumping the StackTrace. * wtf/StackTrace.cpp: (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Canonical link: https://commits.webkit.org/188717@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-08 16:56:32 +00:00
// Skip 2 additional frames i.e. StackTrace::captureStackTrace and WTFGetBacktrace.
framesToSkip += 2;
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
int numberOfFrames = maxFrames + framesToSkip;
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
WTFGetBacktrace(&trace->m_skippedFrame0, &numberOfFrames);
if (numberOfFrames) {
RELEASE_ASSERT(numberOfFrames >= framesToSkip);
trace->m_size = numberOfFrames - framesToSkip;
} else
trace->m_size = 0;
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
trace->m_capacity = maxFrames;
return trace;
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
auto StackTrace::demangle(void* pc) -> std::optional<DemangleEntry>
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
{
#if HAVE(DLADDR)
const char* mangledName = nullptr;
const char* cxaDemangled = nullptr;
Dl_info info;
if (dladdr(pc, &info) && info.dli_sname)
mangledName = info.dli_sname;
if (mangledName) {
int status = 0;
cxaDemangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, &status);
UNUSED_PARAM(status);
}
if (mangledName || cxaDemangled)
return DemangleEntry { mangledName, cxaDemangled };
#else
UNUSED_PARAM(pc);
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
#endif
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
}
Introduce ExceptionScope::assertNoException() and releaseAssertNoException(). https://bugs.webkit.org/show_bug.cgi?id=171776 Reviewed by Keith Miller. Source/JavaScriptCore: Instead of ASSERT(!scope.exception()), we can now do scope.assertNoException(). Ditto for RELEASE_ASSERT and scope.releaseAssertNoException(). The advantage of using ExceptionScope::assertNoException() and releaseAssertNoException() is that if the assertion fails, these utility functions will print the stack trace for where the unexpected exception is detected as well as where the unexpected exception was thrown from. This makes it much easier to debug the source of unhandled exceptions. * debugger/Debugger.cpp: (JSC::Debugger::pauseIfNeeded): * dfg/DFGOperations.cpp: * interpreter/Interpreter.cpp: (JSC::eval): (JSC::notifyDebuggerOfUnwinding): (JSC::Interpreter::executeProgram): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::prepareForRepeatCall): (JSC::Interpreter::execute): (JSC::Interpreter::debug): * interpreter/ShadowChicken.cpp: (JSC::ShadowChicken::functionsOnStack): * jsc.cpp: (GlobalObject::moduleLoaderResolve): (GlobalObject::moduleLoaderFetch): (functionGenerateHeapSnapshot): (functionSamplingProfilerStackTraces): (box): (runWithScripts): * runtime/AbstractModuleRecord.cpp: (JSC::AbstractModuleRecord::finishCreation): * runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::tryInitializeSpeciesWatchpoint): * runtime/Completion.cpp: (JSC::rejectPromise): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::sanitizedToString): * runtime/ExceptionHelpers.cpp: (JSC::createError): * runtime/ExceptionScope.cpp: (JSC::ExceptionScope::unexpectedExceptionMessage): * runtime/ExceptionScope.h: (JSC::ExceptionScope::assertNoException): (JSC::ExceptionScope::releaseAssertNoException): (JSC::ExceptionScope::unexpectedExceptionMessage): * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments<Type>::defineOwnProperty): * runtime/IntlCollator.cpp: (JSC::IntlCollator::createCollator): (JSC::IntlCollator::resolvedOptions): * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::resolvedOptions): (JSC::IntlDateTimeFormat::format): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::createNumberFormat): (JSC::IntlNumberFormat::resolvedOptions): * runtime/JSCJSValue.cpp: (JSC::JSValue::putToPrimitiveByIndex): * runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::genericTypedArrayViewProtoFuncIncludes): (JSC::genericTypedArrayViewProtoFuncIndexOf): (JSC::genericTypedArrayViewProtoFuncLastIndexOf): (JSC::genericTypedArrayViewPrivateFuncSubarrayCreate): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncHostPromiseRejectionTracker): * runtime/JSModuleEnvironment.cpp: (JSC::JSModuleEnvironment::getOwnPropertySlot): * runtime/JSModuleLoader.cpp: (JSC::JSModuleLoader::finishCreation): * runtime/JSModuleNamespaceObject.cpp: (JSC::JSModuleNamespaceObject::finishCreation): * runtime/JSONObject.cpp: (JSC::Stringifier::toJSON): * runtime/JSObject.cpp: (JSC::JSObject::ordinaryToPrimitive): * runtime/JSPropertyNameEnumerator.h: (JSC::propertyNameEnumerator): * runtime/ObjectConstructor.cpp: (JSC::objectConstructorGetOwnPropertyDescriptors): (JSC::objectConstructorDefineProperty): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncHasOwnProperty): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ReflectObject.cpp: (JSC::reflectObjectDefineProperty): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::nameFromCallee): * runtime/StringPrototype.cpp: (JSC::stringProtoFuncRepeatCharacter): * runtime/TemplateRegistry.cpp: (JSC::TemplateRegistry::getTemplateObject): * runtime/VM.cpp: (JSC::VM::throwException): * runtime/VM.h: (JSC::VM::nativeStackTraceOfLastThrow): (JSC::VM::clearException): * wasm/WasmB3IRGenerator.cpp: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::create): Source/WebCore: No new tests because there's no behavior change in functionality. We're only refactoring the code to use the new assertion utility function. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::installReplacement): * bindings/js/JSCryptoKeySerializationJWK.cpp: (WebCore::getJSArrayFromJSON): (WebCore::getStringFromJSON): (WebCore::getBooleanFromJSON): * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::whenDefined): * bindings/js/JSDOMExceptionHandling.cpp: (WebCore::propagateExceptionSlowPath): (WebCore::throwNotSupportedError): (WebCore::throwInvalidStateError): (WebCore::throwSecurityError): (WebCore::throwDOMSyntaxError): (WebCore::throwDataCloneError): (WebCore::throwIndexSizeError): (WebCore::throwTypeMismatchError): * bindings/js/JSDOMGlobalObject.cpp: (WebCore::makeThisTypeErrorForBuiltins): (WebCore::makeGetterTypeErrorForBuiltins): * bindings/js/JSDOMGlobalObjectTask.cpp: * bindings/js/JSDOMPromise.h: (WebCore::callPromiseFunction): * bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowMicrotaskCallback::call): * bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState::~JSMainThreadExecState): * bindings/js/ReadableStreamDefaultController.cpp: (WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked): * bindings/js/ReadableStreamDefaultController.h: (WebCore::ReadableStreamDefaultController::enqueue): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readTerminal): * bindings/scripts/CodeGeneratorJS.pm: (GenerateSerializerFunction): * bindings/scripts/test/JS/JSTestNode.cpp: (WebCore::JSTestNode::serialize): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObj::serialize): * bindings/scripts/test/JS/JSTestSerialization.cpp: (WebCore::JSTestSerialization::serialize): * bindings/scripts/test/JS/JSTestSerializationInherit.cpp: (WebCore::JSTestSerializationInherit::serialize): * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp: (WebCore::JSTestSerializationInheritFinal::serialize): * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::getTypeFlags): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): (WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange): (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Source/WTF: 1. Add an option to skip some number of top frames when capturing the StackTrace. 2. Add an option to use an indentation string when dumping the StackTrace. * wtf/StackTrace.cpp: (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Canonical link: https://commits.webkit.org/188717@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-08 16:56:32 +00:00
void StackTrace::dump(PrintStream& out, const char* indentString) const
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
{
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
const auto* stack = this->stack();
#if HAVE(BACKTRACE_SYMBOLS)
char** symbols = backtrace_symbols(stack, m_size);
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
if (!symbols)
return;
#elif OS(WINDOWS)
HANDLE hProc = GetCurrentProcess();
uint8_t symbolData[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)] = { 0 };
auto symbolInfo = reinterpret_cast<SYMBOL_INFO*>(symbolData);
symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFO);
symbolInfo->MaxNameLen = MAX_SYM_NAME;
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
#endif
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
Introduce ExceptionScope::assertNoException() and releaseAssertNoException(). https://bugs.webkit.org/show_bug.cgi?id=171776 Reviewed by Keith Miller. Source/JavaScriptCore: Instead of ASSERT(!scope.exception()), we can now do scope.assertNoException(). Ditto for RELEASE_ASSERT and scope.releaseAssertNoException(). The advantage of using ExceptionScope::assertNoException() and releaseAssertNoException() is that if the assertion fails, these utility functions will print the stack trace for where the unexpected exception is detected as well as where the unexpected exception was thrown from. This makes it much easier to debug the source of unhandled exceptions. * debugger/Debugger.cpp: (JSC::Debugger::pauseIfNeeded): * dfg/DFGOperations.cpp: * interpreter/Interpreter.cpp: (JSC::eval): (JSC::notifyDebuggerOfUnwinding): (JSC::Interpreter::executeProgram): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::prepareForRepeatCall): (JSC::Interpreter::execute): (JSC::Interpreter::debug): * interpreter/ShadowChicken.cpp: (JSC::ShadowChicken::functionsOnStack): * jsc.cpp: (GlobalObject::moduleLoaderResolve): (GlobalObject::moduleLoaderFetch): (functionGenerateHeapSnapshot): (functionSamplingProfilerStackTraces): (box): (runWithScripts): * runtime/AbstractModuleRecord.cpp: (JSC::AbstractModuleRecord::finishCreation): * runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::tryInitializeSpeciesWatchpoint): * runtime/Completion.cpp: (JSC::rejectPromise): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::sanitizedToString): * runtime/ExceptionHelpers.cpp: (JSC::createError): * runtime/ExceptionScope.cpp: (JSC::ExceptionScope::unexpectedExceptionMessage): * runtime/ExceptionScope.h: (JSC::ExceptionScope::assertNoException): (JSC::ExceptionScope::releaseAssertNoException): (JSC::ExceptionScope::unexpectedExceptionMessage): * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments<Type>::defineOwnProperty): * runtime/IntlCollator.cpp: (JSC::IntlCollator::createCollator): (JSC::IntlCollator::resolvedOptions): * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::resolvedOptions): (JSC::IntlDateTimeFormat::format): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::createNumberFormat): (JSC::IntlNumberFormat::resolvedOptions): * runtime/JSCJSValue.cpp: (JSC::JSValue::putToPrimitiveByIndex): * runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::genericTypedArrayViewProtoFuncIncludes): (JSC::genericTypedArrayViewProtoFuncIndexOf): (JSC::genericTypedArrayViewProtoFuncLastIndexOf): (JSC::genericTypedArrayViewPrivateFuncSubarrayCreate): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncHostPromiseRejectionTracker): * runtime/JSModuleEnvironment.cpp: (JSC::JSModuleEnvironment::getOwnPropertySlot): * runtime/JSModuleLoader.cpp: (JSC::JSModuleLoader::finishCreation): * runtime/JSModuleNamespaceObject.cpp: (JSC::JSModuleNamespaceObject::finishCreation): * runtime/JSONObject.cpp: (JSC::Stringifier::toJSON): * runtime/JSObject.cpp: (JSC::JSObject::ordinaryToPrimitive): * runtime/JSPropertyNameEnumerator.h: (JSC::propertyNameEnumerator): * runtime/ObjectConstructor.cpp: (JSC::objectConstructorGetOwnPropertyDescriptors): (JSC::objectConstructorDefineProperty): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncHasOwnProperty): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ReflectObject.cpp: (JSC::reflectObjectDefineProperty): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::nameFromCallee): * runtime/StringPrototype.cpp: (JSC::stringProtoFuncRepeatCharacter): * runtime/TemplateRegistry.cpp: (JSC::TemplateRegistry::getTemplateObject): * runtime/VM.cpp: (JSC::VM::throwException): * runtime/VM.h: (JSC::VM::nativeStackTraceOfLastThrow): (JSC::VM::clearException): * wasm/WasmB3IRGenerator.cpp: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::create): Source/WebCore: No new tests because there's no behavior change in functionality. We're only refactoring the code to use the new assertion utility function. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::installReplacement): * bindings/js/JSCryptoKeySerializationJWK.cpp: (WebCore::getJSArrayFromJSON): (WebCore::getStringFromJSON): (WebCore::getBooleanFromJSON): * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::whenDefined): * bindings/js/JSDOMExceptionHandling.cpp: (WebCore::propagateExceptionSlowPath): (WebCore::throwNotSupportedError): (WebCore::throwInvalidStateError): (WebCore::throwSecurityError): (WebCore::throwDOMSyntaxError): (WebCore::throwDataCloneError): (WebCore::throwIndexSizeError): (WebCore::throwTypeMismatchError): * bindings/js/JSDOMGlobalObject.cpp: (WebCore::makeThisTypeErrorForBuiltins): (WebCore::makeGetterTypeErrorForBuiltins): * bindings/js/JSDOMGlobalObjectTask.cpp: * bindings/js/JSDOMPromise.h: (WebCore::callPromiseFunction): * bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowMicrotaskCallback::call): * bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState::~JSMainThreadExecState): * bindings/js/ReadableStreamDefaultController.cpp: (WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked): * bindings/js/ReadableStreamDefaultController.h: (WebCore::ReadableStreamDefaultController::enqueue): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readTerminal): * bindings/scripts/CodeGeneratorJS.pm: (GenerateSerializerFunction): * bindings/scripts/test/JS/JSTestNode.cpp: (WebCore::JSTestNode::serialize): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObj::serialize): * bindings/scripts/test/JS/JSTestSerialization.cpp: (WebCore::JSTestSerialization::serialize): * bindings/scripts/test/JS/JSTestSerializationInherit.cpp: (WebCore::JSTestSerializationInherit::serialize): * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp: (WebCore::JSTestSerializationInheritFinal::serialize): * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::getTypeFlags): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): (WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange): (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Source/WTF: 1. Add an option to skip some number of top frames when capturing the StackTrace. 2. Add an option to use an indentation string when dumping the StackTrace. * wtf/StackTrace.cpp: (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Canonical link: https://commits.webkit.org/188717@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-08 16:56:32 +00:00
if (!indentString)
indentString = "";
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
for (int i = 0; i < m_size; ++i) {
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
const char* mangledName = nullptr;
const char* cxaDemangled = nullptr;
#if HAVE(BACKTRACE_SYMBOLS)
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
mangledName = symbols[i];
#elif OS(WINDOWS)
[clang-tidy] Run modernize-use-nullptr over WTF https://bugs.webkit.org/show_bug.cgi?id=211628 Reviewed by Yusuke Suzuki. Use the fix option in clang-tidy to ensure nullptr is being used across WTF. * wtf/Assertions.cpp: * wtf/BumpPointerAllocator.h: (WTF::BumpPointerPool::BumpPointerPool): (WTF::BumpPointerPool::create): (WTF::BumpPointerAllocator::BumpPointerAllocator): * wtf/DataLog.cpp: (WTF::setDataFile): * wtf/DateMath.cpp: (WTF::parseES5DatePortion): (WTF::parseES5TimePortion): * wtf/FastMalloc.cpp: (WTF::fastZeroedMalloc): (WTF::fastStrDup): (WTF::tryFastZeroedMalloc): (WTF::isFastMallocEnabled): (WTF::fastMallocGoodSize): (WTF::fastAlignedMalloc): (WTF::tryFastAlignedMalloc): (WTF::fastAlignedFree): (WTF::tryFastMalloc): (WTF::fastMalloc): (WTF::tryFastCalloc): (WTF::fastCalloc): (WTF::fastFree): (WTF::fastRealloc): (WTF::tryFastRealloc): (WTF::releaseFastMallocFreeMemory): (WTF::releaseFastMallocFreeMemoryForThisThread): (WTF::fastMallocStatistics): (WTF::fastMallocSize): (WTF::fastCommitAlignedMemory): (WTF::fastDecommitAlignedMemory): (WTF::fastEnableMiniMode): (WTF::fastDisableScavenger): (WTF::fastMallocDumpMallocStats): (WTF::AvoidRecordingScope::avoidRecordingCount): (WTF::AvoidRecordingScope::AvoidRecordingScope): (WTF::AvoidRecordingScope::~AvoidRecordingScope): (WTF::MallocCallTracker::MallocSiteData::MallocSiteData): (WTF::MallocCallTracker::singleton): (WTF::MallocCallTracker::MallocCallTracker): (WTF::MallocCallTracker::recordMalloc): (WTF::MallocCallTracker::recordRealloc): (WTF::MallocCallTracker::recordFree): (WTF::MallocCallTracker::dumpStats): * wtf/HashTable.h: (WTF::KeyTraits>::inlineLookup): (WTF::KeyTraits>::lookupForWriting): (WTF::KeyTraits>::fullLookupForWriting): (WTF::KeyTraits>::add): * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::findAndRemoveFreeSpace): * wtf/ParallelJobsGeneric.cpp: * wtf/RandomDevice.cpp: (WTF::RandomDevice::cryptographicallyRandomValues): * wtf/RawPointer.h: (WTF::RawPointer::RawPointer): * wtf/RedBlackTree.h: * wtf/SHA1.cpp: (WTF::SHA1::hexDigest): * wtf/SchedulePair.h: (WTF::SchedulePair::SchedulePair): * wtf/StackTrace.cpp: (WTFGetBacktrace): (WTF::StackTrace::dump const): * wtf/StringExtras.h: (strnstr): * wtf/Variant.h: * wtf/Vector.h: (WTF::VectorBufferBase::deallocateBuffer): (WTF::VectorBufferBase::releaseBuffer): (WTF::VectorBufferBase::VectorBufferBase): * wtf/cf/CFURLExtras.cpp: (WTF::createCFURLFromBuffer): (WTF::getURLBytes): * wtf/cf/CFURLExtras.h: * wtf/cf/FileSystemCF.cpp: (WTF::FileSystem::pathAsURL): * wtf/dtoa/double-conversion.cc: * wtf/dtoa/utils.h: (WTF::double_conversion::BufferReference::BufferReference): * wtf/text/CString.cpp: (WTF::CString::mutableData): * wtf/text/CString.h: * wtf/text/StringBuffer.h: (WTF::StringBuffer::release): * wtf/text/StringImpl.cpp: (WTF::StringImpl::createUninitializedInternal): (WTF::StringImpl::reallocateInternal): * wtf/text/StringImpl.h: (WTF::StringImpl::constructInternal<LChar>): (WTF::StringImpl::constructInternal<UChar>): (WTF::StringImpl::characters<LChar> const): (WTF::StringImpl::characters<UChar> const): (WTF::find): (WTF::reverseFindLineTerminator): (WTF::reverseFind): (WTF::equalIgnoringNullity): (WTF::codePointCompare): (WTF::isSpaceOrNewline): (WTF::lengthOfNullTerminatedString): (WTF::StringImplShape::StringImplShape): (WTF::StringImpl::isolatedCopy const): (WTF::StringImpl::isAllASCII const): (WTF::StringImpl::isAllLatin1 const): (WTF::isAllSpecialCharacters): (WTF::isSpecialCharacter const): (WTF::StringImpl::StringImpl): (WTF::StringImpl::create8BitIfPossible): (WTF::StringImpl::createSubstringSharingImpl): (WTF::StringImpl::createFromLiteral): (WTF::StringImpl::tryCreateUninitialized): (WTF::StringImpl::adopt): (WTF::StringImpl::cost const): (WTF::StringImpl::costDuringGC): (WTF::StringImpl::setIsAtom): (WTF::StringImpl::setHash const): (WTF::StringImpl::ref): (WTF::StringImpl::deref): (WTF::StringImpl::copyCharacters): (WTF::StringImpl::at const): (WTF::StringImpl::allocationSize): (WTF::StringImpl::maxInternalLength): (WTF::StringImpl::tailOffset): (WTF::StringImpl::requiresCopy const): (WTF::StringImpl::tailPointer const): (WTF::StringImpl::tailPointer): (WTF::StringImpl::substringBuffer const): (WTF::StringImpl::substringBuffer): (WTF::StringImpl::assertHashIsCorrect const): (WTF::StringImpl::StaticStringImpl::StaticStringImpl): (WTF::StringImpl::StaticStringImpl::operator StringImpl&): (WTF::equalIgnoringASCIICase): (WTF::startsWithLettersIgnoringASCIICase): (WTF::equalLettersIgnoringASCIICase): * wtf/text/TextBreakIterator.cpp: (WTF::initializeIterator): (WTF::setContextAwareTextForIterator): (WTF::openLineBreakIterator): * wtf/text/TextBreakIterator.h: (WTF::LazyLineBreakIterator::get): * wtf/text/WTFString.cpp: (WTF::charactersToFloat): * wtf/text/cf/StringImplCF.cpp: (WTF::StringWrapperCFAllocator::allocate): (WTF::StringWrapperCFAllocator::create): (WTF::StringImpl::createCFString): * wtf/text/icu/UTextProviderLatin1.cpp: (WTF::uTextLatin1Clone): (WTF::openLatin1ContextAwareUTextProvider): * wtf/text/icu/UTextProviderUTF16.cpp: (WTF::openUTF16ContextAwareUTextProvider): * wtf/win/FileSystemWin.cpp: (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::storageDirectory): (WTF::FileSystemImpl::openTemporaryFile): (WTF::FileSystemImpl::openFile): (WTF::FileSystemImpl::writeToFile): (WTF::FileSystemImpl::readFromFile): (WTF::FileSystemImpl::deleteNonEmptyDirectory): * wtf/win/LanguageWin.cpp: (WTF::localeInfo): * wtf/win/MainThreadWin.cpp: (WTF::initializeMainThreadPlatform): * wtf/win/OSAllocatorWin.cpp: (WTF::OSAllocator::reserveUncommitted): (WTF::OSAllocator::reserveAndCommit): * wtf/win/RunLoopWin.cpp: (WTF::RunLoop::run): (WTF::RunLoop::iterate): (WTF::RunLoop::RunLoop): (WTF::RunLoop::cycle): (WTF::RunLoop::TimerBase::start): * wtf/win/ThreadingWin.cpp: (WTF::Thread::establishHandle): Canonical link: https://commits.webkit.org/224543@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261393 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-08 17:31:54 +00:00
if (DbgHelper::SymFromAddress(hProc, reinterpret_cast<DWORD64>(stack[i]), nullptr, symbolInfo))
mangledName = symbolInfo->Name;
#endif
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
auto demangled = demangle(stack[i]);
if (demangled) {
mangledName = demangled->mangledName();
cxaDemangled = demangled->demangledName();
}
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
const int frameNumber = i + 1;
if (mangledName || cxaDemangled)
out.printf("%s%s%-3d %p %s\n", m_prefix ? m_prefix : "", indentString, frameNumber, stack[i], cxaDemangled ? cxaDemangled : mangledName);
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
else
out.printf("%s%s%-3d %p\n", m_prefix ? m_prefix : "", indentString, frameNumber, stack[i]);
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
}
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
#if HAVE(BACKTRACE_SYMBOLS)
[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): Canonical link: https://commits.webkit.org/186472@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-10 19:01:57 +00:00
free(symbols);
#endif
}
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code https://bugs.webkit.org/show_bug.cgi?id=171199 Reviewed by Mark Lam. Source/JavaScriptCore: This patch adds a utility method to produce demangled names with dladdr. It fixes several memory leaks because the result of abi::__cxa_demangle() needs to be `free`-ed. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * inspector/JSGlobalObjectInspectorController.cpp: (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::StackFrame::displayName): * tools/CellProfile.h: * tools/CodeProfile.cpp: (JSC::CodeProfile::report): (JSC::symbolName): Deleted. Source/WTF: JSC tools/StackTrace's dump code is almost identical to WTF Assertions' stack trace dump code. This patch moves tools/StackTrace to WTF and use it in Assertions. It unifies the two duplicate implementations into one. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/CMakeLists.txt: * wtf/Platform.h: * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp. (WTF::StackTrace::captureStackTrace): (WTF::StackTrace::dump): * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h. (WTF::StackTrace::StackTrace): (WTF::StackTrace::stack): (WTF::StackTrace::DemangleEntry::mangledName): (WTF::StackTrace::DemangleEntry::demangledName): (WTF::StackTrace::DemangleEntry::DemangleEntry): * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h. (WTF::SystemFree::operator()): Canonical link: https://commits.webkit.org/188119@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-25 02:53:49 +00:00
} // namespace WTF