OSDN Git Service

* path.cc (conv_path_list): Take cygwin_conv_path_t as third parameter.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / debug.h
1 /* debug.h
2
3    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
4
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
7 details. */
8
9 #ifndef MALLOC_DEBUG
10 #define MALLOC_CHECK do {} while (0)
11 #else
12 #include <stdlib.h>
13 #include "dlmalloc.h"
14 #define MALLOC_CHECK ({\
15   debug_printf ("checking malloc pool");\
16   mallinfo ();\
17 })
18 #endif
19
20 #if !defined(_DEBUG_H_)
21 #define _DEBUG_H_
22
23 #define being_debugged() (IsDebuggerPresent ())
24
25 #ifndef DEBUGGING
26 # define cygbench(s)
27 # define ForceCloseHandle CloseHandle
28 # define ForceCloseHandle1(h, n) CloseHandle (h)
29 # define ForceCloseHandle2(h, n) CloseHandle (h)
30 # define ModifyHandle(h, n) do {} while (0)
31 # define ProtectHandle(h) do {} while (0)
32 # define ProtectHandle1(h,n) do {} while (0)
33 # define ProtectHandle2(h,n) do {} while (0)
34 # define ProtectHandleINH(h) do {} while (0)
35 # define ProtectHandle1INH(h,n) do {} while (0)
36 # define ProtectHandle2INH(h,n) do {} while (0)
37 # define debug_init() do {} while (0)
38 # define setclexec(h, nh, b) do {} while (0)
39 # define debug_fixup_after_fork_exec() do {} while (0)
40 # define VerifyHandle(h) do {} while (0)
41 # define console_printf small_printf
42
43 #else
44
45 # ifdef NO_DEBUG_DEFINES
46 #   undef NO_DEBUG_DEFINES
47 # else
48 #   define CloseHandle(h) \
49         close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, FALSE)
50 #   define ForceCloseHandle(h) \
51         close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, TRUE)
52 #   define ForceCloseHandle1(h,n) \
53         close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, TRUE)
54 #   define ForceCloseHandle2(h,n) \
55         close_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, TRUE)
56 # endif
57
58 # define ModifyHandle(h, n) modify_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, n)
59
60 # define ProtectHandle(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h)
61 # define ProtectHandle1(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n)
62 # define ProtectHandle2(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n)
63 # define ProtectHandleINH(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, 1)
64 # define ProtectHandle1INH(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, 1)
65 # define ProtectHandle2INH(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, 1)
66 # define VerifyHandle(h) verify_handle (__PRETTY_FUNCTION__, __LINE__, (h))
67
68 void debug_init ();
69 void __stdcall add_handle (const char *, int, HANDLE, const char *, bool = false)
70   __attribute__ ((regparm (3)));
71 void __stdcall verify_handle (const char *, int, HANDLE)
72   __attribute__ ((regparm (3)));
73 bool __stdcall close_handle (const char *, int, HANDLE, const char *, bool)
74   __attribute__ ((regparm (3)));
75 extern "C" void console_printf (const char *fmt,...);
76 void __stdcall cygbench (const char *s) __attribute__ ((regparm (1)));
77 void __stdcall modify_handle (const char *, int, HANDLE, const char *, bool)
78   __attribute__ ((regparm (3)));
79 void setclexec (HANDLE, HANDLE, bool);
80 void debug_fixup_after_fork_exec ();
81
82 struct handle_list
83   {
84     HANDLE h;
85     const char *name;
86     const char *func;
87     int ln;
88     bool inherited;
89     DWORD pid;
90     struct handle_list *next;
91   };
92
93 #endif /*DEBUGGING*/
94 #endif /*_DEBUG_H_*/