Changeset 47236 in webkit for trunk/JavaScriptCore/debugger
- Timestamp:
- Aug 13, 2009, 2:51:50 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/debugger
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/debugger/Debugger.cpp
r44224 r47236 23 23 #include "Debugger.h" 24 24 25 #include "CollectorHeapIterator.h" 26 #include "Interpreter.h" 25 27 #include "JSGlobalObject.h" 26 #include "Interpreter.h"27 28 #include "Parser.h" 28 29 29 30 namespace JSC { 30 31 Debugger::Debugger()32 {33 }34 31 35 32 Debugger::~Debugger() … … 54 51 } 55 52 53 void Debugger::recompileAllJSFunctions(JSGlobalData* globalData) 54 { 55 // If JavaScript is running, it's not safe to recompile, since we'll end 56 // up throwing away code that is live on the stack. 57 ASSERT(!globalData->dynamicGlobalObject); 58 if (globalData->dynamicGlobalObject) 59 return; 60 61 Vector<ProtectedPtr<JSFunction> > functions; 62 Heap::iterator heapEnd = globalData->heap.primaryHeapEnd(); 63 for (Heap::iterator it = globalData->heap.primaryHeapBegin(); it != heapEnd; ++it) { 64 if ((*it)->isObject(&JSFunction::info)) { 65 JSFunction* function = asFunction(*it); 66 if (!function->body()->isHostFunction()) 67 functions.append(function); 68 } 69 } 70 71 typedef HashMap<RefPtr<FunctionBodyNode>, RefPtr<FunctionBodyNode> > FunctionBodyMap; 72 typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap; 73 74 FunctionBodyMap functionBodies; 75 SourceProviderMap sourceProviders; 76 77 size_t size = functions.size(); 78 for (size_t i = 0; i < size; ++i) { 79 JSFunction* function = functions[i]; 80 81 FunctionBodyNode* oldBody = function->body(); 82 pair<FunctionBodyMap::iterator, bool> result = functionBodies.add(oldBody, 0); 83 if (!result.second) { 84 function->setBody(result.first->second); 85 continue; 86 } 87 88 ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec(); 89 const SourceCode& sourceCode = oldBody->source(); 90 91 RefPtr<FunctionBodyNode> newBody = globalData->parser->parse<FunctionBodyNode>(exec, 0, sourceCode); 92 ASSERT(newBody); 93 newBody->finishParsing(oldBody->copyParameters(), oldBody->parameterCount(), oldBody->ident()); 94 95 result.first->second = newBody; 96 function->setBody(newBody.release()); 97 98 if (function->scope().globalObject()->debugger() == this) 99 sourceProviders.add(sourceCode.provider(), exec); 100 } 101 102 // Call sourceParsed() after reparsing all functions because it will execute 103 // JavaScript in the inspector. 104 SourceProviderMap::const_iterator end = sourceProviders.end(); 105 for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter) 106 sourceParsed(iter->second, SourceCode(iter->first), -1, 0); 107 } 108 56 109 JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject) 57 110 { -
trunk/JavaScriptCore/debugger/Debugger.h
r45733 r47236 2 2 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2008 Apple Inc. All rights reserved.4 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 23 23 #define Debugger_h 24 24 25 #include "Protect.h"25 #include <wtf/HashSet.h> 26 26 27 27 namespace JSC { … … 29 29 class DebuggerCallFrame; 30 30 class ExecState; 31 class JSGlobalData; 31 32 class JSGlobalObject; 33 class JSValue; 32 34 class SourceCode; 33 35 class UString; … … 35 37 class Debugger { 36 38 public: 37 Debugger();38 39 virtual ~Debugger(); 39 40 … … 41 42 virtual void detach(JSGlobalObject*); 42 43 43 virtual void sourceParsed(ExecState*, const SourceCode&, int errorLine , const UString& errorMsg) = 0;44 virtual void exception(const DebuggerCallFrame&, intptr_t sourceID, int line no) = 0;45 virtual void atStatement(const DebuggerCallFrame&, intptr_t sourceID, int line no) = 0;46 virtual void callEvent(const DebuggerCallFrame&, intptr_t sourceID, int line no) = 0;47 virtual void returnEvent(const DebuggerCallFrame&, intptr_t sourceID, int line no) = 0;44 virtual void sourceParsed(ExecState*, const SourceCode&, int errorLineNumber, const UString& errorMessage) = 0; 45 virtual void exception(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 46 virtual void atStatement(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 47 virtual void callEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 48 virtual void returnEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 48 49 49 virtual void willExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0; 50 virtual void didExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0; 51 virtual void didReachBreakpoint(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0; 50 virtual void willExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 51 virtual void didExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 52 virtual void didReachBreakpoint(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; 53 54 void recompileAllJSFunctions(JSGlobalData*); 52 55 53 56 private: … … 55 58 }; 56 59 57 // This method exists only for backwards compatibility with existing 58 // WebScriptDebugger clients 60 // This function exists only for backwards compatibility with existing WebScriptDebugger clients. 59 61 JSValue evaluateInGlobalCallFrame(const UString&, JSValue& exception, JSGlobalObject*); 60 62 -
trunk/JavaScriptCore/debugger/DebuggerCallFrame.cpp
r44224 r47236 42 42 return 0; 43 43 44 JSFunction* function = static_cast<JSFunction*>(m_callFrame->callee());44 JSFunction* function = asFunction(m_callFrame->callee()); 45 45 if (!function) 46 46 return 0; … … 53 53 return 0; 54 54 55 JSFunction* function = static_cast<JSFunction*>(m_callFrame->callee());55 JSFunction* function = asFunction(m_callFrame->callee()); 56 56 if (!function) 57 57 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.