rsaenh: Avoid double 'va_end(args)' in case of a premature loop termination.
[wine.git] / dlls / ntdll / debugbuffer.c
blobef8baebda02b01de0e03bdc91e40d8ae97abaafe
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 "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <string.h>
28 #include "ntstatus.h"
29 #define WIN32_NO_STATUS
30 #include "windef.h"
31 #include "winnt.h"
32 #include "winternl.h"
33 #include "ntdll_misc.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(debug_buffer);
38 static void dump_DEBUG_MODULE_INFORMATION(const DEBUG_MODULE_INFORMATION *iBuf)
40 TRACE( "MODULE_INFORMATION:%p\n", iBuf );
41 if (NULL == iBuf) return ;
42 TRACE( "Base:%d\n", iBuf->Base );
43 TRACE( "Size:%d\n", iBuf->Size );
44 TRACE( "Flags:%d\n", iBuf->Flags );
47 static void dump_DEBUG_HEAP_INFORMATION(const DEBUG_HEAP_INFORMATION *iBuf)
49 TRACE( "HEAP_INFORMATION:%p\n", iBuf );
50 if (NULL == iBuf) return ;
51 TRACE( "Base:%d\n", iBuf->Base );
52 TRACE( "Flags:%d\n", iBuf->Flags );
55 static void dump_DEBUG_LOCK_INFORMATION(const DEBUG_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:%d\n", iBuf->OwnerThreadId );
65 TRACE( "ActiveCount:%d\n", iBuf->ActiveCount );
66 TRACE( "ContentionCount:%d\n", iBuf->ContentionCount );
67 TRACE( "EntryCount:%d\n", iBuf->EntryCount );
68 TRACE( "RecursionCount:%d\n", iBuf->RecursionCount );
69 TRACE( "NumberOfSharedWaiters:%d\n", iBuf->NumberOfSharedWaiters );
70 TRACE( "NumberOfExclusiveWaiters:%d\n", iBuf->NumberOfExclusiveWaiters );
73 static void dump_DEBUG_BUFFER(const DEBUG_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:%d\n", iBuf->SectionBaseDelta);
80 TRACE( "EventPairHandle:%p\n", iBuf->EventPairHandle);
81 TRACE( "RemoteThreadHandle:%p\n", iBuf->RemoteThreadHandle);
82 TRACE( "InfoClassMask:%x\n", iBuf->InfoClassMask);
83 TRACE( "SizeOfInfo:%d\n", iBuf->SizeOfInfo);
84 TRACE( "AllocatedSize:%d\n", iBuf->AllocatedSize);
85 TRACE( "SectionSize:%d\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;
95 FIXME("(%d, %d): stub\n", iSize, iEventPair);
96 if (iSize < sizeof(DEBUG_BUFFER)) {
97 iSize = sizeof(DEBUG_BUFFER);
99 oBuf = RtlAllocateHeap(GetProcessHeap(), 0, iSize);
100 memset(oBuf, 0, iSize);
101 FIXME("(%d, %d): returning %p\n", iSize, iEventPair, oBuf);
102 return oBuf;
105 NTSTATUS WINAPI RtlDestroyQueryDebugBuffer(IN PDEBUG_BUFFER iBuf)
107 NTSTATUS nts = STATUS_SUCCESS;
108 FIXME("(%p): stub\n", iBuf);
109 if (NULL != iBuf) {
110 RtlFreeHeap(GetProcessHeap(), 0, iBuf->ModuleInformation);
111 RtlFreeHeap(GetProcessHeap(), 0, iBuf->HeapInformation);
112 RtlFreeHeap(GetProcessHeap(), 0, iBuf->LockInformation);
113 RtlFreeHeap(GetProcessHeap(), 0, iBuf);
115 return nts;
118 NTSTATUS WINAPI RtlQueryProcessDebugInformation(IN ULONG iProcessId, IN ULONG iDebugInfoMask, IN OUT PDEBUG_BUFFER iBuf)
120 NTSTATUS nts = STATUS_SUCCESS;
121 FIXME("(%d, %x, %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);
145 return nts;