static void print_context_cmd(char **ptr) { int free_ici; struct thread *thread=arch_os_get_current_thread(); free_ici = fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,thread)); if (more_p(ptr)) { int index; index = parse_number(ptr); if ((index >= 0) && (index < free_ici)) { printf("There are %d interrupt contexts.\n", free_ici); printf("printing context %d\n", index); print_context(thread->interrupt_contexts[index]); } else { printf("There aren't that many/few contexts.\n"); printf("There are %d interrupt contexts.\n", free_ici); } } else { if (free_ici == 0) printf("There are no interrupt contexts!\n"); else { printf("There are %d interrupt contexts.\n", free_ici); printf("printing context %d\n", free_ici - 1); print_context(thread->interrupt_contexts[free_ici - 1]); } } }
void error(MPL *mpl, char *fmt, ...) { va_list arg; char msg[4095+1]; va_start(arg, fmt); vsprintf(msg, fmt, arg); xassert(strlen(msg) < sizeof(msg)); va_end(arg); switch (mpl->phase) { case 1: case 2: /* translation phase */ xprintf("%s:%d: %s\n", mpl->in_file == NULL ? "(unknown)" : mpl->in_file, mpl->line, msg); print_context(mpl); break; case 3: /* generation/postsolve phase */ xprintf("%s:%d: %s\n", mpl->mod_file == NULL ? "(unknown)" : mpl->mod_file, mpl->stmt == NULL ? 0 : mpl->stmt->line, msg); break; default: xassert(mpl != mpl); } mpl->phase = 4; longjmp(mpl->jump, 1); /* no return */ }
void print_ast(FILE *new_out, const context_t *context) { indent = 0; out = new_out; print_context(context); assert(indent == 0); out = NULL; }
/********************************************************************** * * print_leading_context */ static void print_leading_context(char* bufbeg, char* bufend) { int bytes; int nlines; if (bufbeg >= bufend) return; nlines = leading_context; bytes = get_leading_bytes(bufbeg, bufend, &nlines); print_context(bufend-bytes+1, bufend, leading_context, linecount-nlines); }
static void test_output(const poet_ctx_t *ctx, const unsigned char *k, const unsigned long long klen, const unsigned char *h, const unsigned long long hlen, const unsigned char *m, const unsigned long long mlen, const unsigned char *c, const unsigned long long clen, const unsigned char *t, const unsigned long long tlen) { print_hex("SK: ", k, klen); print_context(ctx); print_hex("Header/Nonce: ", h, hlen); print_hex("Plaintext:", m, mlen); print_hex("Ciphertext:", c, clen); print_hex("Tag:", t, tlen); puts("\n\n"); }
/********************************************************************** * * dgrep_buffer */ static int dgrep_buffer(char* buf, int bufsize) { char* bufend; /* bufend is last EOL character in buffer */ if ((bufend=memrchr(buf+bufsize-1, EOL2, bufsize)) == NULL) { return bufsize; } if (waiting_lines) { print_context(buf, bufend, waiting_lines, linecount+trailing_context-waiting_lines+1); waiting_lines = 0; } return use_normal ? normal_dgrep(buf, bufend, bufsize) : fast_dgrep(buf, bufend, bufsize); }
z_status zp_parser::report_error(z_status status) { z_string data; printf("status=%s\n",z_status_get_text(status)); if(!_ctx_current) return status; if(status==zs_ok) return zs_ok; if(_ctx_current->_obj_factory==0) { printf("No factory\n"); } else printf("Error while parsing object type \"%s\"\n",_ctx_current->_obj_factory->get_name()); zp_text_parser& tmpl=context_get_current_template_parser(); //printf("template=\n%s\n",t.get_buffer()); if(status) { print_context(); tmpl.print_context(); } if(status==zs_no_entry_for_item) { z_string match; tmpl.get_match(match); printf("No entry found for item \"%s\"",match.c_str()); } if(status==zs_syntax_error) { } return status; }
int error(int t, loc* lc, const char* s, const ea& a0, const ea& a1, const ea& a2, const ea& a3) /* "int" not "void" because of "pch" in lex.c legal error types are: not counted in error count: 'w' warning 'd' debug 'D' debug -- no prefix 'C' text -- line no. and no newline 'c' text -- no line no. and no newline counted in error count: 's' "not implemented" message 'l' "compiler limit exceeded" message 0 error 'e' error -- no newline 'i' internal error (causes abort) 't' error while printing error message */ { if (suppress_error && t!='i' && t!='d') return 0; if (in_error++) if (t == 't') t = 'i'; else if (4 < in_error) { fprintf(stderr,"\nOops!, error while handling error\n"); ext(13); } FILE * of = out_file; out_file = stderr; if (!scan_started || t=='t') putch('\n'); else if (lc != &dummy_loc) { if(t != 'D' && t != 'c') lc->put(out_file); } else { if(t != 'D' && t != 'c') print_loc(); } int user_error = 0; switch (t) { case 'C': case 'c': break; case 'e': user_error = 1; // no break case 0: putstring("error: "); user_error += 1; break; case 'd': putstring("DEBUG: "); case 'D': break; case 'w': // no_of_warnings++; putstring("warning: "); break; case 'l': putstring("compiler limit exceeded: "); break; case 's': putstring("sorry, not implemented: "); user_error = 1; break; case 'i': if (error_count++) { fprintf(out_file,"sorry, cannot recover from earlier errors\n"); out_file = of; // restore for fflush() #ifdef TEST_SUITE ext(INTERNAL2); #else ext(INTERNAL); #endif } else fprintf(out_file,"internal %s error: ",prog_name); } ea argv[4]; ea* a = argv; argv[0] = a0; argv[1] = a1; argv[2] = a2; argv[3] = a3; int c; while (c = *s++) { if ('A'<=c && c<='Z') putstring(abbrev_tbl[c-'A']); else if (c == '%') { switch (c = *s++) { case 'k': // TOK assumed passed as an int { int x = TOK(a->i); if (0 < x && x<=MAXTOK && keys[x]) fprintf(out_file," %s",keys[x]); else fprintf(out_file," token(%d)",x); break; } case 't': // Ptype { Ptype tt = Ptype(a->p); if (tt == 0) break; putch(' '); int nt = ntok; emode = 1; tt->dcl_print(0); emode = 0; ntok = nt; break; } case 'n': // Pname { Pname nn = Pname(a->p); if (nn && nn->string) { // suppress generated class names: if (nn->string[0]=='_' && nn->string[1]=='_' && nn->string[2]=='C') break; emode = 1; putch(' '); nn->print(); emode = 0; } else putstring(" ?"); break; } case 'p': // pointer { char* f = sizeof(char*)==sizeof(int)?" %d":" %ld"; fprintf(out_file,f,a->p); break; } case 'a': // fully qualified function { Pname nn = Pname(a->p); if (nn->tp->base!=FCT && nn->tp->base!=OVERLOAD) error('i',"%n not function",nn); if (nn && nn->string) { // suppress generated class names: if (nn->string[0]=='_' && nn->string[1]=='_' && nn->string[2]=='C') break; emode = 1; putch(' '); nn->print(1); emode = 0; } else putstring(" ?"); break; } case 'c': // char assumed passed as an int putch((int)a->i); break; case 'd': // int fprintf(out_file," %d",a->i); break; case 'o': // int fprintf(out_file," 0%o",a->i); break; case 's': // char* { char *s = ((char *)a->p); if ( s ) putst((char*)a->p); break; } } a++; } else putch(c); } /* switch (t) { case 'd': case 't': case 'w': putch('\n'); break; default: */ if (t != 'c' && t != 'e' && t != 'C') print_context(); /* } */ if (user_error) basic_inst::head->print_error_loc(user_error==2); out_file = of; // restore before ext() for fflush() if (!scan_started && t!='d' && t!='w') ext(4); // now we may want to carry on switch (t) { case 't': if (--in_error) { fflush(stderr); //fflush(out_file); return 0; } case 'i': ext(INTERNAL); case 0: case 'e': case 'l': case 's': #ifdef TEST_SUITE if (t == 's') ext(SORRY); #endif if (MAXERR<++error_count) { fprintf(stderr,"Sorry, too many errors\n"); ext(7); } } in_error = 0; fflush(stderr); //fflush(out_file); return 0; }
void __attribute__((naked)) isr_fault() { /* disable interrupts */ /* save registers */ unsigned int sp, lr, psr, usp; sp = __get_sp(); psr = __get_psr(); lr = __get_lr(); usp = __get_usp(); debug(MSG_ERROR, "\nFault type: %x <%08x>\n" " (%x=Usage fault, %x=Bus fault, %x=Memory management fault)", SCB_SHCSR & 0xfff, SCB_SHCSR, USAGE_FAULT, BUS_FAULT, MM_FAULT); debug(MSG_ERROR, "Fault source: "); busfault(); usagefault(); printk("\nKernel Space\n"); print_kernel_status((unsigned int *)sp, lr, psr); printk("\nUser Space\n"); print_user_status((unsigned int *)usp); printk("\nTask Status\n"); print_task_status(current); printk("\nCurrent Context\n"); print_context((unsigned int *)usp); printk("\nSCB_ICSR 0x%08x\n" "SCB_CFSR 0x%08x\n" "SCB_HFSR 0x%08x\n" "SCB_MMFAR 0x%08x\n" "SCB_BFAR 0x%08x\n", SCB_ICSR, SCB_CFSR, SCB_HFSR, SCB_MMFAR, SCB_BFAR); /* led for debugging */ #ifdef LED_DEBUG SET_PORT_CLOCK(ENABLE, PORTD); SET_PORT_PIN(PORTD, 2, PIN_OUTPUT_50MHZ); unsigned int j; while (1) { PUT_PORT(PORTD, GET_PORT(PORTD) ^ 4); for (i = 100; i; i--) { for (j = 10; j; j--) { __asm__ __volatile__( "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" "nop \n\t" ::: "memory"); } } } #endif while (1); /* restore registers */ /* enable interrupts */ }
int main(int argc, char **argv) { int opt, sock, newsock, result, flags, if_index = 0, on = 1; socklen_t sinlen, opt_len; struct sockaddr_storage sin; struct addrinfo hints, *res; struct sctp_sndrcvinfo sinfo; struct pollfd poll_fd; char getsockopt_peerlabel[1024]; char byte, *peerlabel, msglabel[1024], if_name[30]; bool nopeer = false, verbose = false, ipv4 = false, snd_opt = false; char *context, *host_addr = NULL, *bindx_addr = NULL; struct sockaddr_in ipv4_addr; unsigned short port; while ((opt = getopt(argc, argv, "4b:h:inv")) != -1) { switch (opt) { case '4': ipv4 = true; break; case 'b': bindx_addr = optarg; break; case 'h': host_addr = optarg; break; case 'i': snd_opt = true; break; case 'n': nopeer = true; break; case 'v': verbose = true; break; default: usage(argv[0]); } } if ((argc - optind) != 2) usage(argv[0]); port = atoi(argv[optind + 1]); if (!port) usage(argv[0]); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_protocol = IPPROTO_SCTP; if (ipv4) hints.ai_family = AF_INET; else hints.ai_family = AF_INET6; if (!strcmp(argv[optind], "stream")) hints.ai_socktype = SOCK_STREAM; else if (!strcmp(argv[optind], "seq")) hints.ai_socktype = SOCK_SEQPACKET; else usage(argv[0]); if (verbose) { if (getcon(&context) < 0) context = strdup("unavailable"); printf("Server process context: %s\n", context); free(context); } if (host_addr) { char *ptr; ptr = strpbrk(host_addr, "%"); if (ptr) strcpy(if_name, ptr + 1); if_index = if_nametoindex(if_name); if (!if_index) { perror("Server if_nametoindex"); exit(1); } result = getaddrinfo(host_addr, argv[optind + 1], &hints, &res); } else { result = getaddrinfo(NULL, argv[optind + 1], &hints, &res); } if (result < 0) { fprintf(stderr, "Server getaddrinfo: %s\n", gai_strerror(result)); exit(1); } sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (sock < 0) { perror("Server socket"); exit(1); } result = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (result < 0) { perror("Server setsockopt: SO_REUSEADDR"); close(sock); exit(1); } /* Enables sctp_data_io_events for sctp_recvmsg(3) for assoc_id. */ result = setsockopt(sock, SOL_SCTP, SCTP_EVENTS, &on, sizeof(on)); if (result < 0) { perror("Server setsockopt: SCTP_EVENTS"); close(sock); exit(1); } if (bindx_addr) { memset(&ipv4_addr, 0, sizeof(struct sockaddr_in)); ipv4_addr.sin_family = AF_INET; ipv4_addr.sin_port = htons(port); ipv4_addr.sin_addr.s_addr = inet_addr(bindx_addr); result = sctp_bindx(sock, (struct sockaddr *)&ipv4_addr, 1, SCTP_BINDX_ADD_ADDR); if (result < 0) { perror("Server sctp_bindx ADD - ipv4"); close(sock); exit(1); } } else { result = bind(sock, res->ai_addr, res->ai_addrlen); if (result < 0) { perror("Server bind"); close(sock); exit(1); } } if (verbose) { print_context(sock, "Server LISTEN"); print_ip_option(sock, ipv4, "Server LISTEN"); } if (listen(sock, SOMAXCONN)) { perror("Server listen"); close(sock); exit(1); } if (hints.ai_socktype == SOCK_STREAM) { if (verbose) print_context(sock, "Server STREAM"); do { socklen_t labellen = sizeof(getsockopt_peerlabel); sinlen = sizeof(sin); newsock = accept(sock, (struct sockaddr *)&sin, &sinlen); if (newsock < 0) { perror("Server accept"); close(sock); exit(1); } if (verbose) { print_context(newsock, "Server STREAM accept on newsock"); print_addr_info((struct sockaddr *)&sin, "Server connected to Client"); print_ip_option(newsock, ipv4, "Server STREAM accept on newsock"); } if (nopeer) { peerlabel = strdup("nopeer"); } else if (snd_opt) { peerlabel = get_ip_option(newsock, ipv4, &opt_len); if (!peerlabel) peerlabel = strdup("no_ip_options"); } else { result = getpeercon(newsock, &peerlabel); if (result < 0) { perror("Server getpeercon"); close(sock); close(newsock); exit(1); } /* Also test the getsockopt version */ result = getsockopt(newsock, SOL_SOCKET, SO_PEERSEC, getsockopt_peerlabel, &labellen); if (result < 0) { perror("Server getsockopt: SO_PEERSEC"); close(sock); close(newsock); exit(1); } if (verbose) printf("Server STREAM SO_PEERSEC peer label: %s\n", getsockopt_peerlabel); } printf("Server STREAM %s: %s\n", snd_opt ? "sock_opt" : "peer label", peerlabel); result = read(newsock, &byte, 1); if (result < 0) { perror("Server read"); close(sock); close(newsock); exit(1); } result = write(newsock, peerlabel, strlen(peerlabel)); if (result < 0) { perror("Server write"); close(sock); close(newsock); exit(1); } if (verbose) printf("Server STREAM sent: %s\n", peerlabel); free(peerlabel); /* Let the client close the connection first as this * will stop OOTB chunks if newsock closed early. */ poll_fd.fd = newsock; poll_fd.events = POLLRDHUP; poll_fd.revents = 1; result = poll(&poll_fd, 1, 1000); if (verbose && result == 1) printf("Server STREAM: Client closed connection\n"); else if (verbose && result == 0) printf("Server: poll(2) timed out - OKAY\n"); else if (result < 0) perror("Server - poll"); close(newsock); } while (1); } else { /* hints.ai_socktype == SOCK_SEQPACKET */ if (verbose) print_context(sock, "Server SEQPACKET sock"); do { sinlen = sizeof(sin); result = sctp_recvmsg(sock, msglabel, sizeof(msglabel), (struct sockaddr *)&sin, &sinlen, &sinfo, &flags); if (result < 0) { perror("Server sctp_recvmsg"); close(sock); exit(1); } if (verbose) { print_context(sock, "Server SEQPACKET recvmsg"); print_addr_info((struct sockaddr *)&sin, "Server SEQPACKET recvmsg"); print_ip_option(sock, ipv4, "Server SEQPACKET recvmsg"); } if (nopeer) { peerlabel = strdup("nopeer"); } else if (snd_opt) { peerlabel = get_ip_option(sock, ipv4, &opt_len); if (!peerlabel) peerlabel = strdup("no_ip_options"); } else { result = getpeercon(sock, &peerlabel); if (result < 0) { perror("Server getpeercon"); close(sock); exit(1); } } printf("Server SEQPACKET %s: %s\n", snd_opt ? "sock_opt" : "peer label", peerlabel); if (sin.ss_family == AF_INET6 && host_addr) ((struct sockaddr_in6 *)&sin)->sin6_scope_id = if_index; result = sctp_sendmsg(sock, peerlabel, strlen(peerlabel), (struct sockaddr *)&sin, sinlen, 0, 0, 0, 0, 0); if (result < 0) { perror("Server sctp_sendmsg"); close(sock); exit(1); } if (verbose) printf("Server SEQPACKET sent: %s\n", peerlabel); free(peerlabel); } while (1); } close(sock); exit(0); }
void print_warning(const char* message) const { result.has_warning(); std::cerr << "Warning"; print_context(); std::cerr << message << '\n'; }
void print_error(const char* message) const { result.has_error(); std::cerr << "Error"; print_context(); std::cerr << message << '\n'; }
int error(int t, loc* lc, char* s ...) /* "int" not "void" because of "pch" in lex.c subsequent arguments fill in %mumble fields legal error types are: 'w' warning (not counted in error count) 'd' debug 's' "not implemented" message 0 error 'i' internal error (causes abort) 't' error while printing error message */ { FILE * of = out_file; int c; char format[3]; /* used for "% mumble" sequences */ int * a = &t; int argn = 3; /* check variable argument passing mechanism */ int si = sizeof(int); int scp = sizeof(char*); int ssp = sizeof(Pname); if (si!=ssp || si!=scp || ssp!=scp || &a[2]!=(int*)&s) { fprintf(stderr, "\n%s: this c can't handle varargs (%d,%d,%d -- %d %d)\n", prog_name, si, scp, ssp, &a[1], &s); ext(12); } if (t == 'w' && warn==0) return 0; if (in_error++) if (t!='t' || 4<in_error) { fprintf(stderr,"\nUPS!, error while handling error\n"); ext(13); } else if (t == 't') t = 'i'; out_file = stderr; if (!scan_started) /*fprintf(out_file,"error during %s initializing: ",prog_name);*/ putch('\n'); else if (t=='t') putch('\n'); else if (lc != &dummy_loc) lc->put(out_file); else print_loc(); switch (t) { case 0: fprintf(out_file,"error: "); break; case 'w': no_of_warnings++; fprintf(out_file,"warning: "); break; case 's': fprintf(out_file,"sorry, not implemented: "); break; case 'i': if (error_count++) { fprintf(out_file,"sorry, %s cannot recover from earlier errors\n",prog_name); ext(INTERNAL); } else fprintf(out_file,"internal %s error: ",prog_name); break; } while (c = *s++) { if ('A'<=c && c<='Z' && abbrev_tbl['A']) putstring(abbrev_tbl[c]); else if (c == '%') switch (c = *s++) { case 'k': { TOK x = a[argn]; if (0<x && x<MAXTOK && keys[x]) fprintf(out_file," %s",keys[x]); else fprintf(out_file," token(%d)",x); argn++; break; } case 't': /* Ptype */ { Ptype tt = (Ptype)a[argn]; if (tt) { TOK pm = print_mode; extern int ntok; int nt = ntok; print_mode = ERROR; fprintf(out_file," "); tt->dcl_print(0); print_mode = pm; ntok = nt; argn++; } break; } case 'n': /* Pname */ { Pname nn = (Pname)a[argn]; if (nn) { TOK pm = print_mode; print_mode = ERROR; fprintf(out_file," "); nn->print(); print_mode = pm; } else fprintf(out_file," ?"); argn++; break; } default: format[0] = '%'; format[1] = c; format[2] = '\0'; fprintf(out_file,format,a[argn++]); break; } else putch(c); } if (!scan_started) ext(4); switch (t) { case 'd': case 't': case 'w': putch('\n'); break; default: print_context(); } fflush(stderr); /* now we may want to carry on */ out_file = of; switch (t) { case 't': if (--in_error) return 0; case 'i': ext(INTERNAL); case 0: case 's': if (MAXERR<++error_count) { fprintf(stderr,"Sorry, too many errors\n"); ext(7); } } in_error = 0; return 0; }
void printall() { cprintf("$ \n"); cprintf("\\text{Principal } 1 == A \\\\ \n"); cprintf("\\text{Principal } 2 == B \\\\ \n"); cprintf("\\text{Principal } 3 == C \\\\ \n"); cprintf("\\text{Principal } 4 == D \\\\ \n"); cprintf("\\text{Principal } 5 == E \\\\ \n"); cprintf("\\text{Principal } 6 == F \\\\ \n"); cprintf("\\text{Principal } 7 == G \\\\ \n"); cprintf("\\text{Predicate } 99 == OK \\\\ \n"); cprintf("\\text{Predicate } 100 == ALRIGHT \\\\\\\\ \n"); cprintf("\\text{PRINTING FORMULAE} \\\\\\\\ \n"); print_pred(); freeall(); cprintf(" \\\\\\\\ \n"); print_impl(); freeall(); cprintf(" \\\\\\\\ \n"); print_signed(); freeall(); cprintf(" \\\\\\\\ \n"); print_says(); freeall(); cprintf(" \\\\\\\\ \n"); print_confirms(); freeall(); cprintf(" \\\\\\\\ \n"); print_abs(); freeall(); cprintf(" \\\\\\\\ \n"); cprintf("\\text{PRINTING CONTEXT} \\\\\\\\ \n"); print_context(); freeall(); cprintf(" \\\\\\\\ \n"); cprintf("\\text{PRINTING PROOFS} \\\\\\\\ \n"); print_signed_p(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_confirms_p(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_assump_p(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_tauto_p(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_weaken_impl_p(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_impl_p(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_says_confirms(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_says_signed(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_says_says(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); print_says_spec(); freeall(); cprintf(" \\\\\\\\\\\\\\\\ \n"); cprintf("$ \n"); freeall(); cprintf("\\begin{landscape} \n $"); print_delegation(); freeall(); cprintf("$ \n \\end{landscape} \n "); }