ReactOS 0.4.16-dev-125-g798ea90
stacktrace.c File Reference
#include "loadconfig.h"
Include dependency graph for stacktrace.c:

Go to the source code of this file.

Classes

struct  _RTL_PROCESS_BACKTRACE_INFORMATION_32
 

Typedefs

typedef struct _RTL_PROCESS_BACKTRACE_INFORMATION_32 RTL_PROCESS_BACKTRACE_INFORMATION_32
 
typedef struct _RTL_PROCESS_BACKTRACE_INFORMATION_32PRTL_PROCESS_BACKTRACE_INFORMATION_32
 

Functions

NTSTATUS NTAPI RtlQueryProcessBackTraceInformation (IN OUT PRTL_DEBUG_INFORMATION Buffer)
 
 __declspec (noinline)
 
static void Check_Stacktrace (PVOID *BackTrace, USHORT Depth)
 
static void test_QueryBacktrace (PRTL_DEBUG_INFORMATION Buffer1, PRTL_DEBUG_INFORMATION Buffer2)
 
 START_TEST (stacktrace)
 

Variables

static PVOID g_Call_Address
 
static PVOID g_PreviousReturnAddress
 

Typedef Documentation

◆ PRTL_PROCESS_BACKTRACE_INFORMATION_32

◆ RTL_PROCESS_BACKTRACE_INFORMATION_32

Function Documentation

◆ __declspec()

__declspec ( noinline  )

Definition at line 32 of file stacktrace.c.

34{
35 return _ReturnAddress();
36}
#define _ReturnAddress()
Definition: intrin_arm.h:35

◆ Check_Stacktrace()

static void Check_Stacktrace ( PVOID BackTrace,
USHORT  Depth 
)
static

Definition at line 60 of file stacktrace.c.

61{
62 ok(Depth > 2, "Unexpected Depth: %lu\n", (ULONG)Depth);
63 if (Depth > 2)
64 {
65 ULONG_PTR EndAddress = ((ULONG_PTR)g_Call_Address + 0x20);
66 ok(BackTrace[0] >= g_Call_Address && (ULONG_PTR)BackTrace[0] < EndAddress,
67 "Unexpected return: %p, expected between %p and %p\n", BackTrace[0], g_Call_Address, (PVOID)EndAddress);
68 ok(BackTrace[1] == g_PreviousReturnAddress, "Unexpected return: %p, expected: %p\n",
69 BackTrace[1], g_PreviousReturnAddress);
70 }
71}
#define ok(value,...)
Definition: atltest.h:57
#define ULONG_PTR
Definition: config.h:101
static PVOID g_PreviousReturnAddress
Definition: stacktrace.c:30
static PVOID g_Call_Address
Definition: stacktrace.c:29
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by test_QueryBacktrace().

◆ RtlQueryProcessBackTraceInformation()

NTSTATUS NTAPI RtlQueryProcessBackTraceInformation ( IN OUT PRTL_DEBUG_INFORMATION  Buffer)

Referenced by test_QueryBacktrace().

◆ START_TEST()

START_TEST ( stacktrace  )

Definition at line 142 of file stacktrace.c.

143{
144 PRTL_DEBUG_INFORMATION Buffer1, Buffer2;
145
146 if (!check_loadconfig())
147 return;
148
149 skip("QueryBacktrace not implemented yet\n");
150 return;
151
152 Buffer1 = RtlCreateQueryDebugBuffer(0, FALSE);
153 ok(Buffer1 != NULL, "Failed!\n");
154 if (Buffer1)
155 {
156 Buffer2 = RtlCreateQueryDebugBuffer(0, FALSE);
157 ok(Buffer2 != NULL, "Failed!\n");
158 if (Buffer2)
159 {
160 test_QueryBacktrace(Buffer1, Buffer2);
162 }
163
165 }
166}
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL check_loadconfig()
Definition: common.c:35
NTSYSAPI NTSTATUS NTAPI RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer)
NTSYSAPI PRTL_DEBUG_INFORMATION NTAPI RtlCreateQueryDebugBuffer(_In_ ULONG Size, _In_ BOOLEAN EventPair)
Definition: dbgbuffer.c:66
static void test_QueryBacktrace(PRTL_DEBUG_INFORMATION Buffer1, PRTL_DEBUG_INFORMATION Buffer2)
Definition: stacktrace.c:73

