File indexing completed on 2025-04-27 05:16:41
0001 /*************************************************************************** 0002 * Copyright (C) 2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #include "config.h" 0012 #ifndef NO_GPSIM 0013 0014 #include "debugmanager.h" 0015 #include "docmanager.h" 0016 #include "gpsimprocessor.h" 0017 #include "textdocument.h" 0018 0019 #include <QDebug> 0020 // #include <k3staticdeleter.h> 0021 #include <QGlobalStatic> 0022 0023 // BEGIN class DebugManager 0024 // DebugManager * DebugManager::m_pSelf = nullptr; // 2017.10.10 - use K_GLOBAL_STATIC 0025 // static K3StaticDeleter<DebugManager> staticDebugManagerDeleter; 0026 0027 Q_GLOBAL_STATIC(DebugManager, globalDebugManager); 0028 0029 DebugManager *DebugManager::self() 0030 { 0031 return globalDebugManager; 0032 } 0033 0034 DebugManager::DebugManager() 0035 : QObject() 0036 { 0037 } 0038 0039 DebugManager::~DebugManager() 0040 { 0041 } 0042 0043 void DebugManager::registerGpsim(GpsimProcessor *gpsim) 0044 { 0045 if (!gpsim) 0046 return; 0047 0048 m_processors << gpsim; 0049 0050 const QStringList files = gpsim->sourceFileList(); 0051 QStringList::const_iterator end = files.end(); 0052 for (QStringList::const_iterator it = files.begin(); it != end; ++it) { 0053 const QUrl url = QUrl::fromLocalFile(*it); 0054 if (TextDocument *doc = dynamic_cast<TextDocument *>(DocManager::self()->findDocument(url))) { 0055 if (!doc->debuggerIsRunning()) 0056 doc->setDebugger(gpsim->currentDebugger(), false); 0057 } 0058 } 0059 } 0060 0061 void DebugManager::urlOpened(TextDocument *td) 0062 { 0063 if (td->debuggerIsRunning()) 0064 return; 0065 0066 m_processors.removeAll(static_cast<GpsimProcessor *>(nullptr)); 0067 GpsimProcessorList::iterator end = m_processors.end(); 0068 for (GpsimProcessorList::iterator it = m_processors.begin(); it != end; ++it) { 0069 if (!(*it)->sourceFileList().contains(td->url().path())) 0070 continue; 0071 0072 (*it)->setDebugMode((td->guessedCodeType() == TextDocument::ct_asm) ? GpsimDebugger::AsmDebugger : GpsimDebugger::HLLDebugger); 0073 0074 td->setDebugger((*it)->currentDebugger(), false); 0075 return; 0076 } 0077 } 0078 // END class DebugManager 0079 0080 #include "moc_debugmanager.cpp" 0081 0082 #endif