2 * NtDll debug buffer functions
4 * Copyright 2004 Raphael Junqueira
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define WIN32_NO_STATUS
30 #include "ntdll_misc.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(debug_buffer
);
35 static void dump_DEBUG_MODULE_INFORMATION(const DEBUG_MODULE_INFORMATION
*iBuf
)
37 TRACE( "MODULE_INFORMATION:%p\n", iBuf
);
38 if (NULL
== iBuf
) return ;
39 TRACE( "Base:%d\n", iBuf
->Base
);
40 TRACE( "Size:%d\n", iBuf
->Size
);
41 TRACE( "Flags:%d\n", iBuf
->Flags
);
44 static void dump_DEBUG_HEAP_INFORMATION(const DEBUG_HEAP_INFORMATION
*iBuf
)
46 TRACE( "HEAP_INFORMATION:%p\n", iBuf
);
47 if (NULL
== iBuf
) return ;
48 TRACE( "Base:%d\n", iBuf
->Base
);
49 TRACE( "Flags:%d\n", iBuf
->Flags
);
52 static void dump_DEBUG_LOCK_INFORMATION(const DEBUG_LOCK_INFORMATION
*iBuf
)
54 TRACE( "LOCK_INFORMATION:%p\n", iBuf
);
56 if (NULL
== iBuf
) return ;
58 TRACE( "Address:%p\n", iBuf
->Address
);
59 TRACE( "Type:%d\n", iBuf
->Type
);
60 TRACE( "CreatorBackTraceIndex:%d\n", iBuf
->CreatorBackTraceIndex
);
61 TRACE( "OwnerThreadId:%d\n", iBuf
->OwnerThreadId
);
62 TRACE( "ActiveCount:%d\n", iBuf
->ActiveCount
);
63 TRACE( "ContentionCount:%d\n", iBuf
->ContentionCount
);
64 TRACE( "EntryCount:%d\n", iBuf
->EntryCount
);
65 TRACE( "RecursionCount:%d\n", iBuf
->RecursionCount
);
66 TRACE( "NumberOfSharedWaiters:%d\n", iBuf
->NumberOfSharedWaiters
);
67 TRACE( "NumberOfExclusiveWaiters:%d\n", iBuf
->NumberOfExclusiveWaiters
);
70 static void dump_DEBUG_BUFFER(const DEBUG_BUFFER
*iBuf
)
72 if (NULL
== iBuf
) return ;
73 TRACE( "SectionHandle:%p\n", iBuf
->SectionHandle
);
74 TRACE( "SectionBase:%p\n", iBuf
->SectionBase
);
75 TRACE( "RemoteSectionBase:%p\n", iBuf
->RemoteSectionBase
);
76 TRACE( "SectionBaseDelta:%d\n", iBuf
->SectionBaseDelta
);
77 TRACE( "EventPairHandle:%p\n", iBuf
->EventPairHandle
);
78 TRACE( "RemoteThreadHandle:%p\n", iBuf
->RemoteThreadHandle
);
79 TRACE( "InfoClassMask:%x\n", iBuf
->InfoClassMask
);
80 TRACE( "SizeOfInfo:%d\n", iBuf
->SizeOfInfo
);
81 TRACE( "AllocatedSize:%d\n", iBuf
->AllocatedSize
);
82 TRACE( "SectionSize:%d\n", iBuf
->SectionSize
);
83 TRACE( "BackTraceInfo:%p\n", iBuf
->BackTraceInformation
);
84 dump_DEBUG_MODULE_INFORMATION(iBuf
->ModuleInformation
);
85 dump_DEBUG_HEAP_INFORMATION(iBuf
->HeapInformation
);
86 dump_DEBUG_LOCK_INFORMATION(iBuf
->LockInformation
);
89 PDEBUG_BUFFER WINAPI
RtlCreateQueryDebugBuffer(IN ULONG iSize
, IN BOOLEAN iEventPair
)
92 FIXME("(%d, %d): stub\n", iSize
, iEventPair
);
93 if (iSize
< sizeof(DEBUG_BUFFER
)) {
94 iSize
= sizeof(DEBUG_BUFFER
);
96 oBuf
= RtlAllocateHeap(GetProcessHeap(), 0, iSize
);
97 memset(oBuf
, 0, iSize
);
98 FIXME("(%d, %d): returning %p\n", iSize
, iEventPair
, oBuf
);
102 NTSTATUS WINAPI
RtlDestroyQueryDebugBuffer(IN PDEBUG_BUFFER iBuf
)
104 NTSTATUS nts
= STATUS_SUCCESS
;
105 FIXME("(%p): stub\n", iBuf
);
107 RtlFreeHeap(GetProcessHeap(), 0, iBuf
->ModuleInformation
);
108 RtlFreeHeap(GetProcessHeap(), 0, iBuf
->HeapInformation
);
109 RtlFreeHeap(GetProcessHeap(), 0, iBuf
->LockInformation
);
110 RtlFreeHeap(GetProcessHeap(), 0, iBuf
);
115 NTSTATUS WINAPI
RtlQueryProcessDebugInformation(IN ULONG iProcessId
, IN ULONG iDebugInfoMask
, IN OUT PDEBUG_BUFFER iBuf
)
117 NTSTATUS nts
= STATUS_SUCCESS
;
118 FIXME("(%d, %x, %p): stub\n", iProcessId
, iDebugInfoMask
, iBuf
);
119 iBuf
->InfoClassMask
= iDebugInfoMask
;
121 if (iDebugInfoMask
& PDI_MODULES
) {
122 PDEBUG_MODULE_INFORMATION info
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_MODULE_INFORMATION
));
123 memset(info
, 0, sizeof(DEBUG_MODULE_INFORMATION
));
124 iBuf
->ModuleInformation
= info
;
126 if (iDebugInfoMask
& PDI_HEAPS
) {
127 PDEBUG_HEAP_INFORMATION info
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_HEAP_INFORMATION
));
128 memset(info
, 0, sizeof(DEBUG_HEAP_INFORMATION
));
129 if (iDebugInfoMask
& PDI_HEAP_TAGS
) {
131 if (iDebugInfoMask
& PDI_HEAP_BLOCKS
) {
133 iBuf
->HeapInformation
= info
;
135 if (iDebugInfoMask
& PDI_LOCKS
) {
136 PDEBUG_LOCK_INFORMATION info
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_LOCK_INFORMATION
));
137 memset(info
, 0, sizeof(DEBUG_LOCK_INFORMATION
));
138 iBuf
->LockInformation
= info
;
140 TRACE("returns:%p\n", iBuf
);
141 dump_DEBUG_BUFFER(iBuf
);