1 | /* $Id: debug.cpp,v 1.6 2001-04-05 05:54:51 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 debug Subsystem for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1999 Edgar Buerkle
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | /*****************************************************************************
|
---|
13 | * Includes *
|
---|
14 | *****************************************************************************/
|
---|
15 | #include <os2win.h>
|
---|
16 | #include <misc.h>
|
---|
17 | #include <unicode.h>
|
---|
18 | #include "oslibdebug.h"
|
---|
19 |
|
---|
20 | #define DBG_LOCALLOG DBG_debug
|
---|
21 | #include "dbglocal.h"
|
---|
22 |
|
---|
23 | /*****************************************************************************
|
---|
24 | * Name : BOOL WaitForDebugEvent
|
---|
25 | * Purpose : The WaitForDebugEvent function waits for a debugging event to
|
---|
26 | * occur in a process being debugged.
|
---|
27 | * Parameters: LPDEBUG_EVENT lpde address of structure for event information
|
---|
28 | * DWORD dwTimeout number of milliseconds to wait for event
|
---|
29 | * Variables :
|
---|
30 | * Result : TRUE / FALSE
|
---|
31 | * Remark :
|
---|
32 | * Status : UNTESTED STUB
|
---|
33 | *
|
---|
34 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
35 | *****************************************************************************/
|
---|
36 | BOOL WIN32API WaitForDebugEvent(LPDEBUG_EVENT lpde, DWORD dwTimeout)
|
---|
37 | {
|
---|
38 | dprintf(("KERNEL32: WaitForDebugEvent timeout:%d\n", dwTimeout));
|
---|
39 |
|
---|
40 | return OSLibWaitForDebugEvent(lpde, dwTimeout);
|
---|
41 | }
|
---|
42 | /*****************************************************************************
|
---|
43 | * Name : BOOL WIN32API ContinueDebugEvent
|
---|
44 | * Purpose : The ContinueDebugEvent function enables a debugger to continue
|
---|
45 | * a thread that previously reported a debugging event.
|
---|
46 | * Parameters: DWORD dwProcessId process to continue
|
---|
47 | * DWORD dwThreadId thread to continue
|
---|
48 | * DWORD dwContinueStatus continuation status
|
---|
49 | * Variables :
|
---|
50 | * Result : If the function succeeds, the return value is nonzero.
|
---|
51 | * If the function fails, the return value is zero.
|
---|
52 | * To get extended error information, call GetLastError.
|
---|
53 | * Remark : Only the thread that created dwProcessId with the CreateProcess
|
---|
54 | * function can call ContinueDebugEvent.
|
---|
55 | * After the ContinueDebugEvent function succeeds, the specified
|
---|
56 | * thread continues. Depending on the debugging event previously
|
---|
57 | * reported by the thread, different actions occur. If the continued
|
---|
58 | * thread previously reported an EXIT_THREAD_DEBUG_EVENT
|
---|
59 | * debugging event, ContinueDebugEvent closes the handle the
|
---|
60 | * debugger has to the thread. If the continued thread previously
|
---|
61 | * reported an EXIT_PROCESS_DEBUG_EVENT debugging event,
|
---|
62 | * ContinueDebugEvent closes the handles the debugger has to the
|
---|
63 | * process and to the thread.
|
---|
64 | * Status : UNTESTED STUB
|
---|
65 | *
|
---|
66 | * Author : Markus Montkowski [Thu, 1998/05/19 11:46]
|
---|
67 | *****************************************************************************/
|
---|
68 | BOOL WIN32API ContinueDebugEvent( DWORD dwProcessId, DWORD dwThreadId,
|
---|
69 | DWORD dwContinueStatus)
|
---|
70 | {
|
---|
71 |
|
---|
72 | dprintf(("KERNEL32: ContinueDebugEvent(%08x,%08x,%08x)not correctly implemented\n",
|
---|
73 | dwProcessId, dwThreadId, dwContinueStatus));
|
---|
74 |
|
---|
75 | return OSLibContinueDebugEvent(dwProcessId, dwThreadId, dwContinueStatus);
|
---|
76 | }
|
---|
77 | //******************************************************************************
|
---|
78 | //******************************************************************************
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Query if the calling process is running under the context of a debugger.
|
---|
82 | * @returns TRUE (non-zero) Debugged.
|
---|
83 | * FALSE Not debugged.
|
---|
84 | * @status STUB
|
---|
85 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
86 | * @remark An application could use this API to determin whether or not it is
|
---|
87 | * being debugged, so that it can change behaviour and for example
|
---|
88 | * provide more debug information using functions like OutputDebugString.
|
---|
89 | *
|
---|
90 | * You could change the result of this by SET ODIN32.DEBUGGERPRESENT=1 on
|
---|
91 | * the commandline.
|
---|
92 | */
|
---|
93 | BOOL WIN32API IsDebuggerPresent(VOID)
|
---|
94 | {
|
---|
95 | BOOL fRet = getenv("ODIN32.DEBUGGERPRESENT") != NULL;
|
---|
96 | dprintf(("KERNEL32: IsDebuggerPresent() -> %s\n", fRet ? "TRUE" : "FALSE"));
|
---|
97 | return fRet;
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Send a string to the debugger for the current application.
|
---|
103 | * @param lpszOutputString Pointer to the string to send to the debugger. (intput)
|
---|
104 | * @sketch Convert and log the string.
|
---|
105 | * @status STUB
|
---|
106 | * @author Sander van Leeuwen
|
---|
107 | * @remark The string is send to the system debugger if there is no
|
---|
108 | * debugger available for this application.
|
---|
109 | * If the application has not debugger and the system debugger
|
---|
110 | * is not active this API does nothing.
|
---|
111 | */
|
---|
112 | VOID WIN32API OutputDebugStringW(LPCWSTR lpszOutputString)
|
---|
113 | {
|
---|
114 | char *pszAscii = UnicodeToAsciiString((LPWSTR)lpszOutputString);
|
---|
115 | dprintf(("KERNEL32: OS2OutputDebugStringW %s\n", pszAscii));
|
---|
116 | FreeAsciiString(pszAscii);
|
---|
117 | }
|
---|
118 |
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Send a string to the debugger for the current application.
|
---|
122 | * @param lpszOutputString Pointer to the string to send to the debugger. (input)
|
---|
123 | * @sketch Log the string.
|
---|
124 | * @status STUB
|
---|
125 | * @author Sander van Leeuwen
|
---|
126 | * @remark The string is send to the system debugger if there is no
|
---|
127 | * debugger available for this application.
|
---|
128 | * If the application has not debugger and the system debugger
|
---|
129 | * is not active this API does nothing.
|
---|
130 | */
|
---|
131 | VOID WIN32API OutputDebugStringA(LPCSTR lpszOutputString)
|
---|
132 | {
|
---|
133 | dprintf(("KERNEL32: OutputDebugStringA: %s\n", lpszOutputString));
|
---|
134 | }
|
---|
135 |
|
---|