void frame::printRegs() { sparc_sp *sp= my_sp(); const fint step = 4; fint i= 0; for (Location l= L0; l <= I7; i++, l= Location(l+1)) { int32* p= (int32*)location_addr(l); if (i % step == 0) { lprintf("%#0lx ", p); printLocation(l); lprintf("-"); printLocation(Location(l+step-1)); lprintf(": "); } lprintf("%#10x", (void*)*p); if ((i + 1) % step == 0) lprintf("\n"); } }
void MyAsserts::ae( string a , string b ){ Result::cur->_asserts++; if ( a == b ) return; printLocation(); log() << a << " != " << b << endl; throw -1; }
void frame::printVerbose_on_this_platform() { // print stackTemps oop* first= &my_sp()->as_oops()[top_oop_offset]; oop* last= &callees_sp()->as_oops()[bottom_oop_offset]; Location t = Location(StackLocations + (last - first)); oop* temp = first; while (temp <= last) { lprintf("%#9lx: ", temp); fint excess_of_4 = (t - StackLocations) & 3; fint n = excess_of_4 ? excess_of_4 : 3; if (temp == last) n = 0; printLocation(t); lprintf("-"); printLocation(Location(t - n));lprintf(": "); for (fint i = 0; i <= n; i++, temp++) { lprintf("%s%#10lx", i ? "\t" : "", *temp); } lprintf("\n"); t = Location(t - (n + 1)); } }
void MyAsserts::ae( string a , string b ){ Result::cur->_asserts++; if ( a == b ) return; printLocation(); MyAssertionException * e = getBase(); e->ss << a << " != " << b << endl; log() << e->ss.str() << endl; throw e; }
void pp_short(void* p) { FlagSetting fl(PrintVMMessages, true); if (p == NULL) { lprintf("0x0"); } else if (int32(p) < 10000 && int32(p) > -10000) { // guess that it's a location printLocation(*(Location*) &p); // extra indirection to silence warning } else if (oop(p)->is_mem()) { // guess that it's a memOop oop(p)->print_real_oop(); } else { // guess that it's a VMObj* ((VMObj*) p)->print_short_zero(); } }
void pp(void* p) { FlagSetting fl(PrintVMMessages, true); if (p == NULL) { lprintf("0x0"); } else if (int32(p) < 10000 && int32(p) > -10000) { // guess that it's a location printLocation(*(Location*) &p); // use addr to silence warning } else if (oop(p)->is_mem() || oop(p)->is_mark()) { // guess that it's an oop oop(p)->print_real(); } else if (oop(p)->is_float()) { // guess that it's a floatOop (C++ objects should be word-aligned) oop(p)->print_real(); } else { // guess that it's a VMObj* ((VMObj*) p)->print_zero(); } lprintf("\n"); }
void printBusiness(Business * b, int num) { if (b == NULL) { printf("could not find the business\n"); return; } int i; printf("=============================================================================================\n"); printf("Business # %d Name: %s\n", num, b->name); printf("Number of Locations: %d\n", b->num_locations); for (i = 0; i < b->num_locations; i++) { printLocation(b->locations[i], i); } printf("---------------------------------------------------------------------------------------------\n"); printf("=============================================================================================\n"); return; }
/** * Helper function to format the status assert informations into svUnitTest native XML format. * The final reste will be added to the output stream. * @param status Define the current status into which take the assert informations. **/ void svUnitTest::svutResultFormatterXml::printAssertInfo(const svUnitTest::svutStatusInfo& status) { *out << "\t\t\t<AssertInfo>" << endl; printLocation(status.getLocation()); if (!status.getMessage().empty()) *out << "\t\t\t\t<message>" << escapeXmlCharsInString(status.getMessage()) << "</message>" << endl; if (status.getNbEntries() > 0) { *out << "\t\t\t\t<entries>" << endl; status.formatEntries(*out,"\t\t\t\t\t<entry name='","'>","</entry>\n",escapeXmlCharsInString); *out << "\t\t\t\t</entries>" << endl; } if (status.getNbContextEntries() > 0) { *out << "\t\t\t\t<context>" << endl; status.formatContext(*out,"\t\t\t\t\t<entry name='","'>","</entry>\n",escapeXmlCharsInString); *out << "\t\t\t\t</context>" << endl; } if (!status.getOutput().empty()) *out << "\t\t\t\t<output>" << escapeXmlCharsInString(status.getOutput()) << "</output>" << endl; *out << "\t\t\t</AssertInfo>" << endl; }
void printGameStrategyContext(OutputStream* outputStream, GameStrategyContext* context) { appendString(outputStream, "GameStrategyContext\n"); appendString(outputStream, "\tstrategy.name="); // gameStrategy if (context->gameStrategy != NULL) { appendString(outputStream, context->gameStrategy->name); } else { appendString(outputStream, "NULL"); } // elapsedMatchTime appendStringAndDecf(outputStream, "\n\telapsedMatchTime=", context->elapsedMatchTime); println(outputStream); // Robot Position appendString(outputStream, "\trobotPosition="); printPoint(outputStream, &(context->robotPosition), ""); appendStringAndDec(outputStream, "\n\trobotAngle (ddeg)=", context->robotAngle); // nearestLocation appendString(outputStream, "\n\tnearestLocation="); if (context->nearestLocation != NULL) { printLocation(outputStream, context->nearestLocation); } else { appendString(outputStream, "NULL"); } appendStringAndDec(outputStream, "\ntimeSinceLastCollision=", context->timeSinceLastCollision); // Robot Position appendString(outputStream, "\n\topponentRobotPosition="); printPoint(outputStream, &(context->opponentRobotPosition), ""); // Obstacle Position appendString(outputStream, "\n\tlastObstaclePosition="); printPoint(outputStream, &(context->lastObstaclePosition), ""); // current Target appendString(outputStream, "\n\tcurrentTarget="); if (context->currentTarget != NULL) { printGameTarget(outputStream, context->currentTarget, false); } else { appendString(outputStream, "NULL"); } // currentTrajectory if (&(context->currentTrajectory) != NULL) { printLocationList(outputStream, "\n\tcurrentTrajectory:", &(context->currentTrajectory)); } else { appendString(outputStream, "\n\tcurrentTrajectory=NULL"); } appendStringAndDec(outputStream, "\n\tteamColor=", context->color); appendStringAndDec(outputStream, "\n\tstrategyIndex=", context->strategyIndex); appendStringAndDec(outputStream, "\n\tmaxTargetToHandle=", context->maxTargetToHandle); // appendStringAndDec(outputStream, "\n\tmustDoNextStep=", context->mustDoNextStep); appendStringAndDec(outputStream, "\n\thasMoreNextSteps=", context->hasMoreNextSteps); println(outputStream); }
static bool executeCommand(CardinalVM* vm, const char* line) { if (line[0] == '\n') return false; switch (line[0]) { case 'c': cardinalSetDebugState(vm->debugger, CONTINUE); break; case 's': cardinalSetDebugState(vm->debugger, STEP_INTO); break; case 'n': { // step over Code inst = getCurrentInstruction(vm); if ((inst >= CODE_CALL_0 && inst <= CODE_CALL_16) || (inst >= CODE_SUPER_0 && inst <= CODE_SUPER_16)) cardinalSetDebugState(vm->debugger, STEP_OVER); else cardinalSetDebugState(vm->debugger, STEP_INTO); break; } case 'o': // step out cardinalSetDebugState(vm->debugger, STEP_OUT); break; case 'b': { // Set break point printf("On which line do you want to place a breakpoint: <line> "); char breakp[MAX_LINE_LENGTH]; bool check = false; while( !check) { if (!fgets(breakp, MAX_LINE_LENGTH, stdin)) break; char* end; int v = strtol(breakp, &end, 10); if (v != 0) { cardinalAddBreakPoint(vm, vm->debugger, v); check = true; } } printf("\n"); // take more commands return false; } case 'r': { // Remove break point printf("Which breakpoint do you want to remove: <all | line number> "); char breakp[MAX_LINE_LENGTH]; bool check = false; while( !check) { if (!fgets(breakp, MAX_LINE_LENGTH, stdin)) break; if (strcmp(breakp, "all") == 0) { cardinalRemoveAllBreakPoints(vm, vm->debugger); check = true; } else { char* end; int v = strtol(breakp, &end, 10); if (v != 0) { cardinalRemoveBreakPoint(vm, vm->debugger, v); check = true; } } } // take more commands return false; } case 'l': { // List something listData(vm); // take more commands return false; } case 'h': printHelp(); // take more commands return false; case 'w': { // Where am I? printLocation(vm); // take more commands return false; } case 'a': vm->fiber = NULL; break; default: printf("Unknown command\n"); // take more commands return false; } // Continue execution return true; }
/* * function processes each command the user enters * returns 1 if step or continue * returns 0 on success * returns -1 on error */ int runCommand(char command[]) { char *name = strtok(command, " "); char *arg1, *arg2, *arg3; int arg1value, arg2value; struct address translatedAddr; if(strcmp(name,"help")==0 || strcmp(name,"h")==0) //"help" to display all commands { printf("\n step / s\n\t Single step the exection\n\n"); printf(" continue / c\n\t Continue to next breakpoint \n\n"); printf(" reg / r \n\t Prints the value of all registers \n\n"); printf(" reg / r <register_name> \n\t Prints the value of a particular register \n\n"); printf(" reg / r <register_name1> <register_name2> \n\t Prints the value of all registers from <register_name1> to <register_name2> \n\n"); printf(" mem / m <page_num> \n\t Displays contents of a memory page \n\n"); printf(" mem / m <page_num1> <page_num2> \n\t Displays contents of memory pages from <page_num1> to <page_num2>\n\n"); printf(" pcb / p \n \t Displays the PCB with state as running \n\n"); printf(" pcb / p <pid> \n\t Displays the <pid> th PCB \n\n"); printf(" pagetable / pt \n \t Displays the page table at location pointed by PTBR \n\n"); printf(" pagetable / pt <pid> \n\t Displays the <pid> th page table \n\n"); printf(" filetable / ft \n \t Displays the System Wide Open File Table\n\n"); printf(" memfreelist / mf \n \t Displays the Memory Free List\n\n"); printf(" diskfreelist / df \n \t Displays the Memory copy of Disk Free List\n\n"); printf(" fat \n \t Displays the Memory Copy of File Allocation Table\n\n"); printf(" location / l <address> \n \t Displays the content at memory address (Translation takes place in USER mode)\n\n"); printf(" watch / w <physical address> \n \t Sets a watch point at this address\n\n"); printf(" watchclear / wc \n \t Clears all the watch points\n\n"); printf(" exit / e \n\t Exit the interface and Halt the machine\n"); printf(" help / h\n"); } else if (strcmp(name,"step") == 0 || strcmp(name,"s") == 0) //Single Stepping { step_flag = ENABLE; return 1; } else if (strcmp(name,"continue") == 0 || strcmp(name,"c") == 0) //Continue till next breakpoint { step_flag = DISABLE; return 1; } else if (strcmp(name,"reg")==0 || strcmp(name,"r")==0) //Prints the registers. { arg1 = strtok(NULL, " "); arg2 = strtok(NULL, " "); if(arg1 == NULL) printRegisters(R0, NUM_REGS-1); else if(arg2 == NULL) { arg1value = getRegArg(arg1); if(arg1value == -1) { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } else printRegisters(arg1value,arg1value); } else { arg1value = getRegArg(arg1); arg2value = getRegArg(arg2); if(arg1value == -1 || arg2value == -1) { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } else { if(arg1value > arg2value) //swap them { arg1value = arg1value + arg2value; arg2value = arg1value - arg2value; arg1value = arg1value - arg2value; } printRegisters(arg1value,arg2value); } } } else if (strcmp(name,"mem")==0 || strcmp(name,"m")==0) //displays pages in memory { arg1 = strtok(NULL, " "); arg2 = strtok(NULL, " "); if(arg1 == NULL) { printf("Insufficient argument for \"%s\". See \"help\" for more information",name); return -1; } else if(arg2 == NULL) { arg1value = atoi(arg1); if(arg1value >0 && arg1value < NUM_PAGES) printMemory(arg1value); else { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } } else { arg1value = atoi(arg1); arg2value = atoi(arg2); if(arg1value > arg2value) //swap them { arg1value = arg1value + arg2value; arg2value = arg1value - arg2value; arg1value = arg1value - arg2value; } if(arg1value >0 && arg2value < NUM_PAGES) { while(arg1value <= arg2value) { printMemory(arg1value); arg1value++; } } else { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } } } else if (strcmp(name,"pcb")==0 || strcmp(name,"p")==0) //displays PCB of a process { arg1 = strtok(NULL, " "); if(arg1 == NULL) //finds the PCB with state as running { int page_no, word_no; arg1value = 0; while(arg1value < NUM_PCB) { page_no = (READY_LIST + arg1value * PCB_ENTRY + 1) / PAGE_SIZE; word_no = (READY_LIST + arg1value * PCB_ENTRY + 1) % PAGE_SIZE; if(getInteger(page[page_no].word[word_no]) == STATE_RUNNING) break; arg1value++; } if(arg1value == NUM_PCB) { printf("No PCB found with state as running"); return -1; } } else { arg1value = atoi(arg1); if(arg1value<0 || arg1value >=NUM_PCB) { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } } printPCB(arg1value); } else if (strcmp(name,"pagetable")==0 || strcmp(name,"pt")==0) //displays Page Table of a process { arg1 = strtok(NULL, " "); if(arg1 == NULL) //finds the page table using PTBR { int page_no, word_no; arg1value = getInteger(reg[PTBR_REG]); if(arg1value < PAGE_TABLE || arg1value > (PAGE_TABLE + ((NUM_PCB-1)*NUM_PAGE_TABLE*PAGE_TABLE_ENTRY)) ) { printf("Illegal PTBR value"); return -1; } } else { if(atoi(arg1) < 0 || atoi(arg1) >= NUM_PCB ) { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } arg1value = PAGE_TABLE + atoi(arg1) * (PAGE_TABLE_ENTRY * NUM_PAGE_TABLE); } printPageTable(arg1value); } else if (strcmp(name,"filetable")==0 || strcmp(name,"ft")==0) //displays System Wide Open File Table printFileTable(); else if (strcmp(name,"memfreelist")==0 || strcmp(name,"mf")==0) //displays Memory Free Lisk printMemFreeList(); else if (strcmp(name,"diskfreelist")==0 || strcmp(name,"df")==0) //displays Disk Free List printDiskFreeList(); else if (strcmp(name,"fat")==0) //displays File Allocation Table printFAT(); else if (strcmp(name,"location")==0 || strcmp(name,"l")==0 ) //displays a content of a memory location { arg1 = strtok(NULL, " "); if(arg1 == NULL) { printf("Insufficient argument for \"%s\". See \"help\" for more information",name); return -1; } translatedAddr = translate_debug(atoi(arg1)); if(getType(arg1) == TYPE_STR || (translatedAddr.page_no == -1 && translatedAddr.word_no == -1) ) { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } printLocation(translatedAddr); } else if (strcmp(name,"watch")==0 || strcmp(name,"w")==0 ) //Sets watch point to a memory location { arg1 = strtok(NULL, " "); if(arg1 == NULL) { printf("Insufficient argument for \"%s\". See \"help\" for more information",name); return -1; } if( getType(arg1) == TYPE_STR || atoi(arg1) < 0 || atoi(arg1) >= SIZE_OF_MEM ) { printf("Illegal argument for \"%s\". See \"help\" for more information",name); return -1; } if( watch_count >= NUM_WATCH) { printf("You have already used %d watch points. No more watch points can be set.\nUse \"watchclear\" to clear all watch points. \n", NUM_WATCH ); return -1; } watch[watch_count].addr.page_no = atoi(arg1) / PAGE_SIZE; watch[watch_count].addr.word_no = atoi(arg1) % PAGE_SIZE; strcpy(watch[watch_count].value, page[watch[watch_count].addr.page_no].word[watch[watch_count].addr.word_no]); watch_count++; printf("Watch point %d set.\n",watch_count); } else if (strcmp(name,"watchclear")==0 || strcmp(name,"wc")==0 ) //Clears all watch points { initialize_Watch(); printf("All watch points cleared.\n"); } else if (strcmp(name,"exit")==0 || strcmp(name,"e")==0) //Exits the interface exit(0); else { printf("Unknown command \"%s\". See \"help\" for more information",name); return -1; } return 0; }