Debugger.cpp

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
00024  */
00025 
00037 //
00038 // Debugger.cpp
00039 //
00040 // $Id: Debugger.cpp,v 1.1 2008/03/31 19:13:29 iamcamiel Exp $
00041 //
00042 // Library: Foundation
00043 // Package: Core
00044 // Module:  Debugger
00045 //
00046 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00047 // and Contributors.
00048 //
00049 // Permission is hereby granted, free of charge, to any person or organization
00050 // obtaining a copy of the software and accompanying documentation covered by
00051 // this license (the "Software") to use, reproduce, display, distribute,
00052 // execute, and transmit the Software, and to prepare derivative works of the
00053 // Software, and to permit third-parties to whom the Software is furnished to
00054 // do so, all subject to the following:
00055 // 
00056 // The copyright notices in the Software and this entire statement, including
00057 // the above license grant, this restriction and the following disclaimer,
00058 // must be included in all copies of the Software, in whole or in part, and
00059 // all derivative works of the Software, unless such copies or derivative
00060 // works are solely in the form of machine-executable object code generated by
00061 // a source language processor.
00062 // 
00063 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00064 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00065 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00066 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00067 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00068 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00069 // DEALINGS IN THE SOFTWARE.
00070 //
00071 
00072 
00073 #include "VMS/Debugger.h"
00074 #include <sstream>
00075 #include <cstdlib>
00076 #include <cstdio>
00077 #include <lib$routines.h>
00078 #include <ssdef.h>
00079 
00080 // NOTE: In this module, we use the C library functions (fputs) for,
00081 // output since, at the time we're called, the C++ iostream objects std::cout, etc.
00082 // might not have been initialized yet.
00083 
00084 
00085 namespace Poco {
00086 
00087 
00088 bool Debugger::isAvailable()
00089 {
00090 #if defined(_DEBUG)
00091         return true;
00092 #else
00093         return false;
00094 #endif
00095 }
00096 
00097 
00098 void Debugger::message(const std::string& msg)
00099 {
00100 #if defined(_DEBUG)
00101         std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
00102         std::fputs(msg.c_str(), stderr);
00103         std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
00104 #endif
00105 }
00106 
00107 
00108 void Debugger::message(const std::string& msg, const char* file, int line)
00109 {
00110 #if defined(_DEBUG)
00111         std::ostringstream str;
00112         str << msg << " [in file \"" << file << "\", line " << line << "]";
00113         message(str.str());
00114 #endif
00115 }
00116 
00117 
00118 void Debugger::enter()
00119 {
00120 #if defined(_DEBUG)
00121         {
00122                 const char* cmd = "\012SHOW CALLS";
00123                 lib$signal(SS$_DEBUG, 1, cmd);
00124         }
00125 #endif
00126 }
00127 
00128 
00129 void Debugger::enter(const std::string& msg)
00130 {
00131 #if defined(_DEBUG)
00132         message(msg);
00133         enter();
00134 #endif
00135 }
00136 
00137 
00138 void Debugger::enter(const std::string& msg, const char* file, int line)
00139 {
00140 #if defined(_DEBUG)
00141         message(msg, file, line);
00142         enter();
00143 #endif
00144 }
00145 
00146 
00147 void Debugger::enter(const char* file, int line)
00148 {
00149 #if defined(_DEBUG)
00150         message("BREAK", file, line);
00151         enter();
00152 #endif
00153 }
00154 
00155 
00156 } // namespace Poco

SourceForge.net Logo
Project space on SourceForge.net