Ignore:
Timestamp:
Jul 27, 2005, 4:10:48 PM (20 years ago)
Author:
mjs
Message:

Changes by Michael Kahl, reviewed by me.

  • fixed <rdar://problem/4194278> Need better debugging support in JavaScriptCore
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/debugger.cpp: (KJS::AttachedInterpreter::AttachedInterpreter): (KJS::AttachedInterpreter::~AttachedInterpreter): (Debugger::~Debugger): (Debugger::attach): (Debugger::detach): (Debugger::sourceParsed):
  • kjs/debugger.h:
  • kjs/function.cpp: (KJS::FunctionImp::call): (KJS::GlobalFuncImp::call):
  • kjs/function_object.cpp: (FunctionObjectImp::construct):
  • kjs/grammar.y:
  • kjs/internal.cpp: (Parser::parse): (InterpreterImp::evaluate):
  • kjs/internal.h: (KJS::InterpreterImp::setDebugger):
  • kjs/interpreter.cpp:
  • kjs/interpreter.h: (KJS::Interpreter::imp):
  • kjs/nodes.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/debugger.cpp

    r9768 r9929  
    3737  {
    3838  public:
    39     AttachedInterpreter(Interpreter *i) : interp(i) {}
     39    AttachedInterpreter(Interpreter *i, AttachedInterpreter *ai) : interp(i), next(ai) { ++Debugger::debuggersPresent; }
     40    ~AttachedInterpreter() { --Debugger::debuggersPresent; }
    4041    Interpreter *interp;
    4142    AttachedInterpreter *next;
     
    4344
    4445}
     46
     47int Debugger::debuggersPresent = 0;
    4548
    4649Debugger::Debugger()
     
    5154Debugger::~Debugger()
    5255{
    53   // detach from all interpreters
    54   while (rep->interps)
    55     detach(rep->interps->interp);
    56 
     56  detach(0);
    5757  delete rep;
    5858}
     
    6060void Debugger::attach(Interpreter *interp)
    6161{
    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);
    7469}
    7570
    7671void Debugger::detach(Interpreter *interp)
    7772{
    78   if (interp->imp()->debugger() == this)
    79     interp->imp()->setDebugger(this);
     73  if (interp && interp->imp()->debugger() == this)
     74    interp->imp()->setDebugger(0);
    8075
    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    }
    9587  }
    9688}
    9789
    98 bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/,
    99                             const UString &/*source*/, int /*errorLine*/)
     90bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/, const UString &/*sourceURL*/,
     91                           const UString &/*source*/, int /*errorLine*/)
    10092{
    10193  return true;
Note: See TracChangeset for help on using the changeset viewer.