debugmanager.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by David Saxton                                    *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #include "config.h"
00012 #ifndef NO_GPSIM
00013 
00014 #include "debugmanager.h"
00015 #include "docmanager.h"
00016 #include "gpsimprocessor.h"
00017 #include "textdocument.h"
00018 
00019 #include <kdebug.h>
00020 #include <kstaticdeleter.h>
00021 
00022 
00023 //BEGIN class DebugManager
00024 DebugManager * DebugManager::m_pSelf = 0;
00025 static KStaticDeleter<DebugManager> staticDebugManagerDeleter;
00026 
00027 DebugManager * DebugManager::self()
00028 {
00029         if (!m_pSelf)
00030                 staticDebugManagerDeleter.setObject( m_pSelf, new DebugManager );
00031         return m_pSelf;
00032 }
00033 
00034 
00035 DebugManager::DebugManager()
00036         : QObject()
00037 {
00038 }
00039 
00040 
00041 DebugManager::~DebugManager()
00042 {
00043 }
00044 
00045 
00046 void DebugManager::registerGpsim( GpsimProcessor * gpsim )
00047 {
00048         if (!gpsim)
00049                 return;
00050         
00051         m_processors << gpsim;
00052         
00053         const QStringList files = gpsim->sourceFileList();
00054         QStringList::const_iterator end = files.end();
00055         for ( QStringList::const_iterator it = files.begin(); it != end; ++it )
00056         {
00057                 if ( TextDocument * doc = dynamic_cast<TextDocument*>(DocManager::self()->findDocument(*it)) )
00058                 {
00059                         if ( !doc->debuggerIsRunning() )
00060                                 doc->setDebugger( gpsim->currentDebugger(), false );
00061                 }
00062         }
00063 }
00064 
00065 
00066 void DebugManager::urlOpened( TextDocument * td )
00067 {
00068         if ( td->debuggerIsRunning() )
00069                 return;
00070         
00071         m_processors.remove( (GpsimProcessor*)0 );
00072         GpsimProcessorList::iterator end = m_processors.end();
00073         for ( GpsimProcessorList::iterator it = m_processors.begin(); it != end; ++it )
00074         {
00075                 if ( !(*it)->sourceFileList().contains( td->url().path() ) )
00076                         continue;
00077                 
00078                 (*it)->setDebugMode( (td->guessedCodeType() == TextDocument::ct_asm) ? GpsimDebugger::AsmDebugger : GpsimDebugger::HLLDebugger );
00079                 
00080                 td->setDebugger( (*it)->currentDebugger(), false );
00081                 return;
00082         }
00083 }
00084 //END class DebugManager
00085 
00086 
00087 #include "debugmanager.moc"
00088 
00089 #endif

Generated on Tue May 8 17:05:28 2007 for KTechLab by  doxygen 1.5.1