当前位置: 首页>>代码示例>>C++>>正文


C++ Bprint函数代码示例

本文整理汇总了C++中Bprint函数的典型用法代码示例。如果您正苦于以下问题:C++ Bprint函数的具体用法?C++ Bprint怎么用?C++ Bprint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Bprint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dodata

void
dodata(void)
{
    int i, t;
    Sym *s;
    Prog *p;
    long orig, v;

    if(debug['v'])
        Bprint(&bso, "%5.2f dodata\n", cputime());
    Bflush(&bso);
    for(p = datap; p != P; p = p->link) {
        s = p->from.sym;
        if(p->as == ADYNT || p->as == AINIT)
            s->value = dtype;
        if(s->type == SBSS)
            s->type = SDATA;
        if(s->type != SDATA)
            diag("initialize non-data (%d): %s\n%P",
                 s->type, s->name, p);
        v = p->from.offset + p->reg;
        if(v > s->value)
            diag("initialize bounds (%ld): %s\n%P",
                 s->value, s->name, p);
        if((s->type == SBSS || s->type == SDATA) && (p->to.type == D_CONST || p->to.type == D_OCONST) && (p->to.name == D_EXTERN || p->to.name == D_STATIC)) {
            s = p->to.sym;
            if(s != S && (s->type == STEXT || s->type == SLEAF || s->type == SCONST || s->type == SXREF))
                s->fnptr = 1;
        }
    }

    if(debug['t']) {
        /*
         * pull out string constants
         */
        for(p = datap; p != P; p = p->link) {
            s = p->from.sym;
            if(p->to.type == D_SCONST)
                s->type = SSTRING;
        }
    }

    /*
     * pass 1
     *	assign 'small' variables to data segment
     *	(rational is that data segment is more easily
     *	 addressed through offset on R12)
     */
    orig = 0;
    for(i=0; i<NHASH; i++)
        for(s = hash[i]; s != S; s = s->link) {
            t = s->type;
            if(t != SDATA && t != SBSS)
                continue;
            v = s->value;
            if(v == 0) {
                diag("%s: no size", s->name);
                v = 1;
            }
            while(v & 3)
                v++;
            s->value = v;
            if(v > MINSIZ)
                continue;
            s->value = orig;
            orig += v;
            s->type = SDATA1;
        }

    /*
     * pass 2
     *	assign large 'data' variables to data segment
     */
    for(i=0; i<NHASH; i++)
        for(s = hash[i]; s != S; s = s->link) {
            t = s->type;
            if(t != SDATA) {
                if(t == SDATA1)
                    s->type = SDATA;
                continue;
            }
            v = s->value;
            s->value = orig;
            orig += v;
        }

    while(orig & 7)
        orig++;
    datsize = orig;

    /*
     * pass 3
     *	everything else to bss segment
     */
    for(i=0; i<NHASH; i++)
        for(s = hash[i]; s != S; s = s->link) {
            if(s->type != SBSS)
                continue;
            v = s->value;
            s->value = orig;
//.........这里部分代码省略.........
开发者ID:tusharsoni,项目名称:Inferno,代码行数:101,代码来源:pass.c

示例2: span

void
span(void)
{
	Prog *p, *q;
	long v;
	vlong c, idat;
	int m, n, again;

	xdefine("etext", STEXT, 0L);
	idat = INITDAT;
	for(p = firstp; p != P; p = p->link) {
		if(p->as == ATEXT)
			curtext = p;
		n = 0;
		if(p->to.type == D_BRANCH)
			if(p->pcond == P)
				p->pcond = p;
		if((q = p->pcond) != P)
			if(q->back != 2)
				n = 1;
		p->back = n;
		if(p->as == AADJSP) {
			p->to.type = D_SP;
			v = -p->from.offset;
			p->from.offset = v;
			p->as = p->mode != 64? AADDL: AADDQ;
			if(v < 0) {
				p->as = p->mode != 64? ASUBL: ASUBQ;
				v = -v;
				p->from.offset = v;
			}
			if(v == 0)
				p->as = ANOP;
		}
	}
	n = 0;

start:
	if(debug['v'])
		Bprint(&bso, "%5.2f span\n", cputime());
	Bflush(&bso);
	c = INITTEXT;
	for(p = firstp; p != P; p = p->link) {
		if(p->as == ATEXT)
			curtext = p;
		if(p->to.type == D_BRANCH)
			if(p->back)
				p->pc = c;
		asmins(p);
		p->pc = c;
		m = andptr-and;
		p->mark = m;
		c += m;
	}

loop:
	n++;
	if(debug['v'])
		Bprint(&bso, "%5.2f span %d\n", cputime(), n);
	Bflush(&bso);
	if(n > 50) {
		print("span must be looping\n");
		errorexit();
	}
	again = 0;
	c = INITTEXT;
	for(p = firstp; p != P; p = p->link) {
		if(p->as == ATEXT)
			curtext = p;
		if(p->to.type == D_BRANCH || p->back & 0100) {
			if(p->back)
				p->pc = c;
			asmins(p);
			m = andptr-and;
			if(m != p->mark) {
				p->mark = m;
				again++;
			}
		}
		p->pc = c;
		c += p->mark;
	}
	if(again) {
		textsize = c;
		goto loop;
	}
	if(INITRND) {
		INITDAT = rnd(c, INITRND);
		if(INITDAT != idat) {
			idat = INITDAT;
			goto start;
		}
	}
	xdefine("etext", STEXT, c);
	if(debug['v'])
		Bprint(&bso, "etext = %llux\n", c);
	Bflush(&bso);
	for(p = textp; p != P; p = p->pcond)
		p->from.sym->value = p->pc;
	textsize = c - INITTEXT;
//.........这里部分代码省略.........
开发者ID:cephdon,项目名称:inferno-1,代码行数:101,代码来源:span.c

示例3: isum

void
isum(void)
{
	Inst *i;
	int pct, j, k;
	int total, loads, stores, arith, branch;
	int taken, powerreg, syscall, realarith, control;

	total = 0;
	loads = 0;
	stores = 0;
	arith = 0;
	branch = 0;
	taken = 0;
	powerreg = 0;
	syscall = 0;
	realarith = 0;
	control = 0;

	/* Compute the total so we can have percentages */
	for(j = 0; tables[j]; j++)
		for(k = tables[j]->nel; --k >= 0;) {
			i = &tables[j]->tab[k];
			if(i->name && i->func)
				total += i->count;
		}

	Bprint(bioout, "\nInstruction summary.\n\n");

	for(j = 0; tables[j]; j++) {
		for(k =tables[j]->nel; --k>=0; ) {
			i = &tables[j]->tab[k];
			if(i->name && i->func) {
				if(i->count == 0)
					continue;
				pct = Percent(i->count, total);
				if(pct != 0)
					Bprint(bioout, "%-8ud %3d%% %s\n",
					i->count, Percent(i->count, total), i->name);
				else
					Bprint(bioout, "%-8ud      %s\n",
					i->count, i->name);
	
				switch(i->type) {
				default:
					fatal(0, "isum bad stype %d\n", i->type);
				case Iload:
					loads += i->count;
					break;
				case Istore:
					stores += i->count;
					break;
				case Ilog:
				case Iarith:
					arith += i->count;
					break;
				case Ibranch:
					branch += i->count;
					taken += i->taken;
					break;
				case Ireg:
					powerreg += i->count;
					break;
				case Isyscall:
					syscall += i->count;
					break;
				case Ifloat:
					realarith += i->count;
					break;
				case Inop:
					arith += i->count;
					i->count -= nopcount;
					break;
				case Icontrol:
					control += i->count;
					break;
				}
			}
		}
	}

	Bprint(bioout, "\n%-8ud      Memory cycles\n", loads+stores+total);

	if(total == 0)
		return;

	Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
				total, Percent(total, loads+stores+total));

	Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
				loads+stores, Percent(loads+stores, loads+stores+total));	

	Bprint(bioout, "%-8ud %3d%% Stores\n", stores, Percent(stores, total));

	Bprint(bioout, "%-8ud %3d%% Loads\n", loads, Percent(loads, total));

	Bprint(bioout, "   %-8ud Store stall\n", stores*2);

	Bprint(bioout, "   %-8lud Load stall\n", loadlock);

//.........这里部分代码省略.........
开发者ID:Harvey-OS,项目名称:legacy,代码行数:101,代码来源:stats.c

示例4: imap4read

//
// check for new messages on imap4 server
// download new messages, mark deleted messages
//
static char*
imap4read(Imap *imap, Mailbox *mb, int doplumb)
{
    char *s;
    int i, ignore, nnew, t;
    Message *m, *next, **l;

    imap4cmd(imap, "STATUS %Z (MESSAGES UIDVALIDITY)", imap->mbox);
    if(!isokay(s = imap4resp(imap)))
        return s;

    imap->nuid = 0;
    imap->uid = erealloc(imap->uid, imap->nmsg*sizeof(imap->uid[0]));
    imap->muid = imap->nmsg;

    if(imap->nmsg > 0) {
        imap4cmd(imap, "UID FETCH 1:* UID");
        if(!isokay(s = imap4resp(imap)))
            return s;
    }

    l = &mb->root->part;
    for(i=0; i<imap->nuid; i++) {
        ignore = 0;
        while(*l != nil) {
            if((*l)->imapuid == imap->uid[i]) {
                ignore = 1;
                l = &(*l)->next;
                break;
            } else {
                // old mail, we don't have it anymore
                if(doplumb)
                    mailplumb(mb, *l, 1);
                (*l)->inmbox = 0;
                (*l)->deleted = 1;
                l = &(*l)->next;
            }
        }
        if(ignore)
            continue;

        // new message
        m = newmessage(mb->root);
        m->mallocd = 1;
        m->inmbox = 1;
        m->imapuid = imap->uid[i];

        // add to chain, will download soon
        *l = m;
        l = &m->next;
    }

    // whatever is left at the end of the chain is gone
    while(*l != nil) {
        if(doplumb)
            mailplumb(mb, *l, 1);
        (*l)->inmbox = 0;
        (*l)->deleted = 1;
        l = &(*l)->next;
    }

    // download new messages
    t = imap->tag;
    if(pipeline)
        switch(rfork(RFPROC|RFMEM)) {
        case -1:
            sysfatal("rfork: %r");
        default:
            break;
        case 0:
            for(m = mb->root->part; m != nil; m = m->next) {
                if(m->start != nil)
                    continue;
                if(imap->debug)
                    fprint(2, "9X%d UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
                           t, (ulong)m->imapuid);
                Bprint(&imap->bout, "9X%d UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
                       t++, (ulong)m->imapuid);
            }
            Bflush(&imap->bout);
            _exits(nil);
        }

    nnew = 0;
    for(m=mb->root->part; m!=nil; m=next) {
        next = m->next;
        if(m->start != nil)
            continue;

        if(!pipeline) {
            Bprint(&imap->bout, "9X%lud UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
                   (ulong)imap->tag, (ulong)m->imapuid);
            Bflush(&imap->bout);
        }

        if(s = imap4fetch(mb, m)) {
//.........这里部分代码省略.........
开发者ID:aberg001,项目名称:plan9,代码行数:101,代码来源:imap4.c

示例5: dobplist

void
dobplist(void)
{
	Breakpoint *b;
	char buf[512];

	for(b = bplist; b; b = b->next) {
		switch(b->type) {
		case Instruction:
			Bprint(bioout, "0x%lux,%d:b %d done, at ", b->addr, b->count, b->done);
			symoff(buf, sizeof(buf), b->addr, CTEXT);
			Bprint(bioout, "%s", buf);
			break;

		case Access:
			Bprint(bioout, "0x%lux,%d:ba %d done, at ", b->addr, b->count, b->done);
			symoff(buf, sizeof(buf), b->addr, CDATA);
			Bprint(bioout, "%s", buf);
			break;

		case Read:
			Bprint(bioout, "0x%lux,%d:br %d done, at ", b->addr, b->count, b->done);
			symoff(buf, sizeof(buf), b->addr, CDATA);
			Bprint(bioout, "%s", buf);
			break;

		case Write:
			Bprint(bioout, "0x%lux,%d:bw %d done, at ", b->addr, b->count, b->done);
			symoff(buf, sizeof(buf), b->addr, CDATA);
			Bprint(bioout, "%s", buf);
			break;

		case Equal:
			Bprint(bioout, "0x%lux,%d:be at ", b->addr, b->count);
			symoff(buf, sizeof(buf), b->addr, CDATA);
			Bprint(bioout, "%s", buf);
			break;
		}
		Bprint(bioout, "\n");
	}
}
开发者ID:carriercomm,项目名称:legacy,代码行数:41,代码来源:bpt.c

示例6: sdis

void
sdis(char a1, char a2)
{
	int c1, c2;
	int eqnf;
	int lct;

	if(a1 == 'P'){
		while(C1 == ' ')
			;
		if(c == '<') {
			SKIP1;
			return;
		}
	}
	lct = 0;
	eqnf = 1;
	if(c != '\n')
		SKIP1;
	for(;;) {
		while(C1 != '.')
			if(c == '\n')
				continue;
			else
				SKIP1;
		if((c1=C1) == '\n')
			continue;
		if((c2=C1) == '\n') {
			if(a1 == 'f' && (c1 == 'P' || c1 == 'H'))
				return;
			continue;
		}
		if(c1==a1 && c2 == a2) {
			SKIP1;
			if(lct != 0){
				lct--;
				continue;
			}
			if(eqnf)
				Bprint(&(bout.Biobufhdr), " .");
			Bputc(&(bout.Biobufhdr), '\n');
			return;
		} else
		if(a1 == 'L' && c2 == 'L') {
			lct++;
			SKIP1;
		} else
		if(a1 == 'D' && c1 == 'E' && c2 == 'Q') {
			eqn(); 
			eqnf = 0;
		} else
		if(a1 == 'f') {
			if((mac == MS && c2 == 'P') ||
				(mac == MM && c1 == 'H' && c2 == 'U')){
				SKIP1;
				return;
			}
			SKIP1;
		}
		else
			SKIP1;
	}
}
开发者ID:n-t-roff,项目名称:Plan9_troff,代码行数:63,代码来源:deroff.c

示例7: drawline

void
drawline(int i, int cl, int cr, int lintype, int noheight, int shortl)
{
	char	*exhr, *exhl, *lnch;
	int	lcount, ln, linpos, oldpos, nodata;

	lcount = 0;
	exhr = exhl = "";
	switch (lintype) {
	case '-':
		lcount = 1;
		break;
	case '=':
		lcount = pr1403 ? 1 : 2;
		break;
	case SHORTLINE:
		lcount = 1;
		break;
	}
	if (lcount <= 0)
		return;
	nodata = cr - cl >= ncol || noheight || allh(i);
	if (!nodata)
		Bprint(&tabout, "\\v'-.5m'");
	for (ln = oldpos = 0; ln < lcount; ln++) {
		linpos = 2 * ln - lcount + 1;
		if (linpos != oldpos)
			Bprint(&tabout, "\\v'%dp'", linpos - oldpos);
		oldpos = linpos;
		if (shortl == 0) {
			tohcol(cl);
			if (lcount > 1) {
				switch (interv(i, cl)) {
				case TOP:
					exhl = ln == 0 ? "1p" : "-1p";
					break;
				case BOT:
					exhl = ln == 1 ? "1p" : "-1p";
					break;
				case THRU:
					exhl = "1p";
					break;
				}
				if (exhl[0])
					Bprint(&tabout, "\\h'%s'", exhl);
			} else if (lcount == 1) {
				switch (interv(i, cl)) {
				case TOP:
				case BOT:
					exhl = "-1p";
					break;
				case THRU:
					exhl = "1p";
					break;
				}
				if (exhl[0])
					Bprint(&tabout, "\\h'%s'", exhl);
			}
			if (lcount > 1) {
				switch (interv(i, cr + 1)) {
				case TOP:
					exhr = ln == 0 ? "-1p" : "+1p";
					break;
				case BOT:
					exhr = ln == 1 ? "-1p" : "+1p";
					break;
				case THRU:
					exhr = "-1p";
					break;
				}
			} else if (lcount == 1) {
				switch (interv(i, cr + 1)) {
				case TOP:
				case BOT:
					exhr = "+1p";
					break;
				case THRU:
					exhr = "-1p";
					break;
				}
			}
		} else
			Bprint(&tabout, "\\h'|\\n(%2su'", reg(cl, CLEFT));
		Bprint(&tabout, "\\s\\n(%d", LSIZE);
		if (linsize)
			Bprint(&tabout, "\\v'-\\n(%dp/6u'", LSIZE);
		if (shortl)
			Bprint(&tabout, "\\l'|\\n(%2su'", reg(cr, CRIGHT));
		else
		 {
			lnch = "\\(ul";
			if (pr1403)
				lnch = lintype == 2 ? "=" : "\\(ru";
			if (cr + 1 >= ncol)
				Bprint(&tabout, "\\l'|\\n(TWu%s%s'", exhr, lnch);
			else
				Bprint(&tabout, "\\l'(|\\n(%2su+|\\n(%2su)/2u%s%s'", reg(cr, CRIGHT),
				    reg(cr + 1, CLEFT), exhr, lnch);
		}
		if (linsize)
//.........这里部分代码省略.........
开发者ID:dancrossnyc,项目名称:harvey,代码行数:101,代码来源:tu.c

示例8: printtypename

static void
printtypename(Type *t)
{
    Sym *s;
    Type *t1;
    int w;
    char *n;

    for( ; t != nil; t = t->link) {
        switch(t->etype) {
        case TIND:
            // Special handling of *void.
            if(t->link != nil && t->link->etype==TVOID) {
                Bprint(&outbuf, "unsafe.Pointer");
                return;
            }
            // *func == func
            if(t->link != nil && t->link->etype==TFUNC)
                continue;
            Bprint(&outbuf, "*");
            continue;
        case TARRAY:
            w = t->width;
            if(t->link && t->link->width)
                w /= t->link->width;
            Bprint(&outbuf, "[%d]", w);
            continue;
        }
        break;
    }

    if(t == nil) {
        Bprint(&outbuf, "bad // should not happen");
        return;
    }

    switch(t->etype) {
    case TINT:
        Bprint(&outbuf, "int32");
        break;
    case TUINT:
        Bprint(&outbuf, "uint32");
        break;
    case TCHAR:
        Bprint(&outbuf, "int8");
        break;
    case TUCHAR:
        Bprint(&outbuf, "uint8");
        break;
    case TSHORT:
        Bprint(&outbuf, "int16");
        break;
    case TUSHORT:
        Bprint(&outbuf, "uint16");
        break;
    case TLONG:
        Bprint(&outbuf, "int32");
        break;
    case TULONG:
        Bprint(&outbuf, "uint32");
        break;
    case TVLONG:
        Bprint(&outbuf, "int64");
        break;
    case TUVLONG:
        Bprint(&outbuf, "uint64");
        break;
    case TFLOAT:
        Bprint(&outbuf, "float32");
        break;
    case TDOUBLE:
        Bprint(&outbuf, "float64");
        break;
    case TUNION:
    case TSTRUCT:
        s = findsue(t->link);
        n = "bad";
        if(s != S)
            n = s->name;
        else if(t->tag)
            n = t->tag->name;
        if(strcmp(n, "String") == 0) {
            Bprint(&outbuf, "string");
        } else if(strcmp(n, "Slice") == 0) {
            Bprint(&outbuf, "[]byte");
        } else
            Bprint(&outbuf, "%U", n);
        break;
    case TFUNC:
        Bprint(&outbuf, "func(");
        for(t1 = t->down; t1 != T; t1 = t1->down) {
            if(t1->etype == TVOID)
                break;
            if(t1 != t->down)
                Bprint(&outbuf, ", ");
            printtypename(t1);
        }
        Bprint(&outbuf, ")");
        if(t->link && t->link->etype != TVOID) {
            Bprint(&outbuf, " ");
//.........这里部分代码省略.........
开发者ID:h8liu,项目名称:golang,代码行数:101,代码来源:godefs.c

示例9: godefvar

void
godefvar(Sym *s)
{
    Type *t, *t1;
    char n;

    if(dontrun())
        return;

    t = s->type;
    if(t == nil)
        return;

    switch(t->etype) {
    case TENUM:
        if(!typefd[t->etype])
            Bprint(&outbuf, "const %U = %lld\n", s->name, s->vconst);
        else
            Bprint(&outbuf, "const %U = %f\n;", s->name, s->fconst);
        break;

    case TFUNC:
        Bprint(&outbuf, "func %U(", s->name);
        n = 'a';
        for(t1 = t->down; t1 != T; t1 = t1->down) {
            if(t1->etype == TVOID)
                break;
            if(t1 != t->down)
                Bprint(&outbuf, ", ");
            Bprint(&outbuf, "%c ", n++);
            printtypename(t1);
        }
        Bprint(&outbuf, ")");
        if(t->link && t->link->etype != TVOID) {
            Bprint(&outbuf, " ");
            printtypename(t->link);
        }
        Bprint(&outbuf, "\n");
        break;

    default:
        switch(s->class) {
        case CTYPEDEF:
            if(!typesu[t->etype]) {
                Bprint(&outbuf, "// type %U\t", s->name);
                printtypename(t);
                Bprint(&outbuf, "\n");
            }
            break;
        case CSTATIC:
        case CEXTERN:
        case CGLOBL:
            if(strchr(s->name, '$') != nil)	 // TODO(lvd)
                break;
            Bprint(&outbuf, "var %U\t", s->name);
            printtypename(t);
            Bprint(&outbuf, "\n");
            break;
        }
        break;
    }
}
开发者ID:h8liu,项目名称:golang,代码行数:62,代码来源:godefs.c

示例10: dump

static void
dump(Vga* vga, Ctlr* ctlr)
{
	int i;

	printitem(ctlr->name, "misc");
	printreg(vga->misc);
	printitem(ctlr->name, "feature");
	printreg(vga->feature);

	printitem(ctlr->name, "sequencer");
	for(i = 0; i < NSeqx; i++)
		printreg(vga->sequencer[i]);

	printitem(ctlr->name, "crt");
	for(i = 0; i < NCrtx; i++)
		printreg(vga->crt[i]);

	printitem(ctlr->name, "graphics");
	for(i = 0; i < NGrx; i++)
		printreg(vga->graphics[i]);

	printitem(ctlr->name, "attribute");
	for(i = 0; i < NAttrx; i++)
		printreg(vga->attribute[i]);

	if(dflag)
		palette.dump(vga, ctlr);

	printitem(ctlr->name, "virtual");
	Bprint(&stdout, "%ld %ld\n", vga->virtx, vga->virty);
	printitem(ctlr->name, "panning");
	Bprint(&stdout, "%s\n", vga->panning ? "on" : "off");
	if(vga->f[0]){
		printitem(ctlr->name, "clock[0] f");
		Bprint(&stdout, "%9ld\n", vga->f[0]);
		printitem(ctlr->name, "clock[0] d i m");
		Bprint(&stdout, "%9ld %8ld       - %8ld\n",
			vga->d[0], vga->i[0], vga->m[0]);
		printitem(ctlr->name, "clock[0] n p q r");
		Bprint(&stdout, "%9ld %8ld       - %8ld %8ld\n",
			vga->n[0], vga->p[0], vga->q[0], vga->r[0]);
	}
	if(vga->f[1]){
		printitem(ctlr->name, "clock[1] f");
		Bprint(&stdout, "%9ld\n", vga->f[1]);
		printitem(ctlr->name, "clock[1] d i m");
		Bprint(&stdout, "%9ld %8ld       - %8ld\n",
			vga->d[1], vga->i[1], vga->m[1]);
		printitem(ctlr->name, "clock[1] n p q r");
		Bprint(&stdout, "%9ld %8ld       - %8ld %8ld\n",
			vga->n[1], vga->p[1], vga->q[1], vga->r[1]);
	}

	if(vga->vma || vga->vmb){
		printitem(ctlr->name, "vm a b");
		Bprint(&stdout, "%9lud %8lud\n", vga->vma, vga->vmb);
	}
	if(vga->vmz){
		printitem(ctlr->name, "vmz");
		Bprint(&stdout, "%9lud\n", vga->vmz);
	}
	printitem(ctlr->name, "apz");
	Bprint(&stdout, "%9lud\n", vga->apz);

	printitem(ctlr->name, "linear");
	Bprint(&stdout, "%9d\n", vga->linear);
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:68,代码来源:vga.c

示例11: patch

void
patch(void)
{
	int32 c;
	Prog *p, *q;
	Sym *s;
	int32 vexit;
	Sym *plan9_tos;

	if(debug['v'])
		Bprint(&bso, "%5.2f mkfwd\n", cputime());
	Bflush(&bso);
	mkfwd();
	if(debug['v'])
		Bprint(&bso, "%5.2f patch\n", cputime());
	Bflush(&bso);
	s = lookup("exit", 0);
	vexit = s->value;
	
	plan9_tos = S;
	if(HEADTYPE == Hplan9x32)
		plan9_tos = lookup("_tos", 0);
	
	for(cursym = textp; cursym != nil; cursym = cursym->next) {
		for(p = cursym->text; p != P; p = p->link) {
			if(HEADTYPE == Hwindows) {
				// Convert
				//   op	  n(GS), reg
				// to
				//   MOVL 0x14(FS), reg
				//   op	  n(reg), reg
				// The purpose of this patch is to fix some accesses
				// to extern register variables (TLS) on Windows, as
				// a different method is used to access them.
				if(p->from.type == D_INDIR+D_GS
				&& p->to.type >= D_AX && p->to.type <= D_DI) {
					q = appendp(p);
					q->from = p->from;
					q->from.type = D_INDIR + p->to.type;
					q->to = p->to;
					q->as = p->as;
					p->as = AMOVL;
					p->from.type = D_INDIR+D_FS;
					p->from.offset = 0x14;
				}
			}
			if(HEADTYPE == Hlinux) {
				// Running binaries under Xen requires using
				//	MOVL 0(GS), reg
				// and then off(reg) instead of saying off(GS) directly
				// when the offset is negative.
				if(p->from.type == D_INDIR+D_GS && p->from.offset < 0
				&& p->to.type >= D_AX && p->to.type <= D_DI) {
					q = appendp(p);
					q->from = p->from;
					q->from.type = D_INDIR + p->to.type;
					q->to = p->to;
					q->as = p->as;
					p->as = AMOVL;
					p->from.type = D_INDIR+D_GS;
					p->from.offset = 0;
				}
			}
			if(HEADTYPE == Hplan9x32) {
				if(p->from.type == D_INDIR+D_GS
				&& p->to.type >= D_AX && p->to.type <= D_DI) {
					q = appendp(p);
					q->from = p->from;
					q->from.type = D_INDIR + p->to.type;
					q->to = p->to;
					q->as = p->as;
					p->as = AMOVL;
					p->from.type = D_EXTERN;
					p->from.sym = plan9_tos;
					p->from.offset = 0;
				}
			}
			if((p->as == ACALL && p->to.type != D_BRANCH) || (p->as == AJMP && p->to.type != D_BRANCH)) {
				s = p->to.sym;
				if(p->to.type == D_INDIR+D_ADDR) {
					 /* skip check if this is an indirect call (CALL *symbol(SB)) */
					 continue;
				} else if(s) {
					if(debug['c'])
						Bprint(&bso, "%s calls %s\n", TNAME, s->name);
					if((s->type&~SSUB) != STEXT) {
						/* diag prints TNAME first */
						diag("undefined: %s", s->name);
						s->type = STEXT;
						s->value = vexit;
						continue;	// avoid more error messages
					}
					if(s->text == nil)
						continue;
					p->to.type = D_BRANCH;
					p->to.offset = s->text->pc;
					p->pcond = s->text;
					continue;
				}
			}
//.........这里部分代码省略.........
开发者ID:funkygao,项目名称:govtil,代码行数:101,代码来源:pass.c

示例12: patch

void
patch(void)
{
    long c, vexit;
    Prog *p, *q;
    Sym *s, *s1;
    int a;

    if(debug['v'])
        Bprint(&bso, "%5.2f patch\n", cputime());
    Bflush(&bso);
    mkfwd();
    s = lookup("exit", 0);
    vexit = s->value;
    for(p = firstp; p != P; p = p->link) {
        setarch(p);
        a = p->as;
        if(a == ATEXT)
            curtext = p;
        if(seenthumb && a == ABL) {
            // if((s = p->to.sym) != S && (s1 = curtext->from.sym) != S)
            //	print("%s calls %s\n", s1->name, s->name);
            if((s = p->to.sym) != S && (s1 = curtext->from.sym) != S && s->thumb != s1->thumb)
                s->foreign = 1;
        }
        if((a == ABL || a == ABX || a == AB || a == ARET) &&
                p->to.type != D_BRANCH && p->to.sym != S) {
            s = p->to.sym;
            switch(s->type) {
            default:
                diag("undefined: %s\n%P", s->name, p);
                s->type = STEXT;
                s->value = vexit;
                break;
            case STEXT:
                p->to.offset = s->value;
                p->to.type = D_BRANCH;
                break;
            case SUNDEF:
                if(p->as != ABL)
                    diag("help: SUNDEF in AB || ARET");
                p->to.offset = 0;
                p->to.type = D_BRANCH;
                p->cond = UP;
                break;
            }
        }
        if(p->to.type != D_BRANCH || p->cond == UP)
            continue;
        c = p->to.offset;
        for(q = firstp; q != P;) {
            if(q->forwd != P)
                if(c >= q->forwd->pc) {
                    q = q->forwd;
                    continue;
                }
            if(c == q->pc)
                break;
            q = q->link;
        }
        if(q == P) {
            diag("branch out of range %ld\n%P", c, p);
            p->to.type = D_NONE;
        }
        p->cond = q;
    }

    for(p = firstp; p != P; p = p->link) {
        setarch(p);
        a = p->as;
        if(p->as == ATEXT)
            curtext = p;
        if(seenthumb && a == ABL) {
#ifdef CALLEEBX
            if(0)
            {}
#else
            if((s = p->to.sym) != S && (s->foreign || s->fnptr))
                p->as = ABX;
#endif
            else if(p->to.type == D_OREG)
                p->as = ABX;
        }
        if(p->cond != P && p->cond != UP) {
            p->cond = brloop(p->cond);
            if(p->cond != P)
                if(p->to.type == D_BRANCH)
                    p->to.offset = p->cond->pc;
        }
    }
}
开发者ID:tusharsoni,项目名称:Inferno,代码行数:91,代码来源:pass.c

示例13: asmb

void
asmb(void)
{
	int32 magic;
	int i;
	vlong vl, symo, dwarfoff, machlink;
	Section *sect;
	LSym *sym;

	if(debug['v'])
		Bprint(&bso, "%5.2f asmb\n", cputime());
	Bflush(&bso);

	if(debug['v'])
		Bprint(&bso, "%5.2f codeblk\n", cputime());
	Bflush(&bso);

	if(iself)
		asmbelfsetup();

	sect = segtext.sect;
	cseek(sect->vaddr - segtext.vaddr + segtext.fileoff);
	codeblk(sect->vaddr, sect->len);
	for(sect = sect->next; sect != nil; sect = sect->next) {
		cseek(sect->vaddr - segtext.vaddr + segtext.fileoff);
		datblk(sect->vaddr, sect->len);
	}

	if(segrodata.filelen > 0) {
		if(debug['v'])
			Bprint(&bso, "%5.2f rodatblk\n", cputime());
		Bflush(&bso);

		cseek(segrodata.fileoff);
		datblk(segrodata.vaddr, segrodata.filelen);
	}

	if(debug['v'])
		Bprint(&bso, "%5.2f datblk\n", cputime());
	Bflush(&bso);

	cseek(segdata.fileoff);
	datblk(segdata.vaddr, segdata.filelen);

	machlink = 0;
	if(HEADTYPE == Hdarwin) {
		if(debug['v'])
			Bprint(&bso, "%5.2f dwarf\n", cputime());

		dwarfoff = rnd(HEADR+segtext.len, INITRND) + rnd(segdata.filelen, INITRND);
		cseek(dwarfoff);

		segdwarf.fileoff = cpos();
		dwarfemitdebugsections();
		segdwarf.filelen = cpos() - segdwarf.fileoff;

		machlink = domacholink();
	}

	switch(HEADTYPE) {
	default:
		diag("unknown header type %d", HEADTYPE);
	case Hplan9:
	case Helf:
		break;
	case Hdarwin:
		debug['8'] = 1;	/* 64-bit addresses */
		break;
	case Hlinux:
	case Hfreebsd:
	case Hnetbsd:
	case Hopenbsd:
	case Hdragonfly:
	case Hsolaris:
		debug['8'] = 1;	/* 64-bit addresses */
		break;
	case Hnacl:
	case Hwindows:
		break;
	}

	symsize = 0;
	spsize = 0;
	lcsize = 0;
	symo = 0;
	if(!debug['s']) {
		if(debug['v'])
			Bprint(&bso, "%5.2f sym\n", cputime());
		Bflush(&bso);
		switch(HEADTYPE) {
		default:
		case Hplan9:
		case Helf:
			debug['s'] = 1;
			symo = segdata.fileoff+segdata.filelen;
			break;
		case Hdarwin:
			symo = segdata.fileoff+rnd(segdata.filelen, INITRND)+machlink;
			break;
		case Hlinux:
//.........这里部分代码省略.........
开发者ID:8l,项目名称:go,代码行数:101,代码来源:asm.c

示例14: datblk

void
datblk(int64 addr, int64 size)
{
	LSym *sym;
	int64 i, eaddr;
	uchar *p, *ep;
	char *typ, *rsname;
	Reloc *r;

	if(debug['a'])
		Bprint(&bso, "datblk [%#x,%#x) at offset %#llx\n", addr, addr+size, cpos());

	blk(datap, addr, size);

	/* again for printing */
	if(!debug['a'])
		return;

	for(sym = datap; sym != nil; sym = sym->next)
		if(sym->value >= addr)
			break;

	eaddr = addr + size;
	for(; sym != nil; sym = sym->next) {
		if(sym->value >= eaddr)
			break;
		if(addr < sym->value) {
			Bprint(&bso, "\t%.8ux| 00 ...\n", addr);
			addr = sym->value;
		}
		Bprint(&bso, "%s\n\t%.8ux|", sym->name, (uint)addr);
		p = sym->p;
		ep = p + sym->np;
		while(p < ep) {
			if(p > sym->p && (int)(p-sym->p)%16 == 0)
				Bprint(&bso, "\n\t%.8ux|", (uint)(addr+(p-sym->p)));
			Bprint(&bso, " %.2ux", *p++);
		}
		addr += sym->np;
		for(; addr < sym->value+sym->size; addr++)
			Bprint(&bso, " %.2ux", 0);
		Bprint(&bso, "\n");
		
		if(linkmode == LinkExternal) {
			for(i=0; i<sym->nr; i++) {
				r = &sym->r[i];
				rsname = "";
				if(r->sym)
					rsname = r->sym->name;
				typ = "?";
				switch(r->type) {
				case R_ADDR:
					typ = "addr";
					break;
				case R_PCREL:
					typ = "pcrel";
					break;
				case R_CALL:
					typ = "call";
					break;
				}
				Bprint(&bso, "\treloc %.8ux/%d %s %s+%#llx [%#llx]\n",
					(uint)(sym->value+r->off), r->siz, typ, rsname, (vlong)r->add, (vlong)(r->sym->value+r->add));
			}
		}				
	}

	if(addr < eaddr)
		Bprint(&bso, "\t%.8ux| 00 ...\n", (uint)addr);
	Bprint(&bso, "\t%.8ux|\n", (uint)eaddr);
}
开发者ID:LEEWEN-DALIAN,项目名称:golang,代码行数:71,代码来源:data.c

示例15: patch

void
patch(void)
{
	int32 c, vexit;
	Prog *p, *q;
	Sym *s;
	int a;

	if(debug['v'])
		Bprint(&bso, "%5.2f patch\n", cputime());
	Bflush(&bso);
	mkfwd();
	s = lookup("exit", 0);
	vexit = s->value;
	for(cursym = textp; cursym != nil; cursym = cursym->next) {
		for(p = cursym->text; p != P; p = p->link) {
			a = p->as;
			if((a == ABL || a == ABX || a == AB || a == ARET) &&
			   p->to.type != D_BRANCH && p->to.sym != S) {
				s = p->to.sym;
				if(s->text == nil)
					continue;
				switch(s->type&SMASK) {
				default:
					diag("undefined: %s", s->name);
					s->type = STEXT;
					s->value = vexit;
					continue;	// avoid more error messages
				case STEXT:
					p->to.offset = s->value;
					p->to.type = D_BRANCH;
					p->cond = s->text;
					continue;
				}
			}
			if(p->to.type != D_BRANCH)
				continue;
			c = p->to.offset;
			for(q = cursym->text; q != P;) {
				if(c == q->pc)
					break;
				if(q->forwd != P && c >= q->forwd->pc)
					q = q->forwd;
				else
					q = q->link;
			}
			if(q == P) {
				diag("branch out of range %d\n%P", c, p);
				p->to.type = D_NONE;
			}
			p->cond = q;
		}
	}

	for(cursym = textp; cursym != nil; cursym = cursym->next) {
		for(p = cursym->text; p != P; p = p->link) {
			if(p->cond != P) {
				p->cond = brloop(p->cond);
				if(p->cond != P)
				if(p->to.type == D_BRANCH)
					p->to.offset = p->cond->pc;
			}
		}
	}
}
开发者ID:gnanderson,项目名称:go,代码行数:65,代码来源:pass.c


注:本文中的Bprint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。