| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | /**************************************************************************
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-06-17 00:01:27 +10:00
										 |  |  | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Commercial Usage | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Licensees holding valid Qt Commercial licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the Qt Commercial License Agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Nokia. | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** If you are unsure which license is appropriate for your use, please | 
					
						
							| 
									
										
										
										
											2009-08-14 09:30:56 +02:00
										 |  |  | ** contact the sales department at http://qt.nokia.com/contact.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | **************************************************************************/ | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  | #define QT_NO_CAST_FROM_ASCII
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "gdbengine.h"
 | 
					
						
							| 
									
										
										
										
											2009-04-17 09:03:32 +02:00
										 |  |  | #include "gdboptionspage.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-18 12:51:15 +02:00
										 |  |  | #include "trkoptions.h"
 | 
					
						
							|  |  |  | #include "trkoptionspage.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | #include "plaingdbadapter.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  | #include "trkgdbadapter.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-25 13:42:47 +01:00
										 |  |  | #include "watchutils.h"
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:00:06 +01:00
										 |  |  | #include "debuggeractions.h"
 | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  | #include "debuggeragents.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "debuggerconstants.h"
 | 
					
						
							|  |  |  | #include "debuggermanager.h"
 | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  | #include "debuggertooltip.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "gdbmi.h"
 | 
					
						
							|  |  |  | #include "procinterrupt.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "breakhandler.h"
 | 
					
						
							|  |  |  | #include "moduleshandler.h"
 | 
					
						
							|  |  |  | #include "registerhandler.h"
 | 
					
						
							|  |  |  | #include "stackhandler.h"
 | 
					
						
							|  |  |  | #include "watchhandler.h"
 | 
					
						
							| 
									
										
										
										
											2009-02-17 14:08:49 +01:00
										 |  |  | #include "sourcefileswindow.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-02 13:08:30 +01:00
										 |  |  | #include "debuggerdialogs.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-09 16:18:28 +01:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							| 
									
										
										
										
											2009-05-14 14:29:37 +02:00
										 |  |  | #include <texteditor/itexteditor.h>
 | 
					
						
							| 
									
										
										
										
											2009-04-08 17:25:28 +02:00
										 |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-09 16:18:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <QtCore/QDebug>
 | 
					
						
							|  |  |  | #include <QtCore/QDir>
 | 
					
						
							|  |  |  | #include <QtCore/QFileInfo>
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  | #include <QtCore/QMetaObject>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <QtCore/QTime>
 | 
					
						
							|  |  |  | #include <QtCore/QTimer>
 | 
					
						
							| 
									
										
										
										
											2009-04-29 14:15:09 +02:00
										 |  |  | #include <QtCore/QTextStream>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QtGui/QAction>
 | 
					
						
							| 
									
										
										
										
											2009-07-15 16:50:49 +02:00
										 |  |  | #include <QtCore/QCoreApplication>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <QtGui/QLabel>
 | 
					
						
							|  |  |  | #include <QtGui/QMainWindow>
 | 
					
						
							|  |  |  | #include <QtGui/QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2009-04-08 17:25:28 +02:00
										 |  |  | #include <QtGui/QDialogButtonBox>
 | 
					
						
							|  |  |  | #include <QtGui/QPushButton>
 | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  | #ifdef Q_OS_WIN
 | 
					
						
							| 
									
										
										
										
											2009-05-19 15:45:58 +02:00
										 |  |  | #    include "shared/sharedlibraryinjector.h"
 | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  | #ifdef Q_OS_UNIX
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  | #include <dlfcn.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-02 11:41:36 +02:00
										 |  |  | #include <ctype.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-22 09:27:19 +02:00
										 |  |  | // FIXME: temporary hack to evalute tbreak based step-over behaviour
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | static QString lastFile; | 
					
						
							|  |  |  | static int lastLine; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  | namespace Debugger { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | //#define DEBUG_PENDING  1
 | 
					
						
							| 
									
										
										
										
											2009-09-16 12:20:16 +02:00
										 |  |  | //#define DEBUG_SUBITEM  1
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if DEBUG_PENDING
 | 
					
						
							|  |  |  | #   define PENDING_DEBUG(s) qDebug() << s
 | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  | #   define PENDING_DEBUG(s)
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  | #define STRINGIFY_INTERNAL(x) #x
 | 
					
						
							|  |  |  | #define STRINGIFY(x) STRINGIFY_INTERNAL(x)
 | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  | #define CB(callback) &GdbEngine::callback, STRINGIFY(callback)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-22 09:27:19 +02:00
										 |  |  | static bool stateAcceptsGdbCommands(GdbAdapterState state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return state == AdapterStarted | 
					
						
							|  |  |  |         || state == InferiorPreparing | 
					
						
							|  |  |  |         || state == InferiorPrepared | 
					
						
							|  |  |  |         || state == InferiorStarting | 
					
						
							|  |  |  |         || state == InferiorStarted | 
					
						
							|  |  |  |         || state == InferiorShuttingDown | 
					
						
							|  |  |  |         || state == InferiorShutDown | 
					
						
							|  |  |  |         || state == AdapterShuttingDown; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | static int ¤tToken() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     static int token = 0; | 
					
						
							|  |  |  |     return token; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-01 12:49:41 +02:00
										 |  |  | // reads a MI-encoded item frome the consolestream
 | 
					
						
							|  |  |  | static bool parseConsoleStream(const GdbResultRecord &record, GdbMi *contents) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     GdbMi output = record.data.findChild("consolestreamoutput"); | 
					
						
							|  |  |  |     QByteArray out = output.data(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int markerPos = out.indexOf('"') + 1; // position of 'success marker'
 | 
					
						
							|  |  |  |     if (markerPos == 0 || out.at(markerPos) == 'f') {  // 't' or 'f'
 | 
					
						
							|  |  |  |         // custom dumper produced no output
 | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     out = out.mid(markerPos +  1); | 
					
						
							|  |  |  |     out = out.left(out.lastIndexOf('"')); | 
					
						
							|  |  |  |     // optimization: dumper output never needs real C unquoting
 | 
					
						
							|  |  |  |     out.replace('\\', ""); | 
					
						
							|  |  |  |     out = "dummy={" + out + "}"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     contents->fromString(out); | 
					
						
							|  |  |  |     //qDebug() << "CONTENTS" << contents->toString(true);
 | 
					
						
							|  |  |  |     return contents->isValid(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static QByteArray parsePlainConsoleStream(const GdbResultRecord &record) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     GdbMi output = record.data.findChild("consolestreamoutput"); | 
					
						
							|  |  |  |     QByteArray out = output.data(); | 
					
						
							|  |  |  |     // FIXME: proper decoding needed
 | 
					
						
							|  |  |  |     if (out.endsWith("\\n")) | 
					
						
							|  |  |  |         out.chop(2); | 
					
						
							|  |  |  |     while (out.endsWith('\n') || out.endsWith(' ')) | 
					
						
							|  |  |  |         out.chop(1); | 
					
						
							|  |  |  |     int pos = out.indexOf(" = "); | 
					
						
							|  |  |  |     return out.mid(pos + 3); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // GdbEngine
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | GdbEngine::GdbEngine(DebuggerManager *parent) : | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  | #ifdef Q_OS_WIN // Do injection loading with MinGW (call loading does not work with 64bit)
 | 
					
						
							| 
									
										
										
										
											2009-06-29 13:53:41 +02:00
										 |  |  |     m_dumperInjectionLoad(true), | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-06-29 13:53:41 +02:00
										 |  |  |     m_dumperInjectionLoad(false), | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     m_manager(parent), | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     qq(parent->engineInterface()) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     m_gdbAdapter = 0; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GdbEngine::~GdbEngine() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-16 13:29:57 +01:00
										 |  |  |     // prevent sending error messages afterwards
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     if (m_gdbAdapter) { | 
					
						
							|  |  |  |         m_gdbAdapter->disconnect(this); | 
					
						
							|  |  |  |         delete m_gdbAdapter; | 
					
						
							|  |  |  |         m_gdbAdapter = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::setGdbAdapter(AbstractGdbAdapter *gdbAdapter) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_gdbAdapter = gdbAdapter; | 
					
						
							|  |  |  |     initializeVariables(); | 
					
						
							|  |  |  |     initializeConnections(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  | void GdbEngine::initializeConnections() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // Gdb Process interaction
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     connect(m_gdbAdapter, SIGNAL(error(QProcess::ProcessError)), | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |         this, SLOT(gdbProcError(QProcess::ProcessError))); | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     connect(m_gdbAdapter, SIGNAL(readyReadStandardOutput()), | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |         this, SLOT(readGdbStandardOutput())); | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     connect(m_gdbAdapter, SIGNAL(readyReadStandardError()), | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |         this, SLOT(readGdbStandardError())); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(adapterStarted()), | 
					
						
							|  |  |  |         this, SLOT(handleAdapterStarted())); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(adapterStartFailed(QString)), | 
					
						
							|  |  |  |         this, SLOT(handleAdapterStartFailed(QString))); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(adapterShutDown()), | 
					
						
							|  |  |  |         this, SLOT(handleAdapterShutDown())); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(adapterShutdownFailed(QString)), | 
					
						
							|  |  |  |         this, SLOT(handleAdapterShutdownFailed(QString))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(inferiorPrepared()), | 
					
						
							|  |  |  |         this, SLOT(handleInferiorPrepared())); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(inferiorPreparationFailed(QString)), | 
					
						
							|  |  |  |         this, SLOT(handleInferiorPreparationFailed(QString))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(inferiorStarted()), | 
					
						
							|  |  |  |         this, SLOT(handleInferiorStarted())); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(inferiorStartFailed(QString)), | 
					
						
							|  |  |  |         this, SLOT(handleInferiorStartFailed(QString))); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(inferiorShutDown()), | 
					
						
							|  |  |  |         this, SLOT(handleInferiorShutDown())); | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(inferiorShutdownFailed(QString)), | 
					
						
							|  |  |  |         this, SLOT(handleInferiorShutdownFailed(QString))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_gdbAdapter, SIGNAL(adapterCrashed()), | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         m_manager, SLOT(exitDebugger())); | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // Output
 | 
					
						
							| 
									
										
										
										
											2009-01-15 14:47:14 +01:00
										 |  |  |     connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)), | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |         this, SLOT(readDebugeeOutput(QByteArray))); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     connect(this, SIGNAL(gdbOutputAvailable(int,QString)), | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         m_manager, SLOT(showDebuggerOutput(int,QString)), | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     connect(this, SIGNAL(gdbInputAvailable(int,QString)), | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         m_manager, SLOT(showDebuggerInput(int,QString)), | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2009-01-15 14:30:49 +01:00
										 |  |  |     connect(this, SIGNAL(applicationOutputAvailable(QString)), | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         m_manager, SLOT(showApplicationOutput(QString)), | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2009-03-17 17:00:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 10:21:50 +02:00
										 |  |  |     // FIXME: These trigger even if the engine is not active
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     connect(theDebuggerAction(UseDebuggingHelpers), SIGNAL(valueChanged(QVariant)), | 
					
						
							|  |  |  |         this, SLOT(setUseDebuggingHelpers(QVariant))); | 
					
						
							|  |  |  |     connect(theDebuggerAction(DebugDebuggingHelpers), SIGNAL(valueChanged(QVariant)), | 
					
						
							|  |  |  |         this, SLOT(setDebugDebuggingHelpers(QVariant))); | 
					
						
							|  |  |  |     connect(theDebuggerAction(RecheckDebuggingHelpers), SIGNAL(triggered()), | 
					
						
							|  |  |  |         this, SLOT(recheckDebuggingHelperAvailability())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  | void GdbEngine::initializeVariables() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     m_debuggingHelperState = DebuggingHelperUninitialized; | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  |     m_gdbVersion = 100; | 
					
						
							| 
									
										
										
										
											2009-02-23 16:06:23 +01:00
										 |  |  |     m_gdbBuildVersion = -1; | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_fullToShortName.clear(); | 
					
						
							|  |  |  |     m_shortToFullName.clear(); | 
					
						
							|  |  |  |     m_varToType.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_modulesListOutdated = true; | 
					
						
							|  |  |  |     m_oldestAcceptableToken = -1; | 
					
						
							|  |  |  |     m_outputCodec = QTextCodec::codecForLocale(); | 
					
						
							|  |  |  |     m_pendingRequests = 0; | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     m_continuationAfterDone = 0; | 
					
						
							| 
									
										
										
										
											2009-02-13 16:55:24 +01:00
										 |  |  |     m_waitingForFirstBreakpointToBeHit = false; | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     m_commandsToRunOnTemporaryBreak.clear(); | 
					
						
							| 
									
										
										
										
											2009-06-29 13:28:01 +02:00
										 |  |  |     m_cookieForToken.clear(); | 
					
						
							| 
									
										
										
										
											2009-06-29 13:53:41 +02:00
										 |  |  |     m_customOutputForToken.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_pendingConsoleStreamOutput.clear(); | 
					
						
							|  |  |  |     m_pendingTargetStreamOutput.clear(); | 
					
						
							|  |  |  |     m_pendingLogStreamOutput.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_inbuffer.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_currentFunctionArgs.clear(); | 
					
						
							|  |  |  |     m_currentFrame.clear(); | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |     m_dumperHelper.clear(); | 
					
						
							| 
									
										
										
										
											2009-06-29 13:53:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // FIXME: unhandled:
 | 
					
						
							|  |  |  |     //m_outputCodecState = QTextCodec::ConverterState();
 | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     //m_gdbAdapter;
 | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::gdbProcError(QProcess::ProcessError error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString msg; | 
					
						
							| 
									
										
										
										
											2009-06-12 17:34:34 +02:00
										 |  |  |     bool kill = true; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     switch (error) { | 
					
						
							|  |  |  |         case QProcess::FailedToStart: | 
					
						
							| 
									
										
										
										
											2009-06-12 17:34:34 +02:00
										 |  |  |             kill = false; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             msg = tr("The Gdb process failed to start. Either the " | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 "invoked program '%1' is missing, or you may have insufficient " | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 "permissions to invoke the program.") | 
					
						
							| 
									
										
										
										
											2009-03-19 15:44:26 +01:00
										 |  |  |                 .arg(theDebuggerStringSetting(GdbLocation)); | 
					
						
							| 
									
										
										
										
											2009-09-11 09:51:05 +02:00
										 |  |  |             emitStartFailed(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case QProcess::Crashed: | 
					
						
							| 
									
										
										
										
											2009-06-12 17:34:34 +02:00
										 |  |  |             kill = false; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             msg = tr("The Gdb process crashed some time after starting " | 
					
						
							|  |  |  |                 "successfully."); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case QProcess::Timedout: | 
					
						
							|  |  |  |             msg = tr("The last waitFor...() function timed out. " | 
					
						
							|  |  |  |                 "The state of QProcess is unchanged, and you can try calling " | 
					
						
							|  |  |  |                 "waitFor...() again."); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case QProcess::WriteError: | 
					
						
							|  |  |  |             msg = tr("An error occurred when attempting to write " | 
					
						
							|  |  |  |                 "to the Gdb process. For example, the process may not be running, " | 
					
						
							|  |  |  |                 "or it may have closed its input channel."); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case QProcess::ReadError: | 
					
						
							|  |  |  |             msg = tr("An error occurred when attempting to read from " | 
					
						
							|  |  |  |                 "the Gdb process. For example, the process may not be running."); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             msg = tr("An unknown error in the Gdb process occurred. " | 
					
						
							|  |  |  |                 "This is the default return value of error()."); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(msg); | 
					
						
							|  |  |  |     QMessageBox::critical(mainWindow(), tr("Error"), msg); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // act as if it was closed by the core
 | 
					
						
							| 
									
										
										
										
											2009-06-12 17:34:34 +02:00
										 |  |  |     if (kill) | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         m_manager->exitDebugger(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  | static void dump(const char *first, const char *middle, const QString & to) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QByteArray ba(first, middle - first); | 
					
						
							| 
									
										
										
										
											2009-07-13 17:35:17 +02:00
										 |  |  |     Q_UNUSED(to) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // note that qDebug cuts off output after a certain size... (bug?)
 | 
					
						
							|  |  |  |     qDebug("\n>>>>> %s\n%s\n====\n%s\n<<<<<\n", | 
					
						
							|  |  |  |         qPrintable(currentTime()), | 
					
						
							|  |  |  |         qPrintable(QString(ba).trimmed()), | 
					
						
							|  |  |  |         qPrintable(to.trimmed())); | 
					
						
							|  |  |  |     //qDebug() << "";
 | 
					
						
							|  |  |  |     //qDebug() << qPrintable(currentTime())
 | 
					
						
							|  |  |  |     //    << " Reading response:  " << QString(ba).trimmed() << "\n";
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-15 14:47:14 +01:00
										 |  |  | void GdbEngine::readDebugeeOutput(const QByteArray &data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     emit applicationOutputAvailable(m_outputCodec->toUnicode( | 
					
						
							|  |  |  |             data.constData(), data.length(), &m_outputCodecState)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-16 13:29:57 +01:00
										 |  |  | void GdbEngine::debugMessage(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     emit gdbOutputAvailable(LogDebug, msg); | 
					
						
							| 
									
										
										
										
											2009-02-16 13:29:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  | void GdbEngine::handleResponse(const QByteArray &buff) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     static QTime lastTime; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     if (theDebuggerBoolSetting(LogTimeStamps)) | 
					
						
							| 
									
										
										
										
											2009-07-06 09:54:24 +02:00
										 |  |  |         emit gdbOutputAvailable(LogTime, currentTime()); | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     emit gdbOutputAvailable(LogOutput, QString::fromLocal8Bit(buff, buff.length())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  |     qDebug() // << "#### start response handling #### "
 | 
					
						
							|  |  |  |         << currentTime() | 
					
						
							|  |  |  |         << lastTime.msecsTo(QTime::currentTime()) << "ms," | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         << "buf:" << buff.left(1500) << "..." | 
					
						
							|  |  |  |         //<< "buf:" << buff
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         << "size:" << buff.size(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "buf:" << buff;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     lastTime = QTime::currentTime(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     if (buff.isEmpty() || buff == "(gdb) ") | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     const char *from = buff.constData(); | 
					
						
							|  |  |  |     const char *to = from + buff.size(); | 
					
						
							|  |  |  |     const char *inner; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     int token = -1; | 
					
						
							|  |  |  |     // token is a sequence of numbers
 | 
					
						
							|  |  |  |     for (inner = from; inner != to; ++inner) | 
					
						
							|  |  |  |         if (*inner < '0' || *inner > '9') | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     if (from != inner) { | 
					
						
							|  |  |  |         token = QByteArray(from, inner - from).toInt(); | 
					
						
							|  |  |  |         from = inner; | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "found token" << token;
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     // next char decides kind of record
 | 
					
						
							|  |  |  |     const char c = *from++; | 
					
						
							|  |  |  |     //qDebug() << "CODE:" << c;
 | 
					
						
							|  |  |  |     switch (c) { | 
					
						
							|  |  |  |         case '*': | 
					
						
							|  |  |  |         case '+': | 
					
						
							|  |  |  |         case '=': { | 
					
						
							|  |  |  |             QByteArray asyncClass; | 
					
						
							|  |  |  |             for (; from != to; ++from) { | 
					
						
							|  |  |  |                 const char c = *from; | 
					
						
							|  |  |  |                 if (!isNameChar(c)) | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 asyncClass += *from; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             //qDebug() << "ASYNCCLASS" << asyncClass;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             GdbMi record; | 
					
						
							|  |  |  |             while (from != to) { | 
					
						
							|  |  |  |                 GdbMi data; | 
					
						
							| 
									
										
										
										
											2009-04-07 14:14:43 +02:00
										 |  |  |                 if (*from != ',') { | 
					
						
							| 
									
										
										
										
											2009-04-07 09:51:21 +02:00
										 |  |  |                     // happens on archer where we get 
 | 
					
						
							|  |  |  |                     // 23^running <NL> *running,thread-id="all" <NL> (gdb) 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |                     record.m_type = GdbMi::Tuple; | 
					
						
							| 
									
										
										
										
											2009-04-07 14:14:43 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 ++from; // skip ','
 | 
					
						
							|  |  |  |                 data.parseResultOrValue(from, to); | 
					
						
							|  |  |  |                 if (data.isValid()) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |                     //qDebug() << "parsed response:" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2009-04-07 14:14:43 +02:00
										 |  |  |                     record.m_children += data; | 
					
						
							|  |  |  |                     record.m_type = GdbMi::Tuple; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             if (asyncClass == "stopped") { | 
					
						
							|  |  |  |                 handleAsyncOutput(record); | 
					
						
							|  |  |  |             } else if (asyncClass == "running") { | 
					
						
							|  |  |  |                 // Archer has 'thread-id="all"' here
 | 
					
						
							| 
									
										
										
										
											2009-04-01 15:44:34 +02:00
										 |  |  |             } else if (asyncClass == "library-loaded") { | 
					
						
							|  |  |  |                 // Archer has 'id="/usr/lib/libdrm.so.2",
 | 
					
						
							|  |  |  |                 // target-name="/usr/lib/libdrm.so.2",
 | 
					
						
							|  |  |  |                 // host-name="/usr/lib/libdrm.so.2",
 | 
					
						
							| 
									
										
										
										
											2009-04-01 16:06:49 +02:00
										 |  |  |                 // symbols-loaded="0"
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							| 
									
										
										
										
											2009-04-29 10:33:37 +02:00
										 |  |  |                 if (!id.isEmpty()) | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                     showStatusMessage(tr("Library %1 loaded.").arg(_(id))); | 
					
						
							| 
									
										
										
										
											2009-04-07 09:40:56 +02:00
										 |  |  |             } else if (asyncClass == "library-unloaded") { | 
					
						
							|  |  |  |                 // Archer has 'id="/usr/lib/libdrm.so.2",
 | 
					
						
							|  |  |  |                 // target-name="/usr/lib/libdrm.so.2",
 | 
					
						
							|  |  |  |                 // host-name="/usr/lib/libdrm.so.2"
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Library %1 unloaded.").arg(_(id))); | 
					
						
							| 
									
										
										
										
											2009-04-01 16:06:49 +02:00
										 |  |  |             } else if (asyncClass == "thread-group-created") { | 
					
						
							|  |  |  |                 // Archer has "{id="28902"}" 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Thread group %1 created.").arg(_(id))); | 
					
						
							| 
									
										
										
										
											2009-04-01 16:06:49 +02:00
										 |  |  |             } else if (asyncClass == "thread-created") { | 
					
						
							|  |  |  |                 //"{id="1",group-id="28902"}" 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Thread %1 created.").arg(_(id))); | 
					
						
							| 
									
										
										
										
											2009-04-01 16:49:45 +02:00
										 |  |  |             } else if (asyncClass == "thread-group-exited") { | 
					
						
							|  |  |  |                 // Archer has "{id="28902"}" 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Thread group %1 exited.").arg(_(id))); | 
					
						
							| 
									
										
										
										
											2009-04-01 16:49:45 +02:00
										 |  |  |             } else if (asyncClass == "thread-exited") { | 
					
						
							|  |  |  |                 //"{id="1",group-id="28902"}" 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							|  |  |  |                 QByteArray groupid = record.findChild("group-id").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Thread %1 in group %2 exited.") | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                     .arg(_(id)).arg(_(groupid))); | 
					
						
							| 
									
										
										
										
											2009-04-07 09:51:21 +02:00
										 |  |  |             } else if (asyncClass == "thread-selected") { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QByteArray id = record.findChild("id").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Thread %1 selected.").arg(_(id))); | 
					
						
							| 
									
										
										
										
											2009-04-07 09:51:21 +02:00
										 |  |  |                 //"{id="2"}" 
 | 
					
						
							| 
									
										
										
										
											2009-05-11 10:22:03 +02:00
										 |  |  |             #if defined(Q_OS_MAC)
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             } else if (asyncClass == "shlibs-updated") { | 
					
						
							|  |  |  |                 // MAC announces updated libs
 | 
					
						
							|  |  |  |             } else if (asyncClass == "shlibs-added") { | 
					
						
							|  |  |  |                 // MAC announces added libs
 | 
					
						
							|  |  |  |                 // {shlib-info={num="2", name="libmathCommon.A_debug.dylib",
 | 
					
						
							|  |  |  |                 // kind="-", dyld-addr="0x7f000", reason="dyld", requested-state="Y",
 | 
					
						
							|  |  |  |                 // state="Y", path="/usr/lib/system/libmathCommon.A_debug.dylib",
 | 
					
						
							|  |  |  |                 // description="/usr/lib/system/libmathCommon.A_debug.dylib",
 | 
					
						
							|  |  |  |                 // loaded_addr="0x7f000", slide="0x7f000", prefix=""}}
 | 
					
						
							|  |  |  |             #endif
 | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |                 qDebug() << "IGNORED ASYNC OUTPUT" | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |                     << asyncClass << record.toString(); | 
					
						
							| 
									
										
										
										
											2009-02-12 13:31:19 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-12 13:31:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         case '~': { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |             static QRegExp re(_("New .hread 0x[0-9a-f]* \\(LWP ([0-9]*)\\)")); | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |             QByteArray data = GdbMi::parseCString(from, to); | 
					
						
							|  |  |  |             m_pendingConsoleStreamOutput += data; | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |             if (re.indexIn(_(data)) != -1) | 
					
						
							|  |  |  |                 maybeHandleInferiorPidChanged(re.cap(1)); | 
					
						
							|  |  |  |             if (data.startsWith("Reading symbols from ")) | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 showStatusMessage(tr("Reading %1...").arg(_(data.mid(21)))); | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-12 13:31:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         case '@': { | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |             QByteArray data = GdbMi::parseCString(from, to); | 
					
						
							|  |  |  |             m_pendingTargetStreamOutput += data; | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         case '&': { | 
					
						
							|  |  |  |             QByteArray data = GdbMi::parseCString(from, to); | 
					
						
							|  |  |  |             m_pendingLogStreamOutput += data; | 
					
						
							|  |  |  |             // On Windows, the contents seem to depend on the debugger
 | 
					
						
							|  |  |  |             // version and/or OS version used.
 | 
					
						
							|  |  |  |             if (data.startsWith("warning:")) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 qq->showApplicationOutput(_(data.mid(9))); // cut "warning: "
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         case '^': { | 
					
						
							|  |  |  |             GdbResultRecord record; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             record.token = token; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             for (inner = from; inner != to; ++inner) | 
					
						
							|  |  |  |                 if (*inner < 'a' || *inner > 'z') | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:22:13 +02:00
										 |  |  |             QByteArray resultClass = QByteArray::fromRawData(from, inner - from); | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             if (resultClass == "done") | 
					
						
							|  |  |  |                 record.resultClass = GdbResultDone; | 
					
						
							|  |  |  |             else if (resultClass == "running") | 
					
						
							|  |  |  |                 record.resultClass = GdbResultRunning; | 
					
						
							|  |  |  |             else if (resultClass == "connected") | 
					
						
							|  |  |  |                 record.resultClass = GdbResultConnected; | 
					
						
							|  |  |  |             else if (resultClass == "error") | 
					
						
							|  |  |  |                 record.resultClass = GdbResultError; | 
					
						
							|  |  |  |             else if (resultClass == "exit") | 
					
						
							|  |  |  |                 record.resultClass = GdbResultExit; | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 record.resultClass = GdbResultUnknown; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |             from = inner; | 
					
						
							|  |  |  |             if (from != to) { | 
					
						
							| 
									
										
										
										
											2009-04-07 09:51:21 +02:00
										 |  |  |                 if (*from == ',') { | 
					
						
							|  |  |  |                     ++from; | 
					
						
							|  |  |  |                     record.data.parseTuple_helper(from, to); | 
					
						
							|  |  |  |                     record.data.m_type = GdbMi::Tuple; | 
					
						
							|  |  |  |                     record.data.m_name = "data"; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     // Archer has this
 | 
					
						
							|  |  |  |                     record.data.m_type = GdbMi::Tuple; | 
					
						
							|  |  |  |                     record.data.m_name = "data"; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             //qDebug() << "\nLOG STREAM:" + m_pendingLogStreamOutput;
 | 
					
						
							|  |  |  |             //qDebug() << "\nTARGET STREAM:" + m_pendingTargetStreamOutput;
 | 
					
						
							|  |  |  |             //qDebug() << "\nCONSOLE STREAM:" + m_pendingConsoleStreamOutput;
 | 
					
						
							|  |  |  |             record.data.setStreamOutput("logstreamoutput", | 
					
						
							|  |  |  |                 m_pendingLogStreamOutput); | 
					
						
							|  |  |  |             record.data.setStreamOutput("targetstreamoutput", | 
					
						
							|  |  |  |                 m_pendingTargetStreamOutput); | 
					
						
							|  |  |  |             record.data.setStreamOutput("consolestreamoutput", | 
					
						
							|  |  |  |                 m_pendingConsoleStreamOutput); | 
					
						
							|  |  |  |             QByteArray custom = m_customOutputForToken[token]; | 
					
						
							|  |  |  |             if (!custom.isEmpty()) | 
					
						
							|  |  |  |                 record.data.setStreamOutput("customvaluecontents", | 
					
						
							|  |  |  |                     '{' + custom + '}'); | 
					
						
							|  |  |  |             //m_customOutputForToken.remove(token);
 | 
					
						
							|  |  |  |             m_pendingLogStreamOutput.clear(); | 
					
						
							|  |  |  |             m_pendingTargetStreamOutput.clear(); | 
					
						
							|  |  |  |             m_pendingConsoleStreamOutput.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             handleResultRecord(record); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         default: { | 
					
						
							|  |  |  |             qDebug() << "UNKNOWN RESPONSE TYPE" << c; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::readGdbStandardError() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     qWarning() << "Unexpected gdb stderr:" << m_gdbAdapter->readAllStandardError(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::readGdbStandardOutput() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-24 22:36:36 +01:00
										 |  |  |     int newstart = 0; | 
					
						
							|  |  |  |     int scan = m_inbuffer.size(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     m_inbuffer.append(m_gdbAdapter->readAllStandardOutput()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |     while (newstart < m_inbuffer.size()) { | 
					
						
							|  |  |  |         int start = newstart; | 
					
						
							| 
									
										
										
										
											2009-02-24 22:36:36 +01:00
										 |  |  |         int end = m_inbuffer.indexOf('\n', scan); | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         if (end < 0) { | 
					
						
							|  |  |  |             m_inbuffer.remove(0, start); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         newstart = end + 1; | 
					
						
							| 
									
										
										
										
											2009-02-24 22:36:36 +01:00
										 |  |  |         scan = newstart; | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         if (end == start) | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2009-05-11 10:22:03 +02:00
										 |  |  |         #if defined(Q_OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         if (m_inbuffer.at(end - 1) == '\r') { | 
					
						
							|  |  |  |             --end; | 
					
						
							|  |  |  |             if (end == start) | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-24 22:36:36 +01:00
										 |  |  |         #endif
 | 
					
						
							| 
									
										
										
										
											2009-02-24 20:34:30 +01:00
										 |  |  |         handleResponse(QByteArray::fromRawData(m_inbuffer.constData() + start, end - start)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-02-24 21:50:20 +01:00
										 |  |  |     m_inbuffer.clear(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::interruptInferior() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  | //    debugMessage(_("GDBENGINE INTERRUPT INFERIOR: %1").arg(m_gdbAdapter->state()));
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     qq->notifyInferiorStopRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-06 11:37:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  |     if (m_gdbAdapter->state() == AdapterNotRunning) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         debugMessage(_("TRYING TO INTERRUPT INFERIOR WITHOUT RUNNING GDB")); | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         qq->notifyInferiorExited(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     m_gdbAdapter->interruptInferior(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-25 16:22:11 +02:00
										 |  |  |     const qint64 pid = pid0.toLongLong(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (pid == 0) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         debugMessage(_("Cannot parse PID from %1").arg(pid0)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     if (pid == inferiorPid()) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-05-25 16:22:11 +02:00
										 |  |  |     debugMessage(_("FOUND PID %1").arg(pid));     | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  |     qq->notifyInferiorPidChanged(pid); | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |     if (m_dumperInjectionLoad) | 
					
						
							|  |  |  |         tryLoadDebuggingHelpers(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | void GdbEngine::postCommand(const QString &command, AdapterCallback callback, | 
					
						
							|  |  |  |                             const char *callbackName, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     postCommand(command, NoFlags, callback, callbackName, cookie); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::postCommand(const QString &command, GdbCommandFlags flags, | 
					
						
							|  |  |  |                             AdapterCallback callback, | 
					
						
							|  |  |  |                             const char *callbackName, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     GdbCommand cmd; | 
					
						
							|  |  |  |     cmd.command = command; | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     cmd.flags = flags; | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     cmd.adapterCallback = callback; | 
					
						
							|  |  |  |     cmd.callbackName = callbackName; | 
					
						
							|  |  |  |     cmd.cookie = cookie; | 
					
						
							|  |  |  |     postCommandHelper(cmd); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  | void GdbEngine::postCommand(const QString &command, GdbCommandCallback callback, | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |                             const char *callbackName, const QVariant &cookie) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(command, NoFlags, callback, callbackName, cookie); | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  | void GdbEngine::postCommand(const QString &command, GdbCommandFlags flags, | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |                             GdbCommandCallback callback, const char *callbackName, | 
					
						
							|  |  |  |                             const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     GdbCommand cmd; | 
					
						
							|  |  |  |     cmd.command = command; | 
					
						
							|  |  |  |     cmd.flags = flags; | 
					
						
							|  |  |  |     cmd.callback = callback; | 
					
						
							|  |  |  |     cmd.callbackName = callbackName; | 
					
						
							|  |  |  |     cmd.cookie = cookie; | 
					
						
							|  |  |  |     postCommandHelper(cmd); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::postCommandHelper(const GdbCommand &cmd) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-22 09:27:19 +02:00
										 |  |  |     if (!stateAcceptsGdbCommands(m_gdbAdapter->state())) { | 
					
						
							|  |  |  |         PENDING_DEBUG(_("NO GDB PROCESS RUNNING, CMD IGNORED: ") + cmd.command); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |         debugMessage(_("NO GDB PROCESS RUNNING, CMD IGNORED: ") + cmd.command); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     if (cmd.flags & RebuildModel) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         ++m_pendingRequests; | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |         PENDING_DEBUG("   CALLBACK" << cmd.callbackName | 
					
						
							| 
									
										
										
										
											2009-09-22 09:27:19 +02:00
										 |  |  |             << "INCREMENTS PENDING TO:" << m_pendingRequests << cmd.command | 
					
						
							|  |  |  |             << m_gdbAdapter->state()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |         PENDING_DEBUG("   UNKNOWN CALLBACK" << cmd.callbackName | 
					
						
							| 
									
										
										
										
											2009-09-22 09:27:19 +02:00
										 |  |  |             << "LEAVES PENDING AT:" << m_pendingRequests << cmd.command | 
					
						
							|  |  |  |             << m_gdbAdapter->state()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     if ((cmd.flags & NeedsStop) && status() != DebuggerInferiorStopped | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             && status() != DebuggerProcessStartingUp) { | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         // queue the commands that we cannot send at once
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         QTC_ASSERT(status() == DebuggerInferiorRunning, | 
					
						
							|  |  |  |             qDebug() << "STATUS:" << status()); | 
					
						
							|  |  |  |         showStatusMessage(tr("Stopping temporarily.")); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         debugMessage(_("QUEUING COMMAND ") + cmd.command); | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         m_commandsToRunOnTemporaryBreak.append(cmd); | 
					
						
							|  |  |  |         interruptInferior(); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     } else if (!cmd.command.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |         flushCommand(cmd); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | void GdbEngine::flushCommand(const GdbCommand &cmd0) | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     GdbCommand cmd = cmd0; | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  |     if (m_gdbAdapter->state() == AdapterNotRunning) { | 
					
						
							| 
									
										
										
										
											2009-09-15 12:16:21 +02:00
										 |  |  |         emit gdbInputAvailable(LogInput, cmd.command); | 
					
						
							|  |  |  |         debugMessage(_("GDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + cmd.command); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     ++currentToken(); | 
					
						
							| 
									
										
										
										
											2009-07-06 11:37:21 +02:00
										 |  |  |     cmd.postTime = QTime::currentTime(); | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     m_cookieForToken[currentToken()] = cmd; | 
					
						
							|  |  |  |     cmd.command = QString::number(currentToken()) + cmd.command; | 
					
						
							| 
									
										
										
										
											2009-05-06 14:07:55 +02:00
										 |  |  |     if (cmd.flags & EmbedToken) | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |         cmd.command = cmd.command.arg(currentToken()); | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     emit gdbInputAvailable(LogInput, cmd.command); | 
					
						
							| 
									
										
										
										
											2009-09-15 12:16:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_gdbAdapter->write(cmd.command.toLatin1() + "\r\n"); | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::handleResultRecord(const GdbResultRecord &record) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "TOKEN:" << record.token
 | 
					
						
							|  |  |  |     //    << " ACCEPTABLE:" << m_oldestAcceptableToken;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //qDebug() << "";
 | 
					
						
							|  |  |  |     //qDebug() << "\nRESULT" << record.token << record.toString();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int token = record.token; | 
					
						
							|  |  |  |     if (token == -1) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-13 09:42:34 +02:00
										 |  |  |     if (!m_cookieForToken.contains(token)) { | 
					
						
							|  |  |  |         // In theory this should not happen, in practice it does.
 | 
					
						
							|  |  |  |         debugMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN. " | 
					
						
							|  |  |  |             "TWO RESPONSES FOR ONE COMMAND?").arg(token)); | 
					
						
							|  |  |  |         // handle a case known to occur on Linux/gdb 6.8 when debugging moc
 | 
					
						
							|  |  |  |         // with helpers enabled. In this case we get a second response with
 | 
					
						
							|  |  |  |         // msg="Cannot find new threads: generic error"
 | 
					
						
							|  |  |  |         if (record.resultClass == GdbResultError) { | 
					
						
							|  |  |  |             QByteArray msg = record.data.findChild("msg").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							| 
									
										
										
										
											2009-08-13 09:42:34 +02:00
										 |  |  |                 tr("Executable failed:\n") + QString::fromLocal8Bit(msg)); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             showStatusMessage(tr("Process failed to start.")); | 
					
						
							| 
									
										
										
										
											2009-08-13 09:42:34 +02:00
										 |  |  |             exitDebugger(); | 
					
						
							|  |  |  |             //qq->notifyInferiorStopped();
 | 
					
						
							|  |  |  |             //qq->notifyInferiorExited();
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     GdbCommand cmd = m_cookieForToken.take(token); | 
					
						
							| 
									
										
										
										
											2009-07-06 11:37:21 +02:00
										 |  |  |     if (theDebuggerBoolSetting(LogTimeStamps)) { | 
					
						
							|  |  |  |         emit gdbOutputAvailable(LogTime, _("Response time: %1: %2 s") | 
					
						
							|  |  |  |             .arg(cmd.command) | 
					
						
							|  |  |  |             .arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     if (record.token < m_oldestAcceptableToken && (cmd.flags & Discardable)) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "### SKIPPING OLD RESULT" << record.toString();
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         //QMessageBox::information(mainWindow(), tr("Skipped"), "xxx");
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     qDebug() << "# handleOutput," | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |         << "cmd name:" << cmd.callbackName | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         << " cmd synchronized:" << cmd.synchronized | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         << "\n record: " << record.toString(); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // << "\n data: " << record.data.toString(true);
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     if (cmd.callback) | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |         (this->*cmd.callback)(record, cmd.cookie); | 
					
						
							|  |  |  |     if (cmd.adapterCallback) | 
					
						
							|  |  |  |         (m_gdbAdapter->*cmd.adapterCallback)(record, cmd.cookie); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     if (cmd.flags & RebuildModel) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         --m_pendingRequests; | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |         PENDING_DEBUG("   TYPE " << cmd.callbackName << " DECREMENTS PENDING TO: " | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             << m_pendingRequests << cmd.command); | 
					
						
							| 
									
										
										
										
											2009-02-13 12:34:10 +01:00
										 |  |  |         if (m_pendingRequests <= 0) { | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |             PENDING_DEBUG("\n\n ....  AND TRIGGERS MODEL UPDATE\n"); | 
					
						
							|  |  |  |             rebuildModel(); | 
					
						
							| 
									
										
										
										
											2009-02-13 12:34:10 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |         PENDING_DEBUG("   UNKNOWN TYPE " << cmd.callbackName << " LEAVES PENDING AT: " | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             << m_pendingRequests << cmd.command); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-07 12:18:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-15 12:16:21 +02:00
										 |  |  |     // Continue only if there are no commands wire anymore, so this will
 | 
					
						
							|  |  |  |     // be fully synchroneous.
 | 
					
						
							| 
									
										
										
										
											2009-05-07 12:18:45 +02:00
										 |  |  |     // This is somewhat inefficient, as it makes the last command synchronous.
 | 
					
						
							|  |  |  |     // An optimization would be requesting the continue immediately when the
 | 
					
						
							|  |  |  |     // event loop is entered, and let individual commands have a flag to suppress
 | 
					
						
							|  |  |  |     // that behavior.
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     if (m_continuationAfterDone && m_cookieForToken.isEmpty()) { | 
					
						
							|  |  |  |         Continuation cont = m_continuationAfterDone; | 
					
						
							|  |  |  |         m_continuationAfterDone = 0; | 
					
						
							|  |  |  |         (this->*cont)(); | 
					
						
							|  |  |  |         //showStatusMessage(tr("Continuing after temporary stop."));
 | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         PENDING_DEBUG("MISSING TOKENS: " << m_cookieForToken.keys()); | 
					
						
							| 
									
										
										
										
											2009-05-07 12:18:45 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::executeDebuggerCommand(const QString &command) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  |     if (m_gdbAdapter->state() == AdapterNotRunning) { | 
					
						
							| 
									
										
										
										
											2009-09-11 09:51:05 +02:00
										 |  |  |         debugMessage(_("GDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     m_gdbAdapter->write(command.toLatin1() + "\r\n"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleTargetCore(const GdbResultRecord &, const QVariant &) | 
					
						
							| 
									
										
										
										
											2009-03-02 15:14:12 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Core file loaded.")); | 
					
						
							|  |  |  |     m_manager->resetLocation(); | 
					
						
							| 
									
										
										
										
											2009-05-07 11:34:01 +02:00
										 |  |  |     tryLoadDebuggingHelpers(); | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |     qq->stackHandler()->setCurrentIndex(0); | 
					
						
							|  |  |  |     updateLocals(); // Quick shot
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:06:24 +02:00
										 |  |  |     reloadStack(); | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |     if (supportsThreads()) | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), 0); | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |     qq->reloadRegisters(); | 
					
						
							| 
									
										
										
										
											2009-03-02 15:14:12 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleQuerySources(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-02-17 14:08:49 +01:00
										 |  |  |         QMap<QString, QString> oldShortToFull = m_shortToFullName; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         m_shortToFullName.clear(); | 
					
						
							|  |  |  |         m_fullToShortName.clear(); | 
					
						
							|  |  |  |         // "^done,files=[{file="../../../../bin/gdbmacros/gdbmacros.cpp",
 | 
					
						
							|  |  |  |         // fullname="/data5/dev/ide/main/bin/gdbmacros/gdbmacros.cpp"},
 | 
					
						
							|  |  |  |         GdbMi files = record.data.findChild("files"); | 
					
						
							|  |  |  |         foreach (const GdbMi &item, files.children()) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString fileName = QString::fromLocal8Bit(item.findChild("file").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             GdbMi fullName = item.findChild("fullname"); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString full = QString::fromLocal8Bit(fullName.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  |             full = QDir::cleanPath(full); | 
					
						
							|  |  |  |             #endif
 | 
					
						
							|  |  |  |             if (fullName.isValid() && QFileInfo(full).isReadable()) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |                 //qDebug() << "STORING 2:" << fileName << full;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 m_shortToFullName[fileName] = full; | 
					
						
							|  |  |  |                 m_fullToShortName[full] = fileName; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-17 14:08:49 +01:00
										 |  |  |         if (m_shortToFullName != oldShortToFull) | 
					
						
							|  |  |  |             qq->sourceFileWindow()->setSourceFiles(m_shortToFullName); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleInfoThreads(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2009-02-13 17:11:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |     if (record.resultClass != GdbResultDone) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     // FIXME: use something more robust
 | 
					
						
							|  |  |  |     // WIN:     [New thread 3380.0x2bc]
 | 
					
						
							|  |  |  |     //          * 3 Thread 2312.0x4d0  0x7c91120f in ?? ()
 | 
					
						
							|  |  |  |     // LINUX:   * 1 Thread 0x7f466273c6f0 (LWP 21455)  0x0000000000404542 in ...
 | 
					
						
							|  |  |  |     const QString data = _(record.data.findChild("consolestreamoutput").data()); | 
					
						
							|  |  |  |     if (data.isEmpty()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     // check "[New thread 3380.0x2bc]"
 | 
					
						
							|  |  |  |     if (data.startsWith(QLatin1Char('['))) { | 
					
						
							|  |  |  |         QRegExp ren(_("^\\[New thread (\\d+)\\.0x.*")); | 
					
						
							|  |  |  |         Q_ASSERT(ren.isValid()); | 
					
						
							|  |  |  |         if (ren.indexIn(data) != -1) { | 
					
						
							|  |  |  |             maybeHandleInferiorPidChanged(ren.cap(1)); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-13 17:11:34 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |     // check "* 3 Thread ..."
 | 
					
						
							|  |  |  |     QRegExp re(_("^\\*? +\\d+ +[Tt]hread (\\d+)\\.0x.* in")); | 
					
						
							|  |  |  |     Q_ASSERT(re.isValid()); | 
					
						
							|  |  |  |     if (re.indexIn(data) != -1) | 
					
						
							|  |  |  |         maybeHandleInferiorPidChanged(re.cap(1)); | 
					
						
							| 
									
										
										
										
											2009-02-13 17:11:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleInfoProc(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |         #ifdef Q_OS_MAC
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         //^done,process-id="85075"
 | 
					
						
							| 
									
										
										
										
											2009-05-04 11:24:06 +02:00
										 |  |  |         maybeHandleInferiorPidChanged(_(record.data.findChild("process-id").data())); | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |         #else
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // FIXME: use something more robust
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QRegExp re(__("process (\\d+)")); | 
					
						
							|  |  |  |         QString data = __(record.data.findChild("consolestreamoutput").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         if (re.indexIn(data) != -1) | 
					
						
							|  |  |  |             maybeHandleInferiorPidChanged(re.cap(1)); | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleInfoShared(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         // let the modules handler do the parsing
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |         handleModulesList(record, cookie); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 22:32:01 +02:00
										 |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::handleExecJumpToLine(const GdbResultRecord &record) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // FIXME: remove this special case as soon as 'jump'
 | 
					
						
							|  |  |  |     // is supported by MI
 | 
					
						
							|  |  |  |     // "&"jump /home/apoenitz/dev/work/test1/test1.cpp:242"
 | 
					
						
							|  |  |  |     // ~"Continuing at 0x4058f3."
 | 
					
						
							|  |  |  |     // ~"run1 (argc=1, argv=0x7fffb213a478) at test1.cpp:242"
 | 
					
						
							|  |  |  |     // ~"242\t x *= 2;"
 | 
					
						
							|  |  |  |     //109^done"
 | 
					
						
							|  |  |  |     qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Jumped. Stopped.")); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QByteArray output = record.data.findChild("logstreamoutput").data(); | 
					
						
							| 
									
										
										
										
											2009-04-30 22:32:01 +02:00
										 |  |  |     if (output.isEmpty()) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     int idx1 = output.indexOf(' ') + 1; | 
					
						
							|  |  |  |     if (idx1 > 0) { | 
					
						
							|  |  |  |         int idx2 = output.indexOf(':', idx1); | 
					
						
							|  |  |  |         if (idx2 > 0) { | 
					
						
							|  |  |  |             QString file = QString::fromLocal8Bit(output.mid(idx1, idx2 - idx1)); | 
					
						
							|  |  |  |             int line = output.mid(idx2 + 1).toInt(); | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |             gotoLocation(file, line, true); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-30 22:32:01 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleExecRunToFunction(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // FIXME: remove this special case as soon as there's a real
 | 
					
						
							|  |  |  |     // reason given when the temporary breakpoint is hit.
 | 
					
						
							|  |  |  |     // reight now we get:
 | 
					
						
							|  |  |  |     // 14*stopped,thread-id="1",frame={addr="0x0000000000403ce4",
 | 
					
						
							|  |  |  |     // func="foo",args=[{name="str",value="@0x7fff0f450460"}],
 | 
					
						
							|  |  |  |     // file="main.cpp",fullname="/tmp/g/main.cpp",line="37"}
 | 
					
						
							|  |  |  |     qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Run to Function finished. Stopped.")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     GdbMi frame = record.data.findChild("frame"); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     StackFrame f; | 
					
						
							|  |  |  |     f.file = QString::fromLocal8Bit(frame.findChild("fullname").data()); | 
					
						
							|  |  |  |     f.line = frame.findChild("line").data().toInt(); | 
					
						
							|  |  |  |     f.address = _(frame.findChild("addr").data()); | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |     gotoLocation(f, true); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  | static bool isExitedReason(const QByteArray &reason) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     return reason == "exited-normally"   // inferior exited normally
 | 
					
						
							|  |  |  |         || reason == "exited-signalled"  // inferior exited because of a signal
 | 
					
						
							|  |  |  |         //|| reason == "signal-received" // inferior received signal
 | 
					
						
							|  |  |  |         || reason == "exited";           // inferior exited
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  | static bool isStoppedReason(const QByteArray &reason) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     return reason == "function-finished"  // -exec-finish
 | 
					
						
							|  |  |  |         || reason == "signal-received"  // handled as "isExitedReason"
 | 
					
						
							|  |  |  |         || reason == "breakpoint-hit"     // -exec-continue
 | 
					
						
							|  |  |  |         || reason == "end-stepping-range" // -exec-next, -exec-step
 | 
					
						
							|  |  |  |         || reason == "location-reached"   // -exec-until
 | 
					
						
							|  |  |  |         || reason == "access-watchpoint-trigger" | 
					
						
							|  |  |  |         || reason == "read-watchpoint-trigger" | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |         #ifdef Q_OS_MAC
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         || reason.isEmpty() | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |         #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     ; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  | void GdbEngine::handleAqcuiredInferior() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |     #ifdef Q_OS_WIN
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("info thread"), CB(handleInfoThreads)); | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |     #elif defined(Q_OS_MAC)
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("info pid"), NeedsStop, CB(handleInfoProc)); | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |     #else
 | 
					
						
							|  |  |  |     postCommand(_("info proc"), CB(handleInfoProc)); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |     #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-27 12:25:58 +01:00
										 |  |  |     if (theDebuggerBoolSetting(ListSourceFiles)) | 
					
						
							| 
									
										
										
										
											2009-03-10 17:30:11 +01:00
										 |  |  |         reloadSourceFiles(); | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     // Reverse debugging. FIXME: Should only be used when available.
 | 
					
						
							| 
									
										
										
										
											2009-06-10 13:35:40 +02:00
										 |  |  |     //if (theDebuggerBoolSetting(EnableReverseDebugging))
 | 
					
						
							|  |  |  |     //    postCommand(_("target record"));
 | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     tryLoadDebuggingHelpers(); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |     #ifndef Q_OS_MAC
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     // intentionally after tryLoadDebuggingHelpers(),
 | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |     // otherwise we'd interupt solib loading.
 | 
					
						
							| 
									
										
										
										
											2009-03-19 10:54:27 +01:00
										 |  |  |     if (theDebuggerBoolSetting(AllPluginBreakpoints)) { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("set auto-solib-add on")); | 
					
						
							|  |  |  |         postCommand(_("set stop-on-solib-events 0")); | 
					
						
							|  |  |  |         postCommand(_("sharedlibrary .*")); | 
					
						
							| 
									
										
										
										
											2009-03-19 10:54:27 +01:00
										 |  |  |     } else if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("set auto-solib-add on")); | 
					
						
							|  |  |  |         postCommand(_("set stop-on-solib-events 1")); | 
					
						
							|  |  |  |         postCommand(_("sharedlibrary ") | 
					
						
							| 
									
										
										
										
											2009-03-19 10:54:27 +01:00
										 |  |  |           + theDebuggerStringSetting(SelectedPluginBreakpointsPattern)); | 
					
						
							|  |  |  |     } else if (theDebuggerBoolSetting(NoPluginBreakpoints)) { | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |         // should be like that already
 | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |         if (!m_dumperInjectionLoad) | 
					
						
							|  |  |  |             postCommand(_("set auto-solib-add off")); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("set stop-on-solib-events 0")); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |     #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |     // nicer to see a bit of the world we live in
 | 
					
						
							|  |  |  |     reloadModules(); | 
					
						
							| 
									
										
										
										
											2009-02-23 17:03:25 +01:00
										 |  |  |     attemptBreakpointSynchronization(); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::handleAsyncOutput(const GdbMi &data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     const QByteArray reason = data.findChild("reason").data(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-17 16:25:48 +01:00
										 |  |  |     if (isExitedReason(reason)) { | 
					
						
							|  |  |  |         qq->notifyInferiorExited(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString msg; | 
					
						
							| 
									
										
										
										
											2009-02-17 16:25:48 +01:00
										 |  |  |         if (reason == "exited") { | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  |             msg = tr("Program exited with exit code %1") | 
					
						
							|  |  |  |                 .arg(_(data.findChild("exit-code").toString())); | 
					
						
							|  |  |  |         } else if (reason == "exited-signalled" || reason == "signal-received") { | 
					
						
							|  |  |  |             msg = tr("Program exited after receiving signal %1") | 
					
						
							|  |  |  |                 .arg(_(data.findChild("signal-name").toString())); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  |             msg = tr("Program exited normally"); | 
					
						
							| 
									
										
										
										
											2009-02-17 16:25:48 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         showStatusMessage(msg); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("-gdb-exit"), CB(handleExit)); | 
					
						
							| 
									
										
										
										
											2009-02-17 16:25:48 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-13 17:11:34 +01:00
										 |  |  |     //MAC: bool isFirstStop = data.findChild("bkptno").data() == "1";
 | 
					
						
							|  |  |  |     //!MAC: startSymbolName == data.findChild("frame").findChild("func")
 | 
					
						
							|  |  |  |     if (m_waitingForFirstBreakpointToBeHit) { | 
					
						
							| 
									
										
										
										
											2009-05-07 12:11:27 +02:00
										 |  |  |         m_waitingForFirstBreakpointToBeHit = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-17 16:25:48 +01:00
										 |  |  |         // If the executable dies already that early we might get something
 | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |         // like >49*stopped,reason="exited",exit-code="0177"
 | 
					
						
							| 
									
										
										
										
											2009-02-17 16:25:48 +01:00
										 |  |  |         // This is handled now above.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |         handleAqcuiredInferior(); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | // FIXME:        m_continuationAfterDone = true;
 | 
					
						
							| 
									
										
										
										
											2009-02-13 16:55:24 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-02-12 09:55:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     if (!m_commandsToRunOnTemporaryBreak.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         QTC_ASSERT(status() == DebuggerInferiorStopRequested, | 
					
						
							|  |  |  |             qDebug() << "STATUS:" << status()) | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         qq->notifyInferiorStopped(); | 
					
						
							|  |  |  |         // FIXME: racy
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |         while (!m_commandsToRunOnTemporaryBreak.isEmpty()) { | 
					
						
							|  |  |  |             GdbCommand cmd = m_commandsToRunOnTemporaryBreak.takeFirst(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             debugMessage(_("RUNNING QUEUED COMMAND %1 %2") | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |                 .arg(cmd.command).arg(_(cmd.callbackName))); | 
					
						
							|  |  |  |             flushCommand(cmd); | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         showStatusMessage(tr("Processing queued commands.")); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | // FIXME:        m_continuationAfterDone = true;
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     const QByteArray &msg = data.findChild("consolestreamoutput").data(); | 
					
						
							| 
									
										
										
										
											2009-02-12 13:04:01 +01:00
										 |  |  |     if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-03-19 15:44:26 +01:00
										 |  |  |         if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString dataStr = _(data.toString()); | 
					
						
							|  |  |  |             debugMessage(_("SHARED LIBRARY EVENT: ") + dataStr); | 
					
						
							| 
									
										
										
										
											2009-03-19 15:44:26 +01:00
										 |  |  |             QString pat = theDebuggerStringSetting(SelectedPluginBreakpointsPattern); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             debugMessage(_("PATTERN: ") + pat); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |             postCommand(_("sharedlibrary ") + pat); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             continueInferior(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             showStatusMessage(tr("Loading %1...").arg(dataStr)); | 
					
						
							| 
									
										
										
										
											2009-02-12 13:04:01 +01:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  |         m_modulesListOutdated = true; | 
					
						
							| 
									
										
										
										
											2009-02-12 13:04:01 +01:00
										 |  |  |         // fall through
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-13 16:55:24 +01:00
										 |  |  |     // seen on XP after removing a breakpoint while running
 | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     //  >945*stopped,reason="signal-received",signal-name="SIGTRAP",
 | 
					
						
							| 
									
										
										
										
											2009-02-13 16:55:24 +01:00
										 |  |  |     //  signal-meaning="Trace/breakpoint trap",thread-id="2",
 | 
					
						
							|  |  |  |     //  frame={addr="0x7c91120f",func="ntdll!DbgUiConnectToDbg",
 | 
					
						
							|  |  |  |     //  args=[],from="C:\\WINDOWS\\system32\\ntdll.dll"}
 | 
					
						
							|  |  |  |     if (reason == "signal-received" | 
					
						
							|  |  |  |           && data.findChild("signal-name").toString() == "SIGTRAP") { | 
					
						
							|  |  |  |         continueInferior(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // jump over well-known frames
 | 
					
						
							|  |  |  |     static int stepCounter = 0; | 
					
						
							| 
									
										
										
										
											2009-03-19 10:54:27 +01:00
										 |  |  |     if (theDebuggerBoolSetting(SkipKnownFrames)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         if (reason == "end-stepping-range" || reason == "function-finished") { | 
					
						
							|  |  |  |             GdbMi frame = data.findChild("frame"); | 
					
						
							| 
									
										
										
										
											2009-02-16 13:29:57 +01:00
										 |  |  |             //debugMessage(frame.toString());
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             m_currentFrame = _(frame.findChild("addr").data() + '%' + | 
					
						
							|  |  |  |                  frame.findChild("func").data() + '%'); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString funcName = _(frame.findChild("func").data()); | 
					
						
							|  |  |  |             QString fileName = QString::fromLocal8Bit(frame.findChild("file").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             if (isLeavableFunction(funcName, fileName)) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:54:58 +02:00
										 |  |  |                 //debugMessage(_("LEAVING ") + funcName);
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 ++stepCounter; | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 m_manager->stepOutExec(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 //stepExec();
 | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (isSkippableFunction(funcName, fileName)) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:54:58 +02:00
										 |  |  |                 //debugMessage(_("SKIPPING ") + funcName);
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 ++stepCounter; | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |                 m_manager->stepExec(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             //if (stepCounter)
 | 
					
						
							|  |  |  |             //    qDebug() << "STEPCOUNTER:" << stepCounter;
 | 
					
						
							|  |  |  |             stepCounter = 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (isStoppedReason(reason) || reason.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |          QVariant var = QVariant::fromValue<GdbMi>(data); | 
					
						
							|  |  |  |         if (m_debuggingHelperState == DebuggingHelperUninitialized) { | 
					
						
							|  |  |  |             tryLoadDebuggingHelpers(); | 
					
						
							|  |  |  |             postCommand(_("p 4"), CB(handleStop1), var);  // dummy
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |             handleStop1(GdbResultRecord(), var); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     debugMessage(_("STOPPED FOR UNKNOWN REASON: " + data.toString())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // Ignore it. Will be handled with full response later in the
 | 
					
						
							|  |  |  |     // JumpToLine or RunToFunction handlers
 | 
					
						
							|  |  |  | #if 1
 | 
					
						
							|  |  |  |     // FIXME: remove this special case as soon as there's a real
 | 
					
						
							|  |  |  |     // reason given when the temporary breakpoint is hit.
 | 
					
						
							|  |  |  |     // reight now we get:
 | 
					
						
							|  |  |  |     // 14*stopped,thread-id="1",frame={addr="0x0000000000403ce4",
 | 
					
						
							|  |  |  |     // func="foo",args=[{name="str",value="@0x7fff0f450460"}],
 | 
					
						
							|  |  |  |     // file="main.cpp",fullname="/tmp/g/main.cpp",line="37"}
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // MAC yields sometimes:
 | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     // >3661*stopped,time={wallclock="0.00658",user="0.00142",
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // system="0.00136",start="1218810678.805432",end="1218810678.812011"}
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     m_manager->resetLocation(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Run to Function finished. Stopped.")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     GdbMi frame = data.findChild("frame"); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     StackFrame f; | 
					
						
							|  |  |  |     f.file = QString::fromLocal8Bit(frame.findChild("fullname").data()); | 
					
						
							|  |  |  |     f.line = frame.findChild("line").data().toInt(); | 
					
						
							|  |  |  |     f.address = _(frame.findChild("addr").data()); | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |     gotoLocation(f, true); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-06 17:27:15 +02:00
										 |  |  | void GdbEngine::reloadFullStack() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QString cmd = _("-stack-list-frames"); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(cmd, WatchUpdate, CB(handleStackListFrames), true); | 
					
						
							| 
									
										
										
										
											2009-04-06 17:27:15 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:06:24 +02:00
										 |  |  | void GdbEngine::reloadStack() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QString cmd = _("-stack-list-frames"); | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |     int stackDepth = theDebuggerAction(MaximalStackDepth)->value().toInt(); | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     if (stackDepth && !m_gdbAdapter->isTrkAdapter()) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         cmd += _(" 0 ") + QString::number(stackDepth); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(cmd, WatchUpdate, CB(handleStackListFrames), false); | 
					
						
							| 
									
										
										
										
											2009-09-16 11:46:15 +02:00
										 |  |  |     // FIXME: gdb 6.4 symbianelf likes to be asked twice. The first time it
 | 
					
						
							|  |  |  |     // returns with "^error,msg="Previous frame identical to this frame
 | 
					
						
							|  |  |  |     // (corrupt stack?)". Might be related to the fact that we can't
 | 
					
						
							|  |  |  |     // access the memory belonging to the lower frames. But as we know
 | 
					
						
							|  |  |  |     // this always happens, ask the second time immediately instead
 | 
					
						
							|  |  |  |     // of waiting for the first request to fail.
 | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     if (m_gdbAdapter->isTrkAdapter()) | 
					
						
							| 
									
										
										
										
											2009-09-16 11:09:59 +02:00
										 |  |  |         postCommand(cmd, WatchUpdate, CB(handleStackListFrames), false); | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | void GdbEngine::handleStop1(const GdbResultRecord &, const QVariant &cookie) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     GdbMi data = cookie.value<GdbMi>(); | 
					
						
							|  |  |  |     QByteArray reason = data.findChild("reason").data(); | 
					
						
							|  |  |  |     if (m_modulesListOutdated) { | 
					
						
							|  |  |  |         reloadModules(); | 
					
						
							|  |  |  |         m_modulesListOutdated = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // Need another round trip
 | 
					
						
							|  |  |  |     if (reason == "breakpoint-hit") { | 
					
						
							|  |  |  |         showStatusMessage(tr("Stopped at breakpoint.")); | 
					
						
							|  |  |  |         GdbMi frame = data.findChild("frame"); | 
					
						
							|  |  |  |         //debugMessage(_("HIT BREAKPOINT: " + frame.toString()));
 | 
					
						
							|  |  |  |         m_currentFrame = _(frame.findChild("addr").data() + '%' + | 
					
						
							|  |  |  |              frame.findChild("func").data() + '%'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (theDebuggerAction(ListSourceFiles)->value().toBool()) | 
					
						
							|  |  |  |             reloadSourceFiles(); | 
					
						
							|  |  |  |         postCommand(_("-break-list"), CB(handleBreakList)); | 
					
						
							|  |  |  |         QVariant var = QVariant::fromValue<GdbMi>(data); | 
					
						
							|  |  |  |         postCommand(_("p 0"), CB(handleStop2), var);  // dummy
 | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  | #ifdef Q_OS_LINUX
 | 
					
						
							|  |  |  |         // For some reason, attaching to a stopped process causes *two* stops
 | 
					
						
							|  |  |  |         // when trying to continue (kernel 2.6.24-23-ubuntu).
 | 
					
						
							|  |  |  |         // Interestingly enough, on MacOSX no signal is delivered at all.
 | 
					
						
							|  |  |  |         if (reason == "signal-received" | 
					
						
							|  |  |  |             && data.findChild("signal-name").data() == "SIGSTOP") { | 
					
						
							|  |  |  |             GdbMi frameData = data.findChild("frame"); | 
					
						
							|  |  |  |             if (frameData.findChild("func").data() == "_start" | 
					
						
							|  |  |  |                 && frameData.findChild("from").data() == "/lib/ld-linux.so.2") { | 
					
						
							|  |  |  |                 postCommand(_("-exec-continue"), CB(handleExecContinue)); | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |         if (reason == "signal-received" | 
					
						
							|  |  |  |             && theDebuggerBoolSetting(UseMessageBoxForSignals)) { | 
					
						
							|  |  |  |             QByteArray name = data.findChild("signal-name").data(); | 
					
						
							|  |  |  |             // Ignore SIGTRAP as they are showing up regularily when
 | 
					
						
							|  |  |  |             // stopping debugging.
 | 
					
						
							|  |  |  |             if (name != "SIGTRAP") { | 
					
						
							|  |  |  |                 QByteArray meaning = data.findChild("signal-meaning").data(); | 
					
						
							|  |  |  |                 QString msg = tr("<p>The inferior stopped because it received a " | 
					
						
							|  |  |  |                     "signal from the Operating System.<p>" | 
					
						
							|  |  |  |                     "<table><tr><td>Signal name : </td><td>%1</td></tr>" | 
					
						
							|  |  |  |                     "<tr><td>Signal meaning : </td><td>%2</td></tr></table>") | 
					
						
							|  |  |  |                     .arg(name.isEmpty() ? tr(" <Unknown> ") : _(name)) | 
					
						
							|  |  |  |                     .arg(meaning.isEmpty() ? tr(" <Unknown> ") : _(meaning)); | 
					
						
							|  |  |  |                 QMessageBox *mb = new QMessageBox(QMessageBox::Information, | 
					
						
							|  |  |  |                     tr("Signal received"), msg, QMessageBox::NoButton, | 
					
						
							|  |  |  |                     mainWindow()); | 
					
						
							|  |  |  |                 mb->setAttribute(Qt::WA_DeleteOnClose); | 
					
						
							|  |  |  |                 mb->show(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (reason.isEmpty()) | 
					
						
							|  |  |  |             showStatusMessage(tr("Stopped.")); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             showStatusMessage(tr("Stopped: \"%1\"").arg(_(reason))); | 
					
						
							|  |  |  |         handleStop2(data); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleStop2(const GdbResultRecord &, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     handleStop2(cookie.value<GdbMi>()); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:06:24 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | void GdbEngine::handleStop2(const GdbMi &data) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     qq->notifyInferiorStopped(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |     // Sometimes we get some interesting extra information. Grab it.
 | 
					
						
							|  |  |  |     GdbMi frame = data.findChild("frame"); | 
					
						
							|  |  |  |     GdbMi shortName = frame.findChild("file"); | 
					
						
							|  |  |  |     GdbMi fullName = frame.findChild("fullname"); | 
					
						
							|  |  |  |     if (shortName.isValid() && fullName.isValid()) { | 
					
						
							|  |  |  |         QString file = QFile::decodeName(shortName.data()); | 
					
						
							|  |  |  |         QString full = QFile::decodeName(fullName.data()); | 
					
						
							|  |  |  |         if (file != full) { | 
					
						
							|  |  |  |             m_shortToFullName[file] = full; | 
					
						
							|  |  |  |             m_fullToShortName[full] = file; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 13:05:37 +02:00
										 |  |  |     // FIXME: Hack, remove as soon as we get real stack traces.
 | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     if (m_gdbAdapter->isTrkAdapter()) { | 
					
						
							| 
									
										
										
										
											2009-09-11 13:05:37 +02:00
										 |  |  |         StackFrame f; | 
					
						
							|  |  |  |         f.file = QString::fromLocal8Bit(fullName.data()); | 
					
						
							|  |  |  |         f.line = frame.findChild("line").data().toInt(); | 
					
						
							|  |  |  |         f.address = _(frame.findChild("addr").data()); | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |         gotoLocation(f, true); | 
					
						
							| 
									
										
										
										
											2009-09-11 13:05:37 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //
 | 
					
						
							|  |  |  |     // Stack
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     qq->stackHandler()->setCurrentIndex(0); | 
					
						
							|  |  |  |     updateLocals(); // Quick shot
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int currentId = data.findChild("thread-id").data().toInt(); | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:06:24 +02:00
										 |  |  |     reloadStack(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (supportsThreads()) | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), currentId); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // Registers
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     qq->reloadRegisters(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleShowVersion(const GdbResultRecord &response, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-23 16:06:23 +01:00
										 |  |  |     //qDebug () << "VERSION 2:" << response.data.findChild("consolestreamoutput").data();
 | 
					
						
							|  |  |  |     //qDebug () << "VERSION:" << response.toString();
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     debugMessage(_("VERSION: " + response.toString())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (response.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         m_gdbVersion = 100; | 
					
						
							| 
									
										
										
										
											2009-02-23 16:06:23 +01:00
										 |  |  |         m_gdbBuildVersion = -1; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString msg = QString::fromLocal8Bit(response.data.findChild("consolestreamoutput").data()); | 
					
						
							|  |  |  |         QRegExp supported(_("GNU gdb(.*) (\\d+)\\.(\\d+)(\\.(\\d+))?(-(\\d+))?")); | 
					
						
							| 
									
										
										
										
											2008-12-08 14:26:11 +01:00
										 |  |  |         if (supported.indexIn(msg) == -1) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             debugMessage(_("UNSUPPORTED GDB VERSION ") + msg); | 
					
						
							|  |  |  |             QStringList list = msg.split(_c('\n')); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             while (list.size() > 2) | 
					
						
							|  |  |  |                 list.removeLast(); | 
					
						
							|  |  |  |             msg = tr("The debugger you are using identifies itself as:") | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 + _("<p><p>") + list.join(_("<br>")) + _("<p><p>") | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 + tr("This version is not officially supported by Qt Creator.\n" | 
					
						
							|  |  |  |                      "Debugging will most likely not work well.\n" | 
					
						
							|  |  |  |                      "Using gdb 6.7 or later is strongly recommended."); | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  |             // ugly, but 'Show again' check box...
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             static QErrorMessage *err = new QErrorMessage(mainWindow()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             err->setMinimumSize(400, 300); | 
					
						
							|  |  |  |             err->showMessage(msg); | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             //QMessageBox::information(mainWindow(), tr("Warning"), msg);
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-08 14:26:11 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             m_gdbVersion = 10000 * supported.cap(2).toInt() | 
					
						
							|  |  |  |                          +   100 * supported.cap(3).toInt() | 
					
						
							| 
									
										
										
										
											2008-12-17 15:19:22 +01:00
										 |  |  |                          +     1 * supported.cap(5).toInt(); | 
					
						
							| 
									
										
										
										
											2009-02-23 16:06:23 +01:00
										 |  |  |             m_gdbBuildVersion = supported.cap(7).toInt(); | 
					
						
							| 
									
										
										
										
											2009-08-24 14:11:47 +02:00
										 |  |  |             debugMessage(_("GDB VERSION: %1, BUILD: %2 ").arg(m_gdbVersion) | 
					
						
							|  |  |  |                 .arg(m_gdbBuildVersion)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-23 16:06:23 +01:00
										 |  |  |         //qDebug () << "VERSION 3:" << m_gdbVersion << m_gdbBuildVersion;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleFileExecAndSymbols(const GdbResultRecord &response, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (response.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         //m_breakHandler->clearBreakMarkers();
 | 
					
						
							|  |  |  |     } else if (response.resultClass == GdbResultError) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString msg = __(response.data.findChild("msg").data()); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             tr("Starting executable failed:\n") + msg); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         QTC_ASSERT(status() == DebuggerInferiorRunning, /**/); | 
					
						
							| 
									
										
										
										
											2009-07-15 13:48:14 +02:00
										 |  |  |         //interruptInferior();
 | 
					
						
							|  |  |  |         qq->notifyInferiorExited(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleExecRun(const GdbResultRecord &response, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (response.resultClass == GdbResultRunning) { | 
					
						
							|  |  |  |         qq->notifyInferiorRunning(); | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         QTC_ASSERT(response.resultClass == GdbResultError, /**/); | 
					
						
							|  |  |  |         const QByteArray &msg = response.data.findChild("msg").data(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |             tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg)); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         QTC_ASSERT(status() == DebuggerInferiorRunning, /**/); | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |         //interruptInferior();
 | 
					
						
							|  |  |  |         qq->notifyInferiorExited(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleExecContinue(const GdbResultRecord &response, const QVariant &) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (response.resultClass == GdbResultRunning) { | 
					
						
							|  |  |  |         qq->notifyInferiorRunning(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         QTC_ASSERT(response.resultClass == GdbResultError, /**/); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         const QByteArray &msg = response.data.findChild("msg").data(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         if (msg == "Cannot find bounds of current function") { | 
					
						
							|  |  |  |             qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             //showStatusMessage(tr("No debug information available. "
 | 
					
						
							| 
									
										
										
										
											2008-12-08 14:26:11 +01:00
										 |  |  |             //  "Leaving function..."));
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             //stepOutExec();
 | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg)); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             QTC_ASSERT(status() == DebuggerInferiorRunning, /**/); | 
					
						
							| 
									
										
										
										
											2009-07-15 13:48:14 +02:00
										 |  |  |             //interruptInferior();
 | 
					
						
							|  |  |  |             qq->notifyInferiorExited(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString GdbEngine::fullName(const QString &fileName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //QString absName = m_manager->currentWorkingDirectory() + "/" + file; ??
 | 
					
						
							|  |  |  |     if (fileName.isEmpty()) | 
					
						
							|  |  |  |         return QString(); | 
					
						
							|  |  |  |     QString full = m_shortToFullName.value(fileName, QString()); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:54:58 +02:00
										 |  |  |     //debugMessage(_("RESOLVING: ") + fileName + " " +  full);
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (!full.isEmpty()) | 
					
						
							|  |  |  |         return full; | 
					
						
							|  |  |  |     QFileInfo fi(fileName); | 
					
						
							|  |  |  |     if (!fi.isReadable()) | 
					
						
							|  |  |  |         return QString(); | 
					
						
							|  |  |  |     full = fi.absoluteFilePath(); | 
					
						
							|  |  |  |     #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  |     full = QDir::cleanPath(full); | 
					
						
							|  |  |  |     #endif
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:54:58 +02:00
										 |  |  |     //debugMessage(_("STORING: ") + fileName + " " + full);
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     m_shortToFullName[fileName] = full; | 
					
						
							|  |  |  |     m_fullToShortName[full] = fileName; | 
					
						
							|  |  |  |     return full; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString GdbEngine::fullName(const QStringList &candidates) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString full; | 
					
						
							|  |  |  |     foreach (const QString &fileName, candidates) { | 
					
						
							|  |  |  |         full = fullName(fileName); | 
					
						
							|  |  |  |         if (!full.isEmpty()) | 
					
						
							|  |  |  |             return full; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     foreach (const QString &fileName, candidates) { | 
					
						
							|  |  |  |         if (!fileName.isEmpty()) | 
					
						
							|  |  |  |             return fileName; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return full; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::shutdown() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  |     m_outputCollector.shutdown(); | 
					
						
							|  |  |  |     initializeVariables(); | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     m_gdbAdapter->shutdown(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 15:20:44 +02:00
										 |  |  | void GdbEngine::detachDebugger() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     postCommand(_("detach")); | 
					
						
							| 
									
										
										
										
											2009-09-16 13:43:03 +02:00
										 |  |  |     // FIXME: use postCommand(_("detach"), CB(handleExitHelper)) ?
 | 
					
						
							| 
									
										
										
										
											2009-05-07 15:20:44 +02:00
										 |  |  |     postCommand(_("-gdb-exit"), CB(handleExit)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::exitDebugger() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  |     m_outputCollector.shutdown(); | 
					
						
							|  |  |  |     initializeVariables(); | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     m_gdbAdapter->shutdown(); | 
					
						
							| 
									
										
										
										
											2009-09-16 13:43:03 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleExitHelper(const GdbResultRecord &, const QVariant &) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     exitDebugger2(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::exitDebugger2() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-09-16 13:43:03 +02:00
										 |  |  |     postCommand(_("-gdb-exit"), CB(handleExit)); | 
					
						
							|  |  |  |     // 20s can easily happen when loading webkit debug information
 | 
					
						
							|  |  |  |     if (!m_gdbAdapter->waitForFinished(20000)) { | 
					
						
							|  |  |  |         debugMessage(_("FORCING TERMINATION: %1") | 
					
						
							|  |  |  |             .arg(m_gdbAdapter->state())); | 
					
						
							|  |  |  |         m_gdbAdapter->terminate(); | 
					
						
							|  |  |  |         m_gdbAdapter->waitForFinished(20000); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     if (m_gdbAdapter->state() != QProcess::NotRunning) { | 
					
						
							| 
									
										
										
										
											2009-06-12 14:26:54 +02:00
										 |  |  |         debugMessage(_("PROBLEM STOPPING DEBUGGER: STATE %1") | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |             .arg(m_gdbAdapter->state())); | 
					
						
							|  |  |  |         m_gdbAdapter->kill(); | 
					
						
							| 
									
										
										
										
											2009-06-12 14:26:54 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-15 14:47:14 +01:00
										 |  |  |     m_outputCollector.shutdown(); | 
					
						
							| 
									
										
										
										
											2009-02-13 13:50:50 +01:00
										 |  |  |     initializeVariables(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     //m_manager->settings()->m_debugDebuggingHelpers = false;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int GdbEngine::currentFrame() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return qq->stackHandler()->currentIndex(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-17 14:38:15 +02:00
										 |  |  | void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |     m_startParameters = sp; | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     m_gdbAdapter->startAdapter(sp); | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-06-29 13:28:01 +02:00
										 |  |  |     // This should be set by the constructor or in exitDebugger().
 | 
					
						
							|  |  |  |     QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized, | 
					
						
							|  |  |  |         initializeVariables()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     if (m_gdbAdapter->state() != QProcess::NotRunning) { | 
					
						
							|  |  |  |         debugMessage(_("GDB IS ALREADY RUNNING, STATE: %1").arg(m_gdbAdapter->state())); | 
					
						
							|  |  |  |         m_gdbAdapter->kill(); | 
					
						
							| 
									
										
										
										
											2009-09-11 09:51:05 +02:00
										 |  |  |         emitStartFailed(); | 
					
						
							| 
									
										
										
										
											2009-09-10 13:09:42 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-15 12:16:45 +02:00
										 |  |  |     QStringList gdbArgs; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     gdbArgs.prepend(_("mi")); | 
					
						
							|  |  |  |     gdbArgs.prepend(_("-i")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-15 12:16:45 +02:00
										 |  |  |     if (startMode() == AttachCore || startMode() == AttachExternal | 
					
						
							|  |  |  |             || startMode() == AttachCrashedExternal) { | 
					
						
							| 
									
										
										
										
											2009-03-03 09:31:13 +01:00
										 |  |  |         // nothing to do
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     } else if (startMode() == StartRemote) { | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |         // Start the remote server
 | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |         if (m_startParameters->serverStartScript.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             showStatusMessage(_("No server start script given. " | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |                 "Assuming server runs already.")); | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |             if (!m_startParameters->workingDir.isEmpty()) | 
					
						
							|  |  |  |                 m_uploadProc.setWorkingDirectory(m_startParameters->workingDir); | 
					
						
							|  |  |  |             if (!m_startParameters->environment.isEmpty()) | 
					
						
							|  |  |  |                 m_uploadProc.setEnvironment(m_startParameters->environment); | 
					
						
							|  |  |  |             m_uploadProc.start(_("/bin/sh ") + m_startParameters->serverStartScript); | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |             m_uploadProc.waitForStarted(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |     } else if (m_startParameters->useTerminal) { | 
					
						
							| 
									
										
										
										
											2009-02-20 12:33:16 +01:00
										 |  |  |         m_stubProc.stop(); // We leave the console open, so recycle it now.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |         m_stubProc.setWorkingDirectory(m_startParameters->workingDir); | 
					
						
							|  |  |  |         m_stubProc.setEnvironment(m_startParameters->environment); | 
					
						
							|  |  |  |         if (!m_stubProc.start(m_startParameters->executable, | 
					
						
							|  |  |  |                              m_startParameters->processArgs)) { | 
					
						
							| 
									
										
										
										
											2009-09-10 13:09:42 +02:00
										 |  |  |             // Error message for user is delivered via a signal.
 | 
					
						
							| 
									
										
										
										
											2009-09-11 09:51:05 +02:00
										 |  |  |             emitStartFailed(); | 
					
						
							| 
									
										
										
										
											2009-09-10 13:09:42 +02:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-20 12:33:16 +01:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         if (!m_outputCollector.listen()) { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             QMessageBox::critical(mainWindow(), tr("Debugger Startup Failure"), | 
					
						
							| 
									
										
										
										
											2009-03-02 15:14:12 +01:00
										 |  |  |                 tr("Cannot set up communication with child process: %1") | 
					
						
							|  |  |  |                     .arg(m_outputCollector.errorString())); | 
					
						
							| 
									
										
										
										
											2009-09-11 09:51:05 +02:00
										 |  |  |             emitStartFailed(); | 
					
						
							| 
									
										
										
										
											2009-09-10 13:09:42 +02:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2009-02-20 12:33:16 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         gdbArgs.prepend(_("--tty=") + m_outputCollector.serverName()); | 
					
						
							| 
									
										
										
										
											2009-02-20 12:33:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |         if (!m_startParameters->workingDir.isEmpty()) | 
					
						
							|  |  |  |             m_gdbAdapter->setWorkingDirectory(m_startParameters->workingDir); | 
					
						
							|  |  |  |         if (!m_startParameters->environment.isEmpty()) | 
					
						
							|  |  |  |             m_gdbAdapter->setEnvironment(m_startParameters->environment); | 
					
						
							| 
									
										
										
										
											2009-02-20 12:33:16 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     #if 0
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     qDebug() << "Command:" << m_manager->settings()->m_gdbCmd; | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     qDebug() << "WorkingDirectory:" << m_gdbAdapter->workingDirectory(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     qDebug() << "ScriptFile:" << m_manager->settings()->m_scriptFile; | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     qDebug() << "Environment:" << m_gdbAdapter->environment(); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     qDebug() << "Arguments:" << gdbArgs; | 
					
						
							| 
									
										
										
										
											2009-09-17 14:17:43 +02:00
										 |  |  |     qDebug() << "BuildDir:" << m_startParameters->buildDir; | 
					
						
							|  |  |  |     qDebug() << "ExeFile:" << m_startParameters->executable; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-19 10:54:27 +01:00
										 |  |  |     QString loc = theDebuggerStringSetting(GdbLocation); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Starting Debugger: ") + loc + _c(' ') + gdbArgs.join(_(" "))); | 
					
						
							| 
									
										
										
										
											2009-09-11 15:53:08 +02:00
										 |  |  |     m_gdbAdapter->start(loc, gdbArgs); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::continueInferior() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     m_manager->resetLocation(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     setTokenBarrier(); | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |     postCommand(_("-exec-continue"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleAttach(const GdbResultRecord &, const QVariant &) | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     qq->notifyInferiorStopped(); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Attached to running process. Stopped.")); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |     handleAqcuiredInferior(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     m_manager->resetLocation(); | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     recheckDebuggingHelperAvailability(); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // Stack
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     qq->stackHandler()->setCurrentIndex(0); | 
					
						
							|  |  |  |     updateLocals(); // Quick shot
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:06:24 +02:00
										 |  |  |     reloadStack(); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  |     if (supportsThreads()) | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), 0); | 
					
						
							| 
									
										
										
										
											2009-02-18 15:27:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // Registers
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     qq->reloadRegisters(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:35:11 +02:00
										 |  |  | void GdbEngine::handleSetTargetAsync(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2009-05-05 17:48:54 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-09-15 15:01:25 +02:00
										 |  |  |         postCommand(_("target remote %1") | 
					
						
							|  |  |  |                 .arg(m_manager->startParameters()->remoteChannel), | 
					
						
							| 
									
										
										
										
											2009-05-07 09:35:11 +02:00
										 |  |  |             CB(handleTargetRemote)); | 
					
						
							| 
									
										
										
										
											2009-05-05 17:48:54 +02:00
										 |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							|  |  |  |         // a typical response on "old" gdb is:
 | 
					
						
							|  |  |  |         // &"set target-async on\n"
 | 
					
						
							|  |  |  |         //&"No symbol table is loaded.  Use the \"file\" command.\n"
 | 
					
						
							|  |  |  |         //^error,msg="No symbol table is loaded.  Use the \"file\" command."
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("detach")); | 
					
						
							|  |  |  |         postCommand(_("-gdb-exit"), CB(handleExit)); | 
					
						
							| 
									
										
										
										
											2009-05-05 17:48:54 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-05-07 09:35:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleTargetRemote(const GdbResultRecord &record, const QVariant &) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |         //postCommand(_("-exec-continue"), CB(handleExecContinue));
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:35:11 +02:00
										 |  |  |         handleAqcuiredInferior(); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | // FIXME        m_continuationAfterDone = true;
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:35:11 +02:00
										 |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							|  |  |  |         // 16^error,msg="hd:5555: Connection timed out."
 | 
					
						
							|  |  |  |         QString msg = __(record.data.findChild("msg").data()); | 
					
						
							|  |  |  |         QString msg1 = tr("Connecting to remote server failed:"); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         showStatusMessage(msg1 + _c(' ') + msg); | 
					
						
							|  |  |  |         QMessageBox::critical(mainWindow(), tr("Error"), msg1 + _c('\n') + msg); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("-gdb-exit"), CB(handleExit)); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:35:11 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleExit(const GdbResultRecord &, const QVariant &) | 
					
						
							| 
									
										
										
										
											2009-04-16 15:06:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Debugger exited.")); | 
					
						
							| 
									
										
										
										
											2009-04-16 15:06:31 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::stepExec() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     if (qq->isReverseDebugging()) | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |         postCommand(_("-reverse-step"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |         postCommand(_("-exec-step"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::stepIExec() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							|  |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     if (qq->isReverseDebugging()) | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |         postCommand(_("-reverse-stepi"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |         postCommand(_("-exec-step-instruction"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::stepOutExec() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							|  |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |     postCommand(_("-exec-finish"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::nextExec() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     if (qq->isReverseDebugging()) | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |         postCommand(_("-reverse-next"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     else { | 
					
						
							|  |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2009-07-21 14:37:31 +02:00
										 |  |  |         postCommand(_("-exec-next"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  |         postCommand(_("tbreak %1:%2").arg(QFileInfo(lastFile).fileName()) | 
					
						
							|  |  |  |             .arg(lastLine + 1)); | 
					
						
							|  |  |  |         postCommand(_("-exec-continue"), CB(handleExecContinue)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::nextIExec() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							|  |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     if (qq->isReverseDebugging()) | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |         postCommand(_("-reverse-nexti"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |         postCommand(_("-exec-next-instruction"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::runToLineExec(const QString &fileName, int lineNumber) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							|  |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::runToFunctionExec(const QString &functionName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTokenBarrier(); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-break-insert -t ") + functionName); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     // that should be "^running". We need to handle the resulting
 | 
					
						
							|  |  |  |     // "Stopped"
 | 
					
						
							| 
									
										
										
										
											2009-08-13 09:42:34 +02:00
										 |  |  |     postCommand(_("-exec-continue"), CB(handleExecContinue)); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     //postCommand(_("-exec-continue"), handleExecRunToFunction);
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     StackFrame frame; | 
					
						
							|  |  |  |     frame.file = fileName; | 
					
						
							|  |  |  |     frame.line = lineNumber; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #if 1
 | 
					
						
							|  |  |  |     // not available everywhere?
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     //sendCliCommand(_("tbreak ") + fileName + ':' + QString::number(lineNumber));
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-break-insert -t ") + fileName + _c(':') + QString::number(lineNumber)); | 
					
						
							|  |  |  |     postCommand(_("jump ") + fileName + _c(':') + QString::number(lineNumber)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // will produce something like
 | 
					
						
							|  |  |  |     //  &"jump /home/apoenitz/dev/work/test1/test1.cpp:242"
 | 
					
						
							|  |  |  |     //  ~"Continuing at 0x4058f3."
 | 
					
						
							|  |  |  |     //  ~"run1 (argc=1, argv=0x7fffbf1f5538) at test1.cpp:242"
 | 
					
						
							|  |  |  |     //  ~"242\t x *= 2;"
 | 
					
						
							|  |  |  |     //  23^done"
 | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |     gotoLocation(frame, true); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //setBreakpoint();
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     //postCommand(_("jump ") + fileName + ':' + QString::number(lineNumber));
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |     gotoLocation(frame,  true); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     setBreakpoint(fileName, lineNumber); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("jump ") + fileName + ':' + QString::number(lineNumber)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							|  |  |  |     \fn void GdbEngine::setTokenBarrier() | 
					
						
							| 
									
										
										
										
											2009-02-18 13:50:55 +01:00
										 |  |  |     \brief Discard the results of all pending watch-updating commands. | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-18 10:28:31 +01:00
										 |  |  |     This method is called at the beginning of all step/next/finish etc. | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     debugger functions. | 
					
						
							| 
									
										
										
										
											2009-02-18 13:50:55 +01:00
										 |  |  |     If non-watch-updating commands with call-backs are still in the pipe, | 
					
						
							|  |  |  |     it will complain. | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::setTokenBarrier() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     foreach (const GdbCommand &cookie, m_cookieForToken) { | 
					
						
							|  |  |  |         QTC_ASSERT(!cookie.callback || (cookie.flags & Discardable), | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |             qDebug() << "CMD:" << cookie.command << " CALLBACK:" << cookie.callbackName; | 
					
						
							| 
									
										
										
										
											2009-04-14 12:14:01 +02:00
										 |  |  |             return | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  |     PENDING_DEBUG("\n--- token barrier ---\n"); | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     emit gdbInputAvailable(LogMisc, _("--- token barrier ---")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     m_oldestAcceptableToken = currentToken(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::setDebugDebuggingHelpers(const QVariant &on) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-26 15:14:17 +01:00
										 |  |  |     if (on.toBool()) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         debugMessage(_("SWITCHING ON DUMPER DEBUGGING")); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("set unwindonsignal off")); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         m_manager->breakByFunction(_("qDumpObjectData440")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         //updateLocals();
 | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         debugMessage(_("SWITCHING OFF DUMPER DEBUGGING")); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("set unwindonsignal on")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Breakpoint specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!bkpt.isValid()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     if (!data) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     data->pending = false; | 
					
						
							|  |  |  |     data->bpMultiple = false; | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |     data->bpEnabled = true; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     data->bpCondition.clear(); | 
					
						
							|  |  |  |     QStringList files; | 
					
						
							|  |  |  |     foreach (const GdbMi &child, bkpt.children()) { | 
					
						
							|  |  |  |         if (child.hasName("number")) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data->bpNumber = _(child.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else if (child.hasName("func")) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data->bpFuncName = _(child.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else if (child.hasName("addr")) { | 
					
						
							|  |  |  |             // <MULTIPLE> happens in constructors. In this case there are
 | 
					
						
							|  |  |  |             // _two_ fields named "addr" in the response. On Linux that is...
 | 
					
						
							|  |  |  |             if (child.data() == "<MULTIPLE>") | 
					
						
							|  |  |  |                 data->bpMultiple = true; | 
					
						
							|  |  |  |             else | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 data->bpAddress = _(child.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else if (child.hasName("file")) { | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |             files.append(QFile::decodeName(child.data())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else if (child.hasName("fullname")) { | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |             QString fullName = QFile::decodeName(child.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  |             fullName = QDir::cleanPath(fullName); | 
					
						
							|  |  |  |             #endif
 | 
					
						
							|  |  |  |             files.prepend(fullName); | 
					
						
							|  |  |  |         } else if (child.hasName("line")) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data->bpLineNumber = _(child.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             if (child.data().toInt()) | 
					
						
							|  |  |  |                 data->markerLineNumber = child.data().toInt(); | 
					
						
							|  |  |  |         } else if (child.hasName("cond")) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data->bpCondition = _(child.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // gdb 6.3 likes to "rewrite" conditions. Just accept that fact.
 | 
					
						
							|  |  |  |             if (data->bpCondition != data->condition && data->conditionsMatch()) | 
					
						
							|  |  |  |                 data->condition = data->bpCondition; | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |         } else if (child.hasName("enabled")) { | 
					
						
							|  |  |  |             data->bpEnabled = (child.data() == "y"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         else if (child.hasName("pending")) { | 
					
						
							|  |  |  |             data->pending = true; | 
					
						
							|  |  |  |             int pos = child.data().lastIndexOf(':'); | 
					
						
							|  |  |  |             if (pos > 0) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 data->bpLineNumber = _(child.data().mid(pos + 1)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 data->markerLineNumber = child.data().mid(pos + 1).toInt(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 QString file = QString::fromLocal8Bit(child.data().left(pos)); | 
					
						
							|  |  |  |                 if (file.startsWith(_c('"')) && file.endsWith(_c('"'))) | 
					
						
							| 
									
										
										
										
											2009-04-14 09:55:21 +02:00
										 |  |  |                     file = file.mid(1, file.size() - 2); | 
					
						
							|  |  |  |                 files.prepend(file); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 files.prepend(QString::fromLocal8Bit(child.data())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // This field is not present.  Contents needs to be parsed from
 | 
					
						
							|  |  |  |     // the plain "ignore" response.
 | 
					
						
							|  |  |  |     //else if (child.hasName("ignore"))
 | 
					
						
							|  |  |  |     //    data->bpIgnoreCount = child.data();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString name = fullName(files); | 
					
						
							|  |  |  |     if (data->bpFileName.isEmpty()) | 
					
						
							|  |  |  |         data->bpFileName = name; | 
					
						
							|  |  |  |     if (data->markerFileName.isEmpty()) | 
					
						
							|  |  |  |         data->markerFileName = name; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::sendInsertBreakpoint(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const BreakpointData *data = qq->breakHandler()->at(index); | 
					
						
							|  |  |  |     QString where; | 
					
						
							|  |  |  |     if (data->funcName.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-05-11 13:21:59 +02:00
										 |  |  |         if (data->useFullPath) { | 
					
						
							|  |  |  |             where = data->fileName; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             QFileInfo fi(data->fileName); | 
					
						
							|  |  |  |             where = fi.fileName(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-05-05 15:53:17 +02:00
										 |  |  |         // The argument is simply a C-quoted version of the argument to the
 | 
					
						
							|  |  |  |         // non-MI "break" command, including the "original" quoting it wants.
 | 
					
						
							| 
									
										
										
										
											2009-09-11 09:51:05 +02:00
										 |  |  |         where = _("\"\\\"%1\\\":%2\"") | 
					
						
							|  |  |  |             .arg(GdbMi::escapeCString(where)).arg(data->lineNumber); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         where = data->funcName; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // set up fallback in case of pending breakpoints which aren't handled
 | 
					
						
							|  |  |  |     // by the MI interface
 | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  | #if defined(Q_OS_WIN)
 | 
					
						
							|  |  |  |     QString cmd = _("-break-insert "); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //if (!data->condition.isEmpty())
 | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |     //    cmd += "-c " + data->condition + " ";
 | 
					
						
							|  |  |  | #elif defined(Q_OS_MAC)
 | 
					
						
							| 
									
										
										
										
											2009-05-04 09:14:59 +02:00
										 |  |  |     QString cmd = _("-break-insert -l -1 "); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //if (!data->condition.isEmpty())
 | 
					
						
							|  |  |  |     //    cmd += "-c " + data->condition + " ";
 | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  |     QString cmd = _("-break-insert -f "); | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     if (m_gdbAdapter->isTrkAdapter()) | 
					
						
							| 
									
										
										
										
											2009-09-11 13:05:37 +02:00
										 |  |  |         cmd = _("-break-insert "); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //if (!data->condition.isEmpty())
 | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |     //    cmd += _("-c ") + data->condition + ' ';
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-06-17 17:18:31 +02:00
										 |  |  |     cmd += where; | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     emit gdbOutputAvailable(LogStatus, _("Current state: %1").arg(status())); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(cmd, NeedsStop, CB(handleBreakInsert), index); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleBreakList(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // 45^done,BreakpointTable={nr_rows="2",nr_cols="6",hdr=[
 | 
					
						
							|  |  |  |     // {width="3",alignment="-1",col_name="number",colhdr="Num"}, ...
 | 
					
						
							|  |  |  |     // body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
 | 
					
						
							|  |  |  |     //  addr="0x000000000040109e",func="main",file="app.cpp",
 | 
					
						
							|  |  |  |     //  fullname="/home/apoenitz/dev/work/plugintest/app/app.cpp",
 | 
					
						
							|  |  |  |     //  line="11",times="1"},
 | 
					
						
							|  |  |  |     //  bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
 | 
					
						
							|  |  |  |     //  addr="<PENDING>",pending="plugin.cpp:7",times="0"}] ... }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         GdbMi table = record.data.findChild("BreakpointTable"); | 
					
						
							|  |  |  |         if (table.isValid()) | 
					
						
							|  |  |  |             handleBreakList(table); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleBreakList(const GdbMi &table) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "GdbEngine::handleOutput: table:"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //  << table.toString();
 | 
					
						
							|  |  |  |     GdbMi body = table.findChild("body"); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "GdbEngine::handleOutput: body:"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //  << body.toString();
 | 
					
						
							|  |  |  |     QList<GdbMi> bkpts; | 
					
						
							|  |  |  |     if (body.isValid()) { | 
					
						
							|  |  |  |         // Non-Mac
 | 
					
						
							|  |  |  |         bkpts = body.children(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         // Mac
 | 
					
						
							|  |  |  |         bkpts = table.children(); | 
					
						
							|  |  |  |         // remove the 'hdr' and artificial items
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "FOUND" << bkpts.size() << "BREAKPOINTS";
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         for (int i = bkpts.size(); --i >= 0; ) { | 
					
						
							|  |  |  |             int num = bkpts.at(i).findChild("number").data().toInt(); | 
					
						
							|  |  |  |             if (num <= 0) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |                 //qDebug() << "REMOVING" << i << bkpts.at(i).toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 bkpts.removeAt(i); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "LEFT" << bkpts.size() << "BREAKPOINTS";
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  |     for (int index = 0; index != bkpts.size(); ++index) { | 
					
						
							|  |  |  |         BreakpointData temp(handler); | 
					
						
							|  |  |  |         breakpointDataFromOutput(&temp, bkpts.at(index)); | 
					
						
							|  |  |  |         int found = handler->findBreakpoint(temp); | 
					
						
							|  |  |  |         if (found != -1) | 
					
						
							|  |  |  |             breakpointDataFromOutput(handler->at(found), bkpts.at(index)); | 
					
						
							|  |  |  |         //else
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |             //qDebug() << "CANNOT HANDLE RESPONSE" << bkpts.at(index).toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     attemptBreakpointSynchronization(); | 
					
						
							|  |  |  |     handler->updateMarkers(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleBreakIgnore(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     int index = cookie.toInt(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // gdb 6.8:
 | 
					
						
							|  |  |  |     // ignore 2 0:
 | 
					
						
							|  |  |  |     // ~"Will stop next time breakpoint 2 is reached.\n"
 | 
					
						
							|  |  |  |     // 28^done
 | 
					
						
							|  |  |  |     // ignore 2 12:
 | 
					
						
							|  |  |  |     // &"ignore 2 12\n"
 | 
					
						
							|  |  |  |     // ~"Will ignore next 12 crossings of breakpoint 2.\n"
 | 
					
						
							|  |  |  |     // 29^done
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // gdb 6.3 does not produce any console output
 | 
					
						
							|  |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone && index < handler->size()) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString msg = _(record.data.findChild("consolestreamoutput").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         //if (msg.contains(__("Will stop next time breakpoint"))) {
 | 
					
						
							|  |  |  |         //    data->bpIgnoreCount = _("0");
 | 
					
						
							|  |  |  |         //} else if (msg.contains(__("Will ignore next"))) {
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         //    data->bpIgnoreCount = data->ignoreCount;
 | 
					
						
							|  |  |  |         //}
 | 
					
						
							|  |  |  |         // FIXME: this assumes it is doing the right thing...
 | 
					
						
							|  |  |  |         data->bpIgnoreCount = data->ignoreCount; | 
					
						
							|  |  |  |         handler->updateMarkers(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleBreakCondition(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     int index = cookie.toInt(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         // we just assume it was successful. otherwise we had to parse
 | 
					
						
							|  |  |  |         // the output stream data
 | 
					
						
							|  |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "HANDLE BREAK CONDITION" << index << data->condition;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         data->bpCondition = data->condition; | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |     } else { // GdbResultError
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QByteArray msg = record.data.findChild("msg").data(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // happens on Mac
 | 
					
						
							|  |  |  |         if (1 || msg.startsWith("Error parsing breakpoint condition. " | 
					
						
							|  |  |  |                 " Will try again when we hit the breakpoint.")) { | 
					
						
							|  |  |  |             BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |             //qDebug() << "ERROR BREAK CONDITION" << index << data->condition;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             data->bpCondition = data->condition; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |     handler->updateMarkers(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleBreakInsert(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     int index = cookie.toInt(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "HANDLE BREAK INSERT" << index;
 | 
					
						
							| 
									
										
										
										
											2009-05-11 10:22:03 +02:00
										 |  |  | //#if defined(Q_OS_MAC)
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // interesting only on Mac?
 | 
					
						
							|  |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							|  |  |  |         GdbMi bkpt = record.data.findChild("bkpt"); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "BKPT:" << bkpt.toString() << " DATA:" << data->toToolTip();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         breakpointDataFromOutput(data, bkpt); | 
					
						
							|  |  |  | //#endif
 | 
					
						
							|  |  |  |         attemptBreakpointSynchronization(); | 
					
						
							|  |  |  |         handler->updateMarkers(); | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |     } else { // GdbResultError
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         const BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-05-05 15:53:17 +02:00
										 |  |  |         // Note that it is perfectly correct that the file name is put
 | 
					
						
							|  |  |  |         // in quotes but not escaped. GDB simply is like that.
 | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  | #if defined(Q_OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         QFileInfo fi(data->fileName); | 
					
						
							| 
									
										
										
										
											2009-05-04 08:19:56 +02:00
										 |  |  |         QString where = _c('"') + fi.fileName() + _("\":") | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             + data->lineNumber; | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  |         //QString where = m_data->fileName + _c(':') + data->lineNumber;
 | 
					
						
							|  |  |  | #elif defined(Q_OS_MAC)
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         QFileInfo fi(data->fileName); | 
					
						
							| 
									
										
										
										
											2009-05-04 08:19:56 +02:00
										 |  |  |         QString where = _c('"') + fi.fileName() + _("\":") | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             + data->lineNumber; | 
					
						
							| 
									
										
										
										
											2009-06-03 20:45:49 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  |         //QString where = "\"\\\"" + data->fileName + "\\\":"
 | 
					
						
							|  |  |  |         //    + data->lineNumber + "\"";
 | 
					
						
							|  |  |  |         QString where = _c('"') + data->fileName + _("\":") | 
					
						
							|  |  |  |             + data->lineNumber; | 
					
						
							|  |  |  |         // Should not happen with -break-insert -f. gdb older than 6.8?
 | 
					
						
							|  |  |  |         QTC_ASSERT(false, /**/); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("break ") + where, CB(handleBreakInsert1), index); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::extractDataFromInfoBreak(const QString &output, BreakpointData *data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     data->bpFileName = _("<MULTIPLE>"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //qDebug() << output;
 | 
					
						
							|  |  |  |     if (output.isEmpty()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     // "Num     Type           Disp Enb Address            What
 | 
					
						
							|  |  |  |     // 4       breakpoint     keep y   <MULTIPLE>         0x00000000004066ad
 | 
					
						
							|  |  |  |     // 4.1                         y     0x00000000004066ad in CTorTester
 | 
					
						
							|  |  |  |     //  at /data5/dev/ide/main/tests/manual/gdbdebugger/simple/app.cpp:124
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  |     // - or -
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // everything on a single line on Windows for constructors of classes
 | 
					
						
							|  |  |  |     // within namespaces.
 | 
					
						
							|  |  |  |     // Sometimes the path is relative too.
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 12:52:29 +02:00
										 |  |  |     // 2    breakpoint     keep y   <MULTIPLE> 0x0040168e
 | 
					
						
							|  |  |  |     // 2.1    y     0x0040168e in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7
 | 
					
						
							|  |  |  |     // 2.2    y     0x00401792 in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 13:54:34 +02:00
										 |  |  |     // tested in ../../../tests/auto/debugger/
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QRegExp re(_("MULTIPLE.*(0x[0-9a-f]+) in (.*)\\s+at (.*):([\\d]+)([^\\d]|$)")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     re.setMinimal(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (re.indexIn(output) != -1) { | 
					
						
							|  |  |  |         data->bpAddress = re.cap(1); | 
					
						
							|  |  |  |         data->bpFuncName = re.cap(2).trimmed(); | 
					
						
							|  |  |  |         data->bpLineNumber = re.cap(4); | 
					
						
							|  |  |  |         QString full = fullName(re.cap(3)); | 
					
						
							| 
									
										
										
										
											2009-04-16 13:54:34 +02:00
										 |  |  |         if (full.isEmpty()) { | 
					
						
							|  |  |  |             qDebug() << "NO FULL NAME KNOWN FOR" << re.cap(3); | 
					
						
							|  |  |  |             full = re.cap(3); // FIXME: wrong, but prevents recursion
 | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         data->markerLineNumber = data->bpLineNumber.toInt(); | 
					
						
							|  |  |  |         data->markerFileName = full; | 
					
						
							|  |  |  |         data->bpFileName = full; | 
					
						
							|  |  |  |         //qDebug() << "FOUND BREAKPOINT\n" << output
 | 
					
						
							|  |  |  |         //    << re.cap(1) << "\n" << re.cap(2) << "\n"
 | 
					
						
							|  |  |  |         //    << re.cap(3) << "\n" << re.cap(4) << "\n";
 | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         qDebug() << "COULD NOT MATCH " << re.pattern() << " AND " << output; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data->bpNumber = _("<unavailable>"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleBreakInfo(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     int bpNumber = cookie.toInt(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         // Old-style output for multiple breakpoints, presumably in a
 | 
					
						
							|  |  |  |         // constructor
 | 
					
						
							|  |  |  |         int found = handler->findBreakpoint(bpNumber); | 
					
						
							|  |  |  |         if (found != -1) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString str = QString::fromLocal8Bit(record.data.findChild("consolestreamoutput").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             extractDataFromInfoBreak(str, handler->at(found)); | 
					
						
							|  |  |  |             handler->updateMarkers(); | 
					
						
							|  |  |  |             attemptBreakpointSynchronization(); // trigger "ready"
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleBreakInsert1(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     int index = cookie.toInt(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         // Pending breakpoints in dylibs on Mac only?
 | 
					
						
							|  |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							|  |  |  |         GdbMi bkpt = record.data.findChild("bkpt"); | 
					
						
							|  |  |  |         breakpointDataFromOutput(data, bkpt); | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |     } else { // GdbResultError
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         qDebug() << "INSERTING BREAKPOINT WITH BASE NAME FAILED. GIVING UP"; | 
					
						
							|  |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data->bpNumber = _("<unavailable>"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |     attemptBreakpointSynchronization(); // trigger "ready"
 | 
					
						
							|  |  |  |     handler->updateMarkers(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::attemptBreakpointSynchronization() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     BreakHandler *handler = qq->breakHandler(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-28 15:08:52 +02:00
										 |  |  |     foreach (BreakpointData *data, handler->takeDisabledBreakpoints()) { | 
					
						
							|  |  |  |         QString bpNumber = data->bpNumber; | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |         if (!bpNumber.trimmed().isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |             postCommand(_("-break-disable ") + bpNumber, NeedsStop); | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |             data->bpEnabled = false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-04-28 15:08:52 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (BreakpointData *data, handler->takeEnabledBreakpoints()) { | 
					
						
							|  |  |  |         QString bpNumber = data->bpNumber; | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |         if (!bpNumber.trimmed().isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |             postCommand(_("-break-enable ") + bpNumber, NeedsStop); | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |             data->bpEnabled = true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-04-28 15:08:52 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     foreach (BreakpointData *data, handler->takeRemovedBreakpoints()) { | 
					
						
							|  |  |  |         QString bpNumber = data->bpNumber; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         debugMessage(_("DELETING BP %1 IN %2").arg(bpNumber) | 
					
						
							| 
									
										
										
										
											2009-02-16 18:28:15 +01:00
										 |  |  |             .arg(data->markerFileName)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         if (!bpNumber.trimmed().isEmpty()) | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |             postCommand(_("-break-delete ") + bpNumber, NeedsStop); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         delete data; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int index = 0; index != handler->size(); ++index) { | 
					
						
							|  |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |         if (data->bpNumber.isEmpty()) { // unset breakpoint?
 | 
					
						
							|  |  |  |             data->bpNumber = _(" "); // Sent, but no feedback yet
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             sendInsertBreakpoint(index); | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |         } else if (data->bpNumber.toInt()) { | 
					
						
							|  |  |  |             if (data->bpMultiple && data->bpFileName.isEmpty()) { | 
					
						
							|  |  |  |                 postCommand(_("info break %1").arg(data->bpNumber), | 
					
						
							|  |  |  |                     CB(handleBreakInfo), data->bpNumber.toInt()); | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // update conditions if needed
 | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |             if (data->condition != data->bpCondition && !data->conditionsMatch()) | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |                 postCommand(_("condition %1 %2").arg(data->bpNumber).arg(data->condition), | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |                             CB(handleBreakCondition), index); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // update ignorecount if needed
 | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |             if (data->ignoreCount != data->bpIgnoreCount) | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |                 postCommand(_("ignore %1 %2").arg(data->bpNumber).arg(data->ignoreCount), | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |                             CB(handleBreakIgnore), index); | 
					
						
							| 
									
										
										
										
											2009-06-12 14:43:24 +02:00
										 |  |  |             if (!data->enabled && data->bpEnabled) { | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |                 postCommand(_("-break-disable ") + data->bpNumber, NeedsStop); | 
					
						
							|  |  |  |                 data->bpEnabled = false; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int index = 0; index != handler->size(); ++index) { | 
					
						
							|  |  |  |         // happens sometimes on Mac. Brush over symptoms
 | 
					
						
							|  |  |  |         BreakpointData *data = handler->at(index); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         if (data->markerFileName.startsWith(__("../"))) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             data->markerFileName = fullName(data->markerFileName); | 
					
						
							|  |  |  |             handler->updateMarkers(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Modules specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::loadSymbols(const QString &moduleName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // FIXME: gdb does not understand quoted names here (tested with 6.8)
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("sharedlibrary ") + dotEscape(moduleName)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     reloadModules(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::loadAllSymbols() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("sharedlibrary .*")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     reloadModules(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-15 12:01:58 +02:00
										 |  |  | QList<Symbol> GdbEngine::moduleSymbols(const QString &moduleName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QList<Symbol> rc; | 
					
						
							|  |  |  |     bool success = false; | 
					
						
							|  |  |  |     QString errorMessage; | 
					
						
							|  |  |  |     do { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         const QString nmBinary = _("nm"); | 
					
						
							| 
									
										
										
										
											2009-04-15 12:01:58 +02:00
										 |  |  |         QProcess proc; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         proc.start(nmBinary, QStringList() << _("-D") << moduleName); | 
					
						
							| 
									
										
										
										
											2009-04-15 12:01:58 +02:00
										 |  |  |         if (!proc.waitForFinished()) { | 
					
						
							|  |  |  |             errorMessage = tr("Unable to run '%1': %2").arg(nmBinary, proc.errorString()); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         const QString contents = QString::fromLocal8Bit(proc.readAllStandardOutput()); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         const QRegExp re(_("([0-9a-f]+)?\\s+([^\\s]+)\\s+([^\\s]+)")); | 
					
						
							| 
									
										
										
										
											2009-04-15 12:01:58 +02:00
										 |  |  |         Q_ASSERT(re.isValid()); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         foreach (const QString &line, contents.split(_c('\n'))) { | 
					
						
							| 
									
										
										
										
											2009-04-15 12:01:58 +02:00
										 |  |  |             if (re.indexIn(line) != -1) { | 
					
						
							|  |  |  |                 Symbol symbol; | 
					
						
							|  |  |  |                 symbol.address = re.cap(1); | 
					
						
							|  |  |  |                 symbol.state = re.cap(2); | 
					
						
							|  |  |  |                 symbol.name = re.cap(3); | 
					
						
							|  |  |  |                 rc.push_back(symbol); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 qWarning("moduleSymbols: unhandled: %s", qPrintable(line)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         success = true; | 
					
						
							|  |  |  |     } while (false); | 
					
						
							|  |  |  |     if (!success) | 
					
						
							|  |  |  |         qWarning("moduleSymbols: %s\n", qPrintable(errorMessage)); | 
					
						
							|  |  |  |     return rc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::reloadModules() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("info shared"), CB(handleModulesList)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleModulesList(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QList<Module> modules; | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-03-12 12:00:53 +01:00
										 |  |  |         // that's console-based output, likely Linux or Windows,
 | 
					
						
							|  |  |  |         // but we can avoid the #ifdef here
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString data = QString::fromLocal8Bit(record.data.findChild("consolestreamoutput").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         QTextStream ts(&data, QIODevice::ReadOnly); | 
					
						
							|  |  |  |         while (!ts.atEnd()) { | 
					
						
							|  |  |  |             QString line = ts.readLine(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             if (!line.startsWith(__("0x"))) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             Module module; | 
					
						
							|  |  |  |             QString symbolsRead; | 
					
						
							|  |  |  |             QTextStream ts(&line, QIODevice::ReadOnly); | 
					
						
							|  |  |  |             ts >> module.startAddress >> module.endAddress >> symbolsRead; | 
					
						
							|  |  |  |             module.moduleName = ts.readLine().trimmed(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             module.symbolsRead = (symbolsRead == __("Yes")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             modules.append(module); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-03-12 12:00:53 +01:00
										 |  |  |         if (modules.isEmpty()) { | 
					
						
							|  |  |  |             // Mac has^done,shlib-info={num="1",name="dyld",kind="-",
 | 
					
						
							|  |  |  |             // dyld-addr="0x8fe00000",reason="dyld",requested-state="Y",
 | 
					
						
							|  |  |  |             // state="Y",path="/usr/lib/dyld",description="/usr/lib/dyld",
 | 
					
						
							|  |  |  |             // loaded_addr="0x8fe00000",slide="0x0",prefix="__dyld_"},
 | 
					
						
							|  |  |  |             // shlib-info={...}...
 | 
					
						
							|  |  |  |             foreach (const GdbMi &item, record.data.children()) { | 
					
						
							|  |  |  |                 Module module; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 module.moduleName = QString::fromLocal8Bit(item.findChild("path").data()); | 
					
						
							| 
									
										
										
										
											2009-03-12 12:00:53 +01:00
										 |  |  |                 module.symbolsRead = (item.findChild("state").data() == "Y"); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 module.startAddress = _(item.findChild("loaded_addr").data()); | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  |                 //: End address of loaded module
 | 
					
						
							|  |  |  |                 module.endAddress = tr("<unknown>"); | 
					
						
							| 
									
										
										
										
											2009-03-12 12:00:53 +01:00
										 |  |  |                 modules.append(module); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     qq->modulesHandler()->setModules(modules); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-17 14:08:49 +01:00
										 |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Source files specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::reloadSourceFiles() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-file-list-exec-source-files"), CB(handleQuerySources)); | 
					
						
							| 
									
										
										
										
											2009-02-17 14:08:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Stack specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleStackSelectThread(const GdbResultRecord &, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-12-08 14:26:11 +01:00
										 |  |  |     //qDebug("FIXME: StackHandler::handleOutput: SelectThread");
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Retrieving data for stack view..."), 3000); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:06:24 +02:00
										 |  |  |     reloadStack(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleStackListFrames(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-15 15:37:12 +02:00
										 |  |  |     #if defined(Q_OS_MAC)
 | 
					
						
							|  |  |  |     bool handleIt = true; | 
					
						
							|  |  |  |     #else
 | 
					
						
							|  |  |  |     bool handleIt = record.resultClass == GdbResultDone; | 
					
						
							|  |  |  |     #endif
 | 
					
						
							|  |  |  |     if (handleIt) { | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |         bool isFull = cookie.toBool(); | 
					
						
							|  |  |  |         QList<StackFrame> stackFrames; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |         GdbMi stack = record.data.findChild("stack"); | 
					
						
							|  |  |  |         if (!stack.isValid()) { | 
					
						
							|  |  |  |             qDebug() << "FIXME: stack:" << stack.toString(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |         int topFrame = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int n = stack.childCount(); | 
					
						
							|  |  |  |         for (int i = 0; i != n; ++i) { | 
					
						
							|  |  |  |             //qDebug() << "HANDLING FRAME:" << stack.childAt(i).toString();
 | 
					
						
							|  |  |  |             const GdbMi frameMi = stack.childAt(i); | 
					
						
							|  |  |  |             StackFrame frame(i); | 
					
						
							|  |  |  |             QStringList files; | 
					
						
							|  |  |  |             files.append(QFile::decodeName(frameMi.findChild("fullname").data())); | 
					
						
							|  |  |  |             files.append(QFile::decodeName(frameMi.findChild("file").data())); | 
					
						
							|  |  |  |             frame.file = fullName(files); | 
					
						
							|  |  |  |             frame.function = _(frameMi.findChild("func").data()); | 
					
						
							|  |  |  |             frame.from = _(frameMi.findChild("from").data()); | 
					
						
							|  |  |  |             frame.line = frameMi.findChild("line").data().toInt(); | 
					
						
							|  |  |  |             frame.address = _(frameMi.findChild("addr").data()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             stackFrames.append(frame); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             #if defined(Q_OS_WIN)
 | 
					
						
							|  |  |  |             const bool isBogus = | 
					
						
							|  |  |  |                 // Assume this is wrong and points to some strange stl_algobase
 | 
					
						
							|  |  |  |                 // implementation. Happens on Karsten's XP system with Gdb 5.50
 | 
					
						
							|  |  |  |                 (frame.file.endsWith(__("/bits/stl_algobase.h")) && frame.line == 150) | 
					
						
							|  |  |  |                 // Also wrong. Happens on Vista with Gdb 5.50
 | 
					
						
							|  |  |  |                    || (frame.function == __("operator new") && frame.line == 151); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // immediately leave bogus frames
 | 
					
						
							|  |  |  |             if (topFrame == -1 && isBogus) { | 
					
						
							|  |  |  |                 postCommand(_("-exec-finish")); | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |             // Initialize top frame to the first valid frame
 | 
					
						
							|  |  |  |             const bool isValid = !frame.file.isEmpty() && !frame.function.isEmpty(); | 
					
						
							|  |  |  |             if (isValid && topFrame == -1) | 
					
						
							|  |  |  |                 topFrame = i; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |         bool canExpand = !isFull  | 
					
						
							|  |  |  |             && (n >= theDebuggerAction(MaximalStackDepth)->value().toInt()); | 
					
						
							|  |  |  |         theDebuggerAction(ExpandStack)->setEnabled(canExpand); | 
					
						
							|  |  |  |         qq->stackHandler()->setFrames(stackFrames, canExpand); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |         if (topFrame != -1 || theDebuggerBoolSetting(StepByInstruction)) { | 
					
						
							|  |  |  |             const StackFrame &frame = qq->stackHandler()->currentFrame(); | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |             gotoLocation(frame, true); | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-09-15 15:37:12 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         qDebug() << "LISTING STACK FAILED: " << record.toString(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::selectThread(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //reset location arrow
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     m_manager->resetLocation(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ThreadsHandler *threadsHandler = qq->threadsHandler(); | 
					
						
							|  |  |  |     threadsHandler->setCurrentThread(index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<ThreadData> threads = threadsHandler->threads(); | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(index < threads.size(), return); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     int id = threads.at(index).id; | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Retrieving data for stack view..."), 10000); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-thread-select %1").arg(id), CB(handleStackSelectThread)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::activateFrame(int frameIndex) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     if (status() != DebuggerInferiorStopped) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     StackHandler *stackHandler = qq->stackHandler(); | 
					
						
							|  |  |  |     int oldIndex = stackHandler->currentIndex(); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "ACTIVATE FRAME:" << frameIndex << oldIndex
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //    << stackHandler->currentIndex();
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-06 17:27:15 +02:00
										 |  |  |     if (frameIndex == stackHandler->stackSize()) { | 
					
						
							|  |  |  |         reloadFullStack(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(frameIndex < stackHandler->stackSize(), return); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (oldIndex != frameIndex) { | 
					
						
							| 
									
										
										
										
											2009-02-18 13:50:55 +01:00
										 |  |  |         setTokenBarrier(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // Assuming this always succeeds saves a roundtrip.
 | 
					
						
							|  |  |  |         // Otherwise the lines below would need to get triggered
 | 
					
						
							|  |  |  |         // after a response to this -stack-select-frame here.
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("-stack-select-frame ") + QString::number(frameIndex)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         stackHandler->setCurrentIndex(frameIndex); | 
					
						
							|  |  |  |         updateLocals(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const StackFrame &frame = stackHandler->currentFrame(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-26 16:49:28 +01:00
										 |  |  |     if (frame.isUsable()) | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |         gotoLocation(frame, true); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         qDebug() << "FULL NAME NOT USABLE:" << frame.file; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleStackListThreads(const GdbResultRecord &record, const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     int id = cookie.toInt(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
 | 
					
						
							|  |  |  |     const QList<GdbMi> items = record.data.findChild("thread-ids").children(); | 
					
						
							|  |  |  |     QList<ThreadData> threads; | 
					
						
							|  |  |  |     int currentIndex = -1; | 
					
						
							|  |  |  |     for (int index = 0, n = items.size(); index != n; ++index) { | 
					
						
							|  |  |  |         ThreadData thread; | 
					
						
							|  |  |  |         thread.id = items.at(index).data().toInt(); | 
					
						
							|  |  |  |         threads.append(thread); | 
					
						
							|  |  |  |         if (thread.id == id) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |             //qDebug() << "SETTING INDEX TO:" << index << " ID:" << id << " RECOD:" << record.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             currentIndex = index; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ThreadsHandler *threadsHandler = qq->threadsHandler(); | 
					
						
							|  |  |  |     threadsHandler->setThreads(threads); | 
					
						
							|  |  |  |     threadsHandler->setCurrentThread(currentIndex); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Register specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::reloadRegisters() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |     if (m_gdbAdapter->isTrkAdapter()) { | 
					
						
							| 
									
										
										
										
											2009-09-15 15:32:49 +02:00
										 |  |  |         // FIXME: remove that special case. This is only to prevent
 | 
					
						
							|  |  |  |         // gdb from asking for the values of the fixed point registers
 | 
					
						
							| 
									
										
										
										
											2009-09-17 09:00:28 +02:00
										 |  |  |         postCommand(_("-data-list-register-values x 0 1 2 3 4 5 6 7 8 9 " | 
					
						
							| 
									
										
										
										
											2009-09-15 15:32:49 +02:00
										 |  |  |                       "10 11 12 13 14 15 25"), | 
					
						
							|  |  |  |                     Discardable, CB(handleRegisterListValues)); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         postCommand(_("-data-list-register-values x"), | 
					
						
							|  |  |  |                     Discardable, CB(handleRegisterListValues)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  | void GdbEngine::setRegisterValue(int nr, const QString &value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Register reg = qq->registerHandler()->registers().at(nr); | 
					
						
							|  |  |  |     //qDebug() << "NOT IMPLEMENTED: CHANGE REGISTER " << nr << reg.name << ":"
 | 
					
						
							|  |  |  |     //    << value;
 | 
					
						
							|  |  |  |     postCommand(_("-var-delete \"R@\"")); | 
					
						
							|  |  |  |     postCommand(_("-var-create \"R@\" * $%1").arg(reg.name)); | 
					
						
							|  |  |  |     postCommand(_("-var-assign \"R@\" %1").arg(value)); | 
					
						
							|  |  |  |     postCommand(_("-var-delete \"R@\"")); | 
					
						
							|  |  |  |     //postCommand(_("-data-list-register-values d"),
 | 
					
						
							|  |  |  |     //            Discardable, CB(handleRegisterListValues));
 | 
					
						
							|  |  |  |     reloadRegisters(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleRegisterListNames(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass != GdbResultDone) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<Register> registers; | 
					
						
							|  |  |  |     foreach (const GdbMi &item, record.data.findChild("register-names").children()) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         registers.append(Register(_(item.data()))); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     qq->registerHandler()->setRegisters(registers); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleRegisterListValues(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (record.resultClass != GdbResultDone) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<Register> registers = qq->registerHandler()->registers(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // 24^done,register-values=[{number="0",value="0xf423f"},...]
 | 
					
						
							|  |  |  |     foreach (const GdbMi &item, record.data.findChild("register-values").children()) { | 
					
						
							|  |  |  |         int index = item.findChild("number").data().toInt(); | 
					
						
							|  |  |  |         if (index < registers.size()) { | 
					
						
							|  |  |  |             Register ® = registers[index]; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString value = _(item.findChild("value").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             reg.changed = (value != reg.value); | 
					
						
							|  |  |  |             if (reg.changed) | 
					
						
							|  |  |  |                 reg.value = value; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     qq->registerHandler()->setRegisters(registers); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Thread specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GdbEngine::supportsThreads() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-24 14:11:47 +02:00
										 |  |  | #ifdef Q_OS_MAC
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     // FSF gdb 6.3 crashes happily on -thread-list-ids. So don't use it.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // The test below is a semi-random pick, 6.8 works fine
 | 
					
						
							| 
									
										
										
										
											2008-12-08 14:26:11 +01:00
										 |  |  |     return m_gdbVersion > 60500; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Tooltip specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static QString m_toolTipExpression; | 
					
						
							|  |  |  | static QPoint m_toolTipPos; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  | static QString tooltipINameForExpression(const QString &exp) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // FIXME: 'exp' can contain illegal characters
 | 
					
						
							|  |  |  |     //return QLatin1String("tooltip.") + exp;
 | 
					
						
							| 
									
										
										
										
											2009-07-13 17:35:17 +02:00
										 |  |  |     Q_UNUSED(exp) | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     return QLatin1String("tooltip.x"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GdbEngine::showToolTip() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     WatchHandler *handler = qq->watchHandler(); | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     WatchModel *model = handler->model(TooltipsWatch); | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     QString iname = tooltipINameForExpression(m_toolTipExpression); | 
					
						
							|  |  |  |     model->setActiveData(iname); | 
					
						
							| 
									
										
										
										
											2009-07-13 11:25:05 +02:00
										 |  |  |     WatchItem *item = model->findItem(iname, model->rootItem()); | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     if (!item) { | 
					
						
							|  |  |  |         hideDebuggerToolTip(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     QModelIndex index = model->watchIndex(item); | 
					
						
							|  |  |  |     showDebuggerToolTip(m_toolTipPos, model, index, m_toolTipExpression); | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::setToolTipExpression(const QPoint &mousePos, | 
					
						
							|  |  |  |     TextEditor::ITextEditor *editor, int cursorPos) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     if (status() != DebuggerInferiorStopped || !isCppEditor(editor)) { | 
					
						
							| 
									
										
										
										
											2009-05-14 14:29:37 +02:00
										 |  |  |         //qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED/Non Cpp editor";
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (theDebuggerBoolSetting(DebugDebuggingHelpers)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // minimize interference
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-14 14:29:37 +02:00
										 |  |  |     m_toolTipPos = mousePos; | 
					
						
							|  |  |  |     int line, column; | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     QString exp = cppExpressionAt(editor, cursorPos, &line, &column); | 
					
						
							|  |  |  |     m_toolTipExpression = exp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // FIXME: enable caching
 | 
					
						
							|  |  |  |     //if (showToolTip())
 | 
					
						
							|  |  |  |     //    return;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (exp.isEmpty() || exp.startsWith(_c('#')))  { | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |         //QToolTip::hideText();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!hasLetterOrNumber(exp)) { | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |         //QToolTip::showText(m_toolTipPos,
 | 
					
						
							|  |  |  |         //    tr("'%1' contains no identifier").arg(exp));
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (isKeyWord(exp)) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (exp.startsWith(_c('"')) && exp.endsWith(_c('"')))  { | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |         //QToolTip::showText(m_toolTipPos, tr("String literal %1").arg(exp));
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (exp.startsWith(__("++")) || exp.startsWith(__("--"))) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         exp = exp.mid(2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (exp.endsWith(__("++")) || exp.endsWith(__("--"))) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         exp = exp.mid(2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (exp.startsWith(_c('<')) || exp.startsWith(_c('['))) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (hasSideEffects(exp)) { | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |         //QToolTip::showText(m_toolTipPos,
 | 
					
						
							|  |  |  |         //    tr("Cowardly refusing to evaluate expression '%1' "
 | 
					
						
							|  |  |  |         //       "with potential side effects").arg(exp));
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Gdb crashes when creating a variable object with the name
 | 
					
						
							|  |  |  |     // of the type of 'this'
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |     for (int i = 0; i != m_currentLocals.childCount(); ++i) { | 
					
						
							|  |  |  |         if (m_currentLocals.childAt(i).exp == "this") { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |             qDebug() << "THIS IN ROW" << i; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             if (m_currentLocals.childAt(i).type.startsWith(exp)) { | 
					
						
							|  |  |  |                 QToolTip::showText(m_toolTipPos, | 
					
						
							| 
									
										
										
										
											2009-04-08 12:11:30 +02:00
										 |  |  |                     tr("%1: type of current 'this'").arg(exp)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                 qDebug() << " TOOLTIP CRASH SUPPRESSED"; | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     WatchData toolTip; | 
					
						
							|  |  |  |     toolTip.exp = exp; | 
					
						
							|  |  |  |     toolTip.name = exp; | 
					
						
							|  |  |  |     toolTip.iname = tooltipINameForExpression(exp); | 
					
						
							|  |  |  |     qq->watchHandler()->removeData(toolTip.iname); | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     qq->watchHandler()->insertData(toolTip); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Watch specific stuff
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  | //: Variable
 | 
					
						
							|  |  |  | static const QString strNotInScope = | 
					
						
							| 
									
										
										
										
											2009-07-15 16:50:49 +02:00
										 |  |  |         QCoreApplication::translate("Debugger::Internal::GdbEngine", "<not in scope>"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | static void setWatchDataValue(WatchData &data, const GdbMi &mi, | 
					
						
							|  |  |  |     int encoding = 0) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-07 17:35:45 +02:00
										 |  |  |     if (mi.isValid()) | 
					
						
							|  |  |  |         data.setValue(decodeData(mi.data(), encoding)); | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2009-04-02 10:54:22 +02:00
										 |  |  |         data.setValueNeeded(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void setWatchDataEditValue(WatchData &data, const GdbMi &mi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (mi.isValid()) | 
					
						
							|  |  |  |         data.editvalue = mi.data(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-29 16:24:46 +02:00
										 |  |  | static void setWatchDataValueToolTip(WatchData &data, const GdbMi &mi, | 
					
						
							|  |  |  |         int encoding = 0) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (mi.isValid()) | 
					
						
							| 
									
										
										
										
											2009-05-29 16:24:46 +02:00
										 |  |  |         data.setValueToolTip(decodeData(mi.data(), encoding)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void setWatchDataChildCount(WatchData &data, const GdbMi &mi) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |     if (mi.isValid()) | 
					
						
							|  |  |  |         data.setHasChildren(mi.data().toInt() > 0); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  | static void setWatchDataValueEnabled(WatchData &data, const GdbMi &mi) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (mi.data() == "true") | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |         data.valueEnabled = true; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     else if (mi.data() == "false") | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |         data.valueEnabled = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void setWatchDataValueEditable(WatchData &data, const GdbMi &mi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (mi.data() == "true") | 
					
						
							|  |  |  |         data.valueEditable = true; | 
					
						
							|  |  |  |     else if (mi.data() == "false") | 
					
						
							|  |  |  |         data.valueEditable = false; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void setWatchDataExpression(WatchData &data, const GdbMi &mi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (mi.isValid()) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.exp = _('(' + mi.data() + ')'); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void setWatchDataAddress(WatchData &data, const GdbMi &mi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (mi.isValid()) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.addr = _(mi.data()); | 
					
						
							| 
									
										
										
										
											2009-06-03 12:46:55 +02:00
										 |  |  |         if (data.exp.isEmpty() && !data.addr.startsWith(_("$"))) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.exp = _("(*(") + gdbQuoteTypes(data.type) + _("*)") + data.addr + _c(')'); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-11 15:09:33 +01:00
										 |  |  | static void setWatchDataSAddress(WatchData &data, const GdbMi &mi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (mi.isValid()) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.saddr = _(mi.data()); | 
					
						
							| 
									
										
										
										
											2009-03-11 15:09:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::setUseDebuggingHelpers(const QVariant &on) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-30 13:31:41 +02:00
										 |  |  |     //qDebug() << "SWITCHING ON/OFF DUMPER DEBUGGING:" << on;
 | 
					
						
							| 
									
										
										
										
											2009-01-27 15:53:50 +01:00
										 |  |  |     // FIXME: a bit too harsh, but otherwise the treeview sometimes look funny
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //m_expandedINames.clear();
 | 
					
						
							| 
									
										
										
										
											2009-07-13 17:35:17 +02:00
										 |  |  |     Q_UNUSED(on) | 
					
						
							| 
									
										
										
										
											2009-02-18 13:50:55 +01:00
										 |  |  |     setTokenBarrier(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     updateLocals(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | bool GdbEngine::hasDebuggingHelperForType(const QString &type) const | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (!theDebuggerBoolSetting(UseDebuggingHelpers)) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |     if (!startModeAllowsDumpers()) { | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |         // "call" is not possible in gdb when looking at core files
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         return type == __("QString") || type.endsWith(__("::QString")) | 
					
						
							|  |  |  |             || type == __("QStringList") || type.endsWith(__("::QStringList")); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (theDebuggerBoolSetting(DebugDebuggingHelpers) | 
					
						
							|  |  |  |             && qq->stackHandler()->isDebuggingDebuggingHelpers()) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2009-03-19 09:32:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (m_debuggingHelperState != DebuggingHelperAvailable) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2008-12-18 10:11:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // simple types
 | 
					
						
							| 
									
										
										
										
											2009-04-29 14:15:09 +02:00
										 |  |  |     return m_dumperHelper.type(type) != QtDumperHelper::UnknownType; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-15 10:29:19 +02:00
										 |  |  | static inline QString msgRetrievingWatchData(int pending) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return GdbEngine::tr("Retrieving data for watch view (%n requests pending)...", 0, pending); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::runDirectDebuggingHelper(const WatchData &data, bool dumpChildren) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-13 17:35:17 +02:00
										 |  |  |     Q_UNUSED(dumpChildren) | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |     QString type = data.type; | 
					
						
							|  |  |  |     QString cmd; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (type == __("QString") || type.endsWith(__("::QString"))) | 
					
						
							|  |  |  |         cmd = _("qdumpqstring (&") + data.exp + _c(')'); | 
					
						
							|  |  |  |     else if (type == __("QStringList") || type.endsWith(__("::QStringList"))) | 
					
						
							|  |  |  |         cmd = _("qdumpqstringlist (&") + data.exp + _c(')'); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QVariant var; | 
					
						
							|  |  |  |     var.setValue(data); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(cmd, WatchUpdate, CB(handleDebuggingHelperValue3), var); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(msgRetrievingWatchData(m_pendingRequests + 1), 10000); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::runDebuggingHelper(const WatchData &data0, bool dumpChildren) | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |     if (!startModeAllowsDumpers()) { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         runDirectDebuggingHelper(data0, dumpChildren); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     WatchData data = data0; | 
					
						
							| 
									
										
										
										
											2009-04-29 14:15:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 13:51:05 +02:00
										 |  |  |     // Avoid endless loops created by faulty dumpers
 | 
					
						
							| 
									
										
										
										
											2009-08-28 09:44:11 +02:00
										 |  |  |     QString processedName = QString(_("%1-%2").arg(dumpChildren).arg(data.iname)); | 
					
						
							|  |  |  |     if (m_processedNames.contains(processedName)) { | 
					
						
							| 
									
										
										
										
											2009-08-20 13:51:05 +02:00
										 |  |  |         emit gdbInputAvailable(LogStatus, | 
					
						
							|  |  |  |             _("<Breaking endless loop for %1>").arg(data.iname)); | 
					
						
							|  |  |  |         data.setAllUnneeded(); | 
					
						
							|  |  |  |         data.setValue(_("<unavailable>")); | 
					
						
							|  |  |  |         data.setHasChildren(false); | 
					
						
							|  |  |  |         insertData(data); | 
					
						
							|  |  |  |         return;  | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-08-28 09:44:11 +02:00
										 |  |  |     m_processedNames.insert(processedName); | 
					
						
							| 
									
										
										
										
											2009-08-20 13:51:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-29 14:15:09 +02:00
										 |  |  |     QByteArray params; | 
					
						
							|  |  |  |     QStringList extraArgs; | 
					
						
							|  |  |  |     const QtDumperHelper::TypeData td = m_dumperHelper.typeData(data0.type); | 
					
						
							|  |  |  |     m_dumperHelper.evaluationParameters(data, td, QtDumperHelper::GdbDebugger, ¶ms, &extraArgs); | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //int protocol = (data.iname.startsWith("watch") && data.type == "QImage") ? 3 : 2;
 | 
					
						
							|  |  |  |     //int protocol = data.iname.startsWith("watch") ? 3 : 2;
 | 
					
						
							| 
									
										
										
										
											2009-04-29 14:15:09 +02:00
										 |  |  |     const int protocol = 2; | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  |     //int protocol = isDisplayedIName(data.iname) ? 3 : 2;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString addr; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (data.addr.startsWith(__("0x"))) | 
					
						
							|  |  |  |         addr = _("(void*)") + data.addr; | 
					
						
							| 
									
										
										
										
											2009-06-03 12:46:55 +02:00
										 |  |  |     else if (data.exp.isEmpty()) // happens e.g. for QAbstractItem
 | 
					
						
							|  |  |  |         addr = _("0"); | 
					
						
							| 
									
										
										
										
											2009-04-29 17:46:37 +02:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         addr = _("&(") + data.exp + _c(')'); | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     sendWatchParameters(params); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-29 14:15:09 +02:00
										 |  |  |     QString cmd; | 
					
						
							|  |  |  |     QTextStream(&cmd) << "call " << "(void*)qDumpObjectData440(" << | 
					
						
							|  |  |  |             protocol << ',' << "%1+1"                // placeholder for token
 | 
					
						
							|  |  |  |             <<',' <<  addr << ',' << (dumpChildren ? "1" : "0") | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             << ',' << extraArgs.join(QString(_c(','))) <<  ')'; | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QVariant var; | 
					
						
							|  |  |  |     var.setValue(data); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(cmd, WatchUpdate | EmbedToken, CB(handleDebuggingHelperValue1), var); | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(msgRetrievingWatchData(m_pendingRequests + 1), 10000); | 
					
						
							| 
									
										
										
										
											2009-03-04 10:11:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // retrieve response
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("p (char*)&qDumpOutBuffer"), WatchUpdate, | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |         CB(handleDebuggingHelperValue2), var); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::createGdbVariable(const WatchData &data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-28 15:36:52 +02:00
										 |  |  |     if (data.iname == _("local.flist.0")) { | 
					
						
							|  |  |  |         int i = 1; | 
					
						
							|  |  |  |         Q_UNUSED(i); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-var-delete \"%1\"").arg(data.iname), WatchUpdate); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QString exp = data.exp; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (exp.isEmpty() && data.addr.startsWith(__("0x"))) | 
					
						
							|  |  |  |         exp = _("*(") + gdbQuoteTypes(data.type) + _("*)") + data.addr; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QVariant val = QVariant::fromValue<WatchData>(data); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-var-create \"%1\" * \"%2\"").arg(data.iname).arg(exp), | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |         WatchUpdate, CB(handleVarCreate), val); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::updateSubItem(const WatchData &data0) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     WatchData data = data0; | 
					
						
							|  |  |  |     #if DEBUG_SUBITEM
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     qDebug() << "UPDATE SUBITEM:" << data.toString(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(data.isValid(), return); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // in any case we need the type first
 | 
					
						
							|  |  |  |     if (data.isTypeNeeded()) { | 
					
						
							|  |  |  |         // This should only happen if we don't have a variable yet.
 | 
					
						
							|  |  |  |         // Let's play safe, though.
 | 
					
						
							|  |  |  |         if (!data.variable.isEmpty()) { | 
					
						
							|  |  |  |             // Update: It does so for out-of-scope watchers.
 | 
					
						
							|  |  |  |             #if 1
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |             qDebug() << "FIXME: GdbEngine::updateSubItem:" | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                  << data.toString() << "should not happen"; | 
					
						
							|  |  |  |             #else
 | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  |             data.setType(strNotInScope); | 
					
						
							|  |  |  |             data.setValue(strNotInScope); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |             data.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             insertData(data); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |             #endif
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         // The WatchVarCreate handler will receive type information
 | 
					
						
							|  |  |  |         // and re-insert a WatchData item with correct type, so
 | 
					
						
							|  |  |  |         // we will not re-enter this bit.
 | 
					
						
							|  |  |  |         // FIXME: Concurrency issues?
 | 
					
						
							|  |  |  |         createGdbVariable(data); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // we should have a type now. this is relied upon further below
 | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(!data.type.isEmpty(), return); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // a common case that can be easily solved
 | 
					
						
							|  |  |  |     if (data.isChildrenNeeded() && isPointerType(data.type) | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         && !hasDebuggingHelperForType(data.type)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // We sometimes know what kind of children pointers have
 | 
					
						
							|  |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "IT'S A POINTER"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  | #if 1
 | 
					
						
							|  |  |  |         data.setChildrenUnneeded(); | 
					
						
							|  |  |  |         insertData(data); | 
					
						
							| 
									
										
										
										
											2009-07-23 11:18:21 +02:00
										 |  |  |         WatchData data1; | 
					
						
							|  |  |  |         data1.iname = data.iname + QLatin1String(".*"); | 
					
						
							|  |  |  |         data1.name = QLatin1Char('*') + data.name; | 
					
						
							|  |  |  |         data1.exp = QLatin1String("(*(") + data.exp + QLatin1String("))"); | 
					
						
							|  |  |  |         data1.type = stripPointerType(data.type); | 
					
						
							|  |  |  |         data1.setValueNeeded(); | 
					
						
							|  |  |  |         insertData(data1); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #else
 | 
					
						
							|  |  |  |         // Try automatic dereferentiation
 | 
					
						
							| 
									
										
										
										
											2009-07-23 11:18:21 +02:00
										 |  |  |         data.exp = _("*(") + data.exp + _(")"); | 
					
						
							|  |  |  |         data.type = data.type + _("."); // FIXME: fragile HACK to avoid recursion
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         insertData(data); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (data.isValueNeeded() && hasDebuggingHelperForType(data.type)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: CUSTOMVALUE"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         runDebuggingHelper(data, qq->watchHandler()->isExpandedIName(data.iname)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |     if (data.isValueNeeded() && data.exp.isEmpty()) { | 
					
						
							|  |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: NO EXPRESSION?"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  |         data.setError("<no expression given>"); | 
					
						
							|  |  |  |         insertData(data); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (data.isValueNeeded() && data.variable.isEmpty()) { | 
					
						
							|  |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR VALUE"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  |         createGdbVariable(data); | 
					
						
							|  |  |  |         // the WatchVarCreate handler will re-insert a WatchData
 | 
					
						
							|  |  |  |         // item, with valueNeeded() set.
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (data.isValueNeeded()) { | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |         QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: VALUE"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString cmd = _("-var-evaluate-expression \"") + data.iname + _c('"'); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(cmd, WatchUpdate, CB(handleEvaluateExpression), | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             QVariant::fromValue(data)); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (data.isChildrenNeeded() && hasDebuggingHelperForType(data.type)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         runDebuggingHelper(data, true); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (data.isChildrenNeeded() && data.variable.isEmpty()) { | 
					
						
							|  |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR CHILDREN"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  |         createGdbVariable(data); | 
					
						
							|  |  |  |         // the WatchVarCreate handler will re-insert a WatchData
 | 
					
						
							|  |  |  |         // item, with childrenNeeded() set.
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (data.isChildrenNeeded()) { | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |         QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString cmd = _("-var-list-children --all-values \"") + data.variable + _c('"'); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(cmd, WatchUpdate, CB(handleVarListChildren), QVariant::fromValue(data)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |     if (data.isHasChildrenNeeded() && hasDebuggingHelperForType(data.type)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         runDebuggingHelper(data, qq->watchHandler()->isExpandedIName(data.iname)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |     if (data.isHasChildrenNeeded() && data.variable.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         #if DEBUG_SUBITEM
 | 
					
						
							|  |  |  |         qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR CHILDCOUNT"; | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  |         createGdbVariable(data); | 
					
						
							|  |  |  |         // the WatchVarCreate handler will re-insert a WatchData
 | 
					
						
							|  |  |  |         // item, with childrenNeeded() set.
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |     if (data.isHasChildrenNeeded()) { | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |         QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString cmd = _("-var-list-children --all-values \"") + data.variable + _c('"'); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(cmd, Discardable, CB(handleVarListChildren), QVariant::fromValue(data)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     qDebug() << "FIXME: UPDATE SUBITEM:" << data.toString(); | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(false, return); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  | void GdbEngine::updateWatchData(const WatchData &data) | 
					
						
							| 
									
										
										
										
											2009-08-28 17:31:45 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     // Bump requests to avoid model rebuilding during the nested
 | 
					
						
							|  |  |  |     // updateWatchModel runs.
 | 
					
						
							|  |  |  |     ++m_pendingRequests; | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  | #if 1
 | 
					
						
							|  |  |  |     QMetaObject::invokeMethod(this, "updateWatchDataHelper", | 
					
						
							|  |  |  |         Qt::QueuedConnection, Q_ARG(WatchData, data)); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |     updateWatchDataHelper(data); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-08-28 17:31:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  | void GdbEngine::updateWatchDataHelper(const WatchData &data) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |     //m_pendingRequests = 0;
 | 
					
						
							|  |  |  |     PENDING_DEBUG("UPDATE WATCH DATA"); | 
					
						
							|  |  |  |     #if DEBUG_PENDING
 | 
					
						
							|  |  |  |     //qDebug() << "##############################################";
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |     qDebug() << "UPDATE MODEL, FOUND INCOMPLETE:"; | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |     //qDebug() << data.toString();
 | 
					
						
							|  |  |  |     #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updateSubItem(data); | 
					
						
							|  |  |  |     //PENDING_DEBUG("INTERNAL TRIGGERING UPDATE WATCH MODEL");
 | 
					
						
							|  |  |  |     --m_pendingRequests; | 
					
						
							|  |  |  |     if (m_pendingRequests <= 0) | 
					
						
							|  |  |  |         rebuildModel(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  | void GdbEngine::rebuildModel() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |     static int count = 0; | 
					
						
							|  |  |  |     ++count; | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |     m_processedNames.clear(); | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |     PENDING_DEBUG("REBUILDING MODEL" << count); | 
					
						
							|  |  |  |     emit gdbInputAvailable(LogStatus, _("<Rebuild Watchmodel %1>").arg(count)); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     showStatusMessage(tr("Finished retrieving data."), 400); | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     qq->watchHandler()->endCycle(); | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     showToolTip(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  | static inline double getDumperVersion(const GdbMi &contents) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const GdbMi dumperVersionG = contents.findChild("dumperversion"); | 
					
						
							|  |  |  |     if (dumperVersionG.type() != GdbMi::Invalid) { | 
					
						
							|  |  |  |         bool ok; | 
					
						
							|  |  |  |         const double v = QString::fromAscii(dumperVersionG.data()).toDouble(&ok); | 
					
						
							|  |  |  |         if (ok) | 
					
						
							|  |  |  |             return v; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 1.0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void parseSizeCache(const GdbMi &contents, QtDumperHelper *dumperHelper) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const GdbMi sizesList = contents.findChild("sizes"); | 
					
						
							|  |  |  |     if (sizesList.type() == GdbMi::Invalid) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     foreach(const GdbMi &c, sizesList.children()) { | 
					
						
							|  |  |  |         const QString name = QString::fromAscii(c.name()); | 
					
						
							|  |  |  |         if (const int size = QString::fromAscii(c.data()).toInt()) | 
					
						
							|  |  |  |             dumperHelper->addSize(name, size); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleQueryDebuggingHelper(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |     const double dumperVersionRequired = 1.0; | 
					
						
							| 
									
										
										
										
											2009-03-19 12:53:58 +01:00
										 |  |  |     //qDebug() << "DATA DUMPER TRIAL:" << record.toString();
 | 
					
						
							| 
									
										
										
										
											2009-01-21 11:12:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     GdbMi contents; | 
					
						
							| 
									
										
										
										
											2009-07-01 12:49:41 +02:00
										 |  |  |     QTC_ASSERT(parseConsoleStream(record, &contents), /**/); | 
					
						
							| 
									
										
										
										
											2009-09-18 16:55:17 +02:00
										 |  |  |     const bool ok = m_dumperHelper.parseQuery(contents, QtDumperHelper::GdbDebugger) && m_dumperHelper.typeCount(); | 
					
						
							|  |  |  |     if (ok) { | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |         // Get version and sizes from dumpers. Expression cache
 | 
					
						
							|  |  |  |         // currently causes errors.
 | 
					
						
							|  |  |  |         const double dumperVersion = getDumperVersion(contents); | 
					
						
							|  |  |  |         if (dumperVersion < dumperVersionRequired) { | 
					
						
							|  |  |  |             qq->showQtDumperLibraryWarning(QtDumperHelper::msgDumperOutdated(dumperVersionRequired, dumperVersion)); | 
					
						
							|  |  |  |             m_debuggingHelperState = DebuggingHelperUnavailable; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         parseSizeCache(contents, &m_dumperHelper); | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         m_debuggingHelperState = DebuggingHelperAvailable; | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |         const QString successMsg = tr("Dumper version %1, %n custom dumpers found.", 0, m_dumperHelper.typeCount()).arg(dumperVersion); | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         showStatusMessage(successMsg); | 
					
						
							| 
									
										
										
										
											2009-09-18 16:55:17 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |             if (!m_dumperInjectionLoad) // Retry if thread has not terminated yet.
 | 
					
						
							|  |  |  |             m_debuggingHelperState = DebuggingHelperUnavailable; | 
					
						
							|  |  |  |         showStatusMessage(tr("Debugging helpers not found.")); | 
					
						
							| 
									
										
										
										
											2009-01-21 11:12:12 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-04-29 16:52:14 +02:00
										 |  |  |     //qDebug() << m_dumperHelper.toString(true);
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << m_availableSimpleDebuggingHelpers << "DATA DUMPERS AVAILABLE";
 | 
					
						
							| 
									
										
										
										
											2009-01-21 11:12:12 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  | static inline QString arrayFillCommand(const char *array, const QByteArray ¶ms) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     char buf[50]; | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     sprintf(buf, "set {char[%d]} &%s = {", params.size(), array); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QByteArray encoded; | 
					
						
							|  |  |  |     encoded.append(buf); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     const int size = params.size(); | 
					
						
							|  |  |  |     for (int i = 0; i != size; ++i) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         sprintf(buf, "%d,", int(params[i])); | 
					
						
							|  |  |  |         encoded.append(buf); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     encoded[encoded.size() - 1] = '}'; | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     return _(encoded); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::sendWatchParameters(const QByteArray ¶ms0) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QByteArray params = params0; | 
					
						
							|  |  |  |     params.append('\0'); | 
					
						
							|  |  |  |     const QString inBufferCmd = arrayFillCommand("qDumpInBuffer", params); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-02 15:44:03 +02:00
										 |  |  |     params.replace('\0','!'); | 
					
						
							| 
									
										
										
										
											2009-06-19 12:04:21 +02:00
										 |  |  |     emit gdbInputAvailable(LogMisc, QString::fromUtf8(params)); | 
					
						
							| 
									
										
										
										
											2009-06-02 15:44:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     params.clear(); | 
					
						
							|  |  |  |     params.append('\0'); | 
					
						
							|  |  |  |     const QString outBufferCmd = arrayFillCommand("qDumpOutBuffer", params); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     postCommand(inBufferCmd); | 
					
						
							|  |  |  |     postCommand(outBufferCmd); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleVarAssign(const GdbResultRecord &, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // everything might have changed, force re-evaluation
 | 
					
						
							|  |  |  |     // FIXME: Speed this up by re-using variables and only
 | 
					
						
							|  |  |  |     // marking values as 'unknown'
 | 
					
						
							| 
									
										
										
										
											2009-02-18 13:50:55 +01:00
										 |  |  |     setTokenBarrier(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     updateLocals(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-12 11:21:44 +02:00
										 |  |  | // Find the "type" and "displayedtype" children of root and set up type.
 | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  | void GdbEngine::setWatchDataType(WatchData &data, const GdbMi &item) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |     if (item.isValid()) { | 
					
						
							|  |  |  |         const QString miData = _(item.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         if (!data.framekey.isEmpty()) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             m_varToType[data.framekey] = miData; | 
					
						
							|  |  |  |         data.setType(miData); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else if (data.type.isEmpty()) { | 
					
						
							|  |  |  |         data.setTypeNeeded(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::setWatchDataDisplayedType(WatchData &data, const GdbMi &item) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (item.isValid()) | 
					
						
							|  |  |  |         data.displayedType = _(item.data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleVarCreate(const GdbResultRecord &record, | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     WatchData data = cookie.value<WatchData>(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     // happens e.g. when we already issued a var-evaluate command
 | 
					
						
							|  |  |  |     if (!data.isValid()) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "HANDLE VARIABLE CREATION:" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         data.variable = data.iname; | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |         setWatchDataType(data, record.data.findChild("type")); | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         if (hasDebuggingHelperForType(data.type)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // we do not trust gdb if we have a custom dumper
 | 
					
						
							|  |  |  |             if (record.data.findChild("children").isValid()) | 
					
						
							|  |  |  |                 data.setChildrenUnneeded(); | 
					
						
							|  |  |  |             else if (qq->watchHandler()->isExpandedIName(data.iname)) | 
					
						
							|  |  |  |                 data.setChildrenNeeded(); | 
					
						
							|  |  |  |             insertData(data); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             if (record.data.findChild("children").isValid()) | 
					
						
							|  |  |  |                 data.setChildrenUnneeded(); | 
					
						
							|  |  |  |             else if (qq->watchHandler()->isExpandedIName(data.iname)) | 
					
						
							|  |  |  |                 data.setChildrenNeeded(); | 
					
						
							|  |  |  |             setWatchDataChildCount(data, record.data.findChild("numchild")); | 
					
						
							|  |  |  |             //if (data.isValueNeeded() && data.childCount > 0)
 | 
					
						
							| 
									
										
										
										
											2009-04-02 10:54:22 +02:00
										 |  |  |             //    data.setValue(QString());
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             insertData(data); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.setError(QString::fromLocal8Bit(record.data.findChild("msg").data())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         if (data.isWatcher()) { | 
					
						
							|  |  |  |             data.value = strNotInScope; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.type = _(" "); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             data.setAllUnneeded(); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |             data.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |             data.valueEnabled = false; | 
					
						
							|  |  |  |             data.valueEditable = false; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             insertData(data); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleEvaluateExpression(const GdbResultRecord &record, | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     WatchData data = cookie.value<WatchData>(); | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(data.isValid(), qDebug() << "HUH?"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         //if (col == 0)
 | 
					
						
							|  |  |  |         //    data.name = record.data.findChild("value").data();
 | 
					
						
							|  |  |  |         //else
 | 
					
						
							|  |  |  |             setWatchDataValue(data, record.data.findChild("value")); | 
					
						
							|  |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.setError(QString::fromLocal8Bit(record.data.findChild("msg").data())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "HANDLE EVALUATE EXPRESSION:" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     insertData(data); | 
					
						
							|  |  |  |     //updateWatchModel2();
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleDebuggingHelperSetup(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "CUSTOM SETUP RESULT:" << record.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString msg = QString::fromLocal8Bit(record.data.findChild("msg").data()); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "CUSTOM DUMPER SETUP ERROR MESSAGE:" << msg;
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         showStatusMessage(tr("Custom dumper setup: %1").arg(msg), 10000); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::handleDebuggingHelperValue1(const GdbResultRecord &record, | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     WatchData data = cookie.value<WatchData>(); | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(data.isValid(), return); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         // ignore this case, data will follow
 | 
					
						
							|  |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString msg = QString::fromLocal8Bit(record.data.findChild("msg").data()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #ifdef QT_DEBUG
 | 
					
						
							| 
									
										
										
										
											2009-01-21 11:41:32 +01:00
										 |  |  |         // Make debugging of dumpers easier
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         if (theDebuggerBoolSetting(DebugDebuggingHelpers) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 && msg.startsWith(__("The program being debugged stopped while")) | 
					
						
							|  |  |  |                 && msg.contains(__("qDumpObjectData440"))) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // Fake full stop
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |             postCommand(_("p 0"), CB(handleStop2));  // dummy
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record, | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     WatchData data = cookie.value<WatchData>(); | 
					
						
							| 
									
										
										
										
											2008-12-09 12:08:56 +01:00
										 |  |  |     QTC_ASSERT(data.isValid(), return); | 
					
						
							| 
									
										
										
										
											2009-07-01 12:49:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "CUSTOM VALUE RESULT:" << record.toString();
 | 
					
						
							|  |  |  |     //qDebug() << "FOR DATA:" << data.toString() << record.resultClass;
 | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |     if (record.resultClass != GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         qDebug() << "STRANGE CUSTOM DUMPER RESULT DATA:" << data.toString(); | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-01-21 11:12:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |     GdbMi contents; | 
					
						
							| 
									
										
										
										
											2009-07-01 12:49:41 +02:00
										 |  |  |     if (!parseConsoleStream(record, &contents)) { | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |         data.setError(strNotInScope); | 
					
						
							|  |  |  |         insertData(data); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |     setWatchDataType(data, record.data.findChild("type")); | 
					
						
							|  |  |  |     setWatchDataDisplayedType(data, record.data.findChild("displaytype")); | 
					
						
							| 
									
										
										
										
											2009-08-28 15:36:52 +02:00
										 |  |  |     QList<WatchData> list; | 
					
						
							|  |  |  |     handleChildren(data, contents, &list); | 
					
						
							|  |  |  |     //for (int i = 0; i != list.size(); ++i)
 | 
					
						
							|  |  |  |     //    qDebug() << "READ: " << list.at(i).toString();
 | 
					
						
							|  |  |  |     qq->watchHandler()->insertBulkData(list); | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-28 15:36:52 +02:00
										 |  |  | void GdbEngine::handleChildren(const WatchData &data0, const GdbMi &item, | 
					
						
							|  |  |  |     QList<WatchData> *list) | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-28 15:36:52 +02:00
										 |  |  |     //qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
 | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |     WatchData data = data0; | 
					
						
							|  |  |  |     if (!qq->watchHandler()->isExpandedIName(data.iname)) | 
					
						
							|  |  |  |         data.setChildrenUnneeded(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     GdbMi children = item.findChild("children"); | 
					
						
							|  |  |  |     if (children.isValid() || !qq->watchHandler()->isExpandedIName(data.iname)) | 
					
						
							|  |  |  |         data.setChildrenUnneeded(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |     if (qq->watchHandler()->isDisplayedIName(data.iname)) { | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |         GdbMi editvalue = item.findChild("editvalue"); | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |         if (editvalue.isValid()) { | 
					
						
							|  |  |  |             setWatchDataEditValue(data, editvalue); | 
					
						
							|  |  |  |             qq->watchHandler()->showEditValue(data); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |     setWatchDataType(data, item.findChild("type")); | 
					
						
							|  |  |  |     setWatchDataEditValue(data, item.findChild("editvalue")); | 
					
						
							|  |  |  |     setWatchDataExpression(data, item.findChild("exp")); | 
					
						
							|  |  |  |     setWatchDataChildCount(data, item.findChild("numchild")); | 
					
						
							|  |  |  |     setWatchDataValue(data, item.findChild("value"), | 
					
						
							|  |  |  |         item.findChild("valueencoded").data().toInt()); | 
					
						
							|  |  |  |     setWatchDataAddress(data, item.findChild("addr")); | 
					
						
							|  |  |  |     setWatchDataSAddress(data, item.findChild("saddr")); | 
					
						
							|  |  |  |     setWatchDataValueToolTip(data, item.findChild("valuetooltip"), | 
					
						
							|  |  |  |         item.findChild("valuetooltipencoded").data().toInt()); | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |     setWatchDataValueEnabled(data, item.findChild("valueenabled")); | 
					
						
							|  |  |  |     setWatchDataValueEditable(data, item.findChild("valueeditable")); | 
					
						
							| 
									
										
										
										
											2009-08-28 15:36:52 +02:00
										 |  |  |     //qDebug() << "HANDLE CHILDREN: " << data.toString();
 | 
					
						
							|  |  |  |     list->append(data); | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // try not to repeat data too often
 | 
					
						
							|  |  |  |     WatchData childtemplate; | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |     setWatchDataType(childtemplate, item.findChild("childtype")); | 
					
						
							|  |  |  |     setWatchDataChildCount(childtemplate, item.findChild("childnumchild")); | 
					
						
							| 
									
										
										
										
											2009-08-28 17:31:45 +02:00
										 |  |  |     //qDebug() << "CHILD TEMPLATE:" << childtemplate.toString();
 | 
					
						
							| 
									
										
										
										
											2009-07-13 12:28:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-10 13:40:17 +02:00
										 |  |  |     int i = 0; | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |     foreach (GdbMi child, children.children()) { | 
					
						
							| 
									
										
										
										
											2009-01-28 10:57:23 +01:00
										 |  |  |         WatchData data1 = childtemplate; | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |         GdbMi name = child.findChild("name"); | 
					
						
							| 
									
										
										
										
											2009-07-10 13:40:17 +02:00
										 |  |  |         if (name.isValid()) | 
					
						
							|  |  |  |             data1.name = _(name.data()); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             data1.name = QString::number(i); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data1.iname = data.iname + _c('.') + data1.name; | 
					
						
							| 
									
										
										
										
											2009-01-28 12:15:40 +01:00
										 |  |  |         if (!data1.name.isEmpty() && data1.name.at(0).isDigit()) | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data1.name = _c('[') + data1.name + _c(']'); | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |         QByteArray key = child.findChild("key").data(); | 
					
						
							| 
									
										
										
										
											2009-01-28 15:06:05 +01:00
										 |  |  |         if (!key.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2009-08-28 14:34:08 +02:00
										 |  |  |             int encoding = child.findChild("keyencoded").data().toInt(); | 
					
						
							| 
									
										
										
										
											2009-04-07 17:35:45 +02:00
										 |  |  |             QString skey = decodeData(key, encoding); | 
					
						
							|  |  |  |             if (skey.size() > 13) { | 
					
						
							|  |  |  |                 skey = skey.left(12); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |                 skey += _("..."); | 
					
						
							| 
									
										
										
										
											2009-01-28 16:55:09 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-04-07 17:35:45 +02:00
										 |  |  |             //data1.name += " (" + skey + ")";
 | 
					
						
							|  |  |  |             data1.name = skey; | 
					
						
							| 
									
										
										
										
											2009-01-28 15:06:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-08-28 15:36:52 +02:00
										 |  |  |         handleChildren(data1, child, list); | 
					
						
							| 
									
										
										
										
											2009-07-10 13:40:17 +02:00
										 |  |  |         ++i; | 
					
						
							| 
									
										
										
										
											2009-01-21 11:12:12 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::handleDebuggingHelperValue3(const GdbResultRecord &record, | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         WatchData data = cookie.value<WatchData>(); | 
					
						
							|  |  |  |         QByteArray out = record.data.findChild("consolestreamoutput").data(); | 
					
						
							|  |  |  |         while (out.endsWith(' ') || out.endsWith('\n')) | 
					
						
							|  |  |  |             out.chop(1); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |         QList<QByteArray> list = out.split(' '); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() << "RECEIVED" << record.toString() << "FOR" << data0.toString()
 | 
					
						
							|  |  |  |         //    <<  " STREAM:" << out;
 | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |         if (list.isEmpty()) { | 
					
						
							|  |  |  |             //: Value for variable
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |             data.setError(strNotInScope); | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |             data.setAllUnneeded(); | 
					
						
							|  |  |  |             insertData(data); | 
					
						
							|  |  |  |         } else if (data.type == __("QString") | 
					
						
							|  |  |  |                 || data.type.endsWith(__("::QString"))) { | 
					
						
							|  |  |  |             QList<QByteArray> list = out.split(' '); | 
					
						
							|  |  |  |             QString str; | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  |             int l = out.isEmpty() ? 0 : list.size(); | 
					
						
							|  |  |  |             for (int i = 0; i < l; ++i) | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |                  str.append(list.at(i).toInt()); | 
					
						
							|  |  |  |             data.setValue(_c('"') + str + _c('"')); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |             data.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |             data.setAllUnneeded(); | 
					
						
							|  |  |  |             insertData(data); | 
					
						
							|  |  |  |         } else if (data.type == __("QStringList") | 
					
						
							|  |  |  |                 || data.type.endsWith(__("::QStringList"))) { | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  |             if (out.isEmpty()) { | 
					
						
							|  |  |  |                 data.setValue(tr("<0 items>")); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |                 data.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  |                 data.setAllUnneeded(); | 
					
						
							|  |  |  |                 insertData(data); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 int l = list.size(); | 
					
						
							|  |  |  |                 //: In string list
 | 
					
						
							| 
									
										
										
										
											2009-05-15 10:29:19 +02:00
										 |  |  |                 data.setValue(tr("<%n items>", 0, l)); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |                 data.setHasChildren(!list.empty()); | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  |                 data.setAllUnneeded(); | 
					
						
							|  |  |  |                 insertData(data); | 
					
						
							|  |  |  |                 for (int i = 0; i < l; ++i) { | 
					
						
							|  |  |  |                     WatchData data1; | 
					
						
							|  |  |  |                     data1.name = _("[%1]").arg(i); | 
					
						
							|  |  |  |                     data1.type = data.type.left(data.type.size() - 4); | 
					
						
							|  |  |  |                     data1.iname = data.iname + _(".%1").arg(i); | 
					
						
							|  |  |  |                     data1.addr = _(list.at(i)); | 
					
						
							|  |  |  |                     data1.exp = _("((") + gdbQuoteTypes(data1.type) + _("*)") + data1.addr + _c(')'); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |                     data1.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2009-05-07 14:53:53 +02:00
										 |  |  |                     data1.setValueNeeded(); | 
					
						
							|  |  |  |                     QString cmd = _("qdumpqstring (") + data1.exp + _c(')'); | 
					
						
							|  |  |  |                     QVariant var; | 
					
						
							|  |  |  |                     var.setValue(data1); | 
					
						
							|  |  |  |                     postCommand(cmd, WatchUpdate, CB(handleDebuggingHelperValue3), var); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             //: Value for variable
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |             data.setError(strNotInScope); | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |             data.setAllUnneeded(); | 
					
						
							|  |  |  |             insertData(data); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							|  |  |  |         WatchData data = cookie.value<WatchData>(); | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |         data.setError(strNotInScope); | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |         data.setAllUnneeded(); | 
					
						
							|  |  |  |         insertData(data); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void GdbEngine::updateLocals() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |     // Asynchronous load of injected library, initialize in first stop
 | 
					
						
							| 
									
										
										
										
											2009-06-29 13:53:41 +02:00
										 |  |  |     if (m_dumperInjectionLoad && m_debuggingHelperState == DebuggingHelperLoadTried | 
					
						
							| 
									
										
										
										
											2009-09-14 09:46:34 +02:00
										 |  |  |             && m_dumperHelper.typeCount() == 0 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |             && inferiorPid() > 0) | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |         tryQueryDebuggingHelpers(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     m_pendingRequests = 0; | 
					
						
							| 
									
										
										
										
											2009-08-20 13:51:05 +02:00
										 |  |  |     m_processedNames.clear(); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:39:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     PENDING_DEBUG("\nRESET PENDING"); | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     //m_toolTipCache.clear();
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     m_toolTipExpression.clear(); | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     qq->watchHandler()->beginCycle(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QString level = QString::number(currentFrame()); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     // '2' is 'list with type and value'
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QString cmd = _("-stack-list-arguments 2 ") + level + _c(' ') + level; | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(cmd, WatchUpdate, CB(handleStackListArguments)); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     // '2' is 'list with type and value'
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-stack-list-locals 2"), WatchUpdate, | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |         CB(handleStackListLocals)); // stage 2/2
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleStackListArguments(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     // stage 1/2
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Linux:
 | 
					
						
							|  |  |  |     // 12^done,stack-args=
 | 
					
						
							|  |  |  |     //   [frame={level="0",args=[
 | 
					
						
							|  |  |  |     //     {name="argc",type="int",value="1"},
 | 
					
						
							|  |  |  |     //     {name="argv",type="char **",value="(char **) 0x7..."}]}]
 | 
					
						
							|  |  |  |     // Mac:
 | 
					
						
							|  |  |  |     // 78^done,stack-args=
 | 
					
						
							|  |  |  |     //    {frame={level="0",args={
 | 
					
						
							|  |  |  |     //      varobj=
 | 
					
						
							|  |  |  |     //        {exp="this",value="0x38a2fab0",name="var21",numchild="3",
 | 
					
						
							|  |  |  |     //             type="CurrentDocumentFind *  const",typecode="PTR",
 | 
					
						
							|  |  |  |     //             dynamic_type="",in_scope="true",block_start_addr="0x3938e946",
 | 
					
						
							|  |  |  |     //             block_end_addr="0x3938eb2d"},
 | 
					
						
							|  |  |  |     //      varobj=
 | 
					
						
							|  |  |  |     //         {exp="before",value="@0xbfffb9f8: {d = 0x3a7f2a70}",
 | 
					
						
							|  |  |  |     //              name="var22",numchild="1",type="const QString  ...} }}}
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // In both cases, iterating over the children of stack-args/frame/args
 | 
					
						
							|  |  |  |     // is ok.
 | 
					
						
							|  |  |  |     m_currentFunctionArgs.clear(); | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         const GdbMi list = record.data.findChild("stack-args"); | 
					
						
							|  |  |  |         const GdbMi frame = list.findChild("frame"); | 
					
						
							|  |  |  |         const GdbMi args = frame.findChild("args"); | 
					
						
							|  |  |  |         m_currentFunctionArgs = args.children(); | 
					
						
							|  |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							|  |  |  |         qDebug() << "FIXME: GdbEngine::handleStackListArguments: should not happen"; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  | void GdbEngine::handleStackListLocals(const GdbResultRecord &record, const QVariant &) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     // stage 2/2
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     // There could be shadowed variables
 | 
					
						
							|  |  |  |     QList<GdbMi> locals = record.data.findChild("locals").children(); | 
					
						
							|  |  |  |     locals += m_currentFunctionArgs; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     setLocals(locals); | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     qq->watchHandler()->updateWatchers(); | 
					
						
							| 
									
										
										
										
											2008-12-03 16:51:56 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  | void GdbEngine::setLocals(const QList<GdbMi> &locals) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     //qDebug() << m_varToType;
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     QMap<QByteArray, int> seen; | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |     QList<WatchData> list; | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |     foreach (const GdbMi &item, locals) { | 
					
						
							| 
									
										
										
										
											2009-02-16 18:56:20 +01:00
										 |  |  |         // Local variables of inlined code are reported as
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |         // 26^done,locals={varobj={exp="this",value="",name="var4",exp="this",
 | 
					
						
							|  |  |  |         // numchild="1",type="const QtSharedPointer::Basic<CPlusPlus::..."
 | 
					
						
							|  |  |  |         // We do not want these at all. Current hypotheses is that those
 | 
					
						
							|  |  |  |         // "spurious" locals have _two_ "exp" field. Try to filter them:
 | 
					
						
							|  |  |  |         #ifdef Q_OS_MAC
 | 
					
						
							|  |  |  |         int numExps = 0; | 
					
						
							|  |  |  |         foreach (const GdbMi &child, item.children()) | 
					
						
							|  |  |  |             numExps += int(child.name() == "exp"); | 
					
						
							|  |  |  |         if (numExps > 1) | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QByteArray name = item.findChild("exp").data(); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |         #else
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QByteArray name = item.findChild("name").data(); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |         #endif
 | 
					
						
							|  |  |  |         int n = seen.value(name); | 
					
						
							|  |  |  |         if (n) { | 
					
						
							|  |  |  |             seen[name] = n + 1; | 
					
						
							|  |  |  |             WatchData data; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString nam = _(name); | 
					
						
							|  |  |  |             data.iname = _("local.") + nam + QString::number(n + 1); | 
					
						
							| 
									
										
										
										
											2009-06-23 10:43:17 +02:00
										 |  |  |             //: Variable %1 is the variable name, %2 is a simple count
 | 
					
						
							| 
									
										
										
										
											2009-06-23 11:03:13 +02:00
										 |  |  |             data.name = tr("%1 <shadowed %2>").arg(nam).arg(n); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             setWatchDataValue(data, item.findChild("value")); | 
					
						
							| 
									
										
										
										
											2009-06-23 10:43:17 +02:00
										 |  |  |             //: Type of local variable or parameter shadowed by another 
 | 
					
						
							|  |  |  |             //variable of the same name in a nested block
 | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  |             data.setType(tr("<shadowed>")); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |             data.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |             list.append(data); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             seen[name] = 1; | 
					
						
							|  |  |  |             WatchData data; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             QString nam = _(name); | 
					
						
							|  |  |  |             data.iname = _("local.") + nam; | 
					
						
							|  |  |  |             data.name = nam; | 
					
						
							|  |  |  |             data.exp = nam; | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |             data.framekey = m_currentFrame + data.name; | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |             setWatchDataType(data, item.findChild("type")); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |             // set value only directly if it is simple enough, otherwise
 | 
					
						
							|  |  |  |             // pass through the insertData() machinery
 | 
					
						
							|  |  |  |             if (isIntOrFloatType(data.type) || isPointerType(data.type)) | 
					
						
							|  |  |  |                 setWatchDataValue(data, item.findChild("value")); | 
					
						
							| 
									
										
										
										
											2009-09-15 18:21:40 +02:00
										 |  |  |             if (isSymbianIntType(data.type)) { | 
					
						
							|  |  |  |                 setWatchDataValue(data, item.findChild("value")); | 
					
						
							|  |  |  |                 data.setHasChildren(false); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             // Let's be a bit more bold:
 | 
					
						
							|  |  |  |             //if (!hasDebuggingHelperForType(data.type)) {
 | 
					
						
							|  |  |  |             //    QByteArray value = item.findChild("value").data();
 | 
					
						
							|  |  |  |             //    if (!value.isEmpty() && value != "{...}")
 | 
					
						
							|  |  |  |             //        data.setValue(decodeData(value, 0));
 | 
					
						
							|  |  |  |             //}
 | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |             if (!qq->watchHandler()->isExpandedIName(data.iname)) | 
					
						
							|  |  |  |                 data.setChildrenUnneeded(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             if (isPointerType(data.type) || data.name == __("this")) | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |                 data.setHasChildren(true); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |             if (0 && m_varToType.contains(data.framekey)) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |                 qDebug() << "RE-USING" << m_varToType.value(data.framekey); | 
					
						
							| 
									
										
										
										
											2009-02-11 14:17:25 +01:00
										 |  |  |                 data.setType(m_varToType.value(data.framekey)); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |             list.append(data); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-08-31 09:14:04 +02:00
										 |  |  |     qq->watchHandler()->insertBulkData(list); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::insertData(const WatchData &data0) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //qDebug() << "INSERT DATA" << data0.toString();
 | 
					
						
							|  |  |  |     WatchData data = data0; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (data.value.startsWith(__("mi_cmd_var_create:"))) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         qDebug() << "BOGUS VALUE:" << data.toString(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-13 09:11:07 +02:00
										 |  |  |     qq->watchHandler()->insertData(data); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleVarListChildrenHelper(const GdbMi &item, | 
					
						
							|  |  |  |     const WatchData &parent) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() <<  "VAR_LIST_CHILDREN: APPENDEE" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QByteArray exp = item.findChild("exp").data(); | 
					
						
							|  |  |  |     QByteArray name = item.findChild("name").data(); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     if (isAccessSpecifier(_(exp))) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // suppress 'private'/'protected'/'public' level
 | 
					
						
							|  |  |  |         WatchData data; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.variable = _(name); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         data.iname = parent.iname; | 
					
						
							|  |  |  |         //data.iname = data.variable;
 | 
					
						
							|  |  |  |         data.exp = parent.exp; | 
					
						
							|  |  |  |         data.setTypeUnneeded(); | 
					
						
							|  |  |  |         data.setValueUnneeded(); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |         data.setHasChildrenUnneeded(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         data.setChildrenUnneeded(); | 
					
						
							|  |  |  |         //qDebug() << "DATA" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         QString cmd = _("-var-list-children --all-values \"") + data.variable + _c('"'); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         //iname += '.' + exp;
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(cmd, WatchUpdate, CB(handleVarListChildren), QVariant::fromValue(data)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else if (item.findChild("numchild").data() == "0") { | 
					
						
							|  |  |  |         // happens for structs without data, e.g. interfaces.
 | 
					
						
							|  |  |  |         WatchData data; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.name = _(exp); | 
					
						
							|  |  |  |         data.iname = parent.iname + _c('.') + data.name; | 
					
						
							|  |  |  |         data.variable = _(name); | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |         setWatchDataType(data, item.findChild("type")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         setWatchDataValue(data, item.findChild("value")); | 
					
						
							|  |  |  |         setWatchDataAddress(data, item.findChild("addr")); | 
					
						
							| 
									
										
										
										
											2009-03-11 15:09:33 +01:00
										 |  |  |         setWatchDataSAddress(data, item.findChild("saddr")); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |         data.setHasChildren(false); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         insertData(data); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |     } else if (parent.iname.endsWith(_c('.'))) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // Happens with anonymous unions
 | 
					
						
							|  |  |  |         WatchData data; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.iname = _(name); | 
					
						
							|  |  |  |         QString cmd = _("-var-list-children --all-values \"") + data.variable + _c('"'); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(cmd, WatchUpdate, CB(handleVarListChildren), QVariant::fromValue(data)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else if (exp == "staticMetaObject") { | 
					
						
							|  |  |  |         //    && item.findChild("type").data() == "const QMetaObject")
 | 
					
						
							|  |  |  |         // FIXME: Namespaces?
 | 
					
						
							| 
									
										
										
										
											2009-05-29 16:24:46 +02:00
										 |  |  |         // { do nothing }    FIXME: make configurable?
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         // special "clever" hack to avoid clutter in the GUI.
 | 
					
						
							|  |  |  |         // I am not sure this is a good idea...
 | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         WatchData data; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.iname = parent.iname + _c('.') + __(exp); | 
					
						
							|  |  |  |         data.variable = _(name); | 
					
						
							| 
									
										
										
										
											2009-08-25 17:32:14 +02:00
										 |  |  |         setWatchDataType(data, item.findChild("type")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         setWatchDataValue(data, item.findChild("value")); | 
					
						
							|  |  |  |         setWatchDataAddress(data, item.findChild("addr")); | 
					
						
							| 
									
										
										
										
											2009-03-11 15:09:33 +01:00
										 |  |  |         setWatchDataSAddress(data, item.findChild("saddr")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         setWatchDataChildCount(data, item.findChild("numchild")); | 
					
						
							|  |  |  |         if (!qq->watchHandler()->isExpandedIName(data.iname)) | 
					
						
							|  |  |  |             data.setChildrenUnneeded(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.name = _(exp); | 
					
						
							| 
									
										
										
										
											2009-04-30 22:29:42 +02:00
										 |  |  |         if (data.type == data.name) { | 
					
						
							|  |  |  |             if (isPointerType(parent.type)) { | 
					
						
							|  |  |  |                 data.exp = _("*(") + parent.exp + _c(')'); | 
					
						
							|  |  |  |                 data.name = _("*") + parent.name; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 // A type we derive from? gdb crashes when creating variables here
 | 
					
						
							|  |  |  |                 data.exp = parent.exp; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else if (exp.startsWith("*")) { | 
					
						
							|  |  |  |             // A pointer
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.exp = _("*(") + parent.exp + _c(')'); | 
					
						
							|  |  |  |         } else if (startsWithDigit(data.name)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // An array. No variables needed?
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.name = _c('[') + data.name + _c(']'); | 
					
						
							|  |  |  |             data.exp = parent.exp + _('[' + exp + ']'); | 
					
						
							|  |  |  |         } else if (0 && parent.name.endsWith(_c('.'))) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // Happens with anonymous unions
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.exp = parent.exp + data.name; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             //data.name = "<anonymous union>";
 | 
					
						
							|  |  |  |         } else if (exp.isEmpty()) { | 
					
						
							|  |  |  |             // Happens with anonymous unions
 | 
					
						
							|  |  |  |             data.exp = parent.exp; | 
					
						
							| 
									
										
										
										
											2009-04-17 21:11:52 +02:00
										 |  |  |             data.name = tr("<n/a>"); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.iname = parent.iname + _(".@"); | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  |             data.type = tr("<anonymous union>"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             // A structure. Hope there's nothing else...
 | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data.exp = parent.exp + _c('.') + data.name; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |         if (hasDebuggingHelperForType(data.type)) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             // we do not trust gdb if we have a custom dumper
 | 
					
						
							|  |  |  |             data.setValueNeeded(); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |             data.setHasChildrenNeeded(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //qDebug() <<  "VAR_LIST_CHILDREN: PARENT 3" << parent.toString();
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() <<  "VAR_LIST_CHILDREN: APPENDEE" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         insertData(data); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleVarListChildren(const GdbResultRecord &record, | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     const QVariant &cookie) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     //WatchResultCounter dummy(this, WatchVarListChildren);
 | 
					
						
							| 
									
										
										
										
											2009-05-04 18:30:22 +02:00
										 |  |  |     WatchData data = cookie.value<WatchData>(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     if (!data.isValid()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |         //qDebug() <<  "VAR_LIST_CHILDREN: PARENT" << data.toString();
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         GdbMi children = record.data.findChild("children"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         foreach (const GdbMi &child, children.children()) | 
					
						
							|  |  |  |             handleVarListChildrenHelper(child, data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-09 11:35:58 +02:00
										 |  |  |         if (children.children().isEmpty()) { | 
					
						
							|  |  |  |             // happens e.g. if no debug information is present or
 | 
					
						
							|  |  |  |             // if the class really has no children
 | 
					
						
							|  |  |  |             WatchData data1; | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |             data1.iname = data.iname + _(".child"); | 
					
						
							| 
									
										
										
										
											2009-04-30 22:22:37 +02:00
										 |  |  |             //: About variable's value
 | 
					
						
							| 
									
										
										
										
											2009-04-09 11:35:58 +02:00
										 |  |  |             data1.value = tr("<no information>"); | 
					
						
							| 
									
										
										
										
											2009-06-22 11:35:08 +02:00
										 |  |  |             data1.hasChildren = false; | 
					
						
							| 
									
										
										
										
											2009-04-09 11:35:58 +02:00
										 |  |  |             data1.setAllUnneeded(); | 
					
						
							|  |  |  |             insertData(data1); | 
					
						
							|  |  |  |             data.setAllUnneeded(); | 
					
						
							|  |  |  |             insertData(data); | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         } else if (!isAccessSpecifier(data.variable.split(_c('.')).last())) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |             data.setChildrenUnneeded(); | 
					
						
							|  |  |  |             insertData(data); | 
					
						
							| 
									
										
										
										
											2009-04-09 11:35:58 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             // this skips the spurious "public", "private" etc levels
 | 
					
						
							|  |  |  |             // gdb produces
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.setError(QString::fromLocal8Bit(record.data.findChild("msg").data())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2009-04-30 15:21:37 +02:00
										 |  |  |         data.setError(tr("Unknown error: ") + QString::fromLocal8Bit(record.toString())); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  | void GdbEngine::handleChangedItem(QStandardItem *item) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // HACK: Just store the item for the slot
 | 
					
						
							|  |  |  |     //  handleChangedItem(QWidget *widget) below.
 | 
					
						
							|  |  |  |     QModelIndex index = item->index().sibling(item->index().row(), 0); | 
					
						
							|  |  |  |     //WatchData data = m_currentSet.takeData(iname);
 | 
					
						
							|  |  |  |     //m_editedData = inameFromItem(m_model.itemFromIndex(index)).exp;
 | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "HANDLE CHANGED EXPRESSION:" << m_editedData;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::assignValueInDebugger(const QString &expression, const QString &value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("-var-delete assign")); | 
					
						
							|  |  |  |     postCommand(_("-var-create assign * ") + expression); | 
					
						
							|  |  |  |     postCommand(_("-var-assign assign ") + value, Discardable, CB(handleVarAssign)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::tryLoadDebuggingHelpers() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     if (m_debuggingHelperState != DebuggingHelperUninitialized) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-05-07 11:34:01 +02:00
										 |  |  |     if (!startModeAllowsDumpers()) { | 
					
						
							|  |  |  |         // load gdb macro based dumpers at least 
 | 
					
						
							| 
									
										
										
										
											2009-05-19 15:22:48 +02:00
										 |  |  |         QFile file(_(":/gdb/gdbmacros.txt")); | 
					
						
							| 
									
										
										
										
											2009-05-07 12:17:23 +02:00
										 |  |  |         file.open(QIODevice::ReadOnly); | 
					
						
							|  |  |  |         QByteArray contents = file.readAll();  | 
					
						
							|  |  |  |         //qDebug() << "CONTENTS: " << contents;
 | 
					
						
							|  |  |  |         postCommand(_(contents)); | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-05-07 11:34:01 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     if (m_dumperInjectionLoad && inferiorPid() <= 0) // Need PID to inject
 | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     PENDING_DEBUG("TRY LOAD CUSTOM DUMPERS"); | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     m_debuggingHelperState = DebuggingHelperUnavailable; | 
					
						
							| 
									
										
										
										
											2009-04-22 17:28:26 +02:00
										 |  |  |     if (!qq->qtDumperLibraryEnabled()) | 
					
						
							| 
									
										
										
										
											2009-04-20 16:40:50 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-04-22 17:28:26 +02:00
										 |  |  |     const QString lib = qq->qtDumperLibraryName(); | 
					
						
							| 
									
										
										
										
											2009-07-15 17:41:45 +02:00
										 |  |  |     const QStringList &locations = qq->qtDumperLibraryLocations(); | 
					
						
							| 
									
										
										
										
											2009-05-06 20:55:21 +02:00
										 |  |  |     //qDebug() << "DUMPERLIB:" << lib;
 | 
					
						
							| 
									
										
										
										
											2009-04-20 16:40:50 +02:00
										 |  |  |     // @TODO: same in CDB engine...
 | 
					
						
							|  |  |  |     const QFileInfo fi(lib); | 
					
						
							|  |  |  |     if (!fi.exists()) { | 
					
						
							| 
									
										
										
										
											2009-07-15 17:41:45 +02:00
										 |  |  |         const QString loc = locations.join(QLatin1String(", ")); | 
					
						
							|  |  |  |         const QString msg = tr("The dumper library was not found at %1.").arg(loc); | 
					
						
							| 
									
										
										
										
											2009-04-20 16:40:50 +02:00
										 |  |  |         debugMessage(msg); | 
					
						
							| 
									
										
										
										
											2009-04-22 17:28:26 +02:00
										 |  |  |         qq->showQtDumperLibraryWarning(msg); | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-02-13 14:45:46 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     m_debuggingHelperState = DebuggingHelperLoadTried; | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  | #if defined(Q_OS_WIN)
 | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |     if (m_dumperInjectionLoad) { | 
					
						
							|  |  |  |         /// Launch asynchronous remote thread to load.
 | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |         SharedLibraryInjector injector(inferiorPid()); | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |         QString errorMessage; | 
					
						
							|  |  |  |         if (injector.remoteInject(lib, false, &errorMessage)) { | 
					
						
							|  |  |  |             debugMessage(tr("Dumper injection loading triggered (%1)...").arg(lib)); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             debugMessage(tr("Dumper loading (%1) failed: %2").arg(lib, errorMessage)); | 
					
						
							|  |  |  |             debugMessage(errorMessage); | 
					
						
							|  |  |  |             qq->showQtDumperLibraryWarning(errorMessage); | 
					
						
							|  |  |  |             m_debuggingHelperState = DebuggingHelperUnavailable; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         debugMessage(tr("Loading dumpers via debugger call (%1)...").arg(lib)); | 
					
						
							|  |  |  |         postCommand(_("sharedlibrary .*")); // for LoadLibraryA
 | 
					
						
							|  |  |  |         //postCommand(_("handle SIGSEGV pass stop print"));
 | 
					
						
							|  |  |  |         //postCommand(_("set unwindonsignal off"));
 | 
					
						
							|  |  |  |         postCommand(_("call LoadLibraryA(\"") + GdbMi::escapeCString(lib) + _("\")"), | 
					
						
							|  |  |  |                     CB(handleDebuggingHelperSetup)); | 
					
						
							|  |  |  |         postCommand(_("sharedlibrary ") + dotEscape(lib)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  | #elif defined(Q_OS_MAC)
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     //postCommand(_("sharedlibrary libc")); // for malloc
 | 
					
						
							|  |  |  |     //postCommand(_("sharedlibrary libdl")); // for dlopen
 | 
					
						
							|  |  |  |     postCommand(_("call (void)dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"), | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |         CB(handleDebuggingHelperSetup)); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     //postCommand(_("sharedlibrary ") + dotEscape(lib));
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  |     m_debuggingHelperState = DebuggingHelperLoadTried; | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     //postCommand(_("p dlopen"));
 | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  |     QString flag = QString::number(RTLD_NOW); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("sharedlibrary libc")); // for malloc
 | 
					
						
							|  |  |  |     postCommand(_("sharedlibrary libdl")); // for dlopen
 | 
					
						
							|  |  |  |     postCommand(_("call (void*)dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"), | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |         CB(handleDebuggingHelperSetup)); | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  |     // some older systems like CentOS 4.6 prefer this:
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("call (void*)__dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"), | 
					
						
							| 
									
										
										
										
											2009-05-05 11:16:54 +02:00
										 |  |  |         CB(handleDebuggingHelperSetup)); | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("sharedlibrary ") + dotEscape(lib)); | 
					
						
							| 
									
										
										
										
											2009-03-24 12:50:08 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-05-14 15:03:30 +02:00
										 |  |  |     if (!m_dumperInjectionLoad) | 
					
						
							|  |  |  |         tryQueryDebuggingHelpers(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::tryQueryDebuggingHelpers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // retrieve list of dumpable classes
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |     postCommand(_("call (void*)qDumpObjectData440(1,%1+1,0,0,0,0,0,0)"), EmbedToken); | 
					
						
							|  |  |  |     postCommand(_("p (char*)&qDumpOutBuffer"), CB(handleQueryDebuggingHelper)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 16:39:17 +02:00
										 |  |  | void GdbEngine::recheckDebuggingHelperAvailability() | 
					
						
							| 
									
										
										
										
											2009-03-16 13:16:17 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |     if (startModeAllowsDumpers()) { | 
					
						
							|  |  |  |         // retreive list of dumpable classes
 | 
					
						
							| 
									
										
										
										
											2009-05-07 09:51:21 +02:00
										 |  |  |         postCommand(_("call (void*)qDumpObjectData440(1,%1+1,0,0,0,0,0,0)"), EmbedToken); | 
					
						
							|  |  |  |         postCommand(_("p (char*)&qDumpOutBuffer"), CB(handleQueryDebuggingHelper)); | 
					
						
							| 
									
										
										
										
											2009-05-06 16:11:42 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GdbEngine::startModeAllowsDumpers() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-14 11:02:36 +02:00
										 |  |  |     return startMode() == StartInternal | 
					
						
							|  |  |  |         || startMode() == StartExternal | 
					
						
							|  |  |  |         || startMode() == AttachExternal; | 
					
						
							| 
									
										
										
										
											2009-03-16 13:16:17 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-01 12:49:41 +02:00
										 |  |  | void GdbEngine::watchPoint(const QPoint &pnt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //qDebug() << "WATCH " << pnt;
 | 
					
						
							|  |  |  |     postCommand(_("call (void*)watchPoint(%1,%2)").arg(pnt.x()).arg(pnt.y()), | 
					
						
							|  |  |  |         NeedsStop, CB(handleWatchPoint)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleWatchPoint(const GdbResultRecord &record, const QVariant &) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //qDebug() << "HANDLE WATCH POINT:" << record.toString();
 | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         GdbMi contents = record.data.findChild("consolestreamoutput"); | 
					
						
							|  |  |  |         // "$5 = (void *) 0xbfa7ebfc\n"
 | 
					
						
							|  |  |  |         QString str = _(parsePlainConsoleStream(record)); | 
					
						
							|  |  |  |         // "(void *) 0xbfa7ebfc"
 | 
					
						
							|  |  |  |         QString addr = str.mid(9); | 
					
						
							|  |  |  |         QString ns = m_dumperHelper.qtNamespace(); | 
					
						
							|  |  |  |         QString type = ns.isEmpty() ? _("QWidget*") : _("'%1QWidget'*").arg(ns); | 
					
						
							|  |  |  |         QString exp = _("(*(%1)%2)").arg(type).arg(addr); | 
					
						
							|  |  |  |         theDebuggerAction(WatchExpression)->trigger(exp); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct MemoryAgentCookie | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     MemoryAgentCookie() : agent(0), address(0) {} | 
					
						
							|  |  |  |     MemoryAgentCookie(MemoryViewAgent *agent_, quint64 address_) | 
					
						
							|  |  |  |         : agent(agent_), address(address_) | 
					
						
							|  |  |  |     {} | 
					
						
							|  |  |  |     MemoryViewAgent *agent; | 
					
						
							|  |  |  |     quint64 address; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::fetchMemory(MemoryViewAgent *agent, quint64 addr, quint64 length) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     //qDebug() << "GDB MEMORY FETCH" << agent << addr << length;
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     postCommand(_("-data-read-memory %1 x 1 1 %2").arg(addr).arg(length), | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |         NeedsStop, CB(handleFetchMemory), | 
					
						
							|  |  |  |         QVariant::fromValue(MemoryAgentCookie(agent, addr))); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  | void GdbEngine::handleFetchMemory(const GdbResultRecord &record, | 
					
						
							|  |  |  |     const QVariant &cookie) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // ^done,addr="0x08910c88",nr-bytes="16",total-bytes="16",
 | 
					
						
							|  |  |  |     // next-row="0x08910c98",prev-row="0x08910c78",next-page="0x08910c98",
 | 
					
						
							|  |  |  |     // prev-page="0x08910c78",memory=[{addr="0x08910c88",
 | 
					
						
							|  |  |  |     // data=["1","0","0","0","5","0","0","0","0","0","0","0","0","0","0","0"]}]
 | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     MemoryAgentCookie ac = cookie.value<MemoryAgentCookie>(); | 
					
						
							|  |  |  |     QTC_ASSERT(ac.agent, return); | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  |     QByteArray ba; | 
					
						
							|  |  |  |     GdbMi memory = record.data.findChild("memory"); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     QTC_ASSERT(memory.children().size() <= 1, return); | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     if (memory.children().isEmpty()) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  |     GdbMi memory0 = memory.children().at(0); // we asked for only one 'row'
 | 
					
						
							|  |  |  |     GdbMi data = memory0.findChild("data"); | 
					
						
							|  |  |  |     foreach (const GdbMi &child, data.children()) { | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |         bool ok = true; | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  |         unsigned char c = child.data().toUInt(&ok, 0); | 
					
						
							|  |  |  |         QTC_ASSERT(ok, return); | 
					
						
							|  |  |  |         ba.append(c); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     ac.agent->addLazyData(ac.address, ba); | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  | struct DisassemblerAgentCookie | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     DisassemblerAgentCookie() : agent(0) {} | 
					
						
							|  |  |  |     DisassemblerAgentCookie(DisassemblerViewAgent *agent_) | 
					
						
							|  |  |  |         : agent(agent_) | 
					
						
							|  |  |  |     {} | 
					
						
							|  |  |  |     DisassemblerViewAgent *agent; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | void GdbEngine::fetchDisassembler(DisassemblerViewAgent *agent, | 
					
						
							|  |  |  |     const StackFrame &frame) | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     if (frame.file.isEmpty()) { | 
					
						
							|  |  |  |         fetchDisassemblerByAddress(agent, true); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         // Disassemble full function:
 | 
					
						
							|  |  |  |         QString cmd = _("-data-disassemble -f %1 -l %2 -n -1 -- 1"); | 
					
						
							|  |  |  |         postCommand(cmd.arg(frame.file).arg(frame.line), | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             Discardable, CB(handleFetchDisassemblerByLine), | 
					
						
							|  |  |  |             QVariant::fromValue(DisassemblerAgentCookie(agent))); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::fetchDisassemblerByAddress(DisassemblerViewAgent *agent, | 
					
						
							|  |  |  |     bool useMixedMode) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QTC_ASSERT(agent, return); | 
					
						
							|  |  |  |     bool ok = true; | 
					
						
							|  |  |  |     quint64 address = agent->address().toULongLong(&ok, 0); | 
					
						
							|  |  |  |     quint64 start = address - 20; | 
					
						
							|  |  |  |     quint64 end = address + 100; | 
					
						
							|  |  |  |     // -data-disassemble [ -s start-addr -e end-addr ]
 | 
					
						
							|  |  |  |     //  | [ -f filename -l linenum [ -n lines ] ] -- mode
 | 
					
						
							|  |  |  |     if (useMixedMode)  | 
					
						
							|  |  |  |         postCommand(_("-data-disassemble -s %1 -e %2 -- 1").arg(start).arg(end), | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             Discardable, CB(handleFetchDisassemblerByAddress1), | 
					
						
							|  |  |  |             QVariant::fromValue(DisassemblerAgentCookie(agent))); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |         postCommand(_("-data-disassemble -s %1 -e %2 -- 0").arg(start).arg(end), | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             Discardable, CB(handleFetchDisassemblerByAddress0), | 
					
						
							|  |  |  |             QVariant::fromValue(DisassemblerAgentCookie(agent))); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static QByteArray parseLine(const GdbMi &line) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QByteArray ba; | 
					
						
							|  |  |  |     ba.reserve(200); | 
					
						
							|  |  |  |     QByteArray address = line.findChild("address").data(); | 
					
						
							| 
									
										
										
										
											2009-08-17 14:23:54 +02:00
										 |  |  |     //QByteArray funcName = line.findChild("func-name").data();
 | 
					
						
							|  |  |  |     //QByteArray offset = line.findChild("offset").data();
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     QByteArray inst = line.findChild("inst").data(); | 
					
						
							|  |  |  |     ba += address + QByteArray(15 - address.size(), ' '); | 
					
						
							| 
									
										
										
										
											2009-08-17 14:23:54 +02:00
										 |  |  |     //ba += funcName + "+" + offset + "  ";
 | 
					
						
							|  |  |  |     //ba += QByteArray(30 - funcName.size() - offset.size(), ' ');
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     ba += inst; | 
					
						
							|  |  |  |     ba += '\n'; | 
					
						
							|  |  |  |     return ba; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  | QString GdbEngine::parseDisassembler(const GdbMi &lines) | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     // ^done,data={asm_insns=[src_and_asm_line={line="1243",file=".../app.cpp",
 | 
					
						
							|  |  |  |     // line_asm_insn=[{address="0x08054857",func-name="main",offset="27",
 | 
					
						
							|  |  |  |     // inst="call 0x80545b0 <_Z13testQFileInfov>"}]},
 | 
					
						
							|  |  |  |     // src_and_asm_line={line="1244",file=".../app.cpp",
 | 
					
						
							|  |  |  |     // line_asm_insn=[{address="0x0805485c",func-name="main",offset="32",
 | 
					
						
							|  |  |  |     //inst="call 0x804cba1 <_Z11testObject1v>"}]}]}
 | 
					
						
							|  |  |  |     // - or -
 | 
					
						
							|  |  |  |     // ^done,asm_insns=[
 | 
					
						
							|  |  |  |     // {address="0x0805acf8",func-name="...",offset="25",inst="and $0xe8,%al"},
 | 
					
						
							|  |  |  |     // {address="0x0805acfa",func-name="...",offset="27",inst="pop %esp"},
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<QByteArray> fileContents; | 
					
						
							|  |  |  |     bool fileLoaded = false; | 
					
						
							|  |  |  |     QByteArray ba; | 
					
						
							|  |  |  |     ba.reserve(200 * lines.children().size()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // FIXME: Performance?
 | 
					
						
							|  |  |  |     foreach (const GdbMi &child, lines.children()) { | 
					
						
							|  |  |  |         if (child.hasName("src_and_asm_line")) { | 
					
						
							|  |  |  |             // mixed mode
 | 
					
						
							|  |  |  |             int line = child.findChild("line").data().toInt(); | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |             QString fileName = QFile::decodeName(child.findChild("file").data()); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |             if (!fileLoaded) { | 
					
						
							| 
									
										
										
										
											2009-08-18 11:23:01 +02:00
										 |  |  |                 QFile file(fullName(fileName)); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |                 file.open(QIODevice::ReadOnly); | 
					
						
							|  |  |  |                 fileContents = file.readAll().split('\n'); | 
					
						
							|  |  |  |                 fileLoaded = true; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (line >= 0 && line < fileContents.size()) | 
					
						
							| 
									
										
										
										
											2009-08-17 14:23:54 +02:00
										 |  |  |                 ba += "    " + fileContents.at(line) + '\n'; | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |             GdbMi insn = child.findChild("line_asm_insn"); | 
					
						
							|  |  |  |             foreach (const GdbMi &line, insn.children())  | 
					
						
							|  |  |  |                 ba += parseLine(line); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             // the non-mixed version
 | 
					
						
							|  |  |  |             ba += parseLine(child); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return _(ba); | 
					
						
							| 
									
										
										
										
											2009-08-12 10:51:25 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | void GdbEngine::handleFetchDisassemblerByLine(const GdbResultRecord &record, | 
					
						
							|  |  |  |     const QVariant &cookie) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     DisassemblerAgentCookie ac = cookie.value<DisassemblerAgentCookie>(); | 
					
						
							|  |  |  |     QTC_ASSERT(ac.agent, return); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         GdbMi lines = record.data.findChild("asm_insns"); | 
					
						
							|  |  |  |         if (lines.children().isEmpty()) | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             fetchDisassemblerByAddress(ac.agent, true); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             ac.agent->setContents(parseDisassembler(lines)); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     } else if (record.resultClass == GdbResultError) { | 
					
						
							|  |  |  |         //536^error,msg="mi_cmd_disassemble: Invalid line number"
 | 
					
						
							|  |  |  |         QByteArray msg = record.data.findChild("msg").data(); | 
					
						
							|  |  |  |         if (msg == "mi_cmd_disassemble: Invalid line number") | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             fetchDisassemblerByAddress(ac.agent, true); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleFetchDisassemblerByAddress1(const GdbResultRecord &record, | 
					
						
							|  |  |  |     const QVariant &cookie) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |     DisassemblerAgentCookie ac = cookie.value<DisassemblerAgentCookie>(); | 
					
						
							|  |  |  |     QTC_ASSERT(ac.agent, return); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         GdbMi lines = record.data.findChild("asm_insns"); | 
					
						
							|  |  |  |         if (lines.children().isEmpty()) | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             fetchDisassemblerByAddress(ac.agent, false); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  |             ac.agent->setContents(parseDisassembler(lines)); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleFetchDisassemblerByAddress0(const GdbResultRecord &record, | 
					
						
							|  |  |  |     const QVariant &cookie) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-18 11:34:26 +02:00
										 |  |  |     DisassemblerAgentCookie ac = cookie.value<DisassemblerAgentCookie>(); | 
					
						
							|  |  |  |     QTC_ASSERT(ac.agent, return); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (record.resultClass == GdbResultDone) { | 
					
						
							|  |  |  |         GdbMi lines = record.data.findChild("asm_insns"); | 
					
						
							| 
									
										
										
										
											2009-08-18 11:34:26 +02:00
										 |  |  |         ac.agent->setContents(parseDisassembler(lines)); | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  | void GdbEngine::gotoLocation(const StackFrame &frame, bool setMarker) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     lastFile = frame.file; | 
					
						
							|  |  |  |     lastLine = frame.line; | 
					
						
							| 
									
										
										
										
											2009-09-17 16:51:27 +02:00
										 |  |  |     m_manager->gotoLocation(frame, setMarker); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Starting up & shutting down
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleAdapterStartFailed(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("ADAPTER START FAILED")); | 
					
						
							|  |  |  |     m_outputCollector.shutdown(); | 
					
						
							|  |  |  |     QMessageBox::critical(mainWindow(), tr("Error"), msg); | 
					
						
							|  |  |  |     QTC_ASSERT(status() == DebuggerInferiorRunning, /**/); | 
					
						
							|  |  |  |     //interruptInferior();
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleAdapterStarted() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("ADAPTER SUCCESSFULLY STARTED, PREPARING INFERIOR")); | 
					
						
							|  |  |  |     m_gdbAdapter->prepareInferior(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInferiorPreparationFailed(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("INFERIOR PREPARATION FAILD")); | 
					
						
							|  |  |  |     m_outputCollector.shutdown(); | 
					
						
							|  |  |  |     QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							|  |  |  |         tr("Inferior start preparation failed:\n") + msg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInferiorPrepared() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // FIXME: Check that inferior is in "stopped" state
 | 
					
						
							|  |  |  |     qq->notifyInferiorStopped(); | 
					
						
							|  |  |  |     showStatusMessage(tr("Inferior prepared for startup.")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     postCommand(_("show version"), CB(handleShowVersion)); | 
					
						
							|  |  |  |     //postCommand(_("-enable-timings");
 | 
					
						
							|  |  |  |     postCommand(_("set print static-members off")); // Seemingly doesn't work.
 | 
					
						
							|  |  |  |     //postCommand(_("set debug infrun 1"));
 | 
					
						
							|  |  |  |     //postCommand(_("define hook-stop\n-thread-list-ids\n-stack-list-frames\nend"));
 | 
					
						
							|  |  |  |     //postCommand(_("define hook-stop\nprint 4\nend"));
 | 
					
						
							|  |  |  |     //postCommand(_("define hookpost-stop\nprint 5\nend"));
 | 
					
						
							|  |  |  |     //postCommand(_("define hook-call\nprint 6\nend"));
 | 
					
						
							|  |  |  |     //postCommand(_("define hookpost-call\nprint 7\nend"));
 | 
					
						
							|  |  |  |     //postCommand(_("set print object on")); // works with CLI, but not MI
 | 
					
						
							|  |  |  |     //postCommand(_("set step-mode on"));  // we can't work with that yes
 | 
					
						
							|  |  |  |     //postCommand(_("set exec-done-display on"));
 | 
					
						
							|  |  |  |     //postCommand(_("set print pretty on"));
 | 
					
						
							|  |  |  |     //postCommand(_("set confirm off"));
 | 
					
						
							|  |  |  |     //postCommand(_("set pagination off"));
 | 
					
						
							|  |  |  |     postCommand(_("set print inferior-events 1")); | 
					
						
							|  |  |  |     postCommand(_("set breakpoint pending on")); | 
					
						
							|  |  |  |     postCommand(_("set print elements 10000")); | 
					
						
							|  |  |  |     postCommand(_("-data-list-register-names"), CB(handleRegisterListNames)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //postCommand(_("set substitute-path /var/tmp/qt-x11-src-4.5.0 "
 | 
					
						
							|  |  |  |     //    "/home/sandbox/qtsdk-2009.01/qt"));
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // one of the following is needed to prevent crashes in gdb on code like:
 | 
					
						
							|  |  |  |     //  template <class T> T foo() { return T(0); }
 | 
					
						
							|  |  |  |     //  int main() { return foo<int>(); }
 | 
					
						
							|  |  |  |     //  (gdb) call 'int foo<int>'()
 | 
					
						
							|  |  |  |     //  /build/buildd/gdb-6.8/gdb/valops.c:2069: internal-error:
 | 
					
						
							|  |  |  |     postCommand(_("set overload-resolution off")); | 
					
						
							|  |  |  |     //postCommand(_("set demangle-style none"));
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // From the docs:
 | 
					
						
							|  |  |  |     //  Stop means reenter debugger if this signal happens (implies print).
 | 
					
						
							|  |  |  |     //  Print means print a message if this signal happens.
 | 
					
						
							|  |  |  |     //  Pass means let program see this signal;
 | 
					
						
							|  |  |  |     //  otherwise program doesn't know.
 | 
					
						
							|  |  |  |     //  Pass and Stop may be combined.
 | 
					
						
							|  |  |  |     // We need "print" as otherwise we would get no feedback whatsoever
 | 
					
						
							|  |  |  |     // Custom DebuggingHelper crashs which happen regularily for when accessing
 | 
					
						
							|  |  |  |     // uninitialized variables.
 | 
					
						
							|  |  |  |     postCommand(_("handle SIGSEGV nopass stop print")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // This is useful to kill the inferior whenever gdb dies.
 | 
					
						
							|  |  |  |     //postCommand(_("handle SIGTERM pass nostop print"));
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     postCommand(_("set unwindonsignal on")); | 
					
						
							|  |  |  |     //postCommand(_("pwd"));
 | 
					
						
							|  |  |  |     postCommand(_("set width 0")); | 
					
						
							|  |  |  |     postCommand(_("set height 0")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     #ifdef Q_OS_MAC
 | 
					
						
							|  |  |  |     postCommand(_("-gdb-set inferior-auto-start-cfm off")); | 
					
						
							|  |  |  |     postCommand(_("-gdb-set sharedLibrary load-rules " | 
					
						
							|  |  |  |             "dyld \".*libSystem.*\" all " | 
					
						
							|  |  |  |             "dyld \".*libauto.*\" all " | 
					
						
							|  |  |  |             "dyld \".*AppKit.*\" all " | 
					
						
							|  |  |  |             "dyld \".*PBGDBIntrospectionSupport.*\" all " | 
					
						
							|  |  |  |             "dyld \".*Foundation.*\" all " | 
					
						
							|  |  |  |             "dyld \".*CFDataFormatters.*\" all " | 
					
						
							|  |  |  |             "dyld \".*libobjc.*\" all " | 
					
						
							|  |  |  |             "dyld \".*CarbonDataFormatters.*\" all")); | 
					
						
							|  |  |  |     #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString scriptFileName = theDebuggerStringSetting(GdbScriptFile); | 
					
						
							|  |  |  |     if (!scriptFileName.isEmpty()) { | 
					
						
							|  |  |  |         if (QFileInfo(scriptFileName).isReadable()) { | 
					
						
							|  |  |  |             postCommand(_("source ") + scriptFileName); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             QMessageBox::warning(mainWindow(), | 
					
						
							|  |  |  |             tr("Cannot find debugger initialization script"), | 
					
						
							|  |  |  |             tr("The debugger settings point to a script file at '%1' " | 
					
						
							|  |  |  |                "which is not accessible. If a script file is not needed, " | 
					
						
							|  |  |  |                "consider clearing that entry to avoid this warning. " | 
					
						
							|  |  |  |               ).arg(scriptFileName)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |     if (startMode() == AttachExternal || startMode() == AttachCrashedExternal) { | 
					
						
							|  |  |  |         postCommand(_("attach %1").arg(m_startParameters->attachPID), CB(handleAttach)); | 
					
						
							|  |  |  |         // Task 254674 does not want to remove them
 | 
					
						
							|  |  |  |         //qq->breakHandler()->removeAllBreakpoints();
 | 
					
						
							|  |  |  |     } else if (startMode() == AttachCore) { | 
					
						
							|  |  |  |         QFileInfo fi(m_startParameters->executable); | 
					
						
							|  |  |  |         QString fileName = _c('"') + fi.absoluteFilePath() + _c('"'); | 
					
						
							|  |  |  |         QFileInfo fi2(m_startParameters->coreFile); | 
					
						
							|  |  |  |         // quoting core name below fails in gdb 6.8-debian
 | 
					
						
							|  |  |  |         QString coreName = fi2.absoluteFilePath(); | 
					
						
							|  |  |  |         postCommand(_("-file-exec-and-symbols ") + fileName, CB(handleFileExecAndSymbols)); | 
					
						
							|  |  |  |         postCommand(_("target core ") + coreName, CB(handleTargetCore)); | 
					
						
							|  |  |  |         qq->breakHandler()->removeAllBreakpoints(); | 
					
						
							|  |  |  |     } else if (startMode() == StartRemote) { | 
					
						
							|  |  |  |         postCommand(_("set architecture %1").arg(m_startParameters->remoteArchitecture)); | 
					
						
							|  |  |  |         qq->breakHandler()->setAllPending(); | 
					
						
							|  |  |  |         //QFileInfo fi(m_startParameters->executable);
 | 
					
						
							|  |  |  |         //QString fileName = fi.absoluteFileName();
 | 
					
						
							|  |  |  |         QString fileName = m_startParameters->executable; | 
					
						
							|  |  |  |         postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName), CB(handleFileExecAndSymbols)); | 
					
						
							|  |  |  |         // works only for > 6.8
 | 
					
						
							|  |  |  |         postCommand(_("set target-async on"), CB(handleSetTargetAsync)); | 
					
						
							|  |  |  |     } else if (m_startParameters->useTerminal) { | 
					
						
							|  |  |  |         qq->breakHandler()->setAllPending(); | 
					
						
							|  |  |  |     } else if (startMode() == StartInternal || startMode() == StartExternal) { | 
					
						
							|  |  |  |         qq->breakHandler()->setAllPending(); | 
					
						
							|  |  |  |         m_gdbAdapter->attach(); | 
					
						
							| 
									
										
										
										
											2009-09-22 11:31:34 +02:00
										 |  |  |         if (m_gdbAdapter->isTrkAdapter()) { | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |             m_continuationAfterDone = true; | 
					
						
							|  |  |  |             qq->notifyInferiorStopped(); | 
					
						
							|  |  |  |             attemptBreakpointSynchronization(); | 
					
						
							|  |  |  |             qq->notifyInferiorRunningRequested(); | 
					
						
							|  |  |  |         } [...] | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // initial attempt to set breakpoints
 | 
					
						
							|  |  |  |     QTC_ASSERT(m_continuationAfterDone == 0, /**/); | 
					
						
							|  |  |  |     showStatusMessage(tr("Start initial breakpoint setting.")); | 
					
						
							|  |  |  |     m_continuationAfterDone = &GdbEngine::handleInitialBreakpointsSet; | 
					
						
							|  |  |  |     attemptBreakpointSynchronization(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInitialBreakpointsSet() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     showStatusMessage(tr("Finishing initial breakpoint setting.")); | 
					
						
							|  |  |  |     qq->notifyInferiorRunningRequested(); | 
					
						
							|  |  |  |     m_gdbAdapter->startInferior(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInferiorStartFailed(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("INFERIOR START FAILED")); | 
					
						
							|  |  |  |     QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							|  |  |  |         tr("Inferior start failed:\n") + msg); | 
					
						
							|  |  |  |     qq->notifyInferiorExited(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInferiorStarted() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qq->notifyInferiorRunning(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInferiorShutDown() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN")); | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  |     qq->notifyInferiorExited(); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleInferiorShutdownFailed(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("INFERIOR SHUTDOWN FAILED")); | 
					
						
							|  |  |  |     QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							|  |  |  |         tr("Inferior shutdown failed:\n") + msg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 17:35:19 +02:00
										 |  |  | void GdbEngine::handleAdapterShutDown() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("ADAPTER SUCCESSFULLY SHUT DOWN")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GdbEngine::handleAdapterShutdownFailed(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     debugMessage(_("ADAPTER SHUTDOWN FAILED")); | 
					
						
							|  |  |  |     QMessageBox::critical(mainWindow(), tr("Error"), | 
					
						
							|  |  |  |         tr("Inferior shutdown failed:\n") + msg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Factory
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:37:32 +02:00
										 |  |  | IDebuggerEngine *createGdbEngine(DebuggerManager *parent, | 
					
						
							|  |  |  |     QList<Core::IOptionsPage*> *opts) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-17 09:03:32 +02:00
										 |  |  |     opts->push_back(new GdbOptionsPage); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     GdbEngine *engine = new GdbEngine(parent); | 
					
						
							|  |  |  |     PlainGdbAdapter *adapter = new PlainGdbAdapter(engine); | 
					
						
							|  |  |  |     engine->setGdbAdapter(adapter); | 
					
						
							|  |  |  |     return engine; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-11 15:37:32 +02:00
										 |  |  | IDebuggerEngine *createSymbianEngine(DebuggerManager *parent, | 
					
						
							|  |  |  |     QList<Core::IOptionsPage*> *opts) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-18 12:51:15 +02:00
										 |  |  |     QSharedPointer<TrkOptions> options(new TrkOptions); | 
					
						
							|  |  |  |     options->fromSettings(Core::ICore::instance()->settings()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 09:05:05 +02:00
										 |  |  |     if (!qgetenv("QTCREATOR_WITH_S60").isEmpty()) | 
					
						
							|  |  |  |         opts->push_back(new TrkOptionsPage(options)); | 
					
						
							| 
									
										
										
										
											2009-09-21 11:09:38 +02:00
										 |  |  |     GdbEngine *engine = new GdbEngine(parent); | 
					
						
							|  |  |  |     TrkGdbAdapter *adapter = new TrkGdbAdapter(engine, options); | 
					
						
							|  |  |  |     engine->setGdbAdapter(adapter); | 
					
						
							| 
									
										
										
										
											2009-09-11 15:37:32 +02:00
										 |  |  |     QObject::connect(adapter, SIGNAL(output(QString)), | 
					
						
							|  |  |  |         parent, SLOT(showDebuggerOutput(QString))); | 
					
						
							|  |  |  |     return engine; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-18 08:34:48 +02:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace Debugger
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Q_DECLARE_METATYPE(Debugger::Internal::MemoryAgentCookie); | 
					
						
							|  |  |  | Q_DECLARE_METATYPE(Debugger::Internal::DisassemblerAgentCookie); | 
					
						
							|  |  |  | Q_DECLARE_METATYPE(Debugger::Internal::GdbMi); | 
					
						
							|  |  |  | 
 |