File indexing completed on 2024-05-12 04:40:07

0001 /*
0002     SPDX-FileCopyrightText: 2016 Aetf <aetf@unlimitedcodeworks.xyz>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #include "variablecontroller.h"
0008 
0009 #include "debugsession.h"
0010 #include "debuglog.h"
0011 #include "mi/micommand.h"
0012 
0013 #include <debugger/variable/variablecollection.h>
0014 
0015 using namespace KDevelop;
0016 using namespace KDevMI::LLDB;
0017 
0018 VariableController::VariableController(DebugSession *parent)
0019     : MIVariableController(parent)
0020 {
0021 }
0022 
0023 DebugSession *VariableController::debugSession() const
0024 {
0025     return static_cast<DebugSession*>(const_cast<QObject*>(QObject::parent()));
0026 }
0027 
0028 LldbVariable* VariableController::createVariable(TreeModel* model, TreeItem* parent,
0029                                              const QString& expression, const QString& display)
0030 {
0031     return new LldbVariable(debugSession(), model, parent, expression, display);
0032 }
0033 
0034 void VariableController::update()
0035 {
0036     qCDebug(DEBUGGERLLDB) << "autoUpdate =" << autoUpdate();
0037     if (autoUpdate() & UpdateWatches) {
0038         variableCollection()->watches()->reinstall();
0039     }
0040 
0041     if (autoUpdate() & UpdateLocals) {
0042         updateLocals();
0043     }
0044 
0045     if ((autoUpdate() & UpdateLocals) ||
0046        ((autoUpdate() & UpdateWatches) && variableCollection()->watches()->childCount() > 0))
0047     {
0048         debugSession()->updateAllVariables();
0049     }
0050 }
0051 
0052 #include "moc_variablecontroller.cpp"