mirror of
https://github.com/golang/go
synced 2024-11-24 13:10:11 -07:00
ld: fix dwarf decoding of strings for struct's fieldnames
Moved Sym printing to Yconv. Fixed warning in data.c R=rsc CC=golang-dev https://golang.org/cl/4378052
This commit is contained in:
parent
d36271a3e5
commit
0cc055e8f7
@ -722,7 +722,7 @@ addsize(Sym *s, Sym *t)
|
||||
void
|
||||
dodata(void)
|
||||
{
|
||||
int32 h, t, datsize;
|
||||
int32 t, datsize;
|
||||
Section *sect;
|
||||
Sym *s, *last, **l;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
// - eliminate DW_CLS_ if not used
|
||||
// - package info in compilation units
|
||||
// - assign global variables and types to their packages
|
||||
// - (upstream) type info for C parts of runtime
|
||||
// - gdb uses c syntax, meaning clumsy quoting is needed for go identifiers. eg
|
||||
// ptype struct '[]uint8' and qualifiers need to be quoted away
|
||||
// - lexical scoping is lost, so gdb gets confused as to which 'main.i' you mean.
|
||||
@ -943,14 +942,16 @@ enum {
|
||||
static char*
|
||||
decodetype_structfieldname(Sym *s, int i)
|
||||
{
|
||||
Reloc *r;
|
||||
|
||||
// go.string."foo" 0x28 / 0x40
|
||||
s = decode_reloc_sym(s, CommonSize + PtrSize + 2*4 + i*StructFieldSize);
|
||||
if (s == nil) // embedded structs have a nil name.
|
||||
return nil;
|
||||
s = decode_reloc_sym(s, 0); // string."foo"
|
||||
if (s == nil) // shouldn't happen.
|
||||
r = decode_reloc(s, 0); // s has a pointer to the string data at offset 0
|
||||
if (r == nil) // shouldn't happen.
|
||||
return nil;
|
||||
return (char*)s->p; // the c-string
|
||||
return (char*) r->sym->p + r->add; // the c-string
|
||||
}
|
||||
|
||||
static Sym*
|
||||
@ -1021,22 +1022,8 @@ defgotype(Sym *gotype)
|
||||
if (die != nil)
|
||||
return die;
|
||||
|
||||
if (0 && debug['v'] > 2) {
|
||||
print("new type: %s @0x%08x [%d]", gotype->name, gotype->value, gotype->size);
|
||||
for (i = 0; i < gotype->size; i++) {
|
||||
if (!(i%8)) print("\n\t%04x ", i);
|
||||
print("%02x ", gotype->p[i]);
|
||||
}
|
||||
print("\n");
|
||||
for (i = 0; i < gotype->nr; i++) {
|
||||
print("\t0x%02x[%x] %d %s[%llx]\n",
|
||||
gotype->r[i].off,
|
||||
gotype->r[i].siz,
|
||||
gotype->r[i].type,
|
||||
gotype->r[i].sym->name,
|
||||
(vlong)gotype->r[i].add);
|
||||
}
|
||||
}
|
||||
if (0 && debug['v'] > 2)
|
||||
print("new type: %Y\n", gotype);
|
||||
|
||||
kind = decodetype_kind(gotype);
|
||||
bytesize = decodetype_size(gotype);
|
||||
@ -2321,7 +2308,7 @@ dwarfemitdebugsections(void)
|
||||
{
|
||||
vlong infoe;
|
||||
DWDie* die;
|
||||
return;
|
||||
|
||||
// For diagnostic messages.
|
||||
newattr(&dwtypes, DW_AT_name, DW_CLS_STRING, strlen("dwtypes"), "dwtypes");
|
||||
|
||||
|
@ -61,6 +61,7 @@ void
|
||||
libinit(void)
|
||||
{
|
||||
fmtinstall('i', iconv);
|
||||
fmtinstall('Y', Yconv);
|
||||
mywhatsys(); // get goroot, goarch, goos
|
||||
if(strcmp(goarch, thestring) != 0)
|
||||
print("goarch is not known: %s\n", goarch);
|
||||
@ -1307,3 +1308,38 @@ undef(void)
|
||||
if(s->type == SXREF)
|
||||
diag("%s(%d): not defined", s->name, s->version);
|
||||
}
|
||||
|
||||
int
|
||||
Yconv(Fmt *fp)
|
||||
{
|
||||
Sym *s;
|
||||
Fmt fmt;
|
||||
int i;
|
||||
char *str;
|
||||
|
||||
s = va_arg(fp->args, Sym*);
|
||||
if (s == S) {
|
||||
fmtprint(fp, "<nil>");
|
||||
} else {
|
||||
fmtstrinit(&fmt);
|
||||
fmtprint(&fmt, "%s @0x%08x [%d]", s->name, s->value, s->size);
|
||||
for (i = 0; i < s->size; i++) {
|
||||
if (!(i%8)) fmtprint(&fmt, "\n\t0x%04x ", i);
|
||||
fmtprint(&fmt, "%02x ", s->p[i]);
|
||||
}
|
||||
fmtprint(&fmt, "\n");
|
||||
for (i = 0; i < s->nr; i++) {
|
||||
fmtprint(&fmt, "\t0x%04x[%x] %d %s[%llx]\n",
|
||||
s->r[i].off,
|
||||
s->r[i].siz,
|
||||
s->r[i].type,
|
||||
s->r[i].sym->name,
|
||||
(vlong)s->r[i].add);
|
||||
}
|
||||
str = fmtstrflush(&fmt);
|
||||
fmtstrcpy(fp, str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -274,3 +274,6 @@ EXTERN char* headstring;
|
||||
extern Header headers[];
|
||||
|
||||
int headtype(char*);
|
||||
|
||||
int Yconv(Fmt*);
|
||||
#pragma varargck type "Y" Sym*
|
||||
|
Loading…
Reference in New Issue
Block a user