1 | // -*- c-basic-offset: 2 -*-
|
---|
2 | /*
|
---|
3 | * This file is part of the KDE libraries
|
---|
4 | * Copyright (C) 1999-2001 Harri Porten ([email protected])
|
---|
5 | * Copyright (C) 2001 Peter Kelly ([email protected])
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Lesser General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Lesser General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Lesser General Public
|
---|
18 | * License along with this library; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
20 | *
|
---|
21 | * $Id: debugger.cpp 798 2002-03-22 00:31:57Z mjs $
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "debugger.h"
|
---|
25 | #include "value.h"
|
---|
26 | #include "object.h"
|
---|
27 | #include "types.h"
|
---|
28 | #include "interpreter.h"
|
---|
29 | #include "internal.h"
|
---|
30 | #include "ustring.h"
|
---|
31 |
|
---|
32 | using namespace KJS;
|
---|
33 |
|
---|
34 | // ------------------------------ Debugger -------------------------------------
|
---|
35 |
|
---|
36 | namespace KJS {
|
---|
37 | struct AttachedInterpreter
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | AttachedInterpreter(Interpreter *i) : interp(i) {}
|
---|
41 | Interpreter *interp;
|
---|
42 | AttachedInterpreter *next;
|
---|
43 | };
|
---|
44 |
|
---|
45 | }
|
---|
46 |
|
---|
47 | Debugger::Debugger()
|
---|
48 | {
|
---|
49 | rep = new DebuggerImp();
|
---|
50 | }
|
---|
51 |
|
---|
52 | Debugger::~Debugger()
|
---|
53 | {
|
---|
54 | // detach from all interpreters
|
---|
55 | while (rep->interps)
|
---|
56 | detach(rep->interps->interp);
|
---|
57 |
|
---|
58 | delete rep;
|
---|
59 | }
|
---|
60 |
|
---|
61 | void Debugger::attach(Interpreter *interp)
|
---|
62 | {
|
---|
63 | if (interp->imp()->debugger() != this)
|
---|
64 | interp->imp()->setDebugger(this);
|
---|
65 |
|
---|
66 | // add to the list of attached interpreters
|
---|
67 | if (!rep->interps)
|
---|
68 | rep->interps = new AttachedInterpreter(interp);
|
---|
69 | else {
|
---|
70 | AttachedInterpreter *ai = rep->interps;
|
---|
71 | while (ai->next)
|
---|
72 | ai = ai->next;
|
---|
73 | ai->next = new AttachedInterpreter(interp);;
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | void Debugger::detach(Interpreter *interp)
|
---|
78 | {
|
---|
79 | if (interp->imp()->debugger() == this)
|
---|
80 | interp->imp()->setDebugger(this);
|
---|
81 |
|
---|
82 | // remove from the list of attached interpreters
|
---|
83 | if (rep->interps->interp == interp) {
|
---|
84 | AttachedInterpreter *old = rep->interps;
|
---|
85 | rep->interps = rep->interps->next;
|
---|
86 | delete old;
|
---|
87 | }
|
---|
88 |
|
---|
89 | AttachedInterpreter *ai = rep->interps;
|
---|
90 | while (ai->next && ai->next->interp != interp)
|
---|
91 | ai = ai->next;
|
---|
92 | if (ai->next) {
|
---|
93 | AttachedInterpreter *old = ai->next;
|
---|
94 | ai->next = ai->next->next;
|
---|
95 | delete old;
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/,
|
---|
100 | const UString &/*source*/, int /*errorLine*/)
|
---|
101 | {
|
---|
102 | return true;
|
---|
103 | }
|
---|
104 |
|
---|
105 | bool Debugger::sourceUnused(ExecState */*exec*/, int /*sourceId*/)
|
---|
106 | {
|
---|
107 | return true;
|
---|
108 | }
|
---|
109 |
|
---|
110 | bool Debugger::exception(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
|
---|
111 | Object &/*exceptionObj*/)
|
---|
112 | {
|
---|
113 | return true;
|
---|
114 | }
|
---|
115 |
|
---|
116 | bool Debugger::atStatement(ExecState */*exec*/, int /*sourceId*/, int /*firstLine*/,
|
---|
117 | int /*lastLine*/)
|
---|
118 | {
|
---|
119 | return true;
|
---|
120 | }
|
---|
121 |
|
---|
122 | bool Debugger::callEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
|
---|
123 | Object &/*function*/, const List &/*args*/)
|
---|
124 | {
|
---|
125 | return true;
|
---|
126 | }
|
---|
127 |
|
---|
128 | bool Debugger::returnEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
|
---|
129 | Object &/*function*/)
|
---|
130 | {
|
---|
131 | return true;
|
---|
132 | }
|
---|
133 |
|
---|