Changeset 70232 in webkit
- Timestamp:
- Oct 21, 2010 5:31:37 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 deleted
- 26 edited
- 4 copied
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/Android.jscbindings.mk
r70047 r70232 167 167 bindings/js/ScriptArray.cpp \ 168 168 bindings/js/ScriptCachedFrameData.cpp \ 169 bindings/js/ScriptCallFrame.cpp \ 170 bindings/js/ScriptCallStack.cpp \ 169 bindings/js/ScriptCallStackFactory.cpp \ 171 170 bindings/js/ScriptController.cpp \ 172 171 bindings/js/ScriptEventListener.cpp \ -
trunk/WebCore/Android.v8bindings.mk
r69148 r70232 50 50 bindings/v8/ScopedDOMDataStore.cpp \ 51 51 bindings/v8/ScriptArray.cpp \ 52 bindings/v8/ScriptCallFrame.cpp \ 53 bindings/v8/ScriptCallStack.cpp \ 52 bindings/v8/ScriptCallStackFactory.cpp \ 54 53 bindings/v8/ScriptController.cpp \ 55 54 bindings/v8/ScriptEventListener.cpp \ -
trunk/WebCore/CMakeLists.txt
r70140 r70232 687 687 bindings/js/ScheduledAction.cpp 688 688 bindings/js/ScriptCachedFrameData.cpp 689 bindings/js/ScriptCallFrame.cpp 690 bindings/js/ScriptCallStack.cpp 689 bindings/js/ScriptCallStackFactory.cpp 691 690 bindings/js/ScriptController.cpp 692 691 bindings/js/ScriptDebugServer.cpp … … 1124 1123 inspector/InspectorStorageAgent.cpp 1125 1124 inspector/InspectorTimelineAgent.cpp 1125 inspector/ScriptArguments.cpp 1126 1126 inspector/ScriptBreakpoint.cpp 1127 inspector/ScriptCallFrame.cpp 1128 inspector/ScriptCallStack.cpp 1127 1129 inspector/TimelineRecordFactory.cpp 1128 1130 -
trunk/WebCore/ChangeLog
r70231 r70232 1 2010-10-21 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: decouple ScriptArguments from ScriptCallStack 6 https://bugs.webkit.org/show_bug.cgi?id=48058 7 8 ScriptCallFrame and ScriptCallStack are now the same for both JSC and V8. 9 The factory functions that allow to create ScriptCallStack from VM-specific 10 objects are defined in ScriptCallStackFactory.cpp. 11 12 ScriptArguments class is used for passing arguments from JS code to the native 13 part. 14 15 No new tests. This refactoring is covered with existing Console tests. 16 17 * WebCore.gypi: 18 * WebCore.xcodeproj/project.pbxproj: 19 * bindings/js/ScriptCallFrame.cpp: Removed. 20 * bindings/js/ScriptCallFrame.h: Removed. 21 * bindings/js/ScriptCallStack.cpp: Removed. 22 * bindings/js/ScriptCallStack.h: Removed. 23 * bindings/js/ScriptCallStackFactory.cpp: Added. 24 (WebCore::createScriptCallStack): 25 (WebCore::createScriptArguments): 26 (WebCore::ScriptCallStack::stackTrace): 27 * bindings/js/ScriptCallStackFactory.h: Added. 28 * bindings/js/ScriptState.h: 29 (WebCore::ScriptStateProtectedPtr::get): 30 * bindings/scripts/CodeGeneratorJS.pm: 31 * bindings/scripts/CodeGeneratorV8.pm: 32 * bindings/v8/ScriptCallFrame.cpp: Removed. 33 * bindings/v8/ScriptCallFrame.h: Removed. 34 * bindings/v8/ScriptCallStack.cpp: Removed. 35 * bindings/v8/ScriptCallStack.h: Removed. 36 * bindings/v8/ScriptCallStackFactory.cpp: Added. 37 (WebCore::toScriptCallFrame): 38 (WebCore::toScriptCallFramesVector): 39 (WebCore::createScriptCallStack): 40 (WebCore::createScriptArguments): 41 (WebCore::ScriptCallStack::stackTrace): 42 * bindings/v8/ScriptCallStackFactory.h: Added. 43 * bindings/v8/ScriptController.cpp: 44 (WebCore::ScriptController::setCaptureCallStackForUncaughtExceptions): 45 * bindings/v8/ScriptState.h: 46 (WebCore::ScriptStateProtectedPtr::get): 47 * bindings/v8/V8ConsoleMessage.cpp: 48 (WebCore::V8ConsoleMessage::handler): 49 (WebCore::V8ConsoleMessage::dispatchNow): 50 * bindings/v8/V8ConsoleMessage.h: 51 * bindings/v8/custom/V8ConsoleCustom.cpp: 52 (WebCore::V8Console::traceCallback): 53 (WebCore::V8Console::assertCallback): 54 * inspector/ConsoleMessage.cpp: 55 (WebCore::ConsoleMessage::ConsoleMessage): 56 (WebCore::ConsoleMessage::addToFrontend): 57 (WebCore::ConsoleMessage::updateRepeatCountInConsole): 58 (WebCore::ConsoleMessage::isEqual): 59 * inspector/ConsoleMessage.h: 60 * inspector/InspectorController.cpp: 61 (WebCore::InspectorController::addMessageToConsole): 62 (WebCore::InspectorController::startGroup): 63 * inspector/InspectorController.h: 64 * inspector/ScriptArguments.cpp: Added. 65 (WebCore::ScriptArguments::ScriptArguments): 66 (WebCore::ScriptArguments::~ScriptArguments): 67 (WebCore::ScriptArguments::argumentAt): 68 (WebCore::ScriptArguments::globalState): 69 (WebCore::ScriptArguments::getFirstArgumentAsString): 70 (WebCore::ScriptArguments::isEqual): 71 * inspector/ScriptArguments.h: Added. 72 (WebCore::ScriptArguments::argumentCount): 73 * inspector/ScriptCallFrame.cpp: Added. 74 (WebCore::ScriptCallFrame::ScriptCallFrame): 75 (WebCore::ScriptCallFrame::~ScriptCallFrame): 76 (WebCore::ScriptCallFrame::isEqual): 77 (WebCore::ScriptCallFrame::buildInspectorObject): 78 * inspector/ScriptCallFrame.h: Added. 79 (WebCore::ScriptCallFrame::functionName): 80 (WebCore::ScriptCallFrame::sourceURL): 81 (WebCore::ScriptCallFrame::lineNumber): 82 * inspector/ScriptCallStack.cpp: Added. 83 (WebCore::ScriptCallStack::ScriptCallStack): 84 (WebCore::ScriptCallStack::~ScriptCallStack): 85 (WebCore::ScriptCallStack::at): 86 (WebCore::ScriptCallStack::size): 87 (WebCore::ScriptCallStack::isEqual): 88 (WebCore::ScriptCallStack::buildInspectorObject): 89 * inspector/ScriptCallStack.h: Added. 90 * page/Console.cpp: 91 (WebCore::Console::addMessage): 92 (WebCore::Console::debug): 93 (WebCore::Console::error): 94 (WebCore::Console::info): 95 (WebCore::Console::log): 96 (WebCore::Console::dir): 97 (WebCore::Console::dirxml): 98 (WebCore::Console::trace): 99 (WebCore::Console::assertCondition): 100 (WebCore::Console::count): 101 (WebCore::Console::markTimeline): 102 (WebCore::Console::profile): 103 (WebCore::Console::profileEnd): 104 (WebCore::Console::timeEnd): 105 (WebCore::Console::group): 106 (WebCore::Console::groupCollapsed): 107 (WebCore::Console::shouldCaptureFullStackTrace): 108 (WebCore::Console::warn): 109 * page/Console.h: 110 1 111 2010-10-21 Pavel Feldman <pfeldman@chromium.org> 2 112 -
trunk/WebCore/GNUmakefile.am
r70223 r70232 817 817 WebCore/bindings/js/ScriptCachedFrameData.cpp \ 818 818 WebCore/bindings/js/ScriptCachedFrameData.h \ 819 WebCore/bindings/js/ScriptCallFrame.cpp \ 820 WebCore/bindings/js/ScriptCallFrame.h \ 821 WebCore/bindings/js/ScriptCallStack.cpp \ 822 WebCore/bindings/js/ScriptCallStack.h \ 819 WebCore/bindings/js/ScriptCallStackFactory.cpp \ 820 WebCore/bindings/js/ScriptCallStackFactory.h \ 823 821 WebCore/bindings/js/ScriptController.cpp \ 824 822 WebCore/bindings/js/ScriptController.h \ … … 1852 1850 WebCore/inspector/InspectorValues.h \ 1853 1851 WebCore/inspector/InspectorWorkerResource.h \ 1852 WebCore/inspector/ScriptArguments.cpp \ 1853 WebCore/inspector/ScriptArguments.h \ 1854 1854 WebCore/inspector/ScriptBreakpoint.cpp \ 1855 1855 WebCore/inspector/ScriptBreakpoint.h \ 1856 WebCore/inspector/ScriptCallFrame.cpp \ 1857 WebCore/inspector/ScriptCallFrame.h \ 1858 WebCore/inspector/ScriptCallStack.cpp \ 1859 WebCore/inspector/ScriptCallStack.h \ 1856 1860 WebCore/inspector/ScriptDebugListener.h \ 1857 1861 WebCore/inspector/ScriptGCEventListener.h \ -
trunk/WebCore/WebCore.gypi
r70223 r70232 700 700 'bindings/js/ScriptCachedFrameData.cpp', 701 701 'bindings/js/ScriptCachedFrameData.h', 702 'bindings/js/ScriptCallFrame.cpp',703 'bindings/js/ScriptCallFrame.h',704 'bindings/js/ScriptCallStack.cpp',705 'bindings/js/ScriptCallStack.h',706 702 'bindings/js/ScriptController.cpp', 707 703 'bindings/js/ScriptController.h', … … 870 866 'bindings/v8/ScopedDOMDataStore.h', 871 867 'bindings/v8/ScriptCachedFrameData.h', 872 'bindings/v8/ScriptCallFrame.cpp', 873 'bindings/v8/ScriptCallFrame.h', 874 'bindings/v8/ScriptCallStack.cpp', 875 'bindings/v8/ScriptCallStack.h', 868 'bindings/v8/ScriptCallStackFactory.cpp', 869 'bindings/v8/ScriptCallStackFactory.h', 876 870 'bindings/v8/ScriptController.cpp', 877 871 'bindings/v8/ScriptController.h', … … 1954 1948 'inspector/ScriptBreakpoint.cpp', 1955 1949 'inspector/ScriptBreakpoint.h', 1950 'inspector/ScriptArguments.cpp', 1951 'inspector/ScriptArguments.h', 1952 'inspector/ScriptCallFrame.cpp', 1953 'inspector/ScriptCallFrame.h', 1954 'inspector/ScriptCallStack.cpp', 1955 'inspector/ScriptCallStack.h', 1956 1956 'inspector/ScriptDebugListener.h', 1957 1957 'inspector/ScriptGCEventListener.h', -
trunk/WebCore/WebCore.pro
r70223 r70232 352 352 # bindings/v8/ScriptArray.cpp \ 353 353 bindings/v8/ScriptCachedFrameData.cpp \ 354 bindings/v8/ScriptCallFrame.cpp \ 355 bindings/v8/ScriptCallStack.cpp \ 354 bindings/v8/ScriptCallStackFactory.cpp \ 356 355 bindings/ScriptControllerBase.cpp \ 357 356 bindings/v8/ScriptController.cpp \ … … 575 574 bindings/js/JSWorkerContextErrorHandler.cpp \ 576 575 bindings/js/ScriptCachedFrameData.cpp \ 577 bindings/js/ScriptCallFrame.cpp \ 578 bindings/js/ScriptCallStack.cpp \ 576 bindings/js/ScriptCallStackFactory.cpp \ 579 577 bindings/js/ScriptController.cpp \ 580 578 bindings/js/ScriptDebugServer.cpp \ … … 1013 1011 inspector/InspectorTimelineAgent.cpp \ 1014 1012 inspector/InspectorValues.cpp \ 1013 inspector/ScriptArguments.cpp \ 1015 1014 inspector/ScriptBreakpoint.cpp \ 1015 inspector/ScriptCallFrame.cpp \ 1016 inspector/ScriptCallStack.cpp \ 1016 1017 inspector/TimelineRecordFactory.cpp \ 1017 1018 loader/archive/ArchiveFactory.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r70223 r70232 60395 60395 </File> 60396 60396 <File 60397 RelativePath="..\bindings\js\ScriptCall Frame.cpp"60397 RelativePath="..\bindings\js\ScriptCallStackFactory.cpp" 60398 60398 > 60399 60399 <FileConfiguration … … 60447 60447 </File> 60448 60448 <File 60449 RelativePath="..\bindings\js\ScriptCallFrame.h" 60450 > 60451 </File> 60452 <File 60453 RelativePath="..\bindings\js\ScriptCallStack.cpp" 60454 > 60455 <FileConfiguration 60456 Name="Debug|Win32" 60457 ExcludedFromBuild="true" 60458 > 60459 <Tool 60460 Name="VCCLCompilerTool" 60461 /> 60462 </FileConfiguration> 60463 <FileConfiguration 60464 Name="Release|Win32" 60465 ExcludedFromBuild="true" 60466 > 60467 <Tool 60468 Name="VCCLCompilerTool" 60469 /> 60470 </FileConfiguration> 60471 <FileConfiguration 60472 Name="Debug_Internal|Win32" 60473 ExcludedFromBuild="true" 60474 > 60475 <Tool 60476 Name="VCCLCompilerTool" 60477 /> 60478 </FileConfiguration> 60479 <FileConfiguration 60480 Name="Debug_Cairo|Win32" 60481 ExcludedFromBuild="true" 60482 > 60483 <Tool 60484 Name="VCCLCompilerTool" 60485 /> 60486 </FileConfiguration> 60487 <FileConfiguration 60488 Name="Release_Cairo|Win32" 60489 ExcludedFromBuild="true" 60490 > 60491 <Tool 60492 Name="VCCLCompilerTool" 60493 /> 60494 </FileConfiguration> 60495 <FileConfiguration 60496 Name="Debug_All|Win32" 60497 ExcludedFromBuild="true" 60498 > 60499 <Tool 60500 Name="VCCLCompilerTool" 60501 /> 60502 </FileConfiguration> 60503 </File> 60504 <File 60505 RelativePath="..\bindings\js\ScriptCallStack.h" 60449 RelativePath="..\bindings\js\ScriptCallStackFactory.h" 60506 60450 > 60507 60451 </File> … … 63396 63340 </File> 63397 63341 <File 63342 RelativePath="..\inspector\ScriptArguments.cpp" 63343 > 63344 </File> 63345 <File 63346 RelativePath="..\inspector\ScriptArguments.h" 63347 > 63348 </File> 63349 <File 63398 63350 RelativePath="..\inspector\ScriptBreakpoint.cpp" 63399 63351 > … … 63401 63353 <File 63402 63354 RelativePath="..\inspector\ScriptBreakpoint.h" 63355 > 63356 </File> 63357 <File 63358 RelativePath="..\inspector\ScriptCallFrame.cpp" 63359 > 63360 </File> 63361 <File 63362 RelativePath="..\inspector\ScriptCallFrame.h" 63363 > 63364 </File> 63365 <File 63366 RelativePath="..\inspector\ScriptCallStack.cpp" 63367 > 63368 </File> 63369 <File 63370 RelativePath="..\inspector\ScriptCallStack.h" 63403 63371 > 63404 63372 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r70229 r70232 5460 5460 F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; }; 5461 5461 F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */ = {isa = PBXBuildFile; fileRef = F375CC061150D300008DDB81 /* InspectorWorkerResource.h */; }; 5462 F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */; }; 5463 F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; }; 5464 F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; }; 5465 F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; }; 5462 5466 F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; }; 5463 5467 F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; }; … … 11486 11490 F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; }; 11487 11491 F375CC061150D300008DDB81 /* InspectorWorkerResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWorkerResource.h; sourceTree = "<group>"; }; 11492 F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStackFactory.cpp; sourceTree = "<group>"; }; 11493 F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; }; 11494 F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; }; 11495 F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; }; 11488 11496 F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; }; 11489 11497 F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; }; … … 12257 12265 1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */, 12258 12266 BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */, 12267 F39BE95912673BF400E0A674 /* ScriptArguments.cpp */, 12268 F39BE95A12673BF400E0A674 /* ScriptArguments.h */, 12259 12269 200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */, 12260 12270 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */, 12271 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */, 12272 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */, 12273 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */, 12274 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */, 12261 12275 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */, 12262 12276 9FA37EEF1172FD4100C4CD55 /* ScriptProfile.idl */, … … 16774 16788 41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */, 16775 16789 41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */, 16776 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */, 16777 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */, 16778 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */, 16779 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */, 16790 F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */, 16791 F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */, 16780 16792 93B70D5309EB0C7C009D8468 /* ScriptController.cpp */, 16781 16793 93B70D5409EB0C7C009D8468 /* ScriptController.h */, … … 20553 20565 5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */, 20554 20566 BCEC01BE0C274DAC009F4EC9 /* Screen.h in Headers */, 20567 F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */, 20555 20568 A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */, 20556 20569 7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */, … … 21127 21140 081CDFBA126ECFDB00D215CA /* DeprecatedSVGAnimatedTemplate.h in Headers */, 21128 21141 081CDFBF126ECFE800D215CA /* SVGAnimatedPropertySynchronizer.h in Headers */, 21142 F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */, 21129 21143 088A0E04126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h in Headers */, 21130 21144 088A0E05126EF1DB00978F7A /* SVGAnimatedProperty.h in Headers */, … … 23180 23194 BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */, 23181 23195 A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */, 23196 F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */, 23182 23197 200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */, 23183 23198 41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */, … … 23688 23703 E18772F1126E2629003DD586 /* Language.cpp in Sources */, 23689 23704 7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */, 23705 F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */, 23690 23706 ); 23691 23707 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp
r70047 r70232 142 142 #include "ScheduledAction.cpp" 143 143 #include "ScriptCachedFrameData.cpp" 144 #include "ScriptCallFrame.cpp" 145 #include "ScriptCallStack.cpp" 144 #include "ScriptCallStackFactory.cpp" 146 145 #include "ScriptController.cpp" 147 146 #include "ScriptControllerWin.cpp" -
trunk/WebCore/bindings/js/ScriptCallStackFactory.cpp
r70231 r70232 1 1 /* 2 * Copyright (c) 20 08,Google Inc. All rights reserved.2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #include "config.h" 32 #include "ScriptCallStackFactory.h" 33 34 #include "JSDOMBinding.h" 35 #include "ScriptArguments.h" 36 #include "ScriptCallFrame.h" 32 37 #include "ScriptCallStack.h" 33 38 #include "ScriptValue.h" 34 39 #include <interpreter/CallFrame.h> 35 40 #include <interpreter/Interpreter.h> 41 #include <runtime/ArgList.h> 36 42 #include <runtime/JSFunction.h> 43 #include <runtime/JSGlobalData.h> 37 44 #include <runtime/JSValue.h> 38 45 #include <runtime/UString.h> 39 #include <runtime/JSGlobalData.h>40 46 41 47 using namespace JSC; … … 43 49 namespace WebCore { 44 50 45 ScriptCallStack::ScriptCallStack(ExecState* exec, unsigned skipArgumentCount) 46 : m_initialized(false) 47 , m_exec(exec) 48 , m_caller(0) 51 PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) 49 52 { 50 int signedLineNumber; 51 intptr_t sourceID; 52 UString urlString; 53 JSValue function; 53 Vector<ScriptCallFrame> frames; 54 CallFrame* callFrame = exec; 55 while (true) { 56 ASSERT(callFrame); 57 int signedLineNumber; 58 intptr_t sourceID; 59 UString urlString; 60 JSValue function; 54 61 55 exec->interpreter()->retrieveLastCaller(exec, signedLineNumber, sourceID, urlString, function); 56 57 unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0; 58 59 if (function) { 60 m_caller = asFunction(function); 61 m_frames.append(ScriptCallFrame(m_caller->name(m_exec), urlString, lineNumber, m_exec, skipArgumentCount)); 62 } else { 63 // Caller is unknown, but we should still add the frame, because 64 // something called us, and gave us arguments. 65 m_frames.append(ScriptCallFrame(UString(), urlString, lineNumber, m_exec, skipArgumentCount)); 62 exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function); 63 UString functionName; 64 if (function) 65 functionName = asFunction(function)->name(exec); 66 else { 67 // Caller is unknown, but if frames is empty we should still add the frame, because 68 // something called us, and gave us arguments. 69 if (!frames.isEmpty()) 70 break; 71 } 72 unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0; 73 frames.append(ScriptCallFrame(ustringToString(functionName), ustringToString(urlString), lineNumber)); 74 if (!function || frames.size() == maxStackSize) 75 break; 76 callFrame = callFrame->callerFrame(); 66 77 } 78 return new ScriptCallStack(frames); 67 79 } 68 80 69 ScriptCallStack::~ScriptCallStack()81 PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount) 70 82 { 71 } 72 73 const ScriptCallFrame &ScriptCallStack::at(unsigned index) 74 { 75 // First frame is pre-populated in constructor, so don't trigger 76 // initialization unless looking beyond the first frame. 77 if (index > 0) 78 initialize(); 79 ASSERT(m_frames.size() > index); 80 return m_frames[index]; 81 } 82 83 unsigned ScriptCallStack::size() 84 { 85 initialize(); 86 return m_frames.size(); 87 } 88 89 void ScriptCallStack::initialize() 90 { 91 if (!m_caller || m_initialized) 92 return; 93 94 int signedLineNumber; 95 intptr_t sourceID; 96 UString urlString; 97 JSValue function; 98 // callFrame must exist if m_caller is not null. 99 CallFrame* callFrame = m_exec->callerFrame(); 100 while (true) { 101 ASSERT(callFrame); 102 m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function); 103 if (!function) 104 break; 105 JSFunction* jsFunction = asFunction(function); 106 unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0; 107 m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0)); 108 callFrame = callFrame->callerFrame(); 109 } 110 m_initialized = true; 83 Vector<ScriptValue> arguments; 84 size_t argumentCount = exec->argumentCount(); 85 for (size_t i = skipArgumentCount; i < argumentCount; ++i) 86 arguments.append(ScriptValue(exec->argument(i))); 87 return new ScriptArguments(exec, arguments); 111 88 } 112 89 -
trunk/WebCore/bindings/js/ScriptCallStackFactory.h
r70231 r70232 1 1 /* 2 * Copyright (c) 20 08,Google Inc. All rights reserved.2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #i nclude "config.h"32 # include "ScriptCallFrame.h"31 #ifndef ScriptCallStackFactory_h 32 #define ScriptCallStackFactory_h 33 33 34 #include <runtime/ArgList.h> 35 #include <runtime/UString.h> 34 #include <wtf/PassOwnPtr.h> 36 35 37 using namespace JSC; 36 namespace JSC { 37 class ExecState; 38 } 38 39 39 40 namespace WebCore { 40 41 41 ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount) 42 : m_functionName(ustringToString(functionName)) 43 , m_sourceURL(ustringToString(urlString)) 44 , m_lineNumber(lineNumber) 45 { 46 if (!exec) 47 return; 48 size_t argumentCount = exec->argumentCount(); 49 for (size_t i = skipArgumentCount; i < argumentCount; ++i) 50 m_arguments.append(ScriptValue(exec->argument(i))); 51 } 42 class ScriptArguments; 43 class ScriptCallStack; 52 44 53 ScriptCallFrame::~ScriptCallFrame() 54 { 55 } 56 57 const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const 58 { 59 ASSERT(m_arguments.size() > index); 60 return m_arguments[index]; 61 } 45 PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); 46 PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); 62 47 63 48 } // namespace WebCore 49 50 #endif // ScriptCallStackFactory_h -
trunk/WebCore/bindings/js/ScriptState.h
r56708 r70232 53 53 ScriptStateProtectedPtr() { } 54 54 ScriptStateProtectedPtr(ScriptState* scriptState) : m_globalObject(scriptState->lexicalGlobalObject()) { } 55 ScriptState* get() 55 ScriptState* get() const 56 56 { 57 57 if (m_globalObject) -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r70223 r70232 1967 1967 1968 1968 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 1969 push(@implContent, " ScriptCallStack callStack(exec, $numParameters);\n"); 1969 push(@implContent, " OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n"); 1970 push(@implContent, " size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n"); 1971 push(@implContent, " OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n"); 1972 $implIncludes{"ScriptArguments.h"} = 1; 1970 1973 $implIncludes{"ScriptCallStack.h"} = 1; 1974 $implIncludes{"ScriptCallStackFactory.h"} = 1; 1971 1975 } 1972 1976 … … 2358 2362 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 2359 2363 $functionString .= ", " if $paramIndex; 2360 ++$paramIndex;2361 $functionString .= " &callStack";2364 $paramIndex += 2; 2365 $functionString .= "scriptArguments.release(), callStack.release()"; 2362 2366 } 2363 2367 -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r70223 r70232 1305 1305 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 1306 1306 push(@implContentDecls, <<END); 1307 OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, $numParameters)); 1307 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters)); 1308 size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; 1309 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); 1308 1310 if (!callStack) 1309 1311 return v8::Undefined(); 1310 1312 END 1313 $implIncludes{"ScriptArguments.h"} = 1; 1311 1314 $implIncludes{"ScriptCallStack.h"} = 1; 1315 $implIncludes{"ScriptCallStackFactory.h"} = 1; 1312 1316 } 1313 1317 if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) { … … 2720 2724 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 2721 2725 $functionString .= ", " if $index; 2722 $functionString .= " callStack.get()";2723 $index ++;2726 $functionString .= "scriptArguments.release(), callStack.release()"; 2727 $index += 2; 2724 2728 } 2725 2729 -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r67421 r70232 32 32 #include "JSlog.h" 33 33 #include "KURL.h" 34 #include "ScriptArguments.h" 34 35 #include "ScriptCallStack.h" 36 #include "ScriptCallStackFactory.h" 35 37 #include "SerializedScriptValue.h" 36 38 #include "TestObj.h" … … 995 997 TestObj* imp = static_cast<TestObj*>(castedThis->impl()); 996 998 ExceptionCode ec = 0; 997 ScriptCallStack callStack(exec, 1); 999 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1)); 1000 size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; 1001 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); 998 1002 log* intArg = tolog(exec->argument(0)); 999 1003 if (exec->hadException()) 1000 1004 return JSValue::encode(jsUndefined()); 1001 1005 1002 imp->customArgsAndException(intArg, &callStack, ec);1006 imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec); 1003 1007 setDOMException(exec, ec); 1004 1008 return JSValue::encode(jsUndefined()); -
trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r67421 r70232 27 27 #include "IDBKey.h" 28 28 #include "RuntimeEnabledFeatures.h" 29 #include "ScriptArguments.h" 29 30 #include "ScriptCallStack.h" 31 #include "ScriptCallStackFactory.h" 30 32 #include "SerializedScriptValue.h" 31 33 #include "V8Binding.h" … … 706 708 ExceptionCode ec = 0; 707 709 { 708 OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); 710 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1)); 711 size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; 712 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); 709 713 if (!callStack) 710 714 return v8::Undefined(); 711 715 EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); 712 imp->customArgsAndException(intArg, callStack.get(), ec);716 imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec); 713 717 if (UNLIKELY(ec)) 714 718 goto fail; -
trunk/WebCore/bindings/v8/ScriptCallStackFactory.cpp
r70231 r70232 1 1 /* 2 * Copyright ( C) 2008, 2009Google Inc. All rights reserved.3 * 2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 30 30 31 31 #include "config.h" 32 #include "ScriptCallStack .h"32 #include "ScriptCallStackFactory.h" 33 33 34 34 #include "InspectorValues.h" 35 #include "ScriptController.h" 36 #include "ScriptDebugServer.h" 35 #include "ScriptArguments.h" 36 #include "ScriptCallFrame.h" 37 #include "ScriptCallStack.h" 37 38 #include "ScriptScope.h" 39 #include "ScriptValue.h" 38 40 #include "V8Binding.h" 39 41 … … 42 44 namespace WebCore { 43 45 44 static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName)46 static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame) 45 47 { 46 ASSERT(!frame.IsEmpty());48 String sourceName; 47 49 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL()); 50 if (!sourceNameValue.IsEmpty()) 51 sourceName = toWebCoreString(sourceNameValue); 52 53 String functionName; 48 54 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); 49 *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue); 50 *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue); 51 *sourceLineNumber = frame->GetLineNumber(); 55 if (!functionNameValue.IsEmpty()) 56 functionName = toWebCoreString(functionNameValue); 57 58 int sourceLineNumber = frame->GetLineNumber(); 59 return ScriptCallFrame(functionName, sourceName, sourceLineNumber); 52 60 } 53 61 54 static void getTopFrameLocation(v8::Handle<v8::StackTrace> stackTrace, String* sourceName, int* sourceLineNumber, String* functionName)62 static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<ScriptCallFrame>& scriptCallFrames, size_t maxStackSize) 55 63 { 56 if (stackTrace->GetFrameCount() <= 0) { 57 // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example. 58 // Fallback to setting lineNumber to 0, and source and function name to "undefined". 59 *sourceName = "undefined"; 60 *sourceLineNumber = 0; 61 *functionName = "undefined"; 62 } else { 63 v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0); 64 getFrameLocation(frame, sourceName, sourceLineNumber, functionName); 65 } 66 } 67 68 static PassOwnPtr<ScriptCallFrame> toScriptCallFrame(v8::Handle<v8::StackFrame> frame) 69 { 70 String sourceName; 71 int sourceLineNumber; 72 String functionName; 73 getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName); 74 return new ScriptCallFrame(functionName, sourceName, sourceLineNumber); 75 } 76 77 static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames) 78 { 64 // TODO(yurys): remove this??? 79 65 v8::Context::Scope contextScope(context); 80 66 int frameCount = stackTrace->GetFrameCount(); 67 if (frameCount > static_cast<int>(maxStackSize)) 68 frameCount = maxStackSize; 81 69 for (int i = 0; i < frameCount; i++) { 82 70 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); 83 71 scriptCallFrames.append(toScriptCallFrame(stackFrame)); 84 72 } 73 74 if (!frameCount) { 75 // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example. 76 // Fallback to setting lineNumber to 0, and source and function name to "undefined". 77 scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0)); 78 } 85 79 } 86 80 87 const int ScriptCallStack::maxCallStackSizeToCapture = 200; 88 const v8::StackTrace::StackTraceOptions ScriptCallStack::stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>( 89 v8::StackTrace::kLineNumber 90 | v8::StackTrace::kColumnOffset 91 | v8::StackTrace::kScriptNameOrSourceURL 92 | v8::StackTrace::kFunctionName); 81 PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, size_t maxStackSize) 82 { 83 v8::HandleScope scope; 84 v8::Context::Scope contextScope(context); 93 85 86 Vector<ScriptCallFrame> scriptCallFrames; 87 toScriptCallFramesVector(context, stackTrace, scriptCallFrames, maxStackSize); 88 return new ScriptCallStack(scriptCallFrames); 89 } 94 90 95 PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount, int framCountLimit)91 PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize) 96 92 { 97 93 v8::HandleScope scope; 98 94 v8::Local<v8::Context> context = v8::Context::GetCurrent(); 95 // TODO(yurys): remove? 99 96 v8::Context::Scope contextScope(context); 100 v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(framCountLimit, ScriptCallStack::stackTraceOptions)); 101 102 if (stackTrace.IsEmpty()) 103 return 0; 104 105 String sourceName; 106 int sourceLineNumber; 107 String functionName; 108 getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName); 109 110 Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames; 111 if (framCountLimit > 1) 112 toScriptCallFramesVector(context, stackTrace, scriptCallFrames); 113 114 return new ScriptCallStack(ScriptState::forContext(context), new ScriptCallFrame(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount), scriptCallFrames); 97 v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxStackSize, stackTraceOptions)); 98 return createScriptCallStack(context, stackTrace, maxStackSize); 115 99 } 116 100 117 PassOwnPtr<Script CallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace)101 PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount) 118 102 { 119 103 v8::HandleScope scope; 120 Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;121 toScriptCallFramesVector(state->context(), stackTrace, scriptCallFrames);104 v8::Local<v8::Context> context = v8::Context::GetCurrent(); 105 ScriptState* state = ScriptState::forContext(context); 122 106 123 String sourceName; 124 int sourceLineNumber; 125 String functionName; 126 getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName); 107 Vector<ScriptValue> arguments; 108 for (int i = skipArgumentCount; i < v8arguments.Length(); ++i) 109 arguments.append(ScriptValue(v8arguments[i])); 127 110 128 return new Script CallStack(state, new ScriptCallFrame(functionName, sourceName, sourceLineNumber), scriptCallFrames);111 return new ScriptArguments(state, arguments); 129 112 } 130 131 ScriptCallStack::ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)132 : m_topFrame(topFrame)133 , m_scriptState(scriptState)134 {135 m_scriptCallFrames.swap(scriptCallFrames);136 }137 138 ScriptCallStack::~ScriptCallStack()139 {140 }141 142 const ScriptCallFrame& ScriptCallStack::at(unsigned index)143 {144 if (!index && m_topFrame)145 return *m_topFrame;146 return *m_scriptCallFrames.at(index);147 }148 149 unsigned ScriptCallStack::size()150 {151 if (m_scriptCallFrames.isEmpty())152 return 1;153 return m_scriptCallFrames.size();154 }155 156 113 157 114 bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace) -
trunk/WebCore/bindings/v8/ScriptCallStackFactory.h
r70231 r70232 1 1 /* 2 * Copyright (c) 20 08,Google Inc. All rights reserved.2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #i nclude "config.h"32 # include "ScriptCallFrame.h"31 #ifndef ScriptCallStackFactory_h 32 #define ScriptCallStackFactory_h 33 33 34 #include <runtime/ArgList.h> 35 #include <runtime/UString.h> 36 37 using namespace JSC; 34 #include <v8.h> 35 #include <wtf/PassOwnPtr.h> 38 36 39 37 namespace WebCore { 40 38 41 ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount) 42 : m_functionName(ustringToString(functionName)) 43 , m_sourceURL(ustringToString(urlString)) 44 , m_lineNumber(lineNumber) 45 { 46 if (!exec) 47 return; 48 size_t argumentCount = exec->argumentCount(); 49 for (size_t i = skipArgumentCount; i < argumentCount; ++i) 50 m_arguments.append(ScriptValue(exec->argument(i))); 51 } 39 class ScriptState; 52 40 53 ScriptCallFrame::~ScriptCallFrame() 54 { 55 } 41 const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>( 42 v8::StackTrace::kLineNumber 43 | v8::StackTrace::kColumnOffset 44 | v8::StackTrace::kScriptNameOrSourceURL 45 | v8::StackTrace::kFunctionName); 56 46 57 const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const 58 { 59 ASSERT(m_arguments.size() > index); 60 return m_arguments[index]; 61 } 47 class ScriptArguments; 48 class ScriptCallStack; 49 50 PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context>, v8::Handle<v8::StackTrace>, size_t maxStackSize); 51 PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize); 52 PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount); 62 53 63 54 } // namespace WebCore 55 56 #endif // ScriptCallStackFactory_h -
trunk/WebCore/bindings/v8/ScriptController.cpp
r70181 r70232 36 36 #include "Document.h" 37 37 #include "ScriptCallStack.h" 38 #include "ScriptCallStackFactory.h" 38 39 #include "ScriptableDocumentParser.h" 39 40 #include "DOMWindow.h" … … 469 470 void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value) 470 471 { 471 v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);472 v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions); 472 473 } 473 474 #endif -
trunk/WebCore/bindings/v8/ScriptState.h
r56708 r70232 96 96 } 97 97 } 98 ScriptState* get() { return m_scriptState; }98 ScriptState* get() const { return m_scriptState; } 99 99 private: 100 100 ScriptState* m_scriptState; -
trunk/WebCore/bindings/v8/V8ConsoleMessage.cpp
r63746 r70232 38 38 #include "Page.h" 39 39 #include "ScriptCallStack.h" 40 #include "ScriptCallStackFactory.h" 40 41 #include "V8Binding.h" 41 42 #include "V8Proxy.h" … … 118 119 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) { 119 120 v8::Local<v8::Context> context = v8::Context::GetEntered(); 120 ScriptState* scriptState = ScriptState::forContext(context); 121 callStack = ScriptCallStack::create(scriptState, stackTrace); 121 callStack = createScriptCallStack(context, stackTrace, ScriptCallStack::maxCallStackSizeToCapture); 122 122 } 123 123 … … 126 126 String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName); 127 127 V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber()); 128 consoleMessage.dispatchNow(page, callStack. get());128 consoleMessage.dispatchNow(page, callStack.release()); 129 129 } 130 130 131 void V8ConsoleMessage::dispatchNow(Page* page, ScriptCallStack*callStack)131 void V8ConsoleMessage::dispatchNow(Page* page, PassOwnPtr<ScriptCallStack> callStack) 132 132 { 133 133 ASSERT(page); -
trunk/WebCore/bindings/v8/V8ConsoleMessage.h
r63662 r70232 34 34 #include "PlatformString.h" 35 35 #include <v8.h> 36 #include <wtf/PassOwnPtr.h> 36 37 #include <wtf/Vector.h> 37 38 … … 82 83 const unsigned m_lineNumber; 83 84 84 void dispatchNow(Page*, ScriptCallStack*);85 void dispatchNow(Page*, PassOwnPtr<ScriptCallStack>); 85 86 86 87 // All delayed messages are stored in this vector. If the vector -
trunk/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
r69662 r70232 34 34 35 35 #include "Console.h" 36 #include "ScriptArguments.h" 36 37 #include "ScriptCallStack.h" 38 #include "ScriptCallStackFactory.h" 37 39 #include "ScriptProfile.h" 38 40 #include "V8Binding.h" … … 63 65 INC_STATS("DOM.Console.traceCallback"); 64 66 Console* imp = V8Console::toNative(args.Holder()); 65 v8::HandleScope handleScope; 66 ScriptState* scriptState = ScriptState::current(); 67 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions); 68 OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(scriptState, stackTrace)); 69 imp->trace(callStack.get()); 67 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture)); 68 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 0)); 69 imp->trace(scriptArguments.release(), callStack.release()); 70 70 return v8::Handle<v8::Value>(); 71 71 } … … 75 75 INC_STATS("DOM.Console.assertCallback"); 76 76 Console* imp = V8Console::toNative(args.Holder()); 77 OwnPtr<ScriptCallStack> callStack( ScriptCallStack::create(args, 1,ScriptCallStack::maxCallStackSizeToCapture));77 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture)); 78 78 bool condition = args[0]->BooleanValue(); 79 imp->assertCondition(condition, callStack.get()); 79 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1)); 80 imp->assertCondition(condition, scriptArguments.release(), callStack.release()); 80 81 return v8::Handle<v8::Value>(); 81 82 } -
trunk/WebCore/inspector/ConsoleMessage.cpp
r69799 r70232 34 34 #include "InjectedScript.h" 35 35 #include "InjectedScriptHost.h" 36 #include "InspectorFrontend.h" 36 37 #include "InspectorValues.h" 38 #include "ScriptArguments.h" 37 39 #include "ScriptCallStack.h" 38 40 #include "ScriptValue.h" 39 41 40 #if ENABLE(INSPECTOR)41 #include "InspectorFrontend.h"42 #endif43 44 42 namespace WebCore { 45 46 ConsoleMessage::CallFrame::CallFrame(const ScriptCallFrame& frame)47 : m_functionName(frame.functionName())48 , m_sourceURL(frame.sourceURL())49 , m_lineNumber(frame.lineNumber())50 {51 }52 53 ConsoleMessage::CallFrame::CallFrame()54 : m_lineNumber(0)55 {56 }57 58 bool ConsoleMessage::CallFrame::isEqual(const ConsoleMessage::CallFrame& o) const59 {60 return m_functionName == o.m_functionName61 && m_sourceURL == o.m_sourceURL62 && m_lineNumber == o.m_lineNumber;63 }64 65 #if ENABLE(INSPECTOR)66 PassRefPtr<InspectorObject> ConsoleMessage::CallFrame::buildInspectorObject() const67 {68 RefPtr<InspectorObject> frame = InspectorObject::create();69 frame->setString("functionName", m_functionName);70 frame->setString("sourceURL", m_sourceURL);71 frame->setNumber("lineNumber", m_lineNumber);72 return frame;73 }74 #endif75 43 76 44 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g) … … 86 54 } 87 55 88 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace)56 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, unsigned g) 89 57 : m_source(s) 90 58 , m_type(t) 91 59 , m_level(l) 92 60 , m_message(m) 93 #if ENABLE(INSPECTOR) 94 , m_arguments(callStack->at(0).argumentCount()) 95 , m_scriptState(callStack->globalState()) 96 #endif 97 , m_frames(storeTrace ? callStack->size() : 0) 61 , m_arguments(arguments) 62 , m_callStack(callStack) 98 63 , m_groupLevel(g) 99 64 , m_repeatCount(1) 100 65 { 101 const ScriptCallFrame& lastCaller = callStack->at(0);66 const ScriptCallFrame& lastCaller = m_callStack->at(0); 102 67 m_line = lastCaller.lineNumber(); 103 68 m_url = lastCaller.sourceURL(); 104 69 105 if (storeTrace) {106 for (unsigned i = 0; i < callStack->size(); ++i)107 m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i));108 }109 70 110 #if ENABLE(INSPECTOR) 111 for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) 112 m_arguments[i] = lastCaller.argumentAt(i); 113 #endif 71 bool storeTrace = (t == TraceMessageType || t == UncaughtExceptionMessageType || t == AssertMessageType); 72 if (!storeTrace) 73 m_callStack.clear(); 114 74 } 115 75 116 #if ENABLE(INSPECTOR)117 76 void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost) 118 77 { … … 126 85 jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount)); 127 86 jsonObj->setString("message", m_message); 128 if ( !m_arguments.isEmpty()) {129 InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_ scriptState.get());87 if (m_arguments && m_arguments->argumentCount()) { 88 InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState()); 130 89 if (!injectedScript.hasNoValue()) { 131 90 RefPtr<InspectorArray> jsonArgs = InspectorArray::create(); 132 for (unsigned i = 0; i < m_arguments .size(); ++i) {133 RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments [i]);91 for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) { 92 RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i)); 134 93 if (!inspectorValue) { 135 94 ASSERT_NOT_REACHED(); … … 141 100 } 142 101 } 143 if (!m_frames.isEmpty()) { 144 RefPtr<InspectorArray> frames = InspectorArray::create(); 145 for (unsigned i = 0; i < m_frames.size(); i++) 146 frames->pushObject(m_frames.at(i).buildInspectorObject()); 147 jsonObj->setArray("stackTrace", frames); 148 } 102 if (m_callStack) 103 jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject()); 149 104 frontend->addConsoleMessage(jsonObj); 150 105 } … … 154 109 frontend->updateConsoleMessageRepeatCount(m_repeatCount); 155 110 } 156 #endif // ENABLE(INSPECTOR)157 111 158 112 bool ConsoleMessage::isEqual(ConsoleMessage* msg) const 159 113 { 160 #if ENABLE(INSPECTOR) 161 if (msg->m_arguments.size() != m_arguments.size()) 162 return false; 163 if (!msg->m_scriptState.get() && msg->m_arguments.size()) { 164 ASSERT_NOT_REACHED(); 165 return false; 166 } 167 168 for (size_t i = 0; i < m_arguments.size(); ++i) { 169 if (!m_arguments[i].isEqual(msg->m_scriptState.get(), msg->m_arguments[i])) 114 if (m_arguments) { 115 if (!m_arguments->isEqual(msg->m_arguments.get())) 170 116 return false; 171 } 172 #endif // ENABLE(INSPECTOR) 173 174 size_t frameCount = msg->m_frames.size(); 175 if (frameCount != m_frames.size()) 117 } else if (msg->m_arguments) 176 118 return false; 177 119 178 for (size_t i = 0; i < frameCount; ++i) {179 if (!m_ frames[i].isEqual(msg->m_frames[i]))120 if (m_callStack) { 121 if (!m_callStack->isEqual(msg->m_callStack.get())) 180 122 return false; 181 } 123 } else if (msg->m_callStack) 124 return false; 182 125 183 126 return msg->m_source == m_source -
trunk/WebCore/inspector/ConsoleMessage.h
r69799 r70232 2 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 4 * Copyright (C) 2009 Google Inc. All rights reserved.4 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "Console.h" 35 #include "KURL.h"36 35 #include "ScriptState.h" 37 36 … … 42 41 class InspectorFrontend; 43 42 class InspectorObject; 43 class ScriptArguments; 44 44 class ScriptCallFrame; 45 45 class ScriptCallStack; … … 49 49 public: 50 50 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g); 51 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, ScriptCallStack*, unsigned g, bool storeTrace = false);51 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, unsigned g); 52 52 53 #if ENABLE(INSPECTOR)54 53 void addToFrontend(InspectorFrontend*, InjectedScriptHost*); 55 54 void updateRepeatCountInConsole(InspectorFrontend* frontend); 56 #endif57 55 void incrementCount() { ++m_repeatCount; } 58 56 bool isEqual(ConsoleMessage* msg) const; … … 62 60 63 61 private: 64 class CallFrame {65 public:66 explicit CallFrame(const ScriptCallFrame& frame);67 CallFrame();68 bool isEqual(const CallFrame& o) const;69 #if ENABLE(INSPECTOR)70 PassRefPtr<InspectorObject> buildInspectorObject() const;71 #endif72 73 private:74 String m_functionName;75 String m_sourceURL;76 unsigned m_lineNumber;77 };78 79 62 MessageSource m_source; 80 63 MessageType m_type; 81 64 MessageLevel m_level; 82 65 String m_message; 83 #if ENABLE(INSPECTOR) 84 Vector<ScriptValue> m_arguments; 85 ScriptStateProtectedPtr m_scriptState; 86 #endif 87 Vector<CallFrame> m_frames; 66 OwnPtr<ScriptArguments> m_arguments; 67 OwnPtr<ScriptCallStack> m_callStack; 88 68 unsigned m_line; 89 69 String m_url; -
trunk/WebCore/inspector/InspectorController.cpp
r70143 r70232 83 83 #include "ResourceRequest.h" 84 84 #include "ResourceResponse.h" 85 #include "ScriptArguments.h" 85 86 #include "ScriptCallStack.h" 86 87 #include "ScriptFunctionCall.h" … … 340 341 } 341 342 342 void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message) 343 { 344 if (!enabled()) 345 return; 346 347 bool storeStackTrace = type == TraceMessageType || type == UncaughtExceptionMessageType || type == AssertMessageType; 348 addConsoleMessage(new ConsoleMessage(source, type, level, message, callStack, m_groupLevel, storeStackTrace)); 343 void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 344 { 345 if (!enabled()) 346 return; 347 348 addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack, m_groupLevel)); 349 349 } 350 350 … … 392 392 } 393 393 394 void InspectorController::startGroup( MessageSource source, ScriptCallStack*callStack, bool collapsed)394 void InspectorController::startGroup(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, bool collapsed) 395 395 { 396 396 ++m_groupLevel; 397 397 398 addConsoleMessage(new ConsoleMessage( source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel));398 addConsoleMessage(new ConsoleMessage(JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack, m_groupLevel)); 399 399 } 400 400 -
trunk/WebCore/inspector/InspectorController.h
r69948 r70232 82 82 class ResourceResponse; 83 83 class ResourceError; 84 class ScriptArguments; 84 85 class ScriptCallStack; 85 86 class ScriptProfile; … … 146 147 147 148 void setConsoleMessagesEnabled(bool enabled, bool* newState); 148 void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message);149 void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);149 void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>); 150 void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&); 150 151 void clearConsoleMessages(); 151 152 const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; } … … 233 234 bool stopTiming(const String& title, double& elapsed); 234 235 235 void startGroup( MessageSource source, ScriptCallStack*callFrame, bool collapsed = false);236 void startGroup(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callFrame, bool collapsed = false); 236 237 void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL); 237 238 -
trunk/WebCore/inspector/ScriptArguments.cpp
r70231 r70232 1 1 /* 2 * Copyright ( C) 2008, 2009Google Inc. All rights reserved.3 * 2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 30 30 31 31 #include "config.h" 32 #include "Script CallFrame.h"32 #include "ScriptArguments.h" 33 33 34 #include <v8.h>35 36 #include "PlatformString.h"37 #include "V8Binding.h"38 #include "V8Proxy.h"39 34 #include "ScriptValue.h" 40 35 41 36 namespace WebCore { 42 37 43 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount) 44 : m_functionName(functionName) 45 , m_sourceURL(urlString) 46 , m_lineNumber(lineNumber) 38 ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments) 39 : m_scriptState(scriptState) 47 40 { 48 for (int i = skipArgumentCount; i < arguments.Length(); ++i) 49 m_arguments.append(ScriptValue(arguments[i])); 41 m_arguments.swap(arguments); 50 42 } 51 43 52 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber) 53 : m_functionName(functionName) 54 , m_sourceURL(urlString) 55 , m_lineNumber(lineNumber) 44 ScriptArguments::~ScriptArguments() 56 45 { 57 46 } 58 47 59 ScriptCallFrame::~ScriptCallFrame() 60 { 61 } 62 63 const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const 48 const ScriptValue &ScriptArguments::argumentAt(size_t index) const 64 49 { 65 50 ASSERT(m_arguments.size() > index); … … 67 52 } 68 53 54 ScriptState* ScriptArguments::globalState() const 55 { 56 return m_scriptState.get(); 57 } 58 59 bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined) 60 { 61 if (!argumentCount()) 62 return false; 63 64 const ScriptValue& value = argumentAt(0); 65 if (checkForNullOrUndefined && (value.isNull() || value.isUndefined())) 66 return false; 67 68 if (!globalState()) { 69 ASSERT_NOT_REACHED(); 70 return false; 71 } 72 73 result = value.toString(globalState()); 74 return true; 75 } 76 77 bool ScriptArguments::isEqual(ScriptArguments* other) const 78 { 79 if (!other) 80 return false; 81 82 if (m_arguments.size() != other->m_arguments.size()) 83 return false; 84 if (!globalState() && m_arguments.size()) 85 return false; 86 87 for (size_t i = 0; i < m_arguments.size(); ++i) { 88 if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i])) 89 return false; 90 } 91 return true; 92 } 93 69 94 } // namespace WebCore -
trunk/WebCore/inspector/ScriptArguments.h
r70231 r70232 1 1 /* 2 * Copyright (c) 20 08,Google Inc. All rights reserved.2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #ifndef Script CallFrame_h32 #define Script CallFrame_h31 #ifndef ScriptArguments_h 32 #define ScriptArguments_h 33 33 34 34 #include "PlatformString.h" 35 #include "Script Value.h"35 #include "ScriptState.h" 36 36 #include <wtf/Vector.h> 37 38 namespace JSC {39 class ExecState;40 class UString;41 }42 37 43 38 namespace WebCore { 44 39 45 class ScriptCallFrame { 40 class ScriptValue; 41 42 class ScriptArguments { 46 43 public: 47 Script CallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount);48 ~Script CallFrame();44 ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments); 45 ~ScriptArguments(); 49 46 50 const String& functionName() const { return m_functionName; } 51 const String& sourceURL() const { return m_sourceURL; } 52 unsigned lineNumber() const { return m_lineNumber; } 47 const ScriptValue& argumentAt(size_t) const; 48 size_t argumentCount() const { return m_arguments.size(); } 53 49 54 // argument retrieval methods 55 const ScriptValue& argumentAt(unsigned) const; 56 unsigned argumentCount() const { return m_arguments.size(); } 50 ScriptState* globalState() const; 51 52 bool getFirstArgumentAsString(WTF::String& result, bool checkForNullOrUndefined = false); 53 bool isEqual(ScriptArguments*) const; 57 54 58 55 private: 59 String m_functionName; 60 String m_sourceURL; 61 unsigned m_lineNumber; 62 56 ScriptStateProtectedPtr m_scriptState; 63 57 Vector<ScriptValue> m_arguments; 64 58 }; … … 66 60 } // namespace WebCore 67 61 68 #endif // Script CallFrame_h62 #endif // ScriptArguments_h -
trunk/WebCore/inspector/ScriptCallFrame.cpp
r70231 r70232 1 1 /* 2 * Copyright ( C) 2008, 2009Google Inc. All rights reserved.3 * 2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 32 32 #include "ScriptCallFrame.h" 33 33 34 #include <v8.h> 35 36 #include "PlatformString.h" 37 #include "V8Binding.h" 38 #include "V8Proxy.h" 39 #include "ScriptValue.h" 34 #include "InspectorValues.h" 35 #include <wtf/RefPtr.h> 40 36 41 37 namespace WebCore { 42 38 43 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount) 44 : m_functionName(functionName) 45 , m_sourceURL(urlString) 46 , m_lineNumber(lineNumber) 47 { 48 for (int i = skipArgumentCount; i < arguments.Length(); ++i) 49 m_arguments.append(ScriptValue(arguments[i])); 50 } 51 52 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber) 39 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber) 53 40 : m_functionName(functionName) 54 41 , m_sourceURL(urlString) … … 61 48 } 62 49 63 const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const50 bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const 64 51 { 65 ASSERT(m_arguments.size() > index); 66 return m_arguments[index]; 52 return m_functionName == o.m_functionName 53 && m_sourceURL == o.m_sourceURL 54 && m_lineNumber == o.m_lineNumber; 55 } 56 57 PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const 58 { 59 RefPtr<InspectorObject> frame = InspectorObject::create(); 60 frame->setString("functionName", m_functionName); 61 frame->setString("sourceURL", m_sourceURL); 62 frame->setNumber("lineNumber", m_lineNumber); 63 return frame; 67 64 } 68 65 -
trunk/WebCore/inspector/ScriptCallFrame.h
r70231 r70232 1 1 /* 2 * Copyright (c) 20 08,Google Inc. All rights reserved.2 * Copyright (c) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "PlatformString.h" 35 #include "ScriptValue.h" 36 #include <wtf/Vector.h> 37 38 namespace JSC { 39 class ExecState; 40 class UString; 41 } 35 #include <wtf/PassRefPtr.h> 42 36 43 37 namespace WebCore { 44 38 39 class InspectorObject; 40 45 41 class ScriptCallFrame { 46 42 public: 47 ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount);43 ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber); 48 44 ~ScriptCallFrame(); 49 45 … … 52 48 unsigned lineNumber() const { return m_lineNumber; } 53 49 54 // argument retrieval methods 55 const ScriptValue& argumentAt(unsigned) const; 56 unsigned argumentCount() const { return m_arguments.size(); } 50 bool isEqual(const ScriptCallFrame&) const; 51 PassRefPtr<InspectorObject> buildInspectorObject() const; 57 52 58 53 private: … … 60 55 String m_sourceURL; 61 56 unsigned m_lineNumber; 62 63 Vector<ScriptValue> m_arguments;64 57 }; 65 58 -
trunk/WebCore/inspector/ScriptCallStack.cpp
r70231 r70232 30 30 31 31 #include "config.h" 32 #include "ScriptCall Frame.h"32 #include "ScriptCallStack.h" 33 33 34 #include <runtime/ArgList.h> 35 #include <runtime/UString.h> 36 37 using namespace JSC; 34 #include "InspectorValues.h" 38 35 39 36 namespace WebCore { 40 37 41 ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount) 42 : m_functionName(ustringToString(functionName)) 43 , m_sourceURL(ustringToString(urlString)) 44 , m_lineNumber(lineNumber) 38 ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames) 45 39 { 46 if (!exec) 47 return; 48 size_t argumentCount = exec->argumentCount(); 49 for (size_t i = skipArgumentCount; i < argumentCount; ++i) 50 m_arguments.append(ScriptValue(exec->argument(i))); 40 m_frames.swap(frames); 51 41 } 52 42 53 ScriptCall Frame::~ScriptCallFrame()43 ScriptCallStack::~ScriptCallStack() 54 44 { 55 45 } 56 46 57 const Script Value &ScriptCallFrame::argumentAt(unsigned index) const47 const ScriptCallFrame &ScriptCallStack::at(size_t index) 58 48 { 59 ASSERT(m_arguments.size() > index); 60 return m_arguments[index]; 49 ASSERT(m_frames.size() > index); 50 return m_frames[index]; 51 } 52 53 size_t ScriptCallStack::size() 54 { 55 return m_frames.size(); 56 } 57 58 bool ScriptCallStack::isEqual(ScriptCallStack* o) const 59 { 60 if (!o) 61 return false; 62 63 size_t frameCount = o->m_frames.size(); 64 if (frameCount != m_frames.size()) 65 return false; 66 67 for (size_t i = 0; i < frameCount; ++i) { 68 if (!m_frames[i].isEqual(o->m_frames[i])) 69 return false; 70 } 71 72 return true; 73 } 74 75 PassRefPtr<InspectorArray> ScriptCallStack::buildInspectorObject() const 76 { 77 RefPtr<InspectorArray> frames = InspectorArray::create(); 78 for (size_t i = 0; i < m_frames.size(); i++) 79 frames->pushObject(m_frames.at(i).buildInspectorObject()); 80 return frames; 61 81 } 62 82 -
trunk/WebCore/inspector/ScriptCallStack.h
r70231 r70232 1 1 /* 2 * Copyright (c) 2008, Google Inc. All rights reserved.2 * Copyright (c) 2008, 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "ScriptCallFrame.h" 35 #include "ScriptState.h"36 35 #include <wtf/Noncopyable.h> 37 #include <wtf/RefPtr.h> 38 39 namespace JSC { 40 class ExecState; 41 class JSValue; 42 } 36 #include <wtf/Vector.h> 43 37 44 38 namespace WebCore { 45 39 46 40 class InspectorArray; 47 41 48 class ScriptCallStack : public Noncopyable { 49 public: 50 ScriptCallStack(JSC::ExecState*, unsigned skipArgumentCount = 0); 51 ~ScriptCallStack(); 42 class ScriptCallStack : public Noncopyable { 43 public: 44 static const size_t maxCallStackSizeToCapture = 200; 52 45 53 ScriptState* state() const { return m_exec; } 54 ScriptState* globalState() const { return m_exec->lexicalGlobalObject()->globalExec(); } 55 // frame retrieval methods 56 const ScriptCallFrame &at(unsigned); 57 unsigned size(); 58 static bool stackTrace(int, const RefPtr<InspectorArray>&); 46 ScriptCallStack(Vector<ScriptCallFrame>&); 47 ~ScriptCallStack(); 59 48 60 private:61 void initialize();62 bool m_initialized;49 const ScriptCallFrame &at(size_t); 50 size_t size(); 51 static bool stackTrace(int, const RefPtr<InspectorArray>&); 63 52 64 JSC::ExecState* m_exec; 65 Vector<ScriptCallFrame> m_frames; 66 JSC::JSFunction* m_caller; 67 }; 53 bool isEqual(ScriptCallStack*) const; 54 PassRefPtr<InspectorArray> buildInspectorObject() const; 55 56 private: 57 Vector<ScriptCallFrame> m_frames; 58 }; 68 59 69 60 } // namespace WebCore -
trunk/WebCore/page/Console.cpp
r69662 r70232 42 42 #include "PlatformString.h" 43 43 44 #include "ScriptArguments.h" 44 45 #include "ScriptCallStack.h" 45 46 #include "ScriptProfile.h" … … 78 79 } 79 80 80 static bool getFirstArgumentAsString(ScriptState* scriptState, const ScriptCallFrame& callFrame, String& result, bool checkForNullOrUndefined = false)81 {82 if (!callFrame.argumentCount())83 return false;84 85 const ScriptValue& value = callFrame.argumentAt(0);86 if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))87 return false;88 89 result = value.toString(scriptState);90 return true;91 }92 93 81 static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level) 94 82 { … … 145 133 } 146 134 147 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack) 135 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL) 136 { 137 addMessage(source, type, level, message, lineNumber, sourceURL, 0); 138 } 139 140 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack) 148 141 { 149 142 Page* page = this->page(); … … 156 149 #if ENABLE(INSPECTOR) 157 150 if (callStack) 158 page->inspectorController()->addMessageToConsole(source, type, level, callStack, message);151 page->inspectorController()->addMessageToConsole(source, type, level, message, 0, callStack); 159 152 else 160 153 page->inspectorController()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL); … … 170 163 } 171 164 172 void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack*callStack, bool acceptNoArguments)165 void Console::addMessage(MessageType type, MessageLevel level, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, bool acceptNoArguments) 173 166 { 174 167 Page* page = this->page(); … … 178 171 const ScriptCallFrame& lastCaller = callStack->at(0); 179 172 180 if (!acceptNoArguments && ! lastCaller.argumentCount())173 if (!acceptNoArguments && !arguments->argumentCount()) 181 174 return; 182 175 183 176 String message; 184 if ( getFirstArgumentAsString(callStack->state(), lastCaller,message))177 if (arguments->getFirstArgumentAsString(message)) 185 178 page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); 186 179 187 180 #if ENABLE(INSPECTOR) 188 page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, callStack, message);181 page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, "", arguments, callStack); 189 182 #endif 190 183 … … 195 188 printMessageSourceAndLevelPrefix(JSMessageSource, level); 196 189 197 for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) {190 for (unsigned i = 0; i < arguments->argumentCount(); ++i) { 198 191 String argAsString; 199 if ( lastCaller.argumentAt(i).getString(callStack->state(), argAsString))192 if (arguments->argumentAt(i).getString(arguments->globalState(), argAsString)) 200 193 printf(" %s", argAsString.utf8().data()); 201 194 } … … 203 196 } 204 197 205 void Console::debug( ScriptCallStack*callStack)198 void Console::debug(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 206 199 { 207 200 // In Firebug, console.debug has the same behavior as console.log. So we'll do the same. 208 log( callStack);209 } 210 211 void Console::error( ScriptCallStack*callStack)212 { 213 addMessage(LogMessageType, ErrorMessageLevel, callStack);214 } 215 216 void Console::info( ScriptCallStack*callStack)217 { 218 log( callStack);219 } 220 221 void Console::log( ScriptCallStack*callStack)222 { 223 addMessage(LogMessageType, LogMessageLevel, callStack);224 } 225 226 void Console::dir( ScriptCallStack*callStack)227 { 228 addMessage(ObjectMessageType, LogMessageLevel, callStack);229 } 230 231 void Console::dirxml( ScriptCallStack*callStack)201 log(arguments, callStack); 202 } 203 204 void Console::error(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 205 { 206 addMessage(LogMessageType, ErrorMessageLevel, arguments, callStack); 207 } 208 209 void Console::info(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 210 { 211 log(arguments, callStack); 212 } 213 214 void Console::log(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 215 { 216 addMessage(LogMessageType, LogMessageLevel, arguments, callStack); 217 } 218 219 void Console::dir(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 220 { 221 addMessage(ObjectMessageType, LogMessageLevel, arguments, callStack); 222 } 223 224 void Console::dirxml(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 232 225 { 233 226 // The standard behavior of our console.log will print the DOM tree for nodes. 234 log( callStack);235 } 236 237 void Console::trace( ScriptCallStack*callStack)238 { 239 addMessage(TraceMessageType, LogMessageLevel, callStack, true);227 log(arguments, callStack); 228 } 229 230 void Console::trace(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 231 { 232 addMessage(TraceMessageType, LogMessageLevel, arguments, callStack, true); 240 233 241 234 if (!shouldPrintExceptions()) … … 249 242 } 250 243 251 void Console::assertCondition(bool condition, ScriptCallStack*callStack)244 void Console::assertCondition(bool condition, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 252 245 { 253 246 if (condition) 254 247 return; 255 248 256 addMessage(AssertMessageType, ErrorMessageLevel, callStack, true);257 } 258 259 void Console::count( ScriptCallStack*callStack)249 addMessage(AssertMessageType, ErrorMessageLevel, arguments, callStack, true); 250 } 251 252 void Console::count(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 260 253 { 261 254 #if ENABLE(INSPECTOR) … … 268 261 // the same bucket as no argument 269 262 String title; 270 getFirstArgumentAsString(callStack->state(), lastCaller,title);263 arguments->getFirstArgumentAsString(title); 271 264 272 265 page->inspectorController()->count(title, lastCaller.lineNumber(), lastCaller.sourceURL()); … … 276 269 } 277 270 278 void Console::markTimeline(ScriptCallStack* callStack) 279 { 280 #if ENABLE(INSPECTOR) 281 Page* page = this->page(); 282 if (!page) 283 return; 284 285 const ScriptCallFrame& lastCaller = callStack->at(0); 271 void Console::markTimeline(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>) 272 { 273 #if ENABLE(INSPECTOR) 274 Page* page = this->page(); 275 if (!page) 276 return; 277 286 278 String message; 287 getFirstArgumentAsString(callStack->state(), lastCaller,message);279 arguments->getFirstArgumentAsString(message); 288 280 289 281 page->inspectorController()->markTimeline(message); 290 282 #else 291 UNUSED_PARAM( callStack);283 UNUSED_PARAM(arguments); 292 284 #endif 293 285 } … … 322 314 #if ENABLE(JAVASCRIPT_DEBUGGER) 323 315 324 void Console::profile(const String& title, ScriptCallStack*callStack)316 void Console::profile(const String& title, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 325 317 { 326 318 Page* page = this->page(); … … 343 335 #endif 344 336 345 ScriptProfiler::start( callStack->state(), resolvedTitle);337 ScriptProfiler::start(arguments->globalState(), resolvedTitle); 346 338 347 339 #if ENABLE(INSPECTOR) … … 351 343 } 352 344 353 void Console::profileEnd(const String& title, ScriptCallStack*callStack)345 void Console::profileEnd(const String& title, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 354 346 { 355 347 Page* page = this->page(); … … 363 355 #endif 364 356 365 RefPtr<ScriptProfile> profile = ScriptProfiler::stop( callStack->state(), title);357 RefPtr<ScriptProfile> profile = ScriptProfiler::stop(arguments->globalState(), title); 366 358 if (!profile) 367 359 return; … … 395 387 } 396 388 397 void Console::timeEnd(const String& title, ScriptCallStack*callStack)389 void Console::timeEnd(const String& title, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callStack) 398 390 { 399 391 #if ENABLE(INSPECTOR) … … 421 413 } 422 414 423 void Console::group(ScriptCallStack* callStack) 424 { 425 #if ENABLE(INSPECTOR) 426 Page* page = this->page(); 427 if (!page) 428 return; 429 430 page->inspectorController()->startGroup(JSMessageSource, callStack); 431 #else 415 void Console::group(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 416 { 417 #if ENABLE(INSPECTOR) 418 Page* page = this->page(); 419 if (!page) 420 return; 421 422 page->inspectorController()->startGroup(arguments, callStack); 423 #else 424 UNUSED_PARAM(arguments); 432 425 UNUSED_PARAM(callStack); 433 426 #endif 434 427 } 435 428 436 void Console::groupCollapsed(ScriptCallStack* callStack) 437 { 438 #if ENABLE(INSPECTOR) 439 Page* page = this->page(); 440 if (!page) 441 return; 442 443 page->inspectorController()->startGroup(JSMessageSource, callStack, true); 444 #else 429 void Console::groupCollapsed(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 430 { 431 #if ENABLE(INSPECTOR) 432 Page* page = this->page(); 433 if (!page) 434 return; 435 436 page->inspectorController()->startGroup(arguments, callStack, true); 437 #else 438 UNUSED_PARAM(arguments); 445 439 UNUSED_PARAM(callStack); 446 440 #endif … … 458 452 } 459 453 460 void Console::warn(ScriptCallStack* callStack) 461 { 462 addMessage(LogMessageType, WarningMessageLevel, callStack); 454 bool Console::shouldCaptureFullStackTrace() const 455 { 456 #if ENABLE(INSPECTOR) 457 Page* page = this->page(); 458 if (!page) 459 return false; 460 461 return page->inspectorController()->hasFrontend(); 462 #else 463 return false; 464 #endif 465 } 466 467 void Console::warn(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 468 { 469 addMessage(LogMessageType, WarningMessageLevel, arguments, callStack); 463 470 } 464 471 -
trunk/WebCore/page/Console.h
r65021 r70232 39 39 40 40 namespace WebCore { 41 42 class ScriptArguments; 41 43 42 44 #if ENABLE(JAVASCRIPT_DEBUGGER) … … 84 86 void disconnectFrame(); 85 87 86 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack = 0); 88 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); 89 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack); 87 90 88 void debug( ScriptCallStack*);89 void error( ScriptCallStack*);90 void info( ScriptCallStack*);91 void log( ScriptCallStack*);92 void warn( ScriptCallStack*);93 void dir( ScriptCallStack*);94 void dirxml( ScriptCallStack*);95 void trace( ScriptCallStack*);96 void assertCondition(bool condition, ScriptCallStack*);97 void count( ScriptCallStack*);98 void markTimeline( ScriptCallStack*);91 void debug(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 92 void error(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 93 void info(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 94 void log(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 95 void warn(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 96 void dir(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 97 void dirxml(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 98 void trace(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 99 void assertCondition(bool condition, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 100 void count(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 101 void markTimeline(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 99 102 #if ENABLE(WML) 100 103 String lastWMLErrorMessage() const; 101 104 #endif 102 105 #if ENABLE(JAVASCRIPT_DEBUGGER) 103 void profile(const String&, ScriptCallStack*);104 void profileEnd(const String&, ScriptCallStack*);106 void profile(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 107 void profileEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 105 108 #endif 106 109 void time(const String&); 107 void timeEnd(const String&, ScriptCallStack*);108 void group( ScriptCallStack*);109 void groupCollapsed( ScriptCallStack*);110 void timeEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 111 void group(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 112 void groupCollapsed(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>); 110 113 void groupEnd(); 114 115 bool shouldCaptureFullStackTrace() const; 111 116 112 117 static bool shouldPrintExceptions(); … … 121 126 private: 122 127 inline Page* page() const; 123 void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false);128 void addMessage(MessageType, MessageLevel, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, bool acceptNoArguments = false); 124 129 125 130 Console(Frame*);
Note: See TracChangeset
for help on using the changeset viewer.