Commit 33db5b78 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

ntdll/tests: Introduce enumeration to handle stages in test_debugger().

It'll be easier to add stages. Signed-off-by: 's avatarEric Pouech <epouech@codeweavers.com>
parent b7004335
......@@ -190,14 +190,34 @@ static VOID (WINAPI *pRtlUnwindEx)(VOID*, VOID*, EXCEPTION_RECORD*, VOID*,
static int (CDECL *p_setjmp)(_JUMP_BUFFER*);
#endif
enum debugger_stages
{
STAGE_RTLRAISE_NOT_HANDLED = 1,
STAGE_RTLRAISE_HANDLE_LAST_CHANCE,
STAGE_OUTPUTDEBUGSTRINGA_CONTINUE,
STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED,
STAGE_RIPEVENT_CONTINUE,
STAGE_RIPEVENT_NOT_HANDLED,
STAGE_SERVICE_CONTINUE,
STAGE_SERVICE_NOT_HANDLED,
STAGE_BREAKPOINT_CONTINUE,
STAGE_BREAKPOINT_NOT_HANDLED,
STAGE_EXCEPTION_INVHANDLE_CONTINUE,
STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED,
STAGE_NO_EXCEPTION_INVHANDLE_NOT_HANDLED,
STAGE_XSTATE,
STAGE_XSTATE_LEGACY_SSE,
STAGE_SEGMENTS,
};
static int my_argc;
static char** my_argv;
static BOOL is_wow64;
static BOOL have_vectored_api;
static int test_stage;
static enum debugger_stages test_stage;
#if defined(__i386__) || defined(__x86_64__)
static void test_debugger_xstate(HANDLE thread, CONTEXT *ctx, int stage)
static void test_debugger_xstate(HANDLE thread, CONTEXT *ctx, enum debugger_stages stage)
{
char context_buffer[sizeof(CONTEXT) + sizeof(CONTEXT_EX) + sizeof(XSTATE) + 1024];
CONTEXT_EX *c_ex;
......@@ -212,7 +232,7 @@ static void test_debugger_xstate(HANDLE thread, CONTEXT *ctx, int stage)
if (!pRtlGetEnabledExtendedFeatures || !pRtlGetEnabledExtendedFeatures(1 << XSTATE_AVX))
return;
if (stage == 14)
if (stage == STAGE_XSTATE)
return;
length = sizeof(context_buffer);
......@@ -525,7 +545,7 @@ static DWORD rtlraiseexception_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
/* give the debugger a chance to examine the state a second time */
/* without the exception handler changing Eip */
if (test_stage == 2)
if (test_stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
return ExceptionContinueSearch;
/* Eip in context is decreased by 1
......@@ -1110,7 +1130,7 @@ static void test_debugger(DWORD cont_status)
else if (de.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
CONTEXT ctx;
int stage;
enum debugger_stages stage;
counter++;
status = pNtReadVirtualMemory(pi.hProcess, &code_mem, &code_mem_address,
......@@ -1146,7 +1166,7 @@ static void test_debugger(DWORD cont_status)
}
else
{
if (stage == 1)
if (stage == STAGE_RTLRAISE_NOT_HANDLED)
{
ok((char *)ctx.Eip == (char *)code_mem_address + 0xb, "Eip at %lx instead of %p\n",
ctx.Eip, (char *)code_mem_address + 0xb);
......@@ -1157,7 +1177,7 @@ static void test_debugger(DWORD cont_status)
/* let the debuggee handle the exception */
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 2)
else if (stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
{
if (de.u.Exception.dwFirstChance)
{
......@@ -1193,25 +1213,25 @@ static void test_debugger(DWORD cont_status)
/* here we handle exception */
}
}
else if (stage == 7 || stage == 8)
else if (stage == STAGE_SERVICE_CONTINUE || stage == STAGE_SERVICE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Eip == (char *)code_mem_address + 0x1d,
"expected Eip = %p, got 0x%lx\n", (char *)code_mem_address + 0x1d, ctx.Eip);
if (stage == 8) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_SERVICE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 9 || stage == 10)
else if (stage == STAGE_BREAKPOINT_CONTINUE || stage == STAGE_BREAKPOINT_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Eip == (char *)code_mem_address + 2,
"expected Eip = %p, got 0x%lx\n", (char *)code_mem_address + 2, ctx.Eip);
if (stage == 10) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_BREAKPOINT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 11 || stage == 12)
else if (stage == STAGE_EXCEPTION_INVHANDLE_CONTINUE || stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_INVALID_HANDLE,
"unexpected exception code %08lx, expected %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode,
......@@ -1219,18 +1239,18 @@ static void test_debugger(DWORD cont_status)
ok(de.u.Exception.ExceptionRecord.NumberParameters == 0,
"unexpected number of parameters %ld, expected 0\n", de.u.Exception.ExceptionRecord.NumberParameters);
if (stage == 12) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 13)
else if (stage == STAGE_NO_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(FALSE || broken(TRUE) /* < Win10 */, "should not throw exception\n");
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 14 || stage == 15)
else if (stage == STAGE_XSTATE || stage == STAGE_XSTATE_LEGACY_SSE)
{
test_debugger_xstate(pi.hThread, &ctx, stage);
}
else if (stage == 16)
else if (stage == STAGE_SEGMENTS)
{
USHORT ss;
__asm__( "movw %%ss,%0" : "=r" (ss) );
......@@ -1258,7 +1278,7 @@ static void test_debugger(DWORD cont_status)
}
else if (de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT)
{
int stage;
enum debugger_stages stage;
char buffer[64];
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
......@@ -1274,22 +1294,22 @@ static void test_debugger(DWORD cont_status)
de.u.DebugString.nDebugStringLength, &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 3 || stage == 4)
if (stage == STAGE_OUTPUTDEBUGSTRINGA_CONTINUE || stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED)
ok(!strcmp(buffer, "Hello World"), "got unexpected debug string '%s'\n", buffer);
else /* ignore unrelated debug strings like 'SHIMVIEW: ShimInfo(Complete)' */
ok(strstr(buffer, "SHIMVIEW") != NULL, "unexpected stage %x, got debug string event '%s'\n", stage, buffer);
if (stage == 4) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (de.dwDebugEventCode == RIP_EVENT)
{
int stage;
enum debugger_stages stage;
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
sizeof(stage), &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 5 || stage == 6)
if (stage == STAGE_RIPEVENT_CONTINUE || stage == STAGE_RIPEVENT_NOT_HANDLED)
{
ok(de.u.RipInfo.dwError == 0x11223344, "got unexpected rip error code %08lx, expected %08x\n",
de.u.RipInfo.dwError, 0x11223344);
......@@ -1299,7 +1319,7 @@ static void test_debugger(DWORD cont_status)
else
ok(FALSE, "unexpected stage %x\n", stage);
if (stage == 6) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_RIPEVENT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, continuestatus);
......@@ -3651,7 +3671,7 @@ static void rtlraiseexception_handler_( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
/* give the debugger a chance to examine the state a second time */
/* without the exception handler changing pc */
if (test_stage == 2)
if (test_stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
return;
/* pc in context is decreased by 1
......@@ -3665,7 +3685,7 @@ static LONG CALLBACK rtlraiseexception_unhandled_handler(EXCEPTION_POINTERS *Exc
PCONTEXT context = ExceptionInfo->ContextRecord;
PEXCEPTION_RECORD rec = ExceptionInfo->ExceptionRecord;
rtlraiseexception_handler_(rec, NULL, context, NULL, TRUE);
if (test_stage == 2) return EXCEPTION_CONTINUE_SEARCH;
if (test_stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE) return EXCEPTION_CONTINUE_SEARCH;
return EXCEPTION_CONTINUE_EXECUTION;
}
......@@ -3673,7 +3693,7 @@ static DWORD rtlraiseexception_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
{
rtlraiseexception_handler_(rec, frame, context, dispatcher, FALSE);
if (test_stage == 2) return ExceptionContinueSearch;
if (test_stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE) return ExceptionContinueSearch;
return ExceptionContinueExecution;
}
......@@ -3739,7 +3759,7 @@ static void run_rtlraiseexception_test(DWORD exceptioncode)
todo_wine
ok( !rtlraiseexception_handler_called, "Frame handler called\n" );
todo_wine_if (test_stage != 2)
todo_wine_if (test_stage != STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
ok( rtlraiseexception_unhandled_handler_called, "UnhandledExceptionFilter wasn't called\n" );
if (have_vectored_api)
......@@ -3816,7 +3836,7 @@ static void test_debugger(DWORD cont_status)
else if (de.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
CONTEXT ctx;
int stage;
enum debugger_stages stage;
counter++;
status = pNtReadVirtualMemory(pi.hProcess, &code_mem, &code_mem_address,
......@@ -3853,7 +3873,7 @@ static void test_debugger(DWORD cont_status)
}
else
{
if (stage == 1)
if (stage == STAGE_RTLRAISE_NOT_HANDLED)
{
ok((char *)ctx.Rip == (char *)code_mem_address + 0x10, "Rip at %p instead of %p\n",
(char *)ctx.Rip, (char *)code_mem_address + 0x10);
......@@ -3864,7 +3884,7 @@ static void test_debugger(DWORD cont_status)
/* let the debuggee handle the exception */
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 2)
else if (stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
{
if (de.u.Exception.dwFirstChance)
{
......@@ -3892,23 +3912,23 @@ static void test_debugger(DWORD cont_status)
/* here we handle exception */
}
}
else if (stage == 7 || stage == 8)
else if (stage == STAGE_SERVICE_CONTINUE || stage == STAGE_SERVICE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Rip == (char *)code_mem_address + 0x30,
"expected Rip = %p, got %p\n", (char *)code_mem_address + 0x30, (char *)ctx.Rip);
if (stage == 8) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_SERVICE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 9 || stage == 10)
else if (stage == STAGE_BREAKPOINT_CONTINUE || stage == STAGE_BREAKPOINT_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Rip == (char *)code_mem_address + 2,
"expected Rip = %p, got %p\n", (char *)code_mem_address + 2, (char *)ctx.Rip);
if (stage == 10) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_BREAKPOINT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 11 || stage == 12)
else if (stage == STAGE_EXCEPTION_INVHANDLE_CONTINUE || stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_INVALID_HANDLE,
"unexpected exception code %08lx, expected %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode,
......@@ -3916,18 +3936,18 @@ static void test_debugger(DWORD cont_status)
ok(de.u.Exception.ExceptionRecord.NumberParameters == 0,
"unexpected number of parameters %ld, expected 0\n", de.u.Exception.ExceptionRecord.NumberParameters);
if (stage == 12) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 13)
else if (stage == STAGE_NO_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(FALSE || broken(TRUE) /* < Win10 */, "should not throw exception\n");
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 14 || stage == 15)
else if (stage == STAGE_XSTATE || stage == STAGE_XSTATE_LEGACY_SSE)
{
test_debugger_xstate(pi.hThread, &ctx, stage);
}
else if (stage == 16)
else if (stage == STAGE_SEGMENTS)
{
USHORT ss;
__asm__( "movw %%ss,%0" : "=r" (ss) );
......@@ -3959,7 +3979,7 @@ static void test_debugger(DWORD cont_status)
}
else if (de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT)
{
int stage;
enum debugger_stages stage;
char buffer[64];
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
......@@ -3975,22 +3995,22 @@ static void test_debugger(DWORD cont_status)
de.u.DebugString.nDebugStringLength, &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 3 || stage == 4)
if (stage == STAGE_OUTPUTDEBUGSTRINGA_CONTINUE || stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED)
ok(!strcmp(buffer, "Hello World"), "got unexpected debug string '%s'\n", buffer);
else /* ignore unrelated debug strings like 'SHIMVIEW: ShimInfo(Complete)' */
ok(strstr(buffer, "SHIMVIEW") != NULL, "unexpected stage %x, got debug string event '%s'\n", stage, buffer);
if (stage == 4) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (de.dwDebugEventCode == RIP_EVENT)
{
int stage;
enum debugger_stages stage;
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
sizeof(stage), &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 5 || stage == 6)
if (stage == STAGE_RIPEVENT_CONTINUE || stage == STAGE_RIPEVENT_NOT_HANDLED)
{
ok(de.u.RipInfo.dwError == 0x11223344, "got unexpected rip error code %08lx, expected %08x\n",
de.u.RipInfo.dwError, 0x11223344);
......@@ -4000,7 +4020,7 @@ static void test_debugger(DWORD cont_status)
else
ok(FALSE, "unexpected stage %x\n", stage);
if (stage == 6) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_RIPEVENT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, continuestatus);
......@@ -6634,7 +6654,7 @@ static void test_debugger(DWORD cont_status)
else if (de.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
CONTEXT ctx;
int stage;
enum debugger_stages stage;
counter++;
status = pNtReadVirtualMemory(pi.hProcess, &code_mem, &code_mem_address,
......@@ -6671,7 +6691,7 @@ static void test_debugger(DWORD cont_status)
}
else
{
if (stage == 1)
if (stage == STAGE_RTLRAISE_NOT_HANDLED)
{
ok((char *)ctx.Pc == (char *)code_mem_address + 0xb, "Pc at %lx instead of %p\n",
ctx.Pc, (char *)code_mem_address + 0xb);
......@@ -6682,7 +6702,7 @@ static void test_debugger(DWORD cont_status)
/* let the debuggee handle the exception */
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 2)
else if (stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
{
if (de.u.Exception.dwFirstChance)
{
......@@ -6711,23 +6731,23 @@ static void test_debugger(DWORD cont_status)
/* here we handle exception */
}
}
else if (stage == 7 || stage == 8)
else if (stage == STAGE_SERVICE_CONTINUE || stage == STAGE_SERVICE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Pc == (char *)code_mem_address + 0x1d,
"expected Pc = %p, got 0x%lx\n", (char *)code_mem_address + 0x1d, ctx.Pc);
if (stage == 8) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_SERVICE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 9 || stage == 10)
else if (stage == STAGE_BREAKPOINT_CONTINUE || stage == STAGE_BREAKPOINT_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Pc == (char *)code_mem_address + 3,
"expected Pc = %p, got 0x%lx\n", (char *)code_mem_address + 3, ctx.Pc);
if (stage == 10) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_BREAKPOINT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 11 || stage == 12)
else if (stage == STAGE_EXCEPTION_INVHANDLE_CONTINUE || stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_INVALID_HANDLE,
"unexpected exception code %08lx, expected %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode,
......@@ -6735,9 +6755,9 @@ static void test_debugger(DWORD cont_status)
ok(de.u.Exception.ExceptionRecord.NumberParameters == 0,
"unexpected number of parameters %ld, expected 0\n", de.u.Exception.ExceptionRecord.NumberParameters);
if (stage == 12) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 13)
else if (stage == STAGE_NO_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(FALSE || broken(TRUE) /* < Win10 */, "should not throw exception\n");
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
......@@ -6751,7 +6771,7 @@ static void test_debugger(DWORD cont_status)
}
else if (de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT)
{
int stage;
enum debugger_stages stage;
char buffer[64];
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
......@@ -6767,22 +6787,22 @@ static void test_debugger(DWORD cont_status)
de.u.DebugString.nDebugStringLength, &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 3 || stage == 4)
if (stage == STAGE_OUTPUTDEBUGSTRINGA_CONTINUE || stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED)
ok(!strcmp(buffer, "Hello World"), "got unexpected debug string '%s'\n", buffer);
else /* ignore unrelated debug strings like 'SHIMVIEW: ShimInfo(Complete)' */
ok(strstr(buffer, "SHIMVIEW") != NULL, "unexpected stage %x, got debug string event '%s'\n", stage, buffer);
if (stage == 4) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (de.dwDebugEventCode == RIP_EVENT)
{
int stage;
enum debugger_stages stage;
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
sizeof(stage), &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 5 || stage == 6)
if (stage == STAGE_RIPEVENT_CONTINUE || stage == STAGE_RIPEVENT_NOT_HANDLED)
{
ok(de.u.RipInfo.dwError == 0x11223344, "got unexpected rip error code %08lx, expected %08x\n",
de.u.RipInfo.dwError, 0x11223344);
......@@ -6792,7 +6812,7 @@ static void test_debugger(DWORD cont_status)
else
ok(FALSE, "unexpected stage %x\n", stage);
if (stage == 6) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_RIPEVENT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, continuestatus);
......@@ -7889,7 +7909,7 @@ static void test_debugger(DWORD cont_status)
else if (de.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
{
CONTEXT ctx;
int stage;
enum debugger_stages stage;
counter++;
status = pNtReadVirtualMemory(pi.hProcess, &code_mem, &code_mem_address,
......@@ -7926,7 +7946,7 @@ static void test_debugger(DWORD cont_status)
}
else
{
if (stage == 1)
if (stage == STAGE_RTLRAISE_NOT_HANDLED)
{
ok((char *)ctx.Pc == (char *)code_mem_address + 0xb, "Pc at %p instead of %p\n",
(char *)ctx.Pc, (char *)code_mem_address + 0xb);
......@@ -7937,7 +7957,7 @@ static void test_debugger(DWORD cont_status)
/* let the debuggee handle the exception */
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 2)
else if (stage == STAGE_RTLRAISE_HANDLE_LAST_CHANCE)
{
if (de.u.Exception.dwFirstChance)
{
......@@ -7966,23 +7986,23 @@ static void test_debugger(DWORD cont_status)
/* here we handle exception */
}
}
else if (stage == 7 || stage == 8)
else if (stage == STAGE_SERVICE_CONTINUE || stage == STAGE_SERVICE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Pc == (char *)code_mem_address + 0x1d,
"expected Pc = %p, got %p\n", (char *)code_mem_address + 0x1d, (char *)ctx.Pc);
if (stage == 8) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_SERVICE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 9 || stage == 10)
else if (stage == STAGE_BREAKPOINT_CONTINUE || stage == STAGE_BREAKPOINT_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT,
"expected EXCEPTION_BREAKPOINT, got %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode);
ok((char *)ctx.Pc == (char *)code_mem_address + 4,
"expected Pc = %p, got %p\n", (char *)code_mem_address + 4, (char *)ctx.Pc);
if (stage == 10) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_BREAKPOINT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 11 || stage == 12)
else if (stage == STAGE_EXCEPTION_INVHANDLE_CONTINUE || stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_INVALID_HANDLE,
"unexpected exception code %08lx, expected %08lx\n", de.u.Exception.ExceptionRecord.ExceptionCode,
......@@ -7990,9 +8010,9 @@ static void test_debugger(DWORD cont_status)
ok(de.u.Exception.ExceptionRecord.NumberParameters == 0,
"unexpected number of parameters %ld, expected 0\n", de.u.Exception.ExceptionRecord.NumberParameters);
if (stage == 12) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (stage == 13)
else if (stage == STAGE_NO_EXCEPTION_INVHANDLE_NOT_HANDLED)
{
ok(FALSE || broken(TRUE) /* < Win10 */, "should not throw exception\n");
continuestatus = DBG_EXCEPTION_NOT_HANDLED;
......@@ -8006,7 +8026,7 @@ static void test_debugger(DWORD cont_status)
}
else if (de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT)
{
int stage;
enum debugger_stages stage;
char buffer[128];
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
......@@ -8022,23 +8042,23 @@ static void test_debugger(DWORD cont_status)
de.u.DebugString.nDebugStringLength, &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 3 || stage == 4)
if (stage == STAGE_OUTPUTDEBUGSTRINGA_CONTINUE || stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED)
ok(!strcmp(buffer, "Hello World"), "got unexpected debug string '%s'\n", buffer);
else /* ignore unrelated debug strings like 'SHIMVIEW: ShimInfo(Complete)' */
ok(strstr(buffer, "SHIMVIEW") || !strncmp(buffer, "RTL:", 4),
"unexpected stage %x, got debug string event '%s'\n", stage, buffer);
if (stage == 4) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
else if (de.dwDebugEventCode == RIP_EVENT)
{
int stage;
enum debugger_stages stage;
status = pNtReadVirtualMemory(pi.hProcess, &test_stage, &stage,
sizeof(stage), &size_read);
ok(!status,"NtReadVirtualMemory failed with 0x%lx\n", status);
if (stage == 5 || stage == 6)
if (stage == STAGE_RIPEVENT_CONTINUE || stage == STAGE_RIPEVENT_NOT_HANDLED)
{
ok(de.u.RipInfo.dwError == 0x11223344, "got unexpected rip error code %08lx, expected %08x\n",
de.u.RipInfo.dwError, 0x11223344);
......@@ -8048,7 +8068,7 @@ static void test_debugger(DWORD cont_status)
else
ok(FALSE, "unexpected stage %x\n", stage);
if (stage == 6) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
if (stage == STAGE_RIPEVENT_NOT_HANDLED) continuestatus = DBG_EXCEPTION_NOT_HANDLED;
}
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, continuestatus);
......@@ -8973,12 +8993,12 @@ static void test_debuggee_xstate(void)
func();
for (i = 0; i < 4; ++i)
ok(data[i] == (test_stage == 14 ? i + 1 : 0x28282828),
ok(data[i] == (test_stage == STAGE_XSTATE ? i + 1 : 0x28282828),
"Got unexpected data %#x, test_stage %u, i %u.\n", data[i], test_stage, i);
for ( ; i < ARRAY_SIZE(data); ++i)
ok(data[i] == (test_stage == 14 ? i + 1 : 0x48484848)
|| broken(test_stage == 15 && data[i] == i + 1) /* Win7 */,
ok(data[i] == (test_stage == STAGE_XSTATE ? i + 1 : 0x48484848)
|| broken(test_stage == STAGE_XSTATE_LEGACY_SSE && data[i] == i + 1) /* Win7 */,
"Got unexpected data %#x, test_stage %u, i %u.\n", data[i], test_stage, i);
}
......@@ -11199,40 +11219,41 @@ START_TEST(exception)
#if defined(__i386__) || defined(__x86_64__)
if (pRtlRaiseException)
{
test_stage = 1;
test_stage = STAGE_RTLRAISE_NOT_HANDLED;
run_rtlraiseexception_test(0x12345);
run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
test_stage = 2;
test_stage = STAGE_RTLRAISE_HANDLE_LAST_CHANCE;
run_rtlraiseexception_test(0x12345);
run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
}
else skip( "RtlRaiseException not found\n" );
#endif
test_stage = 3;
test_stage = STAGE_OUTPUTDEBUGSTRINGA_CONTINUE;
test_outputdebugstring(FALSE, 0, FALSE, 0);
test_stage = 4;
test_stage = STAGE_OUTPUTDEBUGSTRINGA_NOT_HANDLED;
test_outputdebugstring(FALSE, 2, TRUE, 0); /* is 2 a Windows bug? */
test_stage = 5;
test_stage = STAGE_RIPEVENT_CONTINUE;
test_ripevent(0);
test_stage = 6;
test_stage = STAGE_RIPEVENT_NOT_HANDLED;
test_ripevent(1);
test_stage = 7;
test_stage = STAGE_SERVICE_CONTINUE;
test_debug_service(0);
test_stage = 8;
test_stage = STAGE_SERVICE_NOT_HANDLED;
test_debug_service(1);
test_stage = 9;
test_stage = STAGE_BREAKPOINT_CONTINUE;
test_breakpoint(0);
test_stage = 10;
test_stage = STAGE_BREAKPOINT_NOT_HANDLED;
test_breakpoint(1);
test_stage = 11;
test_stage = STAGE_EXCEPTION_INVHANDLE_CONTINUE;
test_closehandle(0, (HANDLE)0xdeadbeef);
test_closehandle(0, (HANDLE)0x7fffffff);
test_stage = 12;
test_stage = STAGE_EXCEPTION_INVHANDLE_NOT_HANDLED;
test_closehandle(1, (HANDLE)0xdeadbeef);
test_closehandle(1, (HANDLE)~(ULONG_PTR)6);
test_stage = 13; /* special cases */
test_stage = STAGE_NO_EXCEPTION_INVHANDLE_NOT_HANDLED; /* special cases */
test_closehandle(0, 0);
test_closehandle(0, INVALID_HANDLE_VALUE);
test_closehandle(0, GetCurrentProcess());
......@@ -11242,11 +11263,11 @@ START_TEST(exception)
test_closehandle(0, GetCurrentThreadToken());
test_closehandle(0, GetCurrentThreadEffectiveToken());
#if defined(__i386__) || defined(__x86_64__)
test_stage = 14;
test_stage = STAGE_XSTATE;
test_debuggee_xstate();
test_stage = 15;
test_stage = STAGE_XSTATE_LEGACY_SSE;
test_debuggee_xstate();
test_stage = 16;
test_stage = STAGE_SEGMENTS;
test_debuggee_segments();
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment