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