File indexing completed on 2024-04-21 04:36:04
0001 /* 0002 * XDebug-specific implementation of thread and frame model. 0003 * 0004 * Copyright 2009 Niko Sams <niko.sams@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of the 0009 * License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public 0017 * License along with this program; if not, write to the 0018 * Free Software Foundation, Inc., 0019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #include <QXmlStreamReader> 0023 0024 #include <QDebug> 0025 0026 #include "framestackmodel.h" 0027 #include "connection.h" 0028 0029 #include <kdevplatform_version.h> 0030 0031 #include <QDomElement> 0032 0033 namespace XDebug { 0034 void FrameStackModel::fetchThreads() 0035 { 0036 //no multithreading in php, create just one 0037 #if KDEVPLATFORM_VERSION < QT_VERSION_CHECK(5,2,40) 0038 QList<KDevelop::FrameStackModel::ThreadItem> threadsList; 0039 #else 0040 QVector<KDevelop::FrameStackModel::ThreadItem> threadsList; 0041 #endif 0042 KDevelop::FrameStackModel::ThreadItem i; 0043 i.nr = 0; 0044 i.name = "main thread"; 0045 threadsList << i; 0046 setThreads(threadsList); 0047 setCurrentThread(0); 0048 } 0049 0050 void FrameStackModel::handleStack(const QDomDocument& xml) 0051 { 0052 Q_ASSERT(xml.documentElement().attribute("command") == "stack_get"); 0053 0054 #if KDEVPLATFORM_VERSION < QT_VERSION_CHECK(5,2,40) 0055 QList<KDevelop::FrameStackModel::FrameItem> frames; 0056 #else 0057 QVector<KDevelop::FrameStackModel::FrameItem> frames; 0058 #endif 0059 QDomElement el = xml.documentElement().firstChildElement("stack"); 0060 while (!el.isNull()) { 0061 KDevelop::FrameStackModel::FrameItem f; 0062 f.nr = el.attribute("level").toInt(); 0063 f.name = el.attribute("where"); 0064 f.file = el.attribute("filename"); 0065 f.line = el.attribute("lineno").toInt() - 1; 0066 frames << f; 0067 el = el.nextSiblingElement("stack"); 0068 } 0069 setFrames(0, frames); 0070 setHasMoreFrames(0, false); 0071 } 0072 0073 void FrameStackModel::fetchFrames(int threadNumber, int from, int to) 0074 { 0075 Q_UNUSED(from); //we fetch always everything 0076 Q_UNUSED(to); 0077 0078 if (threadNumber == 0) { //we support only one thread 0079 Callback<FrameStackModel>* cb = new Callback<FrameStackModel>(this, &FrameStackModel::handleStack); 0080 session()->connection()->sendCommand("stack_get", QStringList(), QByteArray(), cb); 0081 } 0082 } 0083 }