Gaudi Framework, version v22r1

Home   Generated: Mon Feb 28 2011

Debugger.cpp

Go to the documentation of this file.
00001 //====================================================================
00002 //      Debugger.cpp
00003 //--------------------------------------------------------------------
00004 //
00005 //      Package    : System (The LHCb System service)
00006 //
00007 //  Description: Invoke interactively the debugger from a
00008 //               running application
00009 //
00010 //      Author     : M.Frank
00011 //  Created    : 13/1/99
00012 //      Changes    :
00013 //====================================================================
00014 #if defined(_WIN32)
00015 
00016 #if _MSC_VER < 1500
00017 // This causes a problem with VC9
00018 // http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/cfb5a608-cc6c-49b5-8e9e-6e2cbeef43a3
00019 namespace Win {
00020 #else
00021 // Empty macro to hide the references to the 'Win' namespace
00022 #define Win
00023 #endif
00024 
00025 // Avoid conflicts between Windows' headers and MSG.
00026 #ifndef NOMSG
00027 #  define NOMSG
00028 #  ifndef NOGDI
00029 #    define NOGDI
00030 #  endif
00031 #endif
00032 #include "windows.h"
00033 #include "process.h"
00034 
00035 #if _MSC_VER < 1500
00036 }; // namespace Win
00037 #endif
00038 
00039 #else
00040   #include <unistd.h>
00041 #endif
00042 
00043 // Framework include files
00044 #include "GaudiKernel/Debugger.h"
00045 
00047 long System::breakExecution()   {
00048 #ifdef _WIN32
00049   _asm int 3
00050   return 1;
00051 #else
00052   // I have no clue how to do this in linux
00053   return 0;
00054 #endif
00055 }
00056 
00058 long System::breakExecution(long pid)   {
00059 #ifdef _WIN32
00060   long result = 0;
00061   if ( pid == Win::_getpid() )    {
00062     _asm int 3
00063     return 1;
00064   }
00065   else    {
00066     Win::LPTHREAD_START_ROUTINE fun;
00067     Win::HANDLE th, ph;
00068     Win::HINSTANCE mh;
00069     Win::DWORD id;
00070     mh = Win::LoadLibrary( "Kernel32" );
00071     if ( 0 != mh )    {
00072       fun = (Win::LPTHREAD_START_ROUTINE)Win::GetProcAddress(mh, "DebugBreak");
00073       if ( 0 != fun )   {
00074         ph = Win::OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
00075         if ( 0 != ph )      {
00076           th = Win::CreateRemoteThread(ph,NULL,0,fun,0,0,&id);
00077           if ( 0 != th )   {
00078             Win::CloseHandle(th);
00079             result = 1;
00080           }
00081           Win::CloseHandle(ph);
00082         }
00083       }
00084       Win::FreeLibrary(mh);
00085     }
00086   }
00087   if ( result != 1 ) result = Win::GetLastError();
00088   return result;
00089 #else
00090   // I have no clue how to do this in linux
00091   return pid;
00092 #endif
00093 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Feb 28 2011 18:27:13 for Gaudi Framework, version v22r1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004