| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 #else
21 // Empty macro to hide the references to the 'Win' namespace
22 #define Win
23 #endif
24
25 // Avoid conflicts between Windows' headers and MSG.
26 #ifndef NOMSG
27 # define NOMSG
28 # ifndef NOGDI
29 # define NOGDI
30 # endif
31 #endif
32 #include "windows.h"
33 #include "process.h"
34
35 #if _MSC_VER < 1500
36 }; // namespace Win
37 #endif
38
39 #else
40 #include <unistd.h>
41 #endif
42
43 // Framework include files
44 #include "GaudiKernel/Debugger.h"
45
47 long System::breakExecution() {
48 #ifdef _WIN32
49 _asm int 3
50 return 1;
51 #else
52 // I have no clue how to do this in linux
53 return 0;
54 #endif
55 }
56
58 long System::breakExecution(long pid) {
59 #ifdef _WIN32
60 long result = 0;
61 if ( pid == Win::_getpid() ) {
62 _asm int 3
63 return 1;
64 }
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
for job options legacy (TODO: get rid of these!) ----------------------—
Definition: Constants.py:20
System::breakExecution
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
Definition: Debugger.cpp:47
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26