Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(31)

Delta Between Two Patch Sets: src/cmd/ld/dwarf.c

Issue 116720043: code review 116720043: cmd/ld: add go-specific dwarf type information (Closed)
Left Patch Set: Created 10 years, 9 months ago
Right Patch Set: diff -r 59c67dc02832 https://code.google.com/p/go/ Created 10 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // TODO/NICETOHAVE: 5 // TODO/NICETOHAVE:
6 // - eliminate DW_CLS_ if not used 6 // - eliminate DW_CLS_ if not used
7 // - package info in compilation units 7 // - package info in compilation units
8 // - assign global variables and types to their packages 8 // - assign global variables and types to their packages
9 // - gdb uses c syntax, meaning clumsy quoting is needed for go identifiers. e g 9 // - gdb uses c syntax, meaning clumsy quoting is needed for go identifiers. e g
10 // ptype struct '[]uint8' and qualifiers need to be quoted away 10 // ptype struct '[]uint8' and qualifiers need to be quoted away
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 { 134 {
135 char buf[10]; 135 char buf[10];
136 strnput(buf, sleb128enc(v, buf)); 136 strnput(buf, sleb128enc(v, buf));
137 } 137 }
138 138
139 /* 139 /*
140 * Defining Abbrevs. This is hardcoded, and there will be 140 * Defining Abbrevs. This is hardcoded, and there will be
141 * only a handful of them. The DWARF spec places no restriction on 141 * only a handful of them. The DWARF spec places no restriction on
142 * the ordering of attributes in the Abbrevs and DIEs, and we will 142 * the ordering of attributes in the Abbrevs and DIEs, and we will
143 * always write them out in the order of declaration in the abbrev. 143 * always write them out in the order of declaration in the abbrev.
144 * This implementation relies on tag, attr < 127, so they serialize as
145 * a char. Higher numbered user-defined tags or attributes can be used
146 * for storing internal data but won't be serialized.
147 */ 144 */
148 typedef struct DWAttrForm DWAttrForm; 145 typedef struct DWAttrForm DWAttrForm;
149 struct DWAttrForm { 146 struct DWAttrForm {
150 » uint8 attr; 147 » uint16 attr;
151 uint8 form; 148 uint8 form;
149 };
150
151 // Go-specific type attributes.
152 enum {
153 DW_AT_go_kind = 0x2900,
154 DW_AT_go_key = 0x2901,
155 DW_AT_go_elem = 0x2902,
156
157 DW_AT_internal_location = 253, // params and locals; not emitted
152 }; 158 };
153 159
154 // Index into the abbrevs table below. 160 // Index into the abbrevs table below.
155 // Keep in sync with ispubname() and ispubtype() below. 161 // Keep in sync with ispubname() and ispubtype() below.
156 // ispubtype considers >= NULLTYPE public 162 // ispubtype considers >= NULLTYPE public
157 enum 163 enum
158 { 164 {
159 DW_ABRV_NULL, 165 DW_ABRV_NULL,
160 DW_ABRV_COMPUNIT, 166 DW_ABRV_COMPUNIT,
161 DW_ABRV_FUNCTION, 167 DW_ABRV_FUNCTION,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 DW_TAG_unspecified_type, DW_CHILDREN_no, 276 DW_TAG_unspecified_type, DW_CHILDREN_no,
271 DW_AT_name, DW_FORM_string, 277 DW_AT_name, DW_FORM_string,
272 0, 0 278 0, 0
273 }, 279 },
274 /* BASETYPE */ 280 /* BASETYPE */
275 { 281 {
276 DW_TAG_base_type, DW_CHILDREN_no, 282 DW_TAG_base_type, DW_CHILDREN_no,
277 DW_AT_name, DW_FORM_string, 283 DW_AT_name, DW_FORM_string,
278 DW_AT_encoding, DW_FORM_data1, 284 DW_AT_encoding, DW_FORM_data1,
279 DW_AT_byte_size, DW_FORM_data1, 285 DW_AT_byte_size, DW_FORM_data1,
286 DW_AT_go_kind, DW_FORM_data1,
280 0, 0 287 0, 0
281 }, 288 },
282 /* ARRAYTYPE */ 289 /* ARRAYTYPE */
283 // child is subrange with upper bound 290 // child is subrange with upper bound
284 { 291 {
285 DW_TAG_array_type, DW_CHILDREN_yes, 292 DW_TAG_array_type, DW_CHILDREN_yes,
286 DW_AT_name, DW_FORM_string, 293 DW_AT_name, DW_FORM_string,
287 DW_AT_type, DW_FORM_ref_addr, 294 DW_AT_type, DW_FORM_ref_addr,
288 DW_AT_byte_size, DW_FORM_udata, 295 DW_AT_byte_size, DW_FORM_udata,
296 DW_AT_go_kind, DW_FORM_data1,
289 0, 0 297 0, 0
290 }, 298 },
291 299
292 /* CHANTYPE */ 300 /* CHANTYPE */
293 { 301 {
294 DW_TAG_typedef, DW_CHILDREN_no, 302 DW_TAG_typedef, DW_CHILDREN_no,
295 DW_AT_name, DW_FORM_string, 303 DW_AT_name, DW_FORM_string,
296 DW_AT_type, DW_FORM_ref_addr, 304 DW_AT_type, DW_FORM_ref_addr,
305 DW_AT_go_kind, DW_FORM_data1,
306 DW_AT_go_elem, DW_FORM_ref_addr,
297 0, 0 307 0, 0
298 }, 308 },
299 309
300 /* FUNCTYPE */ 310 /* FUNCTYPE */
301 { 311 {
302 DW_TAG_subroutine_type, DW_CHILDREN_yes, 312 DW_TAG_subroutine_type, DW_CHILDREN_yes,
303 DW_AT_name, DW_FORM_string, 313 DW_AT_name, DW_FORM_string,
304 // DW_AT_type, DW_FORM_ref_addr, 314 // DW_AT_type, DW_FORM_ref_addr,
315 DW_AT_go_kind, DW_FORM_data1,
305 0, 0 316 0, 0
306 }, 317 },
307 318
308 /* IFACETYPE */ 319 /* IFACETYPE */
309 { 320 {
310 DW_TAG_typedef, DW_CHILDREN_yes, 321 DW_TAG_typedef, DW_CHILDREN_yes,
311 DW_AT_name, DW_FORM_string, 322 DW_AT_name, DW_FORM_string,
312 DW_AT_type, DW_FORM_ref_addr, 323 DW_AT_type, DW_FORM_ref_addr,
324 DW_AT_go_kind, DW_FORM_data1,
313 0, 0 325 0, 0
314 }, 326 },
315 327
316 /* MAPTYPE */ 328 /* MAPTYPE */
317 { 329 {
318 DW_TAG_typedef, DW_CHILDREN_no, 330 DW_TAG_typedef, DW_CHILDREN_no,
319 DW_AT_name, DW_FORM_string, 331 DW_AT_name, DW_FORM_string,
320 DW_AT_type, DW_FORM_ref_addr, 332 DW_AT_type, DW_FORM_ref_addr,
333 DW_AT_go_kind, DW_FORM_data1,
334 DW_AT_go_key, DW_FORM_ref_addr,
335 DW_AT_go_elem, DW_FORM_ref_addr,
321 0, 0 336 0, 0
322 }, 337 },
323 338
324 /* PTRTYPE */ 339 /* PTRTYPE */
325 { 340 {
326 DW_TAG_pointer_type, DW_CHILDREN_no, 341 DW_TAG_pointer_type, DW_CHILDREN_no,
327 DW_AT_name, DW_FORM_string, 342 DW_AT_name, DW_FORM_string,
328 DW_AT_type, DW_FORM_ref_addr, 343 DW_AT_type, DW_FORM_ref_addr,
344 DW_AT_go_kind, DW_FORM_data1,
329 0, 0 345 0, 0
330 }, 346 },
331 /* BARE_PTRTYPE */ 347 /* BARE_PTRTYPE */
332 { 348 {
333 DW_TAG_pointer_type, DW_CHILDREN_no, 349 DW_TAG_pointer_type, DW_CHILDREN_no,
334 DW_AT_name, DW_FORM_string, 350 DW_AT_name, DW_FORM_string,
335 0, 0 351 0, 0
336 }, 352 },
337 353
338 /* SLICETYPE */ 354 /* SLICETYPE */
339 { 355 {
340 DW_TAG_structure_type, DW_CHILDREN_yes, 356 DW_TAG_structure_type, DW_CHILDREN_yes,
341 DW_AT_name, DW_FORM_string, 357 DW_AT_name, DW_FORM_string,
342 DW_AT_byte_size, DW_FORM_udata, 358 DW_AT_byte_size, DW_FORM_udata,
359 DW_AT_go_kind, DW_FORM_data1,
360 DW_AT_go_elem, DW_FORM_ref_addr,
343 0, 0 361 0, 0
344 }, 362 },
345 363
346 /* STRINGTYPE */ 364 /* STRINGTYPE */
347 { 365 {
348 DW_TAG_structure_type, DW_CHILDREN_yes, 366 DW_TAG_structure_type, DW_CHILDREN_yes,
349 DW_AT_name, DW_FORM_string, 367 DW_AT_name, DW_FORM_string,
350 DW_AT_byte_size, DW_FORM_udata, 368 DW_AT_byte_size, DW_FORM_udata,
369 DW_AT_go_kind, DW_FORM_data1,
351 0, 0 370 0, 0
352 }, 371 },
353 372
354 /* STRUCTTYPE */ 373 /* STRUCTTYPE */
355 { 374 {
356 DW_TAG_structure_type, DW_CHILDREN_yes, 375 DW_TAG_structure_type, DW_CHILDREN_yes,
357 DW_AT_name, DW_FORM_string, 376 DW_AT_name, DW_FORM_string,
358 DW_AT_byte_size, DW_FORM_udata, 377 DW_AT_byte_size, DW_FORM_udata,
378 DW_AT_go_kind, DW_FORM_data1,
359 0, 0 379 0, 0
360 }, 380 },
361 381
362 /* TYPEDECL */ 382 /* TYPEDECL */
363 { 383 {
364 DW_TAG_typedef, DW_CHILDREN_no, 384 DW_TAG_typedef, DW_CHILDREN_no,
365 DW_AT_name, DW_FORM_string, 385 DW_AT_name, DW_FORM_string,
366 DW_AT_type, DW_FORM_ref_addr, 386 DW_AT_type, DW_FORM_ref_addr,
367 0, 0 387 0, 0
368 }, 388 },
369 }; 389 };
370 390
371 static void 391 static void
372 writeabbrev(void) 392 writeabbrev(void)
373 { 393 {
374 » int i, n; 394 » int i, j;
395 » DWAttrForm *f;
375 396
376 abbrevo = cpos(); 397 abbrevo = cpos();
377 for (i = 1; i < DW_NABRV; i++) { 398 for (i = 1; i < DW_NABRV; i++) {
378 // See section 7.5.3 399 // See section 7.5.3
379 uleb128put(i); 400 uleb128put(i);
380 uleb128put(abbrevs[i].tag); 401 uleb128put(abbrevs[i].tag);
381 cput(abbrevs[i].children); 402 cput(abbrevs[i].children);
382 » » // 0 is not a valid attr or form, and DWAbbrev.attr is 403 » » for(j=0; j<nelem(abbrevs[i].attr); j++) {
383 » » // 0-terminated, so we can treat it as a string 404 » » » f = &abbrevs[i].attr[j];
384 » » n = strlen((char*)abbrevs[i].attr) / 2; 405 » » » uleb128put(f->attr);
385 » » strnput((char*)abbrevs[i].attr, 406 » » » uleb128put(f->form);
386 » » » (n+1) * sizeof(DWAttrForm)); 407 » » » if(f->attr == 0)
408 » » » » break;
409 » » }
387 } 410 }
388 cput(0); 411 cput(0);
389 abbrevsize = cpos() - abbrevo; 412 abbrevsize = cpos() - abbrevo;
390 } 413 }
391 414
392 /* 415 /*
393 * Debugging Information Entries and their attributes. 416 * Debugging Information Entries and their attributes.
394 */ 417 */
395 418
396 enum 419 enum
(...skipping 13 matching lines...) Expand all
410 } 433 }
411 434
412 // For DW_CLS_string and _block, value should contain the length, and 435 // For DW_CLS_string and _block, value should contain the length, and
413 // data the data, for _reference, value is 0 and data is a DWDie* to 436 // data the data, for _reference, value is 0 and data is a DWDie* to
414 // the referenced instance, for all others, value is the whole thing 437 // the referenced instance, for all others, value is the whole thing
415 // and data is null. 438 // and data is null.
416 439
417 typedef struct DWAttr DWAttr; 440 typedef struct DWAttr DWAttr;
418 struct DWAttr { 441 struct DWAttr {
419 DWAttr *link; 442 DWAttr *link;
420 » uint8 atr; // DW_AT_ 443 » uint16 atr; // DW_AT_
421 uint8 cls; // DW_CLS_ 444 uint8 cls; // DW_CLS_
422 vlong value; 445 vlong value;
423 char *data; 446 char *data;
424 }; 447 };
425 448
426 typedef struct DWDie DWDie; 449 typedef struct DWDie DWDie;
427 struct DWDie { 450 struct DWDie {
428 int abbrev; 451 int abbrev;
429 DWDie *link; 452 DWDie *link;
430 DWDie *child; 453 DWDie *child;
431 DWAttr *attr; 454 DWAttr *attr;
432 // offset into .debug_info section, i.e relative to 455 // offset into .debug_info section, i.e relative to
433 // infoo. only valid after call to putdie() 456 // infoo. only valid after call to putdie()
434 vlong offs; 457 vlong offs;
435 DWDie **hash; // optional index of children by name, enabled by mkindex () 458 DWDie **hash; // optional index of children by name, enabled by mkindex ()
436 DWDie *hlink; // bucket chain in parent's index 459 DWDie *hlink; // bucket chain in parent's index
437 }; 460 };
438 461
439 /* 462 /*
440 * Root DIEs for compilation units, types and global variables. 463 * Root DIEs for compilation units, types and global variables.
441 */ 464 */
442 465
443 static DWDie dwroot; 466 static DWDie dwroot;
444 static DWDie dwtypes; 467 static DWDie dwtypes;
445 static DWDie dwglobals; 468 static DWDie dwglobals;
446 469
447 static DWAttr* 470 static DWAttr*
448 newattr(DWDie *die, uint8 attr, int cls, vlong value, char *data) 471 newattr(DWDie *die, uint16 attr, int cls, vlong value, char *data)
449 { 472 {
450 DWAttr *a; 473 DWAttr *a;
451 474
452 a = mal(sizeof *a); 475 a = mal(sizeof *a);
453 a->link = die->attr; 476 a->link = die->attr;
454 die->attr = a; 477 die->attr = a;
455 a->atr = attr; 478 a->atr = attr;
456 a->cls = cls; 479 a->cls = cls;
457 a->value = value; 480 a->value = value;
458 a->data = data; 481 a->data = data;
459 return a; 482 return a;
460 } 483 }
461 484
462 // Each DIE (except the root ones) has at least 1 attribute: its 485 // Each DIE (except the root ones) has at least 1 attribute: its
463 // name. getattr moves the desired one to the front so 486 // name. getattr moves the desired one to the front so
464 // frequently searched ones are found faster. 487 // frequently searched ones are found faster.
465 static DWAttr* 488 static DWAttr*
466 getattr(DWDie *die, uint8 attr) 489 getattr(DWDie *die, uint16 attr)
467 { 490 {
468 DWAttr *a, *b; 491 DWAttr *a, *b;
469 492
470 if (die->attr->atr == attr) 493 if (die->attr->atr == attr)
471 return die->attr; 494 return die->attr;
472 495
473 a = die->attr; 496 a = die->attr;
474 b = a->link; 497 b = a->link;
475 while (b != nil) { 498 while (b != nil) {
476 if (b->atr == attr) { 499 if (b->atr == attr) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 case 8: 638 case 8:
616 VPUT(addend); 639 VPUT(addend);
617 break; 640 break;
618 default: 641 default:
619 diag("bad size in adddwarfrel"); 642 diag("bad size in adddwarfrel");
620 break; 643 break;
621 } 644 }
622 } 645 }
623 646
624 static DWAttr* 647 static DWAttr*
625 newrefattr(DWDie *die, uint8 attr, DWDie* ref) 648 newrefattr(DWDie *die, uint16 attr, DWDie* ref)
626 { 649 {
627 if (ref == nil) 650 if (ref == nil)
628 return nil; 651 return nil;
629 return newattr(die, attr, DW_CLS_REFERENCE, 0, (char*)ref); 652 return newattr(die, attr, DW_CLS_REFERENCE, 0, (char*)ref);
630 } 653 }
631 654
632 static int fwdcount; 655 static int fwdcount;
633 656
634 static void 657 static void
635 putattr(int abbrev, int form, int cls, vlong value, char *data) 658 putattr(int abbrev, int form, int cls, vlong value, char *data)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 diag("dwarf: unsupported attribute form %d / class %d", form, cl s); 778 diag("dwarf: unsupported attribute form %d / class %d", form, cl s);
756 errorexit(); 779 errorexit();
757 } 780 }
758 } 781 }
759 782
760 // Note that we can (and do) add arbitrary attributes to a DIE, but 783 // Note that we can (and do) add arbitrary attributes to a DIE, but
761 // only the ones actually listed in the Abbrev will be written out. 784 // only the ones actually listed in the Abbrev will be written out.
762 static void 785 static void
763 putattrs(int abbrev, DWAttr* attr) 786 putattrs(int abbrev, DWAttr* attr)
764 { 787 {
765 DWAttr *attrs[DW_AT_recursive + 1];
766 DWAttrForm* af; 788 DWAttrForm* af;
767 789 » DWAttr *ap;
768 » memset(attrs, 0, sizeof attrs); 790
769 » for( ; attr; attr = attr->link) 791 » for(af = abbrevs[abbrev].attr; af->attr; af++) {
770 » » if (attr->atr < nelem(attrs)) 792 » » for(ap=attr; ap; ap=ap->link) {
771 » » » attrs[attr->atr] = attr; 793 » » » if(ap->atr == af->attr) {
772 794 » » » » putattr(abbrev, af->form,
773 » for(af = abbrevs[abbrev].attr; af->attr; af++) 795 » » » » » ap->cls,
774 » » if (attrs[af->attr]) 796 » » » » » ap->value,
775 » » » putattr(abbrev, af->form, 797 » » » » » ap->data);
776 » » » » attrs[af->attr]->cls, 798 » » » » goto done;
777 » » » » attrs[af->attr]->value, 799 » » » }
778 » » » » attrs[af->attr]->data); 800 » » }
779 » » else 801 » » putattr(abbrev, af->form, 0, 0, nil);
780 » » » putattr(abbrev, af->form, 0, 0, nil); 802 » done:;
803 » }
781 } 804 }
782 805
783 static void putdie(DWDie* die); 806 static void putdie(DWDie* die);
784 807
785 static void 808 static void
786 putdies(DWDie* die) 809 putdies(DWDie* die)
787 { 810 {
788 for(; die; die = die->link) 811 for(; die; die = die->link)
789 putdie(die); 812 putdie(die);
790 } 813 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 memmove(die->attr->data, block, i); 864 memmove(die->attr->data, block, i);
842 } 865 }
843 866
844 // GDB doesn't like DW_FORM_addr for DW_AT_location, so emit a 867 // GDB doesn't like DW_FORM_addr for DW_AT_location, so emit a
845 // location expression that evals to a const. 868 // location expression that evals to a const.
846 static void 869 static void
847 newabslocexprattr(DWDie *die, vlong addr, LSym *sym) 870 newabslocexprattr(DWDie *die, vlong addr, LSym *sym)
848 { 871 {
849 newattr(die, DW_AT_location, DW_CLS_ADDRESS, addr, (char*)sym); 872 newattr(die, DW_AT_location, DW_CLS_ADDRESS, addr, (char*)sym);
850 } 873 }
851
852
853 // Fake attributes for slices, maps and channel
854 enum {
855 DW_AT_internal_elem_type = 250, // channels and slices
856 DW_AT_internal_key_type = 251, // maps
857 DW_AT_internal_val_type = 252, // maps
858 DW_AT_internal_location = 253, // params and locals
859 };
860 874
861 static DWDie* defptrto(DWDie *dwtype); // below 875 static DWDie* defptrto(DWDie *dwtype); // below
862 876
863 // Lookup predefined types 877 // Lookup predefined types
864 static LSym* 878 static LSym*
865 lookup_or_diag(char *n) 879 lookup_or_diag(char *n)
866 { 880 {
867 LSym *s; 881 LSym *s;
868 882
869 s = linkrlookup(ctxt, n, 0); 883 s = linkrlookup(ctxt, n, 0);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 newrefattr(die, DW_AT_type, defgotype(s)); 993 newrefattr(die, DW_AT_type, defgotype(s));
980 fld = newdie(die, DW_ABRV_ARRAYRANGE, "range"); 994 fld = newdie(die, DW_ABRV_ARRAYRANGE, "range");
981 newattr(fld, DW_AT_upper_bound, DW_CLS_CONSTANT, decodetype_arra ylen(gotype), 0); 995 newattr(fld, DW_AT_upper_bound, DW_CLS_CONSTANT, decodetype_arra ylen(gotype), 0);
982 newrefattr(fld, DW_AT_type, find_or_diag(&dwtypes, "uintptr")); 996 newrefattr(fld, DW_AT_type, find_or_diag(&dwtypes, "uintptr"));
983 break; 997 break;
984 998
985 case KindChan: 999 case KindChan:
986 die = newdie(&dwtypes, DW_ABRV_CHANTYPE, name); 1000 die = newdie(&dwtypes, DW_ABRV_CHANTYPE, name);
987 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, bytesize, 0); 1001 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, bytesize, 0);
988 s = decodetype_chanelem(gotype); 1002 s = decodetype_chanelem(gotype);
989 » » newrefattr(die, DW_AT_internal_elem_type, defgotype(s)); 1003 » » newrefattr(die, DW_AT_go_elem, defgotype(s));
990 break; 1004 break;
991 1005
992 case KindFunc: 1006 case KindFunc:
993 die = newdie(&dwtypes, DW_ABRV_FUNCTYPE, name); 1007 die = newdie(&dwtypes, DW_ABRV_FUNCTYPE, name);
994 dotypedef(&dwtypes, name, die); 1008 dotypedef(&dwtypes, name, die);
995 newrefattr(die, DW_AT_type, find_or_diag(&dwtypes, "void")); 1009 newrefattr(die, DW_AT_type, find_or_diag(&dwtypes, "void"));
996 nfields = decodetype_funcincount(gotype); 1010 nfields = decodetype_funcincount(gotype);
997 for (i = 0; i < nfields; i++) { 1011 for (i = 0; i < nfields; i++) {
998 s = decodetype_funcintype(gotype, i); 1012 s = decodetype_funcintype(gotype, i);
999 fld = newdie(die, DW_ABRV_FUNCTYPEPARAM, s->name+5); 1013 fld = newdie(die, DW_ABRV_FUNCTYPEPARAM, s->name+5);
(...skipping 17 matching lines...) Expand all
1017 if (nfields == 0) 1031 if (nfields == 0)
1018 s = lookup_or_diag("type.runtime.eface"); 1032 s = lookup_or_diag("type.runtime.eface");
1019 else 1033 else
1020 s = lookup_or_diag("type.runtime.iface"); 1034 s = lookup_or_diag("type.runtime.iface");
1021 newrefattr(die, DW_AT_type, defgotype(s)); 1035 newrefattr(die, DW_AT_type, defgotype(s));
1022 break; 1036 break;
1023 1037
1024 case KindMap: 1038 case KindMap:
1025 die = newdie(&dwtypes, DW_ABRV_MAPTYPE, name); 1039 die = newdie(&dwtypes, DW_ABRV_MAPTYPE, name);
1026 s = decodetype_mapkey(gotype); 1040 s = decodetype_mapkey(gotype);
1027 » » newrefattr(die, DW_AT_internal_key_type, defgotype(s)); 1041 » » newrefattr(die, DW_AT_go_key, defgotype(s));
1028 s = decodetype_mapvalue(gotype); 1042 s = decodetype_mapvalue(gotype);
1029 » » newrefattr(die, DW_AT_internal_val_type, defgotype(s)); 1043 » » newrefattr(die, DW_AT_go_elem, defgotype(s));
1030 break; 1044 break;
1031 1045
1032 case KindPtr: 1046 case KindPtr:
1033 die = newdie(&dwtypes, DW_ABRV_PTRTYPE, name); 1047 die = newdie(&dwtypes, DW_ABRV_PTRTYPE, name);
1034 dotypedef(&dwtypes, name, die); 1048 dotypedef(&dwtypes, name, die);
1035 s = decodetype_ptrelem(gotype); 1049 s = decodetype_ptrelem(gotype);
1036 newrefattr(die, DW_AT_type, defgotype(s)); 1050 newrefattr(die, DW_AT_type, defgotype(s));
1037 break; 1051 break;
1038 1052
1039 case KindSlice: 1053 case KindSlice:
1040 die = newdie(&dwtypes, DW_ABRV_SLICETYPE, name); 1054 die = newdie(&dwtypes, DW_ABRV_SLICETYPE, name);
1041 dotypedef(&dwtypes, name, die); 1055 dotypedef(&dwtypes, name, die);
1042 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, bytesize, 0); 1056 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, bytesize, 0);
1043 s = decodetype_arrayelem(gotype); 1057 s = decodetype_arrayelem(gotype);
1044 » » newrefattr(die, DW_AT_internal_elem_type, defgotype(s)); 1058 » » newrefattr(die, DW_AT_go_elem, defgotype(s));
1045 break; 1059 break;
1046 1060
1047 case KindString: 1061 case KindString:
1048 die = newdie(&dwtypes, DW_ABRV_STRINGTYPE, name); 1062 die = newdie(&dwtypes, DW_ABRV_STRINGTYPE, name);
1049 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, bytesize, 0); 1063 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, bytesize, 0);
1050 break; 1064 break;
1051 1065
1052 case KindStruct: 1066 case KindStruct:
1053 die = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, name); 1067 die = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, name);
1054 dotypedef(&dwtypes, name, die); 1068 dotypedef(&dwtypes, name, die);
(...skipping 11 matching lines...) Expand all
1066 break; 1080 break;
1067 1081
1068 case KindUnsafePointer: 1082 case KindUnsafePointer:
1069 die = newdie(&dwtypes, DW_ABRV_BARE_PTRTYPE, name); 1083 die = newdie(&dwtypes, DW_ABRV_BARE_PTRTYPE, name);
1070 break; 1084 break;
1071 1085
1072 default: 1086 default:
1073 diag("dwarf: definition of unknown kind %d: %s", kind, gotype->n ame); 1087 diag("dwarf: definition of unknown kind %d: %s", kind, gotype->n ame);
1074 die = newdie(&dwtypes, DW_ABRV_TYPEDECL, name); 1088 die = newdie(&dwtypes, DW_ABRV_TYPEDECL, name);
1075 newrefattr(die, DW_AT_type, find_or_diag(&dwtypes, "<unspecified >")); 1089 newrefattr(die, DW_AT_type, find_or_diag(&dwtypes, "<unspecified >"));
1076 » } 1090 » }
1091
1092 » newattr(die, DW_AT_go_kind, DW_CLS_CONSTANT, kind, 0);
1077 1093
1078 return die; 1094 return die;
1079 } 1095 }
1080 1096
1081 // Find or construct *T given T. 1097 // Find or construct *T given T.
1082 static DWDie* 1098 static DWDie*
1083 defptrto(DWDie *dwtype) 1099 defptrto(DWDie *dwtype)
1084 { 1100 {
1085 char ptrname[1024]; 1101 char ptrname[1024];
1086 DWDie *die; 1102 DWDie *die;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 DWDie *prototype, *elem; 1177 DWDie *prototype, *elem;
1162 1178
1163 prototype = walktypedef(defgotype(lookup_or_diag("type.runtime.slice"))) ; 1179 prototype = walktypedef(defgotype(lookup_or_diag("type.runtime.slice"))) ;
1164 if (prototype == nil) 1180 if (prototype == nil)
1165 return; 1181 return;
1166 1182
1167 for (; die != nil; die = die->link) { 1183 for (; die != nil; die = die->link) {
1168 if (die->abbrev != DW_ABRV_SLICETYPE) 1184 if (die->abbrev != DW_ABRV_SLICETYPE)
1169 continue; 1185 continue;
1170 copychildren(die, prototype); 1186 copychildren(die, prototype);
1171 » » elem = (DWDie*) getattr(die, DW_AT_internal_elem_type)->data; 1187 » » elem = (DWDie*) getattr(die, DW_AT_go_elem)->data;
1172 substitutetype(die, "array", defptrto(elem)); 1188 substitutetype(die, "array", defptrto(elem));
1173 } 1189 }
1174 } 1190 }
1175 1191
1176 static char* 1192 static char*
1177 mkinternaltypename(char *base, char *arg1, char *arg2) 1193 mkinternaltypename(char *base, char *arg1, char *arg2)
1178 { 1194 {
1179 char buf[1024]; 1195 char buf[1024];
1180 char *n; 1196 char *n;
1181 1197
(...skipping 25 matching lines...) Expand all
1207 hash = walktypedef(defgotype(lookup_or_diag("type.runtime.hma p"))); 1223 hash = walktypedef(defgotype(lookup_or_diag("type.runtime.hma p")));
1208 bucket = walktypedef(defgotype(lookup_or_diag("type.runtime.buc ket"))); 1224 bucket = walktypedef(defgotype(lookup_or_diag("type.runtime.buc ket")));
1209 1225
1210 if (hash == nil) 1226 if (hash == nil)
1211 return; 1227 return;
1212 1228
1213 for (; die != nil; die = die->link) { 1229 for (; die != nil; die = die->link) {
1214 if (die->abbrev != DW_ABRV_MAPTYPE) 1230 if (die->abbrev != DW_ABRV_MAPTYPE)
1215 continue; 1231 continue;
1216 1232
1217 » » keytype = walktypedef((DWDie*) getattr(die, DW_AT_internal_key_t ype)->data); 1233 » » keytype = walktypedef((DWDie*) getattr(die, DW_AT_go_key)->data) ;
1218 » » valtype = walktypedef((DWDie*) getattr(die, DW_AT_internal_val_t ype)->data); 1234 » » valtype = walktypedef((DWDie*) getattr(die, DW_AT_go_elem)->data );
1219 1235
1220 // compute size info like hashmap.c does. 1236 // compute size info like hashmap.c does.
1221 a = getattr(keytype, DW_AT_byte_size); 1237 a = getattr(keytype, DW_AT_byte_size);
1222 keysize = a ? a->value : PtrSize; // We don't store size with P ointers 1238 keysize = a ? a->value : PtrSize; // We don't store size with P ointers
1223 a = getattr(valtype, DW_AT_byte_size); 1239 a = getattr(valtype, DW_AT_byte_size);
1224 valsize = a ? a->value : PtrSize; 1240 valsize = a ? a->value : PtrSize;
1225 indirect_key = 0; 1241 indirect_key = 0;
1226 indirect_val = 0; 1242 indirect_val = 0;
1227 if(keysize > MaxKeySize) { 1243 if(keysize > MaxKeySize) {
1228 keysize = PtrSize; 1244 keysize = PtrSize;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 waitq = walktypedef(defgotype(lookup_or_diag("type.runtime.waitq"))); 1315 waitq = walktypedef(defgotype(lookup_or_diag("type.runtime.waitq")));
1300 hchan = walktypedef(defgotype(lookup_or_diag("type.runtime.hchan"))); 1316 hchan = walktypedef(defgotype(lookup_or_diag("type.runtime.hchan")));
1301 if (sudog == nil || waitq == nil || hchan == nil) 1317 if (sudog == nil || waitq == nil || hchan == nil)
1302 return; 1318 return;
1303 1319
1304 sudogsize = getattr(sudog, DW_AT_byte_size)->value; 1320 sudogsize = getattr(sudog, DW_AT_byte_size)->value;
1305 1321
1306 for (; die != nil; die = die->link) { 1322 for (; die != nil; die = die->link) {
1307 if (die->abbrev != DW_ABRV_CHANTYPE) 1323 if (die->abbrev != DW_ABRV_CHANTYPE)
1308 continue; 1324 continue;
1309 » » elemtype = (DWDie*) getattr(die, DW_AT_internal_elem_type)->data ; 1325 » » elemtype = (DWDie*) getattr(die, DW_AT_go_elem)->data;
1310 a = getattr(elemtype, DW_AT_byte_size); 1326 a = getattr(elemtype, DW_AT_byte_size);
1311 elemsize = a ? a->value : PtrSize; 1327 elemsize = a ? a->value : PtrSize;
1312 1328
1313 // sudog<T> 1329 // sudog<T>
1314 dws = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, 1330 dws = newdie(&dwtypes, DW_ABRV_STRUCTTYPE,
1315 mkinternaltypename("sudog", 1331 mkinternaltypename("sudog",
1316 getattr(elemtype, DW_AT_name)->data, nil)); 1332 getattr(elemtype, DW_AT_name)->data, nil));
1317 copychildren(dws, sudog); 1333 copychildren(dws, sudog);
1318 substitutetype(dws, "elem", elemtype); 1334 substitutetype(dws, "elem", elemtype);
1319 newattr(dws, DW_AT_byte_size, DW_CLS_CONSTANT, 1335 newattr(dws, DW_AT_byte_size, DW_CLS_CONSTANT,
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 newattr(&dwtypes, DW_AT_name, DW_CLS_STRING, strlen("dwtypes"), "dwtypes "); 2034 newattr(&dwtypes, DW_AT_name, DW_CLS_STRING, strlen("dwtypes"), "dwtypes ");
2019 2035
2020 mkindex(&dwroot); 2036 mkindex(&dwroot);
2021 mkindex(&dwtypes); 2037 mkindex(&dwtypes);
2022 mkindex(&dwglobals); 2038 mkindex(&dwglobals);
2023 2039
2024 // Some types that must exist to define other ones. 2040 // Some types that must exist to define other ones.
2025 newdie(&dwtypes, DW_ABRV_NULLTYPE, "<unspecified>"); 2041 newdie(&dwtypes, DW_ABRV_NULLTYPE, "<unspecified>");
2026 newdie(&dwtypes, DW_ABRV_NULLTYPE, "void"); 2042 newdie(&dwtypes, DW_ABRV_NULLTYPE, "void");
2027 newdie(&dwtypes, DW_ABRV_BARE_PTRTYPE, "unsafe.Pointer"); 2043 newdie(&dwtypes, DW_ABRV_BARE_PTRTYPE, "unsafe.Pointer");
2044
2028 die = newdie(&dwtypes, DW_ABRV_BASETYPE, "uintptr"); // needed for arra y size 2045 die = newdie(&dwtypes, DW_ABRV_BASETYPE, "uintptr"); // needed for arra y size
2029 newattr(die, DW_AT_encoding, DW_CLS_CONSTANT, DW_ATE_unsigned, 0); 2046 newattr(die, DW_AT_encoding, DW_CLS_CONSTANT, DW_ATE_unsigned, 0);
2030 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, PtrSize, 0); 2047 newattr(die, DW_AT_byte_size, DW_CLS_CONSTANT, PtrSize, 0);
2048 newattr(die, DW_AT_go_kind, DW_CLS_CONSTANT, KindUintptr, 0);
2031 2049
2032 // Needed by the prettyprinter code for interface inspection. 2050 // Needed by the prettyprinter code for interface inspection.
2033 defgotype(lookup_or_diag("type.runtime.rtype")); 2051 defgotype(lookup_or_diag("type.runtime.rtype"));
2034 defgotype(lookup_or_diag("type.runtime.interfaceType")); 2052 defgotype(lookup_or_diag("type.runtime.interfaceType"));
2035 defgotype(lookup_or_diag("type.runtime.itab")); 2053 defgotype(lookup_or_diag("type.runtime.itab"));
2036 2054
2037 genasmsym(defdwsymb); 2055 genasmsym(defdwsymb);
2038 2056
2039 writeabbrev(); 2057 writeabbrev();
2040 align(abbrevsize); 2058 align(abbrevsize);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 2439
2422 newPEDWARFSection(".debug_abbrev", abbrevsize); 2440 newPEDWARFSection(".debug_abbrev", abbrevsize);
2423 newPEDWARFSection(".debug_line", linesize); 2441 newPEDWARFSection(".debug_line", linesize);
2424 newPEDWARFSection(".debug_frame", framesize); 2442 newPEDWARFSection(".debug_frame", framesize);
2425 newPEDWARFSection(".debug_info", infosize); 2443 newPEDWARFSection(".debug_info", infosize);
2426 newPEDWARFSection(".debug_pubnames", pubnamessize); 2444 newPEDWARFSection(".debug_pubnames", pubnamessize);
2427 newPEDWARFSection(".debug_pubtypes", pubtypessize); 2445 newPEDWARFSection(".debug_pubtypes", pubtypessize);
2428 newPEDWARFSection(".debug_aranges", arangessize); 2446 newPEDWARFSection(".debug_aranges", arangessize);
2429 newPEDWARFSection(".debug_gdb_scripts", gdbscriptsize); 2447 newPEDWARFSection(".debug_gdb_scripts", gdbscriptsize);
2430 } 2448 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b