| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

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