Gaudi Framework, version v20r3

Generated: 24 Nov 2008

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 #define GAUDIKERNEL_DEBUGGER_CPP
00015 
00016 #ifdef _WIN32
00017 namespace Win   {
00018   #define NOMSG
00019   #define NOGDI
00020   #include "windows.h"
00021   #include "process.h"
00022   #undef NOMSG
00023   #undef NOGDI
00024 };
00025 #else
00026   #include <unistd.h>
00027 #endif
00028 
00029 // Framework include files
00030 #include "GaudiKernel/Debugger.h"
00031 
00033 long System::breakExecution()   {
00034 #ifdef _WIN32
00035   _asm int 3
00036   return 1;
00037 #else
00038   // I have no clu how to do this in linux
00039   return 0;
00040 #endif
00041 }
00042 
00044 long System::breakExecution(long pid)   {
00045 #ifdef _WIN32
00046   long result = 0;
00047   if ( pid == Win::_getpid() )    {
00048     _asm int 3
00049     return 1;
00050   }
00051   else    {
00052     Win::LPTHREAD_START_ROUTINE fun;
00053     Win::HANDLE th, ph;
00054     Win::HINSTANCE mh;
00055     Win::DWORD id;
00056     mh = Win::LoadLibrary( "Kernel32" );
00057     if ( 0 != mh )    {
00058       fun = (Win::LPTHREAD_START_ROUTINE)Win::GetProcAddress(mh, "DebugBreak");
00059       if ( 0 != fun )   {
00060         ph = Win::OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
00061         if ( 0 != ph )      {
00062           th = Win::CreateRemoteThread(ph,NULL,0,fun,0,0,&id);
00063           if ( 0 != th )   {
00064             Win::CloseHandle(th);
00065             result = 1;
00066           }
00067           Win::CloseHandle(ph);
00068         }
00069       }
00070       Win::FreeLibrary(mh);
00071     }
00072   }
00073   if ( result != 1 ) result = Win::GetLastError();
00074   return result;
00075 #else
00076   // I have no clu how to do this in linux
00077   return pid;
00078 #endif
00079 }
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 

Generated at Mon Nov 24 14:38:47 2008 for Gaudi Framework, version v20r3 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004