int test_top ( void ) { Stack_t *sp = NULL; Stack_t *sp1 = NULL; printf("*** test_top\n"); sp = StackCreate(4); (void)push(sp,100); (void)push(sp,200); (void)push(sp,300); (void)push(sp,700); StackDump(sp, 0); printf("\tTest01 return 700 %d\n", top(sp)); printf("\tTest02 return -1 %d NULL stack\n", top(NULL)); sp1 = StackCreate(4); printf("\tTest02 return -1 %d Empty Stack\n", top(sp1)); (void)StackDestroy(sp); (void)StackDestroy(sp1); printf("test_top - Ends\n"); return 0; }
static int Player_Mindtrick(lua_State *L){ jpluaEntity_t *entity = &ents[CheckPlayer(L, 1)->clientNum]; std::array<int, MAX_CLIENTS> out; out.fill(-1); //Clients who will be invisible for player { if (lua_type(L, -1) != LUA_TTABLE) { trap->Print("Player_Mindtrick failed, not a table\n"); StackDump(L); return 0; } lua_pushnil(L); for (int i = 0; i < MAX_CLIENTS && lua_next(L, -2); i++) { out[i] = lua_tointeger(L, -1); lua_pop(L, 1); } lua_pop(L, 1); } for (int i = 0; i < MAX_CLIENTS && out[i] != -1; i++){ gentity_t *ent = &g_entities[i]; Q_AddToBitflags(ent->client->ps.fd.forceMindtrickTargetIndex, entity->s.number, 16); } return 0; }
void CreateCallStack( LPVOID lpMem, SIZE_T dwBytes ) { if( !lpMem ) { return; } try { CSingleLock lockObj( &g_Config::SyncObj, TRUE ); if( g_Config::g_bHooked && g_Config::g_bTrack ) { g_Config::g_bTrack = false; StackDump( lpMem, dwBytes ); #ifdef ENABLE_LOG CString cs; cs.Format( "Allocating %x" ,(UINT)lpMem); OutputDebugString(cs); #endif g_Config::g_bTrack = true; } } catch(...) { } }
void __stdcall GLDebugLog(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { std::cerr << "\nOpenGL log (" << id << "): "; DebugLogStream(std::cerr, source, type, id, severity, length, message, userParam); StackDump((int)(userParam)); }
void __stdcall GLDebugLogOnce(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { static std::set<std::string> set; std::ostringstream ss; DebugLogStream(ss, source, type, id, severity, length, message, userParam); std::pair<std::set<std::string>::iterator, bool> ip = set.insert(ss.str()); if (ip.second) { std::cerr << "\nOpenGL log (" << id << "): " << *ip.first; StackDump((int)(userParam)); } }
int CPU_Dump ( CPU_t* Processor ) { #ifdef DEBUG freopen ( "dump.log", "a", stdout ); time_t RawTime = time ( NULL ); printf ( "\n\n$$$$$ Date: %s \n", ctime ( &RawTime ) ); int IsOutProcessor = 0; switch ( CPU_Errno ) { case ENOMEM: printf ( "-----> No memory for create structures \n\r" ); break; case EFAULT: printf ( "-----> Processors address no valid \n\r" ); break; case EAGAIN: printf ( "-----> Other address of inside field of processors no valid \n\r" ); break; case ESTCK: printf ( "|====> Dump stack: \n\r" ); StackDump ( Processor->CPUStack ); break; case ENOTDIR: printf ( "-----> No bin file! \n\r" ); break; case EBADF: printf ( "-----> Incorrect format bin file or size = 0! \n\r" ); break; case EINVAL: printf ( "-----> Incorrect arithmetic operation! \n\r" ); IsOutProcessor = 1; break; default: printf ( "-----> Unknown error! \n\r" ); IsOutProcessor = 1; } if ( IsOutProcessor == 1 ) { printf ( "Processor at address 0x%p:\n", Processor ); printf ( "The contents of the registers at address 0x%p:\n", Processor->CPURegister ); for ( int i = 0; i < MaxRegisters; i++ ) printf ( "%lg ", Processor->CPURegister[i] ); printf ( "\nThe contents of the RAM at address 0x%p:\n", Processor->RAM ); for ( int i = 0; i < Processor->RAM[9]; i++ ) printf ( "%lg ", Processor->RAM[i] ); printf ( "\nProgramCounter = %ld \n", Processor->ProgramCounter ); } printf ( "\n************************************************************************ " ); fclose ( stdout ); CPU_Errno = 0; #endif // DEBUG return 0; }
//____________________________________________________ int main() { const char *command = new const char[5]; double value; SProcessor *proc = new SProcessor; proc->ProcConstruct( ); proc->IsOk( ); scanf("%s", command ); while ( strcmp( command, "end" ) ) { if ( !strcmp( command, "push" ) ) { scanf("%lf", &value ); proc->stack->Push( value ); } if ( !strcmp( command, "pop" ) ) { proc->stack->Pop( );} if ( !strcmp( command, "add" ) ) { proc->Add( );} if ( !strcmp( command, "sub" ) ) { proc->Sub( );} if ( !strcmp( command, "mul" ) ) { proc->Mul( );} if ( !strcmp( command, "div" ) ) { proc->Div( );} if ( !strcmp( command, "pow" ) ) { proc->Pow( );} if ( !strcmp( command, "sin" ) ) { proc->Sin( );} if ( !strcmp( command, "cos" ) ) { proc->Cos( );} scanf("%s", command ); } StackDump( proc->stack ); proc->ProcDestruct( ); delete proc; return 0; }
int test_swap ( void ) { Stack_t *sp = NULL; Stack_t *sp1= NULL; Stack_t *sp2 = NULL; Stack_t *sp3 = NULL; Stack_t *sp4 = NULL; Stack_t *sp5 = NULL; Stack_t *sp6 = NULL; Stack_t *sp7 = NULL; Stack_t *sp8 = NULL; Stack_t *sp9 = NULL; printf("test_swap - create <int> stack\n"); sp = StackCreate(4); sp1= StackCreate(4); (void)push(sp,100); (void)push(sp,200); (void)push(sp,300); (void)push(sp,700); (void)push(sp1,101); (void)push(sp1,201); (void)push(sp1,301); (void)push(sp1,701); (void)StackDestroy(sp); printf("\tTest01 swap - same size, but stack freed -1 = %d\n", swap(sp,sp1)); /* * Test02 positive swap - same size */ sp2 = StackCreate(4); sp3 = StackCreate(4); (void)push(sp2,1); (void)push(sp2,2); (void)push(sp2,3); (void)push(sp2,4); printf("\tTest02 - before sp2\n"); StackDump(sp2,0); (void)push(sp3,5); (void)push(sp3,6); (void)push(sp3,7); (void)push(sp3,8); printf("\tTest02 - before sp3\n"); StackDump(sp3,0); printf("Test02 swap same size, but ok 0 = %d\n", swap(sp2,sp3)); printf("\tTest02 - after sp2\n"); StackDump(sp2,0); printf("\tTest02 - after sp3\n"); StackDump(sp3,0); /* * Test04 positive swap - src size is less than dst, will need to increase src */ sp6 = StackCreate(2); /* src */ sp7 = StackCreate(4); /* dst */ (void)push(sp6,1); (void)push(sp6,2); printf("\tTest04 - before sp6, size %d\n", size(sp6)); StackDump(sp6,0); (void)push(sp7,3); (void)push(sp7,4); (void)push(sp7,5); (void)push(sp7,4); printf("\tTest04 - before sp7, size %d\n", size(sp7)); StackDump(sp7,0); printf("Test04 swap dst size less than src size, but ok 0 = %d\n", swap(sp6,sp7)); printf("\tTest04 - after sp6, size %d\n", size(sp6)); StackDump(sp6,0); printf("\tTest04 - after sp7, size %d\n", size(sp7)); StackDump(sp7,0); /* * Test05 positive swap - dst size is less than src, will need to increase dst */ sp8 = StackCreate(2); /* dst */ sp9 = StackCreate(4); /* src */ (void)push(sp8,101); (void)push(sp8,201); printf("\tTest05 - before dst sp8, size %d\n", size(sp8)); StackDump(sp8,0); (void)push(sp9,301); (void)push(sp9,401); (void)push(sp9,501); (void)push(sp9,401); printf("\tTest05 - before src sp9, size %d\n", size(sp9)); StackDump(sp9,0); printf("Test05 swap dst size less than src size, but ok 0 = %d\n", swap(sp9,sp8)); printf("\tTest05 - after dst sp8, size %d\n", size(sp8)); StackDump(sp8,0); printf("\tTest05 - after src sp9, size %d\n", size(sp9)); StackDump(sp9,0); printf("test_swap - Ends\n"); StackDestroy(sp ); StackDestroy(sp1); StackDestroy(sp2); StackDestroy(sp3); StackDestroy(sp4); StackDestroy(sp5); StackDestroy(sp6); StackDestroy(sp7); StackDestroy(sp8); StackDestroy(sp9); return 0; }