Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

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

Generated at Wed Nov 21 12:22:03 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000