mirror of
https://github.com/golang/go
synced 2024-11-25 13:17:56 -07:00
ld: add -w to disable dwarf, make errors obviously from dwarf
Reenable dwarf output on Mac. Was writing headers but no actual dwarf data. Fixes #1877 (accidentally). Workaround for issue 1878. R=lvd CC=golang-dev https://golang.org/cl/4515139
This commit is contained in:
parent
2ad58d48fb
commit
64b497c62a
@ -828,6 +828,7 @@ asmb(void)
|
|||||||
dwarfemitdebugsections();
|
dwarfemitdebugsections();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Hdarwin:
|
||||||
case Hwindows:
|
case Hwindows:
|
||||||
seek(cout, symo, 0);
|
seek(cout, symo, 0);
|
||||||
if(debug['v'])
|
if(debug['v'])
|
||||||
|
@ -781,6 +781,7 @@ asmb(void)
|
|||||||
cflush();
|
cflush();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Hdarwin:
|
||||||
case Hwindows:
|
case Hwindows:
|
||||||
seek(cout, symo, 0);
|
seek(cout, symo, 0);
|
||||||
if(debug['v'])
|
if(debug['v'])
|
||||||
|
@ -529,8 +529,10 @@ find_or_diag(DWDie *die, char* name)
|
|||||||
{
|
{
|
||||||
DWDie *r;
|
DWDie *r;
|
||||||
r = find(die, name);
|
r = find(die, name);
|
||||||
if (r == nil)
|
if (r == nil) {
|
||||||
diag("dwarf find: %s has no %s", getattr(die, DW_AT_name)->data, name);
|
diag("dwarf find: %s has no %s", getattr(die, DW_AT_name)->data, name);
|
||||||
|
errorexit();
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +615,7 @@ putattr(int form, int cls, vlong value, char *data)
|
|||||||
|
|
||||||
case DW_FORM_ref_addr: // reference to a DIE in the .info section
|
case DW_FORM_ref_addr: // reference to a DIE in the .info section
|
||||||
if (data == nil) {
|
if (data == nil) {
|
||||||
diag("null dwarf reference");
|
diag("dwarf: null reference");
|
||||||
LPUT(0); // invalid dwarf, gdb will complain.
|
LPUT(0); // invalid dwarf, gdb will complain.
|
||||||
} else {
|
} else {
|
||||||
if (((DWDie*)data)->offs == 0)
|
if (((DWDie*)data)->offs == 0)
|
||||||
@ -631,7 +633,7 @@ putattr(int form, int cls, vlong value, char *data)
|
|||||||
case DW_FORM_strp: // string
|
case DW_FORM_strp: // string
|
||||||
case DW_FORM_indirect: // (see Section 7.5.3)
|
case DW_FORM_indirect: // (see Section 7.5.3)
|
||||||
default:
|
default:
|
||||||
diag("Unsupported atribute form %d / class %d", form, cls);
|
diag("dwarf: unsupported attribute form %d / class %d", form, cls);
|
||||||
errorexit();
|
errorexit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -823,7 +825,7 @@ decode_inuxi(uchar* p, int sz)
|
|||||||
inuxi = inuxi8;
|
inuxi = inuxi8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
diag("decode inuxi %d", sz);
|
diag("dwarf: decode inuxi %d", sz);
|
||||||
errorexit();
|
errorexit();
|
||||||
}
|
}
|
||||||
for (i = 0; i < sz; i++)
|
for (i = 0; i < sz; i++)
|
||||||
@ -1013,7 +1015,7 @@ defgotype(Sym *gotype)
|
|||||||
return find_or_diag(&dwtypes, "<unspecified>");
|
return find_or_diag(&dwtypes, "<unspecified>");
|
||||||
|
|
||||||
if (strncmp("type.", gotype->name, 5) != 0) {
|
if (strncmp("type.", gotype->name, 5) != 0) {
|
||||||
diag("Type name doesn't start with \".type\": %s", gotype->name);
|
diag("dwarf: type name doesn't start with \".type\": %s", gotype->name);
|
||||||
return find_or_diag(&dwtypes, "<unspecified>");
|
return find_or_diag(&dwtypes, "<unspecified>");
|
||||||
}
|
}
|
||||||
name = gotype->name + 5; // could also decode from Type.string
|
name = gotype->name + 5; // could also decode from Type.string
|
||||||
@ -1164,7 +1166,7 @@ defgotype(Sym *gotype)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
diag("definition of unknown kind %d: %s", kind, gotype->name);
|
diag("dwarf: definition of unknown kind %d: %s", kind, gotype->name);
|
||||||
die = newdie(&dwtypes, DW_ABRV_TYPEDECL, name);
|
die = newdie(&dwtypes, DW_ABRV_TYPEDECL, name);
|
||||||
newrefattr(die, DW_AT_type, find_or_diag(&dwtypes, "<unspecified>"));
|
newrefattr(die, DW_AT_type, find_or_diag(&dwtypes, "<unspecified>"));
|
||||||
}
|
}
|
||||||
@ -1513,12 +1515,12 @@ decodez(char *s)
|
|||||||
ss = s + 1; // first is 0
|
ss = s + 1; // first is 0
|
||||||
while((o = ((uint8)ss[0] << 8) | (uint8)ss[1]) != 0) {
|
while((o = ((uint8)ss[0] << 8) | (uint8)ss[1]) != 0) {
|
||||||
if (o < 0 || o >= ftabsize) {
|
if (o < 0 || o >= ftabsize) {
|
||||||
diag("corrupt z entry");
|
diag("dwarf: corrupt z entry");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
f = ftab[o];
|
f = ftab[o];
|
||||||
if (f == nil) {
|
if (f == nil) {
|
||||||
diag("corrupt z entry");
|
diag("dwarf: corrupt z entry");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
len += strlen(f) + 1; // for the '/'
|
len += strlen(f) + 1; // for the '/'
|
||||||
@ -1630,11 +1632,11 @@ checknesting(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (includetop < 0) {
|
if (includetop < 0) {
|
||||||
diag("corrupt z stack");
|
diag("dwarf: corrupt z stack");
|
||||||
errorexit();
|
errorexit();
|
||||||
}
|
}
|
||||||
if (includetop >= nelem(includestack)) {
|
if (includetop >= nelem(includestack)) {
|
||||||
diag("nesting too deep");
|
diag("dwarf: nesting too deep");
|
||||||
for (i = 0; i < nelem(includestack); i++)
|
for (i = 0; i < nelem(includestack); i++)
|
||||||
diag("\t%s", histfile[includestack[i].file]);
|
diag("\t%s", histfile[includestack[i].file]);
|
||||||
errorexit();
|
errorexit();
|
||||||
@ -1660,7 +1662,7 @@ inithist(Auto *a)
|
|||||||
// We have a new history. They are guaranteed to come completely
|
// We have a new history. They are guaranteed to come completely
|
||||||
// at the beginning of the compilation unit.
|
// at the beginning of the compilation unit.
|
||||||
if (a->aoffset != 1) {
|
if (a->aoffset != 1) {
|
||||||
diag("stray 'z' with offset %d", a->aoffset);
|
diag("dwarf: stray 'z' with offset %d", a->aoffset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1915,7 +1917,7 @@ writelines(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (unitstart < 0) {
|
if (unitstart < 0) {
|
||||||
diag("reachable code before seeing any history: %P", s->text);
|
diag("dwarf: reachable code before seeing any history: %P", s->text);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1932,7 +1934,7 @@ writelines(void)
|
|||||||
for(q = s->text; q != P; q = q->link) {
|
for(q = s->text; q != P; q = q->link) {
|
||||||
lh = searchhist(q->line);
|
lh = searchhist(q->line);
|
||||||
if (lh == nil) {
|
if (lh == nil) {
|
||||||
diag("corrupt history or bad absolute line: %P", q);
|
diag("dwarf: corrupt history or bad absolute line: %P", q);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2066,7 +2068,7 @@ writeframes(void)
|
|||||||
// 4 is to exclude the length field.
|
// 4 is to exclude the length field.
|
||||||
pad = CIERESERVE + frameo + 4 - cpos();
|
pad = CIERESERVE + frameo + 4 - cpos();
|
||||||
if (pad < 0) {
|
if (pad < 0) {
|
||||||
diag("CIERESERVE too small by %lld bytes.", -pad);
|
diag("dwarf: CIERESERVE too small by %lld bytes.", -pad);
|
||||||
errorexit();
|
errorexit();
|
||||||
}
|
}
|
||||||
strnput("", pad);
|
strnput("", pad);
|
||||||
@ -2296,6 +2298,9 @@ dwarfemitdebugsections(void)
|
|||||||
vlong infoe;
|
vlong infoe;
|
||||||
DWDie* die;
|
DWDie* die;
|
||||||
|
|
||||||
|
if(debug['w']) // disable dwarf
|
||||||
|
return;
|
||||||
|
|
||||||
// For diagnostic messages.
|
// For diagnostic messages.
|
||||||
newattr(&dwtypes, DW_AT_name, DW_CLS_STRING, strlen("dwtypes"), "dwtypes");
|
newattr(&dwtypes, DW_AT_name, DW_CLS_STRING, strlen("dwtypes"), "dwtypes");
|
||||||
|
|
||||||
@ -2348,11 +2353,11 @@ dwarfemitdebugsections(void)
|
|||||||
seek(cout, infoo, 0);
|
seek(cout, infoo, 0);
|
||||||
writeinfo();
|
writeinfo();
|
||||||
if (fwdcount > 0) {
|
if (fwdcount > 0) {
|
||||||
diag("unresolved references after first dwarf info pass");
|
diag("dwarf: unresolved references after first dwarf info pass");
|
||||||
errorexit();
|
errorexit();
|
||||||
}
|
}
|
||||||
if (infoe != cpos()) {
|
if (infoe != cpos()) {
|
||||||
diag("inconsistent second dwarf info pass");
|
diag("dwarf: inconsistent second dwarf info pass");
|
||||||
errorexit();
|
errorexit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2401,6 +2406,9 @@ vlong elfstrdbg[NElfStrDbg];
|
|||||||
void
|
void
|
||||||
dwarfaddshstrings(Sym *shstrtab)
|
dwarfaddshstrings(Sym *shstrtab)
|
||||||
{
|
{
|
||||||
|
if(debug['w']) // disable dwarf
|
||||||
|
return;
|
||||||
|
|
||||||
elfstrdbg[ElfStrDebugAbbrev] = addstring(shstrtab, ".debug_abbrev");
|
elfstrdbg[ElfStrDebugAbbrev] = addstring(shstrtab, ".debug_abbrev");
|
||||||
elfstrdbg[ElfStrDebugAranges] = addstring(shstrtab, ".debug_aranges");
|
elfstrdbg[ElfStrDebugAranges] = addstring(shstrtab, ".debug_aranges");
|
||||||
elfstrdbg[ElfStrDebugFrame] = addstring(shstrtab, ".debug_frame");
|
elfstrdbg[ElfStrDebugFrame] = addstring(shstrtab, ".debug_frame");
|
||||||
@ -2420,6 +2428,9 @@ dwarfaddelfheaders(void)
|
|||||||
{
|
{
|
||||||
ElfShdr *sh;
|
ElfShdr *sh;
|
||||||
|
|
||||||
|
if(debug['w']) // disable dwarf
|
||||||
|
return;
|
||||||
|
|
||||||
sh = newElfShdr(elfstrdbg[ElfStrDebugAbbrev]);
|
sh = newElfShdr(elfstrdbg[ElfStrDebugAbbrev]);
|
||||||
sh->type = SHT_PROGBITS;
|
sh->type = SHT_PROGBITS;
|
||||||
sh->off = abbrevo;
|
sh->off = abbrevo;
|
||||||
@ -2488,6 +2499,9 @@ dwarfaddmachoheaders(void)
|
|||||||
vlong fakestart;
|
vlong fakestart;
|
||||||
int nsect;
|
int nsect;
|
||||||
|
|
||||||
|
if(debug['w']) // disable dwarf
|
||||||
|
return;
|
||||||
|
|
||||||
// Zero vsize segments won't be loaded in memory, even so they
|
// Zero vsize segments won't be loaded in memory, even so they
|
||||||
// have to be page aligned in the file.
|
// have to be page aligned in the file.
|
||||||
fakestart = abbrevo & ~0xfff;
|
fakestart = abbrevo & ~0xfff;
|
||||||
@ -2562,6 +2576,9 @@ dwarfaddmachoheaders(void)
|
|||||||
void
|
void
|
||||||
dwarfaddpeheaders(void)
|
dwarfaddpeheaders(void)
|
||||||
{
|
{
|
||||||
|
if(debug['w']) // disable dwarf
|
||||||
|
return;
|
||||||
|
|
||||||
newPEDWARFSection(".debug_abbrev", abbrevsize);
|
newPEDWARFSection(".debug_abbrev", abbrevsize);
|
||||||
newPEDWARFSection(".debug_line", linesize);
|
newPEDWARFSection(".debug_line", linesize);
|
||||||
newPEDWARFSection(".debug_frame", framesize);
|
newPEDWARFSection(".debug_frame", framesize);
|
||||||
|
Loading…
Reference in New Issue
Block a user