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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/port.h"
29 #define WIN32_NO_STATUS
33 #include "ntdll_misc.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(debug_buffer);
38 static void dump_DEBUG_MODULE_INFORMATION(PDEBUG_MODULE_INFORMATION iBuf)
40 TRACE( "MODULE_INFORMATION:%p\n", iBuf );
41 if (NULL == iBuf) return ;
42 TRACE( "Base:%ld\n", iBuf->Base );
43 TRACE( "Size:%ld\n", iBuf->Size );
44 TRACE( "Flags:%ld\n", iBuf->Flags );
47 static void dump_DEBUG_HEAP_INFORMATION(PDEBUG_HEAP_INFORMATION iBuf)
49 TRACE( "HEAP_INFORMATION:%p\n", iBuf );
50 if (NULL == iBuf) return ;
51 TRACE( "Base:%ld\n", iBuf->Base );
52 TRACE( "Flags:%ld\n", iBuf->Flags );
55 static void dump_DEBUG_LOCK_INFORMATION(PDEBUG_LOCK_INFORMATION iBuf)
57 TRACE( "LOCK_INFORMATION:%p\n", iBuf );
59 if (NULL == iBuf) return ;
61 TRACE( "Address:%p\n", iBuf->Address );
62 TRACE( "Type:%d\n", iBuf->Type );
63 TRACE( "CreatorBackTraceIndex:%d\n", iBuf->CreatorBackTraceIndex );
64 TRACE( "OwnerThreadId:%ld\n", iBuf->OwnerThreadId );
65 TRACE( "ActiveCount:%ld\n", iBuf->ActiveCount );
66 TRACE( "ContentionCount:%ld\n", iBuf->ContentionCount );
67 TRACE( "EntryCount:%ld\n", iBuf->EntryCount );
68 TRACE( "RecursionCount:%ld\n", iBuf->RecursionCount );
69 TRACE( "NumberOfSharedWaiters:%ld\n", iBuf->NumberOfSharedWaiters );
70 TRACE( "NumberOfExclusiveWaiters:%ld\n", iBuf->NumberOfExclusiveWaiters );
73 static void dump_DEBUG_BUFFER(PDEBUG_BUFFER iBuf)
75 if (NULL == iBuf) return ;
76 TRACE( "SectionHandle:%p\n", iBuf->SectionHandle);
77 TRACE( "SectionBase:%p\n", iBuf->SectionBase);
78 TRACE( "RemoteSectionBase:%p\n", iBuf->RemoteSectionBase);
79 TRACE( "SectionBaseDelta:%ld\n", iBuf->SectionBaseDelta);
80 TRACE( "EventPairHandle:%p\n", iBuf->EventPairHandle);
81 TRACE( "RemoteThreadHandle:%p\n", iBuf->RemoteThreadHandle);
82 TRACE( "InfoClassMask:%lx\n", iBuf->InfoClassMask);
83 TRACE( "SizeOfInfo:%ld\n", iBuf->SizeOfInfo);
84 TRACE( "AllocatedSize:%ld\n", iBuf->AllocatedSize);
85 TRACE( "SectionSize:%ld\n", iBuf->SectionSize);
86 TRACE( "BackTraceInfo:%p\n", iBuf->BackTraceInformation);
87 dump_DEBUG_MODULE_INFORMATION(iBuf->ModuleInformation);
88 dump_DEBUG_HEAP_INFORMATION(iBuf->HeapInformation);
89 dump_DEBUG_LOCK_INFORMATION(iBuf->LockInformation);
92 PDEBUG_BUFFER WINAPI RtlCreateQueryDebugBuffer(IN ULONG iSize, IN BOOLEAN iEventPair)
94 PDEBUG_BUFFER oBuf = NULL;
95 FIXME("(%ld, %d): stub\n", iSize, iEventPair);
96 if (iSize < sizeof(DEBUG_BUFFER)) {
97 iSize = sizeof(DEBUG_BUFFER);
99 oBuf = (PDEBUG_BUFFER) RtlAllocateHeap(GetProcessHeap(), 0, iSize);
100 memset(oBuf, 0, iSize);
101 FIXME("(%ld, %d): returning %p\n", iSize, iEventPair, oBuf);
105 NTSTATUS WINAPI RtlDestroyQueryDebugBuffer(IN PDEBUG_BUFFER iBuf)
107 NTSTATUS nts = STATUS_SUCCESS;
108 FIXME("(%p): stub\n", iBuf);
110 if (NULL != iBuf->ModuleInformation) RtlFreeHeap(GetProcessHeap(), 0, iBuf->ModuleInformation);
111 if (NULL != iBuf->HeapInformation) RtlFreeHeap(GetProcessHeap(), 0, iBuf->HeapInformation);
112 if (NULL != iBuf->LockInformation) RtlFreeHeap(GetProcessHeap(), 0, iBuf->LockInformation);
113 RtlFreeHeap(GetProcessHeap(), 0, iBuf);
118 NTSTATUS WINAPI RtlQueryProcessDebugInformation(IN ULONG iProcessId, IN ULONG iDebugInfoMask, IN OUT PDEBUG_BUFFER iBuf)
120 NTSTATUS nts = STATUS_SUCCESS;
121 FIXME("(%ld, %lx, %p): stub\n", iProcessId, iDebugInfoMask, iBuf);
122 iBuf->InfoClassMask = iDebugInfoMask;
124 if (iDebugInfoMask & PDI_MODULES) {
125 PDEBUG_MODULE_INFORMATION info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_MODULE_INFORMATION));
126 memset(info, 0, sizeof(DEBUG_MODULE_INFORMATION));
127 iBuf->ModuleInformation = info;
129 if (iDebugInfoMask & PDI_HEAPS) {
130 PDEBUG_HEAP_INFORMATION info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_HEAP_INFORMATION));
131 memset(info, 0, sizeof(DEBUG_HEAP_INFORMATION));
132 if (iDebugInfoMask & PDI_HEAP_TAGS) {
134 if (iDebugInfoMask & PDI_HEAP_BLOCKS) {
136 iBuf->HeapInformation = info;
138 if (iDebugInfoMask & PDI_LOCKS) {
139 PDEBUG_LOCK_INFORMATION info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_LOCK_INFORMATION));
140 memset(info, 0, sizeof(DEBUG_LOCK_INFORMATION));
141 iBuf->LockInformation = info;
143 TRACE("returns:%p\n", iBuf);
144 dump_DEBUG_BUFFER(iBuf);