Changeset 9929 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jul 27, 2005, 4:10:48 PM (20 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r9924 r9929 1 2005-07-27 Maciej Stachowiak <[email protected]> 2 3 Changes by Michael Kahl, reviewed by me. 4 5 - fixed <rdar://problem/4194278> Need better debugging support in JavaScriptCore 6 7 * JavaScriptCore.xcodeproj/project.pbxproj: 8 * kjs/debugger.cpp: 9 (KJS::AttachedInterpreter::AttachedInterpreter): 10 (KJS::AttachedInterpreter::~AttachedInterpreter): 11 (Debugger::~Debugger): 12 (Debugger::attach): 13 (Debugger::detach): 14 (Debugger::sourceParsed): 15 * kjs/debugger.h: 16 * kjs/function.cpp: 17 (KJS::FunctionImp::call): 18 (KJS::GlobalFuncImp::call): 19 * kjs/function_object.cpp: 20 (FunctionObjectImp::construct): 21 * kjs/grammar.y: 22 * kjs/internal.cpp: 23 (Parser::parse): 24 (InterpreterImp::evaluate): 25 * kjs/internal.h: 26 (KJS::InterpreterImp::setDebugger): 27 * kjs/interpreter.cpp: 28 * kjs/interpreter.h: 29 (KJS::Interpreter::imp): 30 * kjs/nodes.cpp: 31 1 32 2005-07-27 Geoffrey Garen <[email protected]> 2 33 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r9855 r9929 29 29 932F5B420822A1C700736975 /* collector.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8530255597D01FF60F7 /* collector.h */; settings = {ATTRIBUTES = (Private, ); }; }; 30 30 932F5B430822A1C700736975 /* date_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8560255597D01FF60F7 /* date_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; 31 932F5B450822A1C700736975 /* debugger.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8590255597D01FF60F7 /* debugger.h */; };31 932F5B450822A1C700736975 /* debugger.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8590255597D01FF60F7 /* debugger.h */; settings = {ATTRIBUTES = (Private, ); }; }; 32 32 932F5B460822A1C700736975 /* error_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A85B0255597D01FF60F7 /* error_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; 33 33 932F5B470822A1C700736975 /* function_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A85D0255597D01FF60F7 /* function_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 57 57 932F5B650822A1C700736975 /* completion.h in Headers */ = {isa = PBXBuildFile; fileRef = F5BB2BC5030F772101FCFE1D /* completion.h */; settings = {ATTRIBUTES = (Private, ); }; }; 58 58 932F5B660822A1C700736975 /* identifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A349A038AE7C6008635CE /* identifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 59 932F5B670822A1C700736975 /* array_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 938772E5038BFE19008635CE /* array_instance.h */; };59 932F5B670822A1C700736975 /* array_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 938772E5038BFE19008635CE /* array_instance.h */; settings = {ATTRIBUTES = (Private, ); }; }; 60 60 932F5B680822A1C700736975 /* scope_chain.h in Headers */ = {isa = PBXBuildFile; fileRef = 9374D3A7038D9D74008635CE /* scope_chain.h */; settings = {ATTRIBUTES = (Private, ); }; }; 61 61 932F5B690822A1C700736975 /* context.h in Headers */ = {isa = PBXBuildFile; fileRef = 9373524E038DA8C2008635CE /* context.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 173 173 A85D81F9087B2822006A9172 /* collector.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8530255597D01FF60F7 /* collector.h */; settings = {ATTRIBUTES = (Private, ); }; }; 174 174 A85D81FA087B2822006A9172 /* date_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8560255597D01FF60F7 /* date_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; 175 A85D81FB087B2822006A9172 /* debugger.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8590255597D01FF60F7 /* debugger.h */; };175 A85D81FB087B2822006A9172 /* debugger.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8590255597D01FF60F7 /* debugger.h */; settings = {ATTRIBUTES = (Private, ); }; }; 176 176 A85D81FC087B2822006A9172 /* error_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A85B0255597D01FF60F7 /* error_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; 177 177 A85D81FD087B2822006A9172 /* function_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A85D0255597D01FF60F7 /* function_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 201 201 A85D8215087B2822006A9172 /* completion.h in Headers */ = {isa = PBXBuildFile; fileRef = F5BB2BC5030F772101FCFE1D /* completion.h */; settings = {ATTRIBUTES = (Private, ); }; }; 202 202 A85D8216087B2822006A9172 /* identifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A349A038AE7C6008635CE /* identifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 203 A85D8217087B2822006A9172 /* array_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 938772E5038BFE19008635CE /* array_instance.h */; };203 A85D8217087B2822006A9172 /* array_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 938772E5038BFE19008635CE /* array_instance.h */; settings = {ATTRIBUTES = (Private, ); }; }; 204 204 A85D8218087B2822006A9172 /* scope_chain.h in Headers */ = {isa = PBXBuildFile; fileRef = 9374D3A7038D9D74008635CE /* scope_chain.h */; settings = {ATTRIBUTES = (Private, ); }; }; 205 205 A85D8219087B2822006A9172 /* context.h in Headers */ = {isa = PBXBuildFile; fileRef = 9373524E038DA8C2008635CE /* context.h */; settings = {ATTRIBUTES = (Private, ); }; }; -
trunk/JavaScriptCore/kjs/debugger.cpp
r9768 r9929 37 37 { 38 38 public: 39 AttachedInterpreter(Interpreter *i) : interp(i) {} 39 AttachedInterpreter(Interpreter *i, AttachedInterpreter *ai) : interp(i), next(ai) { ++Debugger::debuggersPresent; } 40 ~AttachedInterpreter() { --Debugger::debuggersPresent; } 40 41 Interpreter *interp; 41 42 AttachedInterpreter *next; … … 43 44 44 45 } 46 47 int Debugger::debuggersPresent = 0; 45 48 46 49 Debugger::Debugger() … … 51 54 Debugger::~Debugger() 52 55 { 53 // detach from all interpreters 54 while (rep->interps) 55 detach(rep->interps->interp); 56 56 detach(0); 57 57 delete rep; 58 58 } … … 60 60 void Debugger::attach(Interpreter *interp) 61 61 { 62 if (interp->imp()->debugger() != this) 63 interp->imp()->setDebugger(this); 64 65 // add to the list of attached interpreters 66 if (!rep->interps) 67 rep->interps = new AttachedInterpreter(interp); 68 else { 69 AttachedInterpreter *ai = rep->interps; 70 while (ai->next) 71 ai = ai->next; 72 ai->next = new AttachedInterpreter(interp);; 73 } 62 Debugger *other = interp->imp()->debugger(); 63 if (other == this) 64 return; 65 if (other) 66 other->detach(interp); 67 interp->imp()->setDebugger(this); 68 rep->interps = new AttachedInterpreter(interp, rep->interps); 74 69 } 75 70 76 71 void Debugger::detach(Interpreter *interp) 77 72 { 78 if (interp ->imp()->debugger() == this)79 interp->imp()->setDebugger( this);73 if (interp && interp->imp()->debugger() == this) 74 interp->imp()->setDebugger(0); 80 75 81 // remove from the list of attached interpreters 82 if (rep->interps->interp == interp) { 83 AttachedInterpreter *old = rep->interps; 84 rep->interps = rep->interps->next; 85 delete old; 86 } 87 88 AttachedInterpreter *ai = rep->interps; 89 while (ai->next && ai->next->interp != interp) 90 ai = ai->next; 91 if (ai->next) { 92 AttachedInterpreter *old = ai->next; 93 ai->next = ai->next->next; 94 delete old; 76 // iterate the addresses where AttachedInterpreter pointers are stored 77 // so we can unlink items from the list 78 AttachedInterpreter **p = &rep->interps; 79 AttachedInterpreter *q; 80 while ((q = *p)) { 81 if (!interp || q->interp == interp) { 82 *p = q->next; 83 delete q; 84 } else { 85 p = &q->next; 86 } 95 87 } 96 88 } 97 89 98 bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/, 99 90 bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/, const UString &/*sourceURL*/, 91 const UString &/*source*/, int /*errorLine*/) 100 92 { 101 93 return true; -
trunk/JavaScriptCore/kjs/debugger.h
r9768 r9929 102 102 * @param sourceId The ID of the source code (corresponds to the 103 103 * sourceId supplied in other functions such as atStatement() 104 * @param sourceURL Where the source code that was parsed came from 104 105 * @param source The source code that was parsed 105 106 * @param errorLine The line number at which parsing encountered an … … 108 109 * be aborted 109 110 */ 110 virtual bool sourceParsed(ExecState *exec, int sourceId, 111 virtual bool sourceParsed(ExecState *exec, int sourceId, const UString &sourceURL, 111 112 const UString &source, int errorLine); 112 113 … … 206 207 private: 207 208 DebuggerImp *rep; 209 210 public: 211 static int debuggersPresent; 208 212 }; 209 213 -
trunk/JavaScriptCore/kjs/function.cpp
r9889 r9929 78 78 Object &globalObj = exec->dynamicInterpreter()->globalObject(); 79 79 80 // enter a new execution context 81 ContextImp ctx(globalObj, exec->dynamicInterpreter()->imp(), thisObj, codeType(), 82 exec->context().imp(), this, &args); 83 ExecState newExec(exec->dynamicInterpreter(), &ctx); 84 newExec.setException(exec->exception()); // could be null 85 86 // assign user supplied arguments to parameters 87 processParameters(&newExec, args); 88 // add variable declarations (initialized to undefined) 89 processVarDecls(&newExec); 90 80 91 Debugger *dbg = exec->dynamicInterpreter()->imp()->debugger(); 81 92 int sid = -1; … … 88 99 89 100 Object func(this); 90 bool cont = dbg->callEvent( exec,sid,lineno,func,args);101 bool cont = dbg->callEvent(&newExec,sid,lineno,func,args); 91 102 if (!cont) { 92 103 dbg->imp()->abort(); … … 95 106 } 96 107 97 // enter a new execution context98 ContextImp ctx(globalObj, exec->dynamicInterpreter()->imp(), thisObj, codeType(),99 exec->context().imp(), this, &args);100 ExecState newExec(exec->dynamicInterpreter(), &ctx);101 newExec.setException(exec->exception()); // could be null102 103 // assign user supplied arguments to parameters104 processParameters(&newExec, args);105 // add variable declarations (initialized to undefined)106 processVarDecls(&newExec);107 108 108 Completion comp = execute(&newExec); 109 109 110 110 // if an exception occured, propogate it back to the previous execution object 111 111 if (newExec.hadException()) 112 exec->setException(newExec.exception());112 comp = Completion(Throw, newExec.exception()); 113 113 114 114 #ifdef KJS_VERBOSE … … 122 122 123 123 if (dbg) { 124 if (inherits(&DeclaredFunctionImp::info)) 125 lineno = static_cast<DeclaredFunctionImp*>(this)->body->lastLine(); 126 127 if (comp.complType() == Throw) 128 newExec.setException(comp.value()); 129 124 130 Object func(this); 125 int cont = dbg->returnEvent( exec,sid,lineno,func);131 int cont = dbg->returnEvent(&newExec,sid,lineno,func); 126 132 if (!cont) { 127 133 dbg->imp()->abort(); … … 790 796 UString errMsg; 791 797 ProgramNode *progNode = Parser::parse(UString(), 0, s.data(),s.size(),&sid,&errLine,&errMsg); 792 798 799 Debugger *dbg = exec->dynamicInterpreter()->imp()->debugger(); 800 if (dbg) { 801 bool cont = dbg->sourceParsed(exec, sid, UString(), s, errLine); 802 if (!cont) 803 return Undefined(); 804 } 805 793 806 // no program node means a syntax occurred 794 807 if (!progNode) { -
trunk/JavaScriptCore/kjs/function_object.cpp
r9768 r9929 218 218 Debugger *dbg = exec->dynamicInterpreter()->imp()->debugger(); 219 219 if (dbg) { 220 bool cont = dbg->sourceParsed(exec,sid,body,errLine); 220 // send empty sourceURL to indicate constructed code 221 bool cont = dbg->sourceParsed(exec,sid,UString(),body,errLine); 221 222 if (!cont) { 222 223 dbg->imp()->abort(); -
trunk/JavaScriptCore/kjs/grammar.y
r9768 r9929 509 509 CONTINUE ';' { $$ = new ContinueNode(); DBG($$,@1,@2); } 510 510 | CONTINUE error { if (automatic()) { 511 $$ = new ContinueNode(); DBG($$,@1,@ 2);511 $$ = new ContinueNode(); DBG($$,@1,@1); 512 512 } else 513 513 YYABORT; } … … 539 539 } else 540 540 YYABORT; } 541 | RETURN Expr ';' { $$ = new ReturnNode($2); }542 | RETURN Expr error { if (automatic()) 543 $$ = new ReturnNode($2); 544 else541 | RETURN Expr ';' { $$ = new ReturnNode($2); DBG($$,@1,@3); } 542 | RETURN Expr error { if (automatic()) { 543 $$ = new ReturnNode($2); DBG($$,@1,@2); 544 } else 545 545 YYABORT; } 546 546 ; … … 588 588 589 589 ThrowStatement: 590 THROW Expr ';' { $$ = new ThrowNode($2); }591 | THROW Expr error { if (automatic()) $$ = new ThrowNode($2);else YYABORT; }590 THROW Expr ';' { $$ = new ThrowNode($2); DBG($$,@1,@3); } 591 | THROW Expr error { if (automatic()) { $$ = new ThrowNode($2); DBG($$,@1,@2); } else YYABORT; } 592 592 ; 593 593 594 594 TryStatement: 595 TRY Block Catch { $$ = new TryNode($2, $3); }596 | TRY Block Finally { $$ = new TryNode($2, $3); }597 | TRY Block Catch Finally { $$ = new TryNode($2, $3, $4); }595 TRY Block Catch { $$ = new TryNode($2, $3); DBG($$,@1,@2); } 596 | TRY Block Finally { $$ = new TryNode($2, $3); DBG($$,@1,@2); } 597 | TRY Block Catch Finally { $$ = new TryNode($2, $3, $4); DBG($$,@1,@2); } 598 598 ; 599 599 -
trunk/JavaScriptCore/kjs/internal.cpp
r9768 r9929 453 453 ProgramNode *prog = progNode; 454 454 progNode = 0; 455 sid = -1;455 // sid = -1; 456 456 457 457 if (parseError || lexError) { … … 762 762 // notify debugger that source has been parsed 763 763 if (dbg) { 764 bool cont = dbg->sourceParsed(globExec,sid, code,errLine);764 bool cont = dbg->sourceParsed(globExec,sid,sourceURL,code,errLine); 765 765 if (!cont) 766 766 #if APPLE_CHANGES … … 823 823 #endif 824 824 return res; 825 }826 827 void InterpreterImp::setDebugger(Debugger *d)828 {829 if (d)830 d->detach(m_interpreter);831 dbg = d;832 825 } 833 826 -
trunk/JavaScriptCore/kjs/internal.h
r9768 r9929 292 292 Completion evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber); 293 293 Debugger *debugger() const { return dbg; } 294 void setDebugger(Debugger *d) ;294 void setDebugger(Debugger *d) { dbg = d; } 295 295 296 296 Object builtinObject() const { return b_Object; } -
trunk/JavaScriptCore/kjs/interpreter.cpp
r9781 r9929 141 141 } 142 142 143 InterpreterImp *Interpreter::imp()144 {145 return rep;146 }147 148 143 Object Interpreter::builtinObject() const 149 144 { -
trunk/JavaScriptCore/kjs/interpreter.h
r9768 r9929 222 222 * Only useful for internal KJS operations. 223 223 */ 224 InterpreterImp *imp() ;224 InterpreterImp *imp() const { return rep; } 225 225 226 226 /** -
trunk/JavaScriptCore/kjs/nodes.cpp
r9889 r9929 48 48 using namespace KJS; 49 49 50 // Disabled for now because it shows up on benchmark (0.5%).51 #if DEBUGGER_SUPPORT52 53 50 #define KJS_BREAKPOINT \ 54 if ( !hitStatement(exec)) \51 if (Debugger::debuggersPresent > 0 && !hitStatement(exec)) \ 55 52 return Completion(Normal); 56 53 57 54 #define KJS_ABORTPOINT \ 58 if (exec->dynamicInterpreter()->imp()->debugger() && \ 55 if (Debugger::debuggersPresent > 0 && \ 56 exec->dynamicInterpreter()->imp()->debugger() && \ 59 57 exec->dynamicInterpreter()->imp()->debugger()->imp()->aborted()) \ 60 58 return Completion(Normal); 61 62 #else63 64 #define KJS_BREAKPOINT65 #define KJS_ABORTPOINT66 67 #endif68 59 69 60 #define KJS_CHECKEXCEPTION \
Note:
See TracChangeset
for help on using the changeset viewer.