9 static void ds2acid(Dwarf*, DwarfSym*, Biobuf*, char*);
12 valof(uint ty, DwarfVal *v)
16 fmtinstall('H', encodefmt);
17 fprint(2, "valof %d %.*H\n", ty, v->b.len, v->b.data);
25 xnewtype(uint ty, DwarfSym *s)
29 t = typebynum(s->unit+s->uoff, 0);
35 dwarf2acid(Dwarf *d, Biobuf *b)
39 /* pass over dwarf section pulling out type info */
41 if(dwarfenum(d, &s) < 0)
44 while(dwarfnextsymat(d, &s, 0) == 1)
45 ds2acid(d, &s, b, nil);
54 ds2acid(Dwarf *d, DwarfSym *s, Biobuf *b, char *fn)
62 case TagSubroutineType:
63 t = xnewtype(Function, s);
71 case TagLexDwarfBlock:
73 /* recurse into substructure */
74 while(dwarfnextsymat(d, s, depth+1) == 1)
79 t = xnewtype(Typedef, s);
80 t->name = s->attrs.name;
81 t->sub = typebynum(s->attrs.type, 0);
85 t = xnewtype(Base, s);
86 t->xsizeof = s->attrs.bytesize;
87 switch(s->attrs.encoding){
96 case TypeUnsignedChar:
102 case TypeComplexFloat:
105 case TypeImaginaryFloat:
112 t = xnewtype(Pointer, s);
113 t->sub = typebynum(s->attrs.type, 0);
117 case TagVolatileType:
118 t = xnewtype(Defer, s);
119 t->sub = typebynum(s->attrs.type, 0);
123 t = xnewtype(Array, s);
124 t->sub = typebynum(s->attrs.type, 0);
129 t = xnewtype(Aggr, s);
130 t->sue = s->attrs.tag==TagStructType ? 's' : 'u';
131 t->xsizeof = s->attrs.bytesize;
132 t->suename = s->attrs.name;
133 t->isunion = s->attrs.tag==TagUnionType;
134 while(dwarfnextsymat(d, s, depth+1) == 1){
135 if(s->attrs.tag != TagMember){
136 ds2acid(d, s, b, fn);
139 if(!s->attrs.have.name || !s->attrs.have.type)
142 t->tname = erealloc(t->tname, (t->n+32)*sizeof(t->tname[0]));
143 t->val = erealloc(t->val, (t->n+32)*sizeof(t->val[0]));
144 t->t = erealloc(t->t, (t->n+32)*sizeof(t->t[0]));
146 t->tname[t->n] = s->attrs.name;
150 t->val[t->n] = valof(s->attrs.have.datamemberloc, &s->attrs.datamemberloc);
151 t->t[t->n] = typebynum(s->attrs.type, 0);
156 case TagEnumerationType:
157 t = xnewtype(Enum, s);
159 t->suename = s->attrs.name;
160 t->xsizeof = s->attrs.bytesize;
161 while(dwarfnextsymat(d, s, depth+1) == 1){
162 if(s->attrs.tag != TagEnumerator){
163 ds2acid(d, s, b, fn);
166 if(!s->attrs.have.name || !s->attrs.have.constvalue)
169 t->tname = erealloc(t->tname, (t->n+32)*sizeof(t->tname[0]));
170 t->val = erealloc(t->val, (t->n+32)*sizeof(t->val[0]));
172 t->tname[t->n] = s->attrs.name;
173 t->val[t->n] = valof(s->attrs.have.constvalue, &s->attrs.constvalue);
178 case TagFormalParameter:
180 if(s->attrs.name==nil || s->attrs.type==0)
182 addsymx(fn, s->attrs.name, typebynum(s->attrs.type, 0));