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 | */
|
---|
22 |
|
---|
23 | #include "debugger.h"
|
---|
24 | #include "value.h"
|
---|
25 | #include "object.h"
|
---|
26 | #include "types.h"
|
---|
27 | #include "interpreter.h"
|
---|
28 | #include "internal.h"
|
---|
29 | #include "ustring.h"
|
---|
30 |
|
---|
31 | using namespace KJS;
|
---|
32 |
|
---|
33 | // ------------------------------ Debugger -------------------------------------
|
---|
34 |
|
---|
35 | namespace KJS {
|
---|
36 | struct AttachedInterpreter
|
---|
37 | {
|
---|
38 | public:
|
---|
39 | AttachedInterpreter(Interpreter *i) : interp(i) {}
|
---|
40 | Interpreter *interp;
|
---|
41 | AttachedInterpreter *next;
|
---|
42 | };
|
---|
43 |
|
---|
44 | }
|
---|
45 |
|
---|
46 | Debugger::Debugger()
|
---|
47 | {
|
---|
48 | rep = new DebuggerImp();
|
---|
49 | }
|
---|
50 |
|
---|
51 | Debugger::~Debugger()
|
---|
52 | {
|
---|
53 | // detach from all interpreters
|
---|
54 | while (rep->interps)
|
---|
55 | detach(rep->interps->interp);
|
---|
56 |
|
---|
57 | delete rep;
|
---|
58 | }
|
---|
59 |
|
---|
60 | void Debugger::attach(Interpreter *interp)
|
---|
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 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | void Debugger::detach(Interpreter *interp)
|
---|
77 | {
|
---|
78 | if (interp->imp()->debugger() == this)
|
---|
79 | interp->imp()->setDebugger(this);
|
---|
80 |
|
---|
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;
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/,
|
---|
99 | const UString &/*source*/, int /*errorLine*/)
|
---|
100 | {
|
---|
101 | return true;
|
---|
102 | }
|
---|
103 |
|
---|
104 | bool Debugger::sourceUnused(ExecState */*exec*/, int /*sourceId*/)
|
---|
105 | {
|
---|
106 | return true;
|
---|
107 | }
|
---|
108 |
|
---|
109 | bool Debugger::exception(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
|
---|
110 | Object &/*exceptionObj*/)
|
---|
111 | {
|
---|
112 | return true;
|
---|
113 | }
|
---|
114 |
|
---|
115 | bool Debugger::atStatement(ExecState */*exec*/, int /*sourceId*/, int /*firstLine*/,
|
---|
116 | int /*lastLine*/)
|
---|
117 | {
|
---|
118 | return true;
|
---|
119 | }
|
---|
120 |
|
---|
121 | bool Debugger::callEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
|
---|
122 | Object &/*function*/, const List &/*args*/)
|
---|
123 | {
|
---|
124 | return true;
|
---|
125 | }
|
---|
126 |
|
---|
127 | bool Debugger::returnEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
|
---|
128 | Object &/*function*/)
|
---|
129 | {
|
---|
130 | return true;
|
---|
131 | }
|
---|
132 |
|
---|