// walk symtab accumulating path names for use by pc/ln table. // don't need the full generality of the z entry history stack because // there are no includes in go (and only sensible includes in our c); // assume code only appear in top-level files. static void dosrcline(Sym *sym) { static byte srcbuf[1000]; static struct { String srcstring; int32 aline; int32 delta; } files[200]; static int32 incstart; static int32 nfunc, nfile, nhist; Func *f; int32 i; switch(sym->symtype) { case 't': case 'T': if(runtime·strcmp(sym->name, (byte*)"etext") == 0) break; f = &func[nfunc++]; // find source file for(i = 0; i < nfile - 1; i++) { if (files[i+1].aline > f->ln0) break; } f->src = files[i].srcstring; f->ln0 -= files[i].delta; break; case 'z': if(sym->value == 1) { // entry for main source file for a new object. makepath(srcbuf, sizeof srcbuf, sym->name+1); nhist = 0; nfile = 0; if(nfile == nelem(files)) return; files[nfile].srcstring = runtime·gostring(srcbuf); files[nfile].aline = 0; files[nfile++].delta = 0; } else { // push or pop of included file. makepath(srcbuf, sizeof srcbuf, sym->name+1); if(srcbuf[0] != '\0') { if(nhist++ == 0) incstart = sym->value; if(nhist == 0 && nfile < nelem(files)) { // new top-level file files[nfile].srcstring = runtime·gostring(srcbuf); files[nfile].aline = sym->value; // this is "line 0" files[nfile++].delta = sym->value - 1; } }else{ if(--nhist == 0) files[nfile-1].delta += sym->value - incstart; } } } }
String signame(int32 sig) { if(sig < 0 || sig >= NSIG) return emptystring; return gostring((byte*)sigtab[sig].name); }
static void _cgo_panic_internal(byte *p) { String s; Eface err; s = runtime·gostring(p); ·cgoStringToEface(s, &err); runtime·panic(err); }
static void dofunc(Sym *sym) { Func *f; switch(sym->symtype) { case 't': case 'T': case 'l': case 'L': if(strcmp(sym->name, (byte*)"etext") == 0) break; if(func == nil) { nfunc++; break; } f = &func[nfunc++]; f->name = gostring(sym->name); f->entry = sym->value; if(sym->symtype == 'L' || sym->symtype == 'l') f->frame = -sizeof(uintptr); break; case 'm': if(nfunc > 0 && func != nil) func[nfunc-1].frame += sym->value; break; case 'p': if(nfunc > 0 && func != nil) { f = &func[nfunc-1]; // args counts 32-bit words. // sym->value is the arg's offset. // don't know width of this arg, so assume it is 64 bits. if(f->args < sym->value/4 + 2) f->args = sym->value/4 + 2; } break; case 'f': if(fname == nil) { if(sym->value >= nfname) nfname = sym->value+1; break; } fname[sym->value] = sym->name; break; } }
void ·_Cfunc_GoString(int8 *p, String s) { s = runtime·gostring((byte*)p); FLUSH(&s); }