| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Debugger.cpp
Go to the documentation of this file.
1 //====================================================================
2 // Debugger.cpp
3 //--------------------------------------------------------------------
4 //
5 // Package : System (The LHCb System service)
6 //
7 // Description: Invoke interactively the debugger from a
8 // running application
9 //
10 // Author : M.Frank
11 // Created : 13/1/99
12 // Changes :
13 //====================================================================
14 #if defined( _WIN32 )
15
16 #if _MSC_VER < 1500
17 // This causes a problem with VC9
18 // http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/cfb5a608-cc6c-49b5-8e9e-6e2cbeef43a3
19 namespace Win
20 {
21 #else
22 // Empty macro to hide the references to the 'Win' namespace
23 #define Win
24 #endif
25
26 // Avoid conflicts between Windows' headers and MSG.
27 #ifndef NOMSG
28 #define NOMSG
29 #ifndef NOGDI
30 #define NOGDI
31 #endif
32 #endif
33 #include "process.h"
34 #include "windows.h"
35
36 #if _MSC_VER < 1500
37 }; // namespace Win
38 #endif
39
40 #else
41 #include <unistd.h>
42 #endif
43
44 // Framework include files
45 #include "GaudiKernel/Debugger.h"
46
48 long System::breakExecution()
49 {
50 #ifdef _WIN32
51 _asm int 3 return 1;
52 #else
53 // I have no clue how to do this in linux
54 return 0;
55 #endif
56 }
57
59 long System::breakExecution( long pid )
60 {
61 #ifdef _WIN32
62 long result = 0;
63 if ( pid == Win::_getpid() ) {
64 _asm int 3 return 1;
65 } else {
66 Win::LPTHREAD_START_ROUTINE fun;
67 Win::HANDLE th, ph;
68 Win::HINSTANCE mh;
69 Win::DWORD id;
70 mh = Win::LoadLibrary( "Kernel32" );
71 if ( 0 != mh ) {
72 fun = (Win::LPTHREAD_START_ROUTINE)Win::GetProcAddress( mh, "DebugBreak" );
73 if ( 0 != fun ) {
74 ph = Win::OpenProcess( PROCESS_ALL_ACCESS, TRUE, pid );
75 if ( 0 != ph ) {
76 th = Win::CreateRemoteThread( ph, NULL, 0, fun, 0, 0, &id );
77 if ( 0 != th ) {
78 Win::CloseHandle( th );
79 result = 1;
80 }
81 Win::CloseHandle( ph );
82 }
83 }
84 Win::FreeLibrary( mh );
85 }
86 }
87 if ( result != 1 ) result = Win::GetLastError();
88 return result;
89 #else
90 // I have no clue how to do this in linux
91 return pid;
92 #endif
93 }
Debugger.h
GaudiKernel.Constants.TRUE
bool TRUE
Definition: Constants.py:20
System::breakExecution
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
Definition: Debugger.cpp:48
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26