void printVariable(Variable * var) { if (var != NULL) { printVariable(var->left); printf("\tVariable %s, occured %d times:\n", var->name, var->count); printLines(var->last_line); printVariable(var->right); } }
/* This function prints the current dataset representation either to the specified file name (given by the function setFile()) or to stdout if there is no such file name given. */ void dataset::print (void) { FILE * f = stdout; // open file for writing if (file) { if ((f = fopen (file, "w")) == NULL) { logprint (LOG_ERROR, "cannot create file `%s': %s\n", file, strerror (errno)); return; } } // print header fprintf (f, "<Qucs Dataset " PACKAGE_VERSION ">\n"); // print dependencies for (vector * d = dependencies; d != NULL; d = (vector *) d->getNext ()) { printDependency (d, f); } // print variables for (vector * v = variables; v != NULL; v = (vector *) v->getNext ()) { if (v->getDependencies () != NULL) printVariable (v, f); else printDependency (v, f); } // close file if necessary if (file) fclose (f); }
void OCamlSource::printVar ( ) { emit printVariable( _selected_text ); QTextCursor current_cur = textCursor(); current_cur.clearSelection(); setTextCursor( current_cur ); }
void printGroup(Group * g) { if (g != NULL) { printGroup(g->left); printf("Group %s, %d variables:\n", g->tag, g->total_count); printVariable(g->var); printGroup(g->right); } }
void printConfigVariables(FILE *out, int html) { ConfigVariablePtr var; int entryno = 0; #define PRINT_SEP() \ do {if(html) fprintf(out, "</td><td>"); else fprintf(out, " ");} while(0) if(html) { fprintf(out, "<table>\n"); fprintf(out, "<tbody>\n"); } if(html) { alternatingHttpStyle(out, "configlist"); fprintf(out, "<table id=configlist>\n" "<thead>\n" "<tr><th>variable name</th>" "<th>current value</th>" "<th>new value</th>" "<th>description</th>\n" "</thead><tbody>\n" ); } /* configFile is not a config variable, for obvious bootstrapping reasons. CHUNK_SIZE is hardwired for now. */ fprintf(out, html ? "<tr class=\"even\"><td>configFile</td><td>%s</td><td></td><td>" "Configuration file.</td></tr>\n" : "configFile %s Configuration file.\n", configFile && configFile->length > 0 ? configFile->string : "(none)"); fprintf(out, html ? "<tr class=\"odd\"><td>CHUNK_SIZE</td><td>%d</td><td></td><td>" "Unit of chunk memory allocation.</td></tr>\n" : "CHUNK_SIZE %d Unit of chunk memory allocation.\n", CHUNK_SIZE); var = configVariables; while(var != NULL) { if(html) { if(entryno % 2) fprintf(out, "<tr class=odd>"); else fprintf(out, "<tr class=even>"); fprintf(out, "<td>"); } fprintf(out, "%s", var->name->string); fprintf(out, html ? "<br/>" : " "); fprintf(out, html ? "<i>" : ""); switch(var->type) { case CONFIG_INT: case CONFIG_OCTAL: case CONFIG_HEX: fprintf(out, "integer"); break; case CONFIG_TIME: fprintf(out, "time"); break; case CONFIG_BOOLEAN: fprintf(out, "boolean"); break; case CONFIG_TRISTATE: fprintf(out, "tristate"); break; case CONFIG_TETRASTATE: fprintf(out, "4-state"); break; case CONFIG_PENTASTATE: fprintf(out, "5-state"); break; case CONFIG_FLOAT: fprintf(out, "float"); break; case CONFIG_ATOM: case CONFIG_ATOM_LOWER: case CONFIG_PASSWORD: fprintf(out, "atom"); break; case CONFIG_INT_LIST: fprintf(out, "intlist"); break; case CONFIG_ATOM_LIST: case CONFIG_ATOM_LIST_LOWER: fprintf(out, "list"); break; default: abort(); } fprintf(out, html ? "</i>" : ""); PRINT_SEP(); printVariable(out, var, html, 0); PRINT_SEP(); if(html) { printVariableForm(out, var); PRINT_SEP(); } fprintf(out, "%s", var->help?var->help:""); if(html) fprintf(out, "</td></tr>\n"); else fprintf(out, "\n"); entryno++; var = var->next; } if(html) { fprintf(out, "</tbody>\n"); fprintf(out, "</table>\n"); } return; #undef PRINT_SEP }
static void printVariableForm(FILE *out, ConfigVariablePtr var) { char *disabled = ""; int i; if(disableConfiguration || !var->setter) disabled = "disabled=true"; fprintf(out, "<form method=POST action=\"config?\">"); switch(var->type) { case CONFIG_INT: case CONFIG_OCTAL: case CONFIG_HEX: case CONFIG_TIME: case CONFIG_FLOAT: case CONFIG_ATOM: case CONFIG_ATOM_LOWER: case CONFIG_PASSWORD: case CONFIG_INT_LIST: case CONFIG_ATOM_LIST: case CONFIG_ATOM_LIST_LOWER: fprintf(out, "<input value=\""); printVariable(out, var, 1, 1); fprintf(out, "\"%s size=14 name=%s %s>\n", var->type == CONFIG_PASSWORD ? " type=password" : "", var->name->string, disabled); break; case CONFIG_BOOLEAN: { static char *states[] = {"false", "true"}; fprintf(out, "<select name=%s %s>", var->name->string, disabled); for(i=0; i < sizeof(states) / sizeof(states[0]); i++) { if(*var->value.i == i) { fprintf(out, "<option selected>%s</option>", states[i]); } else { fprintf(out, "<option>%s</option>", states[i]); } } fprintf(out, "</select>"); if(var->setter) fprintf(out, "<input type=\"submit\" value=\"set\"\n>"); break; } case CONFIG_TRISTATE: { static char *states[] = {"false", "maybe", "true"}; fprintf(out, "<select name=%s %s>", var->name->string, disabled); for(i=0; i < sizeof(states) / sizeof(states[0]); i++) { if(*var->value.i == i) { fprintf(out, "<option selected>%s</option>", states[i]); } else { fprintf(out, "<option>%s</option>", states[i]); } } fprintf(out, "</select>"); if(var->setter) fprintf(out, "<input type=\"submit\" value=\"set\"\n>"); break; } case CONFIG_TETRASTATE: { static char *states[] = {"false", "reluctantly", "happily", "true"}; fprintf(out, "<select name=%s %s>", var->name->string, disabled); for(i=0; i <sizeof(states) / sizeof(states[0]); i++) { if(*var->value.i == i) { fprintf(out, "<option selected>%s</option>", states[i]); } else { fprintf(out, "<option>%s</option>", states[i]); } } fprintf(out, "</select>"); if(var->setter) fprintf(out, "<input type=\"submit\" value=\"set\"\n>"); break; } case CONFIG_PENTASTATE: { static char *states[] = {"no", "reluctantly", "maybe", "happily", "true"}; fprintf(out, "<select name=%s %s>", var->name->string, disabled); for(i=0; i < sizeof(states) / sizeof(states[0]); i++) { if(*var->value.i == i) { fprintf(out, "<option selected>%s</option>", states[i]); } else { fprintf(out, "<option>%s</option>", states[i]); } } fprintf(out, "</select>"); if(var->setter) fprintf(out,"<input type=\"submit\" value=\"set\"\n>"); break; } default: abort(); } fprintf(out, "</form>"); }
static int printNode(D4printer* out, NCD4node* node, int depth) { int ret = NC_NOERR; int i; char* fqn = NULL; switch (node->sort) { case NCD4_GROUP: if(node->group.isdataset) printDataset(out,node,depth); else printGroup(out,node,depth); break; case NCD4_DIM: INDENT(depth); CAT("<Dimension"); if(node->name != NULL) printXMLAttributeName(out, "name", node->name); printXMLAttributeSize(out, "size", node->dim.size); if(node->dim.isunlimited) printXMLAttributeString(out, UCARTAGUNLIM, "1"); CAT("/>"); break; case NCD4_TYPE: switch (node->subsort) { default: break; case NC_OPAQUE: INDENT(depth); CAT("<Opaque"); ncbytesclear(out->tmp); printXMLAttributeName(out, "name", node->name); if(node->opaque.size > 0) printXMLAttributeSize(out, "size", node->opaque.size); CAT("/>"); break; case NC_ENUM: INDENT(depth); CAT("<Enumeration"); printXMLAttributeName(out, "name", node->name); if(node->basetype->subsort <= NC_MAX_ATOMIC_TYPE) printXMLAttributeName(out, "basetype", node->basetype->name); else { char* fqn = NULL; printXMLAttributeName(out, "basetype", (fqn = NCD4_makeFQN(node->basetype))); nullfree(fqn); } CAT(">\n"); depth++; for(i=0;i<nclistlength(node->en.econsts);i++) { NCD4node* ec = (NCD4node*)nclistget(node->en.econsts,i); INDENT(depth); CAT("<EnumConst"); printXMLAttributeName(out, "name", ec->name); printXMLAttributeAtomics(out, "value", &ec->en.ecvalue, node->basetype->subsort); CAT("/>\n"); } depth--; INDENT(depth); CAT("</Enumeration>"); break; case NC_STRUCT: INDENT(depth); CAT("<Structure"); printXMLAttributeName(out, "name", node->name); CAT(">\n"); depth++; for(i=0;i<nclistlength(node->vars);i++) { NCD4node* field = (NCD4node*)nclistget(node->vars,i); printVariable(out,field,depth); CAT("\n"); } if((ret=printMetaData(out,node,depth))) goto done; depth--; INDENT(depth); CAT("</Structure>"); break; case NC_SEQ: INDENT(depth); CAT("<Vlen"); printXMLAttributeName(out, "name", node->name); printXMLAttributeName(out, "type", (fqn=NCD4_makeFQN(node->basetype))); if(hasMetaData(node)) { CAT(">\n"); depth++; if((ret=printMetaData(out,node,depth))) goto done; depth--; INDENT(depth); CAT("</Vlen>"); } else CAT("/>"); break; } break; case NCD4_VAR: /* Only top-level vars are printed here */ if(ISTOPLEVEL(node)) { if((ret=printVariable(out,node,depth))) goto done; CAT("\n"); } break; default: abort(); break; } done: nullfree(fqn); return THROW(ret); }
void ASTPrint( int lev, ASTNode node ) { if (! node) { indent( lev ); ec_stderr_printf( "NULL" ); return; } /* Simplify our lives ... */ if (currentScope) { if (currentScope->type == PackageScope) { currentPackage = currentScope->target; currentBytecode = EC_PACKAGECODE(currentScope->target); } else { currentBytecode = currentScope->target; } currentLiteral = EC_COMPILEDLFRAME(currentBytecode); } switch ( node->type ) { case nullType: indent( lev ); ec_stderr_printf( "<nullType>" ); break; case symbolType: printSymbol( lev, node ); break; case qualifiedSymbolType: printQualifiedSymbol( lev, node ); break; case constExprType: printConstant( lev, node ); break; case variableExprType: printVariable( lev, node ); break; case arrayConstructionExprType: printArrayCons( lev, node ); break; case hashConstructionExprType: printHashCons( lev, node ); break; case unaryExprType: printUnary( lev, node ); break; case binaryExprType: printBinary( lev, node ); break; case conditionalExprType: printConditional( lev, node ); break; case orExprType: printOr( lev, node ); break; case andExprType: printAnd( lev, node ); break; case assignExprType: printAssign( lev, node ); break; case simAssignExprType: printSimAssign( lev, node ); break; case arrayRefExprType: printArrayRef( lev, node ); break; case declNodeType: printDecl( lev, node ); break; case declAtomNodeType: printDeclAtom( lev, node ); break; case statementType: printStatement( lev, node ); break; case labeledStmtType: printLabeledStmt( lev, node ); break; case exprStmtType: printExprStmt( lev, node ); break; case ifStmtType: printIf( lev, node ); break; case whileStmtType: printWhile( lev, node ); break; case doStmtType: printDo( lev, node ); break; case forStmtType: printFor( lev, node ); break; case forInStmtType: printForIn( lev, node ); break; case breakStmtType: printBreak( lev, node ); break; case continueStmtType: printContinue( lev, node ); break; case gotoStmtType: printGoto( lev, node ); break; case tryStmtType: printTry( lev, node ); break; case catchStmtType: printCatch( lev, node ); break; case throwStmtType: printThrow( lev, node ); break; case importStmtType: printImport( lev, node ); break; case paramNodeType: printParam( lev, node ); break; case paramListType: printParamList( lev, node ); break; case callNodeType: printCall( lev, node ); break; case methodCallNodeType: printMethodCall( lev, node ); break; case stmtListType: printStmtList( lev, node ); break; case funcNodeType: printFunction( lev, node ); break; case returnNodeType: printReturn( lev, node ); break; case classNodeType: printClass( lev, node ); break; case methodNodeType: printMethod( lev, node ); break; case packageNodeType: printPackage( lev, node ); break; } }
void debugger(){ int hasStarted = 0; int hasContinued = 0; while(1){ //wait for a signal wait(&status); //if the program exited, just return if (WIFEXITED( status )){ printf("\nthe program terminated\n"); return; } // Quick overview of what's going on here: // **Variable 'done': Done will keep us within this while loop. If it is // set to 1 that means we issued the "continue" command. // // **Variable 'hasContinued': In the event that we stop at a breakpoint // and issue a command other than "continue", we will end up calling // fixBreakpoint a second time. hasContinued will tell the loop // to pump the breaks, we haven't moved on yet! int done = 0; while(!done){ //get user input, what should we do? if((breakpointCount > 0) && hasStarted && hasContinued){ printf("breakpoint %d hit\n",findBreakpoint(AFTER_BREAKPOINT)); fixBreakpoint(0); // Restore our opcode and registers hasContinued = 0; } user_command * cmd = debugger_interface_get_cmd(); if (cmd){ //now handle the input switch(cmd->command_type){ case CMD_TYPE_BREAKPOINT: if(breakpoint(cmd->value.line_number)){ printf("Could not set breakpoint at line %d.\n",cmd->value.line_number); } break; case CMD_TYPE_STACKTRACE: stacktrace(); break; case CMD_TYPE_PRINT: printVariable(cmd->value.var.format,cmd->value.var.name,0); break; case CMD_TYPE_PRINT_GEN: printVariable(cmd->value.var.format,cmd->value.var.name,1); break; case CMD_TYPE_CONTINUE: if(!hasStarted){ // If we are here, that means we are just starting to run the // program, so nothing special. hasStarted = 1; } else{ // However, if we are here that means we were "interuptted" // by a break. We fixed the breakpoint and altered our registers // At the beginning of the parent while loop, so now we want // to use SINGLE_STEP and then reset the breakpoint that we just // fixed. fixBreakpoint(1); } done = 1; hasContinued = 1; break; case CMD_TYPE_WHERE: whereAmI(); break; } } } ptrace( PTRACE_CONT, child, NULL, NULL ); } }