◆ test_QueryBacktrace()

static void test_QueryBacktrace ( PRTL_DEBUG_INFORMATION  Buffer1,
PRTL_DEBUG_INFORMATION  Buffer2 
)
static

Definition at line 73 of file stacktrace.c.

74{
76 USHORT StackTrace;
77 PRTL_PROCESS_BACKTRACES Backtraces;
78 ULONG OldNumberOfBackTraces, n;
80 int found = 0;
81
85 return;
86
87 Backtraces = Buffer1->BackTraces;
88 ok(Backtraces != NULL, "No BackTraces\n");
89 if (!Backtraces)
90 return;
91
92 OldNumberOfBackTraces = Backtraces->NumberOfBackTraces;
93 // Capture a stacktrace
94 StackTrace = Call_Backtrace_1();
95
96 // Show that the old debugbuffer is not changed
97 ok(OldNumberOfBackTraces == Backtraces->NumberOfBackTraces, "Debug buffer changed! (%lu => %lu)\n",
98 OldNumberOfBackTraces, Backtraces->NumberOfBackTraces);
99
100 // Ask for a new snapshot
103 if (Status != STATUS_SUCCESS)
104 return;
105
106 Backtraces = Buffer2->BackTraces;
107 ok(Backtraces != NULL, "No BackTraces\n");
108 if (!Backtraces)
109 return;
110
111 ok(OldNumberOfBackTraces+1 == Backtraces->NumberOfBackTraces, "Stacktrace not added! (%lu => %lu)\n",
112 OldNumberOfBackTraces, Backtraces->NumberOfBackTraces);
113
114 FirstBacktrace = (PRTL_PROCESS_BACKTRACE_INFORMATION_32)&Backtraces->BackTraces[0];
115 trace("NumberOfBackTraces=%lu\n", Backtraces->NumberOfBackTraces);
116 for (n = 0; n < Backtraces->NumberOfBackTraces; ++n)
117 {
119#if 0
120 USHORT j;
121
122 trace("BackTraces[%02lu]->SymbolicBackTrace = %p\n", n, Info->SymbolicBackTrace);
123 trace("BackTraces[%02lu]->TraceCount = %lu\n", n, Info->TraceCount);
124 trace("BackTraces[%02lu]->Index = %lu\n", n, (ULONG)Info->Index);
125 trace("BackTraces[%02lu]->Depth = %lu\n", n, (ULONG)Info->Depth);
126 for (j = 0; j < Info->Depth; ++j)
127 {
128 trace("BackTraces[%02lu]->BackTrace[%02u] = %p\n", n, j, Info->BackTrace[j]);
129 }
130 trace("\n");
131#endif
132 if (Info->Index == StackTrace)
133 {
134 found = 1;
135 Check_Stacktrace(Info->BackTrace, Info->Depth);
136 }
137 }
138 ok(found, "Stacktrace not found :(\n");
139}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Check_Stacktrace(PVOID *BackTrace, USHORT Depth)
Definition: stacktrace.c:60
NTSTATUS NTAPI RtlQueryProcessBackTraceInformation(IN OUT PRTL_DEBUG_INFORMATION Buffer)
struct _RTL_PROCESS_BACKTRACE_INFORMATION_32 * PRTL_PROCESS_BACKTRACE_INFORMATION_32
PRTL_PROCESS_BACKTRACES BackTraces
Definition: rtltypes.h:1205
RTL_PROCESS_BACKTRACE_INFORMATION BackTraces[1]
Definition: rtltypes.h:1173
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by START_TEST().

Variable Documentation

◆ g_Call_Address

PVOID g_Call_Address
static

Definition at line 29 of file stacktrace.c.

Referenced by Check_Stacktrace().

◆ g_PreviousReturnAddress

PVOID g_PreviousReturnAddress
static

Definition at line 30 of file stacktrace.c.

Referenced by Check_Stacktrace().