static void do_harg_dump (harglst *a, int level) { hargwalk *w ; harg **R, *r ; static void **harg_walk_next_ptr (hargwalk*); if(a == 0 || (w = harg_walk_init (a)) == 0) { do_printf ("-error; no such list!\n",0,0,0,0,0); return; } while ((R = (harg**)harg_walk_next_ptr (w)) != 0) { int ptrky, flags = 0; do_indent (level); if ((r = *R) == 0) { do_printf ("Warning: NULL entry in list\n",0,0,0,0,0); continue ; } ptrky = (is_ptrkey_type (r->type) != 0); switch (get_simple_type (r->type)) { case HARG_STRING: do_printf ("\"%s\"", R, (void*)r->d.d.data, flags, ptrky, 0); continue ; case HARG_BLOB: do_printf ("%#x[%u]", R, (void*)r->d.d.data, flags, ptrky, r->size); continue ; #ifdef ARG_ARGLIST case HARG_ARGLIST: do_newlevel (); do_printf ("(old mode>) sublist ...", R, 0, flags, ptrky, 0); arg_dump (r->d.d.ptr [0], level+1); continue ; #endif case HARG_HARG: /* do_newlevel (); */ if (is_remote_type (r->type)) do_printf ("remote sublist{%s} ...", R, r->d.d.ptr+1, flags, ptrky, 0); else do_printf ("sublist{%#x} ...", R, r->d.d.ptr [0], flags, ptrky, 0); do_harg_dump (r->d.d.ptr [0], level+1); continue ; case HARG_INT: do_printf ("%d", R, r->d.d.ptr [0], flags, ptrky, 0); continue; default: do_printf ("*%#x", R, r->d.d.ptr [0], flags, ptrky, 0); } } harg_walk_stop (w); }
int kprintf( int loglevel, const char* format, ... ) { va_list args; // spinlock_disable( &console_lock ); /* Print the text */ va_start( args, format ); do_printf( kprintf_helper, ( void* )&loglevel, format, args ); va_end( args ); /* Flush the consoles */ if ( ( loglevel > DEBUG ) && ( screen != NULL ) && ( screen->ops->flush != NULL ) ) { screen->ops->flush( screen ); } if ( ( debug != NULL ) && ( debug->ops->flush != NULL ) ) { debug->ops->flush( debug ); } // spinunlock_enable( &console_lock ); return 0; }
static int tcc_writesection(conf_section *ts, void *file, int lv, char *d, tcio_fn ofn) { int l = lv * 8; tclist_item_t *li = NULL; char *m; do_printf(file, ofn, "%*s%s", l, "", ts->name); while((m = tclist_next(ts->merge, &li))) fprintf(file, " : %s", m); do_printf(file, ofn, " %c\n", d[0]); tcc_writelist(ts->entries, file, lv + 1, ofn); do_printf(file, ofn, "%*s%c\n", l, "", d[1]); return 0; }
CELL * bi_printf(CELL *sp) { register int k; register CELL *p; FILE *fp; TRACE_FUNC("bi_printf", sp); k = sp->type; if (k < 0) { /* k has redirection */ if ((--sp)->type < C_STRING) cast1_to_s(sp); fp = (FILE *) file_find(string(sp), k); free_STRING(string(sp)); k = (--sp)->type; /* k is now number of args including format */ } else fp = stdout; sp -= k; /* sp points at the format string */ k--; if (sp->type < C_STRING) cast1_to_s(sp); do_printf(fp, string(sp)->str, (unsigned) k, sp + 1); free_STRING(string(sp)); /* cleanup arguments on eval stack */ for (p = sp + 1; k; k--, p++) cell_destroy(p); return --sp; }
int vsprintf(char *buffer, const char *fmt, va_list args) { int ret_val = do_printf(fmt, args, vsprintf_help, (void *)buffer); buffer[ret_val] = '\0'; return ret_val; }
// ===================================================================================================================== void kprintf_unlocked(const char* format, ...) { va_list args; va_start(args, format); do_printf(kprintf_helper, NULL, format, args); va_end(args); }
// ===================================================================================================================== void dprintf(const char* format, ...) { va_list args; va_start(args, format); do_printf(dprintf_helper, NULL, format, args); va_end(args); }
int vsprintf(char *buf, const char *fmt, va_list args) { int rv; rv = do_printf(fmt, args, vsprintf_help, (void *)buf); buf[rv] = '\0'; return rv; }
Response & Response::status(int code) { if( statusSet ) return *this; do_printf("HTTP/1.1 %d OK\r\n",code); statusSet = true; return *this; }
// Função printf void printf(const char *fmt, ...) { va_list args; va_start(args, fmt); (void)do_printf(fmt, args, kprintf_help, NULL, 0); va_end(args); }
WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...) { WORD ret; charp = buff; ret = do_printf(fmt, (BYTE **) & fmt + 1); handle_char(NULL); return ret; }
void printf(const char *fmt, ...) { va_list args; va_start(args, fmt); do_printf(fmt, args, printf_helper, NULL); va_end(args); }
void printfln(char* fmt, ...) { va_list args; va_start(args, fmt); do_printf(fmt, args, printf_helper, NULL); putc('\n'); va_end(args); }
// ===================================================================================================================== void kprintf(const char* format, ...) { va_list args; spinlock_disable(&s_console_lock); va_start(args, format); do_printf(kprintf_helper, NULL, format, args); va_end(args); spinunlock_enable(&s_console_lock); }
Response & Response::contentType(char const * type) { if( contentTypeSet ) return *this; if( ! statusSet ) { status(200); } do_printf("Content-Type: %s\r\n",type); contentTypeSet = true; return *this; }
/******************************************************************** * Prints the string to the con_idx's console buffer. Takes care of * updating the screen when it's the current console. * * In : con_idx = index number of the console. * fmt = string which holds a normal "printf" format * ... = unknown number of parameters of all kinds (va_list) * * Out : -1 on error, 1 on OK */ int con_printf (console_t *console, const char *fmt, ...) { va_list args; if (console == NULL) return ERR_CON_INVALID_CONSOLE; va_start (args, fmt); do_printf (fmt, args, &con_printf_helper, (void *)console); va_end (args); // Show the string we just printed if necessary... con_flush (console); // Return return ERR_OK; }
static int tcc_writeentry(tcc_entry *te, void *file, int lv, tcio_fn ofn) { tclist_item_t *li = NULL; tcc_value *tv; int l = lv * 8; switch(te->type){ case TCC_VALUE: do_printf(file, ofn, "%*s%s", l, "", te->value.key); while((tv = tclist_next(te->value.values, &li)) != NULL){ char sd; switch(tv->type & TCC_TYPEMASK){ case TCC_INTEGER: do_printf(file, ofn, " %ld", tv->value.integer); break; case TCC_FLOAT: do_printf(file, ofn, " %.16g", tv->value.floating); break; case TCC_BOOLEAN: do_printf(file, ofn, " %s", tv->value.boolean? "true": "false"); break; case TCC_STRING: sd = tv->type & TCC_EXPAND? '"': '\''; do_printf(file, ofn, " %c%s%c", sd, tv->value.string, sd); break; case TCC_REF: do_printf(file, ofn, " %s", tv->value.string); break; } } do_printf(file, ofn, "\n"); break; case TCC_SECTION: tcc_writesection(te->section, file, lv, "{}", ofn); break; case TCC_MSECTION: tcc_writesection(te->section, file, lv, "[]", ofn); break; default: fprintf(stderr, "Internal error.\n"); return -1; } return 0; }
int dprintf_unlocked( const char* format, ... ) { #ifndef MK_RELEASE_BUILD va_list args; /* Print the text */ va_start( args, format ); do_printf( dprintf_helper, NULL, format, args ); va_end( args ); /* Flush the debug console */ if ( ( debug != NULL ) && ( debug->ops->flush != NULL ) ) { debug->ops->flush( debug ); } #endif /* !MK_RELEASE_BUILD */ return 0; }
void panic(const char *fmt, ...) { set_con(get_con()); va_list args; va_start(args, fmt); disable(); set_color(CRED, CBLACK); puts("\nPANIC: "); set_color(CBRIGHTWHITE, CBLACK); (void)do_printf(fmt, args, kprintf_help, NULL); va_end(args); while(1){ asm("cli\n" "hlt\n"); } }
int kvprintf( int loglevel, const char* format, va_list args ) { // spinlock_disable( &console_lock ); /* Print the text */ do_printf( kprintf_helper, ( void* )&loglevel, format, args ); /* Flush the consoles */ if ( ( screen != NULL ) && ( screen->ops->flush != NULL ) ) { screen->ops->flush( screen ); } if ( ( debug != NULL ) && ( debug->ops->flush != NULL ) ) { debug->ops->flush( debug ); } // spinunlock_enable( &console_lock ); return 0; }
CELL * bi_sprintf(CELL *sp) { CELL *p; int argcnt = sp->type; STRING *sval; TRACE_FUNC("bi_sprintf", sp); sp -= argcnt; /* sp points at the format string */ argcnt--; if (sp->type != C_STRING) cast1_to_s(sp); sval = do_printf((FILE *) 0, string(sp)->str, (unsigned) argcnt, sp + 1); free_STRING(string(sp)); sp->ptr = (PTR) sval; /* cleanup */ for (p = sp + 1; argcnt; argcnt--, p++) cell_destroy(p); return sp; }
int vprintf(const char *fmt, va_list args) { return do_printf(fmt, args, vprintf_help, (void *)0); }
int vprintf(const char *fmt, va_list args) { return do_printf(fmt, args, vprintf_help, NULL); }
/* printf -- short version of printf to conserve space */ WORD CDECL printf(CONST BYTE * fmt, ...) { charp = 0; return do_printf(fmt, (BYTE **) & fmt + 1); }
// ===================================================================================================================== void kvprintf_unlocked(const char* format, va_list args) { do_printf(kprintf_helper, NULL, format, args); }
/* ULONG FAR retcs(int i) { char *p = (char*)&i; p -= 4; return *(ULONG *)p; } */ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) { int base; BYTE s[11], FAR * p; int c, flag, size, fill; int longarg; long currentArg; /* long cs = retcs(1); put_console("0123456789ABCDEF"[(cs >> 28) & 0x0f]); put_console("0123456789ABCDEF"[(cs >> 24) & 0x0f]); put_console("0123456789ABCDEF"[(cs >> 20) & 0x0f]); put_console("0123456789ABCDEF"[(cs >> 16) & 0x0f]); put_console(':'); put_console("0123456789ABCDEF"[(cs >> 12) & 0x0f]); put_console("0123456789ABCDEF"[(cs >> 8) & 0x0f]); put_console("0123456789ABCDEF"[(cs >> 4) & 0x0f]); put_console("0123456789ABCDEF"[(cs >> 0) & 0x0f]); */ while ((c = *fmt++) != '\0') { if (c != '%') { handle_char(c); continue; } longarg = FALSE; size = 0; flag = RIGHT; fill = ' '; if (*fmt == '-') { flag = LEFT; fmt++; } if (*fmt == '0') { fill = '0'; fmt++; } while (*fmt >= '0' && *fmt <= '9') { size = size * 10 + (*fmt++ - '0'); } if (*fmt == 'l') { longarg = TRUE; fmt++; } c = *fmt++; switch (c) { case '\0': return 0; case 'c': handle_char(*(COUNT *) arg++); continue; case 'p': { UWORD w[2]; w[1] = *((UWORD *) arg); arg += sizeof(UWORD) / sizeof(BYTE *); w[0] = *((UWORD *) arg); arg += sizeof(UWORD) / sizeof(BYTE *); do_printf("%04x:%04x", (BYTE **) & w); continue; } case 's': p = *arg++; goto do_outputstring; case 'F': fmt++; /* we assume %Fs here */ case 'S': p = *((BYTE FAR **) arg); arg += sizeof(BYTE FAR *) / sizeof(BYTE *); goto do_outputstring; case 'i': case 'd': base = -10; goto lprt; case 'o': base = 8; goto lprt; case 'u': base = 10; goto lprt; case 'X': case 'x': base = 16; lprt: if (longarg) { currentArg = *((LONG *) arg); arg += sizeof(LONG) / sizeof(BYTE *); } else { if (base < 0) { currentArg = *((int *)arg); arg += sizeof(int) / sizeof(BYTE *); } else { currentArg = *((unsigned int *)arg); arg += sizeof(unsigned int) / sizeof(BYTE *); } } ltob(currentArg, s, base); p = s; do_outputstring: size -= fstrlen(p); if (flag == RIGHT) { for (; size > 0; size--) handle_char(fill); } for (; *p != '\0'; p++) handle_char(*p); for (; size > 0; size--) handle_char(fill); continue; default: handle_char('?'); handle_char(c); break; } } return 0; }
void goto_convertt::do_function_call_symbol( const exprt &lhs, const symbol_exprt &function, const exprt::operandst &arguments, goto_programt &dest) { if(function.get_bool("#invalid_object")) return; // ignore // lookup symbol const irep_idt &identifier=function.get_identifier(); const symbolt *symbol; if(ns.lookup(identifier, symbol)) { err_location(function); throw "error: function `"+id2string(identifier)+"' not found"; } if(symbol->type.id()!=ID_code) { err_location(function); throw "error: function `"+id2string(identifier)+"' type mismatch: expected code"; } if(identifier==CPROVER_PREFIX "assume" || identifier=="__VERIFIER_assume") { if(arguments.size()!=1) { err_location(function); throw "`"+id2string(identifier)+"' expected to have one argument"; } goto_programt::targett t=dest.add_instruction(ASSUME); t->guard=arguments.front(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); // let's double-check the type of the argument if(t->guard.type().id()!=ID_bool) t->guard.make_typecast(bool_typet()); if(lhs.is_not_nil()) { err_location(function); throw id2string(identifier)+" expected not to have LHS"; } } else if(identifier=="__VERIFIER_error") { if(!arguments.empty()) { err_location(function); throw "`"+id2string(identifier)+"' expected to have no arguments"; } goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=false_exprt(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); if(lhs.is_not_nil()) { err_location(function); throw id2string(identifier)+" expected not to have LHS"; } } else if(has_prefix(id2string(identifier), "java::java.lang.AssertionError.<init>:")) { // insert function call anyway code_function_callt function_call; function_call.lhs()=lhs; function_call.function()=function; function_call.arguments()=arguments; function_call.add_source_location()=function.source_location(); copy(function_call, FUNCTION_CALL, dest); if(arguments.size()!=1 && arguments.size()!=2) { err_location(function); throw "`"+id2string(identifier)+"' expected to have one or two arguments"; } goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=false_exprt(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment("assertion at "+function.source_location().as_string()); } else if(identifier=="assert" && !ns.lookup(identifier).location.get_function().empty()) { if(arguments.size()!=1) { err_location(function); throw "`"+id2string(identifier)+"' expected to have one argument"; } goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=arguments.front(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment("assertion "+id2string(from_expr(ns, "", t->guard))); // let's double-check the type of the argument if(t->guard.type().id()!=ID_bool) t->guard.make_typecast(bool_typet()); if(lhs.is_not_nil()) { err_location(function); throw id2string(identifier)+" expected not to have LHS"; } } else if(identifier==CPROVER_PREFIX "assert") { if(arguments.size()!=2) { err_location(function); throw "`"+id2string(identifier)+"' expected to have two arguments"; } const irep_idt description= get_string_constant(arguments[1]); goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=arguments[0]; t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment(description); // let's double-check the type of the argument if(t->guard.type().id()!=ID_bool) t->guard.make_typecast(bool_typet()); if(lhs.is_not_nil()) { err_location(function); throw id2string(identifier)+" expected not to have LHS"; } } else if(identifier==CPROVER_PREFIX "printf") { do_printf(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "scanf") { do_scanf(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "input" || identifier=="__CPROVER::input") { do_input(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "output" || identifier=="__CPROVER::output") { do_output(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "atomic_begin" || identifier=="__CPROVER::atomic_begin" || identifier=="__VERIFIER_atomic_begin") { do_atomic_begin(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "atomic_end" || identifier=="__CPROVER::atomic_end" || identifier=="__VERIFIER_atomic_end") { do_atomic_end(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "prob_biased_coin") { do_prob_coin(lhs, function, arguments, dest); } else if(has_prefix(id2string(identifier), CPROVER_PREFIX "prob_uniform_")) { do_prob_uniform(lhs, function, arguments, dest); } else if(has_prefix(id2string(identifier), "nondet_") || has_prefix(id2string(identifier), "__VERIFIER_nondet_")) { // make it a side effect if there is an LHS if(lhs.is_nil()) return; exprt rhs; // We need to special-case for _Bool, which // can only be 0 or 1. if(lhs.type().id()==ID_c_bool) { rhs=side_effect_expr_nondett(bool_typet()); rhs.add_source_location()=function.source_location(); rhs.set(ID_C_identifier, identifier); rhs=typecast_exprt(rhs, lhs.type()); } else { rhs=side_effect_expr_nondett(lhs.type()); rhs.add_source_location()=function.source_location(); rhs.set(ID_C_identifier, identifier); } code_assignt assignment(lhs, rhs); assignment.add_source_location()=function.source_location(); copy(assignment, ASSIGN, dest); } else if(has_prefix(id2string(identifier), CPROVER_PREFIX "uninterpreted_")) { // make it a side effect if there is an LHS if(lhs.is_nil()) return; function_application_exprt rhs; rhs.type()=lhs.type(); rhs.add_source_location()=function.source_location(); rhs.function()=function; rhs.arguments()=arguments; code_assignt assignment(lhs, rhs); assignment.add_source_location()=function.source_location(); copy(assignment, ASSIGN, dest); } else if(has_prefix(id2string(identifier), CPROVER_PREFIX "array_set")) { do_array_set(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "array_equal" || identifier=="__CPROVER::array_equal") { do_array_equal(lhs, function, arguments, dest); } else if(identifier==CPROVER_PREFIX "array_copy" || identifier=="__CPROVER::array_equal") { do_array_copy(lhs, function, arguments, dest); } else if(identifier=="printf") /* identifier=="fprintf" || identifier=="sprintf" || identifier=="snprintf") */ { do_printf(lhs, function, arguments, dest); } else if(identifier=="__assert_fail" || identifier=="_assert" || identifier=="__assert_c99" || identifier=="_wassert") { // __assert_fail is Linux // These take four arguments: // "expression", "file.c", line, __func__ // klibc has __assert_fail with 3 arguments // "expression", "file.c", line // MingW has // void _assert (const char*, const char*, int); // with three arguments: // "expression", "file.c", line // This has been seen in Solaris 11. // Signature: // void __assert_c99(const char *desc, const char *file, int line, const char *func); // _wassert is Windows. The arguments are // L"expression", L"file.c", line if(arguments.size()!=4 && arguments.size()!=3) { err_location(function); throw "`"+id2string(identifier)+"' expected to have four arguments"; } const irep_idt description= "assertion "+id2string(get_string_constant(arguments[0])); goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=false_exprt(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment(description); // we ignore any LHS } else if(identifier=="__assert_rtn" || identifier=="__assert") { // __assert_rtn has been seen on MacOS; // __assert is FreeBSD and Solaris 11. // These take four arguments: // __func__, "file.c", line, "expression" // On Solaris 11, it's three arguments: // "expression", "file", line irep_idt description; if(arguments.size()==4) { description= "assertion "+id2string(get_string_constant(arguments[3])); } else if(arguments.size()==3) { description= "assertion "+id2string(get_string_constant(arguments[1])); } else { err_location(function); throw "`"+id2string(identifier)+"' expected to have four arguments"; } goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=false_exprt(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment(description); // we ignore any LHS } else if(identifier=="__assert_func") { // __assert_func is newlib (used by, e.g., cygwin) // These take four arguments: // "file.c", line, __func__, "expression" if(arguments.size()!=4) { err_location(function); throw "`"+id2string(identifier)+"' expected to have four arguments"; } const irep_idt description= "assertion "+id2string(get_string_constant(arguments[3])); goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=false_exprt(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment(description); // we ignore any LHS } else if(identifier==CPROVER_PREFIX "fence") { if(arguments.size()<1) { err_location(function); throw "`"+id2string(identifier)+"' expected to have at least one argument"; } goto_programt::targett t=dest.add_instruction(OTHER); t->source_location=function.source_location(); t->code.set(ID_statement, ID_fence); forall_expr(it, arguments) { const irep_idt kind=get_string_constant(*it); t->code.set(kind, true); } } else if(identifier=="__builtin_prefetch")