static void waitForBreak(uint64_t breakAddress, const CPUState* cpuState, uint64_t checkMask) { CPUState outState; //printf("wait for break $%llx\n", breakAddress); for (int i = 0; i < 12; ++i) { uint64_t address = 0; PDReader* reader = s_session->reader; PDBinaryReader_initStream(reader, PDBinaryWriter_getData(s_session->currentWriter), PDBinaryWriter_getSize(s_session->currentWriter)); if (getExceptionLocation(reader, &address, &outState)) { if (checkMask & CPUState_maskA) assert_true(cpuState->a == outState.a); if (checkMask & CPUState_maskX) assert_true(cpuState->x == outState.x); if (checkMask & CPUState_maskY) assert_int_equal(cpuState->y, outState.y); assert_int_equal((int)address, (int)breakAddress); return; } Time_sleepMs(1); Session_update(s_session); } fail(); }
static void test_lldb(void** state) { (void)state; // we only do the LLDB test on Mac for now #ifdef __APPLE__ PluginData* pluginData; Session* session; int count = 0; assert_true(PluginHandler_addPlugin(OBJECT_DIR, "lldb_plugin")); assert_non_null(pluginData = PluginHandler_getBackendPlugins(&count)[0]); session = Session_createLocal((PDBackendPlugin*)pluginData->plugin, OBJECT_DIR "/crashing_native"); assert_non_null(session); // I hate to do this but there is really no good way to deal with this otherwise (at least currently) Time_sleepMs(800); Session_update(session); Session_update(session); // Expect that we have a crash here and thus are in PDDebugState_stopException state assert_int_equal(session->state, PDDebugState_StopException); // Request locals location. PDWriter* writer = session->currentWriter; PDReader* reader = session->reader; PDWrite_event_begin(writer, PDEventType_GetCallstack); PDWrite_u8(writer, "dummy", 0); PDWrite_event_end(writer); Session_update(session); PDBinaryWriter_finalize(session->currentWriter); PDBinaryReader_initStream(reader, PDBinaryWriter_getData(session->currentWriter), PDBinaryWriter_getSize(session->currentWriter)); uint32_t event; bool foundCallstack = false; while ((event = PDRead_get_event(reader)) != 0) { switch (event) { case PDEventType_SetCallstack: { foundCallstack = true; break; } } } assert_true(foundCallstack); #endif }
static void test_c64_vice_connect(void**) { int count = 0; PluginData* pluginData; pluginData = PluginHandler_getBackendPlugins(&count)[0]; // Lanuch C64 VICE // TODO: Fix hardcoded path #ifdef PRODBG_MAC //const char* viceLaunchPath = "../../vice/x64.app/Contents/MacOS/x64"; const char* viceLaunchPath = "/Applications/VICE/x64.app/Contents/MacOS/x64"; #elif PRODBG_WIN const char* viceLaunchPath = "..\\..\\vice\\x64.exe"; #else // Not supported on Linux yet const char* viceLaunchPath = 0; #endif assert_non_null(viceLaunchPath); //const char* argv[] = { viceLaunchPath, "-remotemonitor", "-console", "examples/c64_vice/test.prg", 0 }; const char* argv[] = { viceLaunchPath, "-remotemonitor", "-console", 0 }; s_viceHandle = Process_spawn(viceLaunchPath, argv); assert_non_null(s_viceHandle); // Wait 3 sec for VICE to launch Time_sleepMs(3000); // TODO: Non hard-coded path s_session = Session_createLocal((PDBackendPlugin*)pluginData->plugin, 0); // make sure we attach to VICE PDWriter* writer = s_session->currentWriter; PDWrite_eventBegin(writer, PDEventType_menuEvent); PDWrite_u32(writer, "menu_id", 0); PDWrite_eventEnd(writer); Session_update(s_session); // We haven't setup vice at this point so no connect assert_int_not_equal(s_session->state, PDDebugState_noTarget); }
void test_c64_vice_start_executable(void**) { const char* prgFile = "/Users/danielcollin/code/ProDBG/examples/c64_vice/test.prg"; PDWriter* writer = s_session->currentWriter; PDWrite_eventBegin(writer, PDEventType_setExecutable); PDWrite_string(writer, "filename", prgFile); PDWrite_eventEnd(writer); PDBinaryWriter_finalize(writer); Session_update(s_session); // Annoying to da anything about this as VICE doesn't reply back anything // when doing <g $xxx> Time_sleepMs(200); }
static void stepToPC(uint64_t pc) { // first we step the CPU se we have the PC at known position, we try to step 10 times // and if we don't get the correct PC with in that time we fail the test for (int i = 0; i < 10; ++i) { CPUState state; Session_action(s_session, PDAction_step); //Session_update(s_session); assert_true(handleEvents(&state, s_session)); if (state.pc == pc) break; if (i == 9) fail(); Time_sleepMs(1); } }