static void debug_read_mem(struct gdbcontext *ctx, const char *spec) { uint32_t vaddr, length, i; uint32_t word; uint8_t byte; const char *curptr; char buf[BUFLEN]; vaddr = strtoul(spec, (char **)&curptr, 16); length = strtoul(curptr+1, NULL, 16); buf[0] = 0; for (i=0; i<length && (vaddr+i)%4 != 0; i++) { if (cpudebug_fetch_byte(debug_cpu, vaddr+i, &byte)) { debug_send(ctx, "E03"); return; } printbyte(buf, sizeof(buf), byte); } for (; i<length; i += 4) { if (cpudebug_fetch_word(debug_cpu, vaddr+i, &word)) { debug_send(ctx, "E03"); return; } printword(buf, sizeof(buf), word); } debug_send(ctx, buf); }
static void printdict(Word **d) { int i; for (i=0; i<nword; i++) { printword(d[i]); } }
static int do_diff_lines(struct file fl[2], struct csl *csl) { int a, b; int exit_status = 0; a = b = 0; while (a < fl[0].elcnt || b < fl[1].elcnt) { if (a < csl->a) { if (fl[0].list[a].start[0]) { printf("-"); printword(stdout, fl[0].list[a]); } a++; exit_status++; } else if (b < csl->b) { if (fl[1].list[b].start[0]) { printf("+"); printword(stdout, fl[1].list[b]); } b++; exit_status++; } else { if (fl[0].list[a].start[0] == '\0') printsep(fl[0].list[a], fl[1].list[b]); else { printf(" "); printword(stdout, fl[0].list[a]); } a++; b++; if (a >= csl->a+csl->len) csl++; } } return exit_status; }
static void debug_register_print(struct gdbcontext *ctx) { uint32_t regs[256]; int i, nregs; char buf[BUFLEN]; cpudebug_getregs(debug_cpu, regs, 256, &nregs); Assert(nregs <= 256); buf[0] = 0; for (i=0; i<nregs; i++) { printword(buf, sizeof(buf), regs[i]); } debug_send(ctx, buf); }
main() #endif { FILE *fp = stdin; /* File pointer, default stdin */ CRITICALS *tuples; int i; int n; CUBE_INFO *p; printf("\ntuples - version %1.2f\n\n", VERSION_NUM); #ifndef NO_CMD_LINE /* Check the command line and open file if required */ command_line(&fp,argc, argv, &n); #else /* Read command info from standard input */ command_input(&fp, &n); #endif /* Read in info from the file, setting up Fsa and so on... */ switch (read_file_info(fp)) { case FORMAT_ERROR: ERROR(FORMAT); case NOT_A_GEN: ERROR(GEN_ERR); } fclose(fp); /* No more reading required */ tuples = find_n_criticals(n); printf("Number of Critical %d-tuples = %d\n\n", n, tuples->num); for (i=0; i < tuples->num; i++) { printword(stdout, tuples->info[i]->word); printf("\t"); for (p = tuples->info[i]->vert; p != NULL; p = p->next) printf("[%d,%d] ", p->pos, p->len); printf("\n"); } /* Clean up */ delete_criticals(tuples); return 0; }
static int do_travel(struct trie_node_st *rootp) { static char worddump[WORDLENMAX+1]; static int pos=0; int i; if (rootp == NULL) { return 0; } if (rootp->count) { worddump[pos]='\0'; printword(worddump, rootp->count); } for (i=0;i<TREE_WIDTH;++i) { worddump[pos++]=i; do_travel(rootp->next[i]); pos--; } return 0; }
static int do_diff_words(struct file fl[2], struct csl *csl) { int a, b; int exit_status = 0; int sol = 1; /* start of line */ a = b = 0; while (a < fl[0].elcnt || b < fl[1].elcnt) { if (a < csl->a) { exit_status++; if (sol) { int a1; /* If we remove a * whole line, output * +line else clear * sol and retry */ sol = 0; for (a1 = a; a1 < csl->a ; a1++) if (ends_line(fl[0].list[a1])) { sol = 1; break; } if (sol) { printf("-"); for (; a < csl->a ; a++) { printword(stdout, fl[0].list[a]); if (ends_line(fl[0].list[a])) { a++; break; } } } else printf("|"); } if (!sol) { printf("<<<--"); do { if (sol) printf("|"); printword(stdout, fl[0].list[a]); sol = ends_line(fl[0].list[a]); a++; } while (a < csl->a); printf("%s-->>>", sol ? "|" : ""); sol = 0; } } else if (b < csl->b) { exit_status++; if (sol) { int b1; sol = 0; for (b1 = b; b1 < csl->b; b1++) if (ends_line(fl[1].list[b1])) { sol = 1; break; } if (sol) { printf("+"); for (; b < csl->b ; b++) { printword(stdout, fl[1].list[b]); if (ends_line(fl[1].list[b])) { b++; break; } } } else printf("|"); } if (!sol) { printf("<<<++"); do { if (sol) printf("|"); printword(stdout, fl[1].list[b]); sol = ends_line(fl[1].list[b]); b++; } while (b < csl->b); printf("%s++>>>", sol ? "|" : ""); sol = 0; } } else { if (sol) { int a1; sol = 0; for (a1 = a; a1 < csl->a+csl->len; a1++) if (ends_line(fl[0].list[a1])) sol = 1; if (sol) { if (fl[0].list[a].start[0]) { printf(" "); for (; a < csl->a+csl->len; a++, b++) { printword(stdout, fl[0].list[a]); if (ends_line(fl[0].list[a])) { a++, b++; break; } } } else { printsep(fl[0].list[a], fl[1].list[b]); a++; b++; } } else printf("|"); } if (!sol) { printword(stdout, fl[0].list[a]); if (ends_line(fl[0].list[a])) sol = 1; a++; b++; } if (a >= csl->a+csl->len) csl++; } } return exit_status; }