Changeset View
Changeset View
Standalone View
Standalone View
debuggers/common/mivariable.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
56 | { | 56 | { | ||
57 | if (!varobj_.isEmpty()) | 57 | if (!varobj_.isEmpty()) | ||
58 | { | 58 | { | ||
59 | // Delete only top-level variable objects. | 59 | // Delete only top-level variable objects. | ||
60 | if (topLevel()) { | 60 | if (topLevel()) { | ||
61 | if (hasStartedSession()) { | 61 | if (hasStartedSession()) { | ||
62 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | 62 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | ||
63 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | 63 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | ||
64 | s->addCommand(new MICommand(VarDelete, | 64 | s->addCommand(VarDelete, QString("\"%1\"").arg(varobj_)); | ||
65 | QString("\"%1\"").arg(varobj_))); | | |||
66 | } | 65 | } | ||
67 | } | 66 | } | ||
68 | allVariables_.remove(varobj_); | 67 | allVariables_.remove(varobj_); | ||
69 | } | 68 | } | ||
70 | } | 69 | } | ||
71 | 70 | | |||
72 | MIVariable* MIVariable::findByVarobjName(const QString& varobjName) | 71 | MIVariable* MIVariable::findByVarobjName(const QString& varobjName) | ||
73 | { | 72 | { | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | |||||
152 | void MIVariable::attachMaybe(QObject *callback, const char *callbackMethod) | 151 | void MIVariable::attachMaybe(QObject *callback, const char *callbackMethod) | ||
153 | { | 152 | { | ||
154 | if (!varobj_.isEmpty()) | 153 | if (!varobj_.isEmpty()) | ||
155 | return; | 154 | return; | ||
156 | 155 | | |||
157 | if (hasStartedSession()) { | 156 | if (hasStartedSession()) { | ||
158 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | 157 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | ||
159 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | 158 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | ||
160 | s->addCommand( | 159 | s->addCommand(VarCreate, | ||
161 | new MICommand( | | |||
162 | VarCreate, | | |||
163 | QString("var%1 @ %2").arg(nextId++).arg(enquotedExpression()), | 160 | QString("var%1 @ %2").arg(nextId++).arg(enquotedExpression()), | ||
164 | new CreateVarobjHandler(this, callback, callbackMethod))); | 161 | new CreateVarobjHandler(this, callback, callbackMethod)); | ||
165 | } | 162 | } | ||
166 | } | 163 | } | ||
167 | 164 | | |||
168 | void MIVariable::markAllDead() | 165 | void MIVariable::markAllDead() | ||
169 | { | 166 | { | ||
170 | QMap<QString, MIVariable*>::iterator i, e; | 167 | QMap<QString, MIVariable*>::iterator i, e; | ||
171 | for (i = allVariables_.begin(), e = allVariables_.end(); i != e; ++i) | 168 | for (i = allVariables_.begin(), e = allVariables_.end(); i != e; ++i) | ||
172 | { | 169 | { | ||
Show All 19 Lines | 183 | { | |||
192 | if (r.hasField("children")) | 189 | if (r.hasField("children")) | ||
193 | { | 190 | { | ||
194 | const Value& children = r["children"]; | 191 | const Value& children = r["children"]; | ||
195 | for (int i = 0; i < children.size(); ++i) { | 192 | for (int i = 0; i < children.size(); ++i) { | ||
196 | const Value& child = children[i]; | 193 | const Value& child = children[i]; | ||
197 | const QString& exp = child["exp"].literal(); | 194 | const QString& exp = child["exp"].literal(); | ||
198 | if (exp == "public" || exp == "protected" || exp == "private") { | 195 | if (exp == "public" || exp == "protected" || exp == "private") { | ||
199 | ++m_activeCommands; | 196 | ++m_activeCommands; | ||
200 | m_session->addCommand( | 197 | m_session->addCommand(VarListChildren, | ||
201 | new MICommand(VarListChildren, | 198 | QString("--all-values \"%1\"").arg(child["name"].literal()), | ||
202 | QString("--all-values \"%1\"") | 199 | this/*use again as handler*/); | ||
203 | .arg(child["name"].literal()), | | |||
204 | this/*use again as handler*/)); | | |||
205 | } else { | 200 | } else { | ||
206 | KDevelop::Variable* xvar = m_session->variableController()-> | 201 | KDevelop::Variable* xvar = m_session->variableController()-> | ||
207 | createVariable(variable->model(), variable, | 202 | createVariable(variable->model(), variable, | ||
208 | child["exp"].literal()); | 203 | child["exp"].literal()); | ||
209 | MIVariable* var = static_cast<MIVariable*>(xvar); | 204 | MIVariable* var = static_cast<MIVariable*>(xvar); | ||
210 | var->setTopLevel(false); | 205 | var->setTopLevel(false); | ||
211 | var->setVarobj(child["name"].literal()); | 206 | var->setVarobj(child["name"].literal()); | ||
212 | bool hasMore = child["numchild"].toInt() != 0 || ( child.hasField("dynamic") && child["dynamic"].toInt()!=0 ); | 207 | bool hasMore = child["numchild"].toInt() != 0 || ( child.hasField("dynamic") && child["dynamic"].toInt()!=0 ); | ||
Show All 37 Lines | |||||
250 | void MIVariable::fetchMoreChildren() | 245 | void MIVariable::fetchMoreChildren() | ||
251 | { | 246 | { | ||
252 | int c = childItems.size(); | 247 | int c = childItems.size(); | ||
253 | // FIXME: should not even try this if app is not started. | 248 | // FIXME: should not even try this if app is not started. | ||
254 | // Probably need to disable open, or something | 249 | // Probably need to disable open, or something | ||
255 | if (hasStartedSession()) { | 250 | if (hasStartedSession()) { | ||
256 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | 251 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | ||
257 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | 252 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | ||
258 | s->addCommand( | 253 | s->addCommand(VarListChildren, | ||
259 | new MICommand(VarListChildren, | 254 | QString("--all-values \"%1\" %2 %3") | ||
260 | QString("--all-values \"%1\" %2 %3").arg(varobj_) | 255 | .arg(varobj_).arg( c ).arg( c + fetchStep ), // fetch from .. to .. | ||
261 | .arg( c ).arg( c + fetchStep ), // fetch from .. to .. | 256 | new FetchMoreChildrenHandler(this, s)); | ||
262 | new FetchMoreChildrenHandler(this, s))); | | |||
263 | } | 257 | } | ||
264 | } | 258 | } | ||
265 | 259 | | |||
266 | void MIVariable::handleUpdate(const Value& var) | 260 | void MIVariable::handleUpdate(const Value& var) | ||
267 | { | 261 | { | ||
268 | if (var.hasField("type_changed") | 262 | if (var.hasField("type_changed") | ||
269 | && var["type_changed"].literal() == "true") | 263 | && var["type_changed"].literal() == "true") | ||
270 | { | 264 | { | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 362 | if( MIVariable* var=dynamic_cast<MIVariable*>(item)) | |||
369 | var->setFormat(format()); | 363 | var->setFormat(format()); | ||
370 | } | 364 | } | ||
371 | } | 365 | } | ||
372 | else | 366 | else | ||
373 | { | 367 | { | ||
374 | if (hasStartedSession()) { | 368 | if (hasStartedSession()) { | ||
375 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | 369 | IDebugSession* is = ICore::self()->debugController()->currentSession(); | ||
376 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | 370 | MIDebugSession * s = static_cast<MIDebugSession *>(is); | ||
377 | s->addCommand( | 371 | s->addCommand(VarSetFormat, | ||
378 | new MICommand(VarSetFormat, | | |||
379 | QString(" \"%1\" %2 ").arg(varobj_).arg(format2str(format())), | 372 | QString(" \"%1\" %2 ").arg(varobj_).arg(format2str(format())), | ||
380 | new SetFormatHandler(this) | 373 | new SetFormatHandler(this)); | ||
381 | ) | | |||
382 | ); | | |||
383 | } | 374 | } | ||
384 | } | 375 | } | ||
385 | } | 376 | } |