kernelbase/tests: Use win_skip() for missing APIs.
[wine.git] / dlls / ntdll / debugbuffer.c
blobf073207ac0605062d2f009414658732a360a24da
1 /*
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
21 #include <stdarg.h>
22 #include <stdlib.h>
23 #include <string.h>
25 #include "ntstatus.h"
26 #define WIN32_NO_STATUS
27 #include "windef.h"
28 #include "winnt.h"
29 #include "winternl.h"
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:%lx\n", iBuf->Base );
40 TRACE( "Size:%lx\n", iBuf->Size );
41 TRACE( "Flags:%lx\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:%lx\n", iBuf->Base );
49 TRACE( "Flags:%lx\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:%lx\n", iBuf->OwnerThreadId );
62 TRACE( "ActiveCount:%ld\n", iBuf->ActiveCount );
63 TRACE( "ContentionCount:%ld\n", iBuf->ContentionCount );
64 TRACE( "EntryCount:%ld\n", iBuf->EntryCount );
65 TRACE( "RecursionCount:%ld\n", iBuf->RecursionCount );
66 TRACE( "NumberOfSharedWaiters:%ld\n", iBuf->NumberOfSharedWaiters );
67 TRACE( "NumberOfExclusiveWaiters:%ld\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:%lx\n", iBuf->SectionBaseDelta);
77 TRACE( "EventPairHandle:%p\n", iBuf->EventPairHandle);
78 TRACE( "RemoteThreadHandle:%p\n", iBuf->RemoteThreadHandle);
79 TRACE( "InfoClassMask:%lx\n", iBuf->InfoClassMask);
80 TRACE( "SizeOfInfo:%ld\n", iBuf->SizeOfInfo);
81 TRACE( "AllocatedSize:%ld\n", iBuf->AllocatedSize);
82 TRACE( "SectionSize:%ld\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)
91 PDEBUG_BUFFER oBuf;
92 FIXME("(%ld, %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("(%ld, %d): returning %p\n", iSize, iEventPair, oBuf);
99 return oBuf;
102 NTSTATUS WINAPI RtlDestroyQueryDebugBuffer(IN PDEBUG_BUFFER iBuf)
104 NTSTATUS nts = STATUS_SUCCESS;
105 FIXME("(%p): stub\n", iBuf);
106 if (NULL != iBuf) {
107 RtlFreeHeap(GetProcessHeap(), 0, iBuf->ModuleInformation);
108 RtlFreeHeap(GetProcessHeap(), 0, iBuf->HeapInformation);
109 RtlFreeHeap(GetProcessHeap(), 0, iBuf->LockInformation);
110 RtlFreeHeap(GetProcessHeap(), 0, iBuf);
112 return nts;
115 NTSTATUS WINAPI RtlQueryProcessDebugInformation(IN ULONG iProcessId, IN ULONG iDebugInfoMask, IN OUT PDEBUG_BUFFER iBuf)
117 CLIENT_ID cid;
118 NTSTATUS status;
119 HANDLE process;
121 cid.UniqueProcess = ULongToHandle( iProcessId );
122 cid.UniqueThread = 0;
124 if ((status = NtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, NULL, &cid ))) return status;
125 NtClose( process );
127 FIXME("(%ld, %lx, %p): stub\n", iProcessId, iDebugInfoMask, iBuf);
128 iBuf->InfoClassMask = iDebugInfoMask;
130 if (iDebugInfoMask & PDI_MODULES) {
131 PDEBUG_MODULE_INFORMATION info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_MODULE_INFORMATION));
132 memset(info, 0, sizeof(DEBUG_MODULE_INFORMATION));
133 iBuf->ModuleInformation = info;
135 if (iDebugInfoMask & PDI_HEAPS) {
136 PDEBUG_HEAP_INFORMATION info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_HEAP_INFORMATION));
137 memset(info, 0, sizeof(DEBUG_HEAP_INFORMATION));
138 if (iDebugInfoMask & PDI_HEAP_TAGS) {
140 if (iDebugInfoMask & PDI_HEAP_BLOCKS) {
142 iBuf->HeapInformation = info;
144 if (iDebugInfoMask & PDI_LOCKS) {
145 PDEBUG_LOCK_INFORMATION info = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(DEBUG_LOCK_INFORMATION));
146 memset(info, 0, sizeof(DEBUG_LOCK_INFORMATION));
147 iBuf->LockInformation = info;
149 TRACE("returns:%p\n", iBuf);
150 dump_DEBUG_BUFFER(iBuf);
151 return status;