ignore-declarations.test 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # Test that we properly ignore DIEs that have DW_AT_declaration=true.
  2. # This indicates a function that was declared, but not defined.
  3. # We don't want to register declarations, only definitions.
  4. #
  5. # This test is somewhat unrealistic, as it contains DIEs we would
  6. # probably never see in the real world (specifically, DIEs that have
  7. # both DW_AT_declaration and DW_AT_low_pc). However this may be the
  8. # only way of testing that we are truly skipping declarations, since
  9. # the skipping of declarations may not have any actual observable
  10. # effect on real-world data.
  11. # RUN: %yaml2obj %s --docnum=1 -o %t.obj
  12. # RUN: %yaml2obj %s --docnum=2 -o %t.dwo
  13. # RUN: %bloaty %t.obj --debug-file %t.dwo -d compileunits --raw-map --domain=vm | %FileCheck %s
  14. --- !ELF
  15. FileHeader:
  16. Class: ELFCLASS64
  17. Data: ELFDATA2LSB
  18. Type: ET_DYN
  19. Machine: EM_X86_64
  20. Entry: 0x1040
  21. ProgramHeaders:
  22. - Type: PT_LOAD
  23. Flags: [ PF_X, PF_R ]
  24. FirstSec: .text
  25. LastSec: .text
  26. VAddr: 0x1000
  27. Align: 0x1000
  28. Sections:
  29. - Name: .note.gnu.build-id
  30. Type: SHT_NOTE
  31. Notes:
  32. - Name: GNU
  33. Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57
  34. Type: 0x3 # NT_GNU_BUILD_ID
  35. - Name: .text
  36. Type: SHT_PROGBITS
  37. Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
  38. Address: 0x1000
  39. AddressAlign: 0x10
  40. Size: 0x20
  41. ...
  42. --- !ELF
  43. FileHeader:
  44. Class: ELFCLASS64
  45. Data: ELFDATA2LSB
  46. Type: ET_DYN
  47. Machine: EM_X86_64
  48. Entry: 0x1040
  49. Sections:
  50. - Name: .note.gnu.build-id
  51. Type: SHT_NOTE
  52. Notes:
  53. - Name: GNU
  54. Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57
  55. Type: 0x3 # NT_GNU_BUILD_ID
  56. DWARF:
  57. debug_str:
  58. - foo.c
  59. - bar.c
  60. debug_abbrev:
  61. - ID: 0
  62. Table:
  63. - Code: 0x1
  64. Tag: DW_TAG_compile_unit
  65. Children: DW_CHILDREN_yes
  66. Attributes:
  67. - Attribute: DW_AT_name
  68. Form: DW_FORM_strp
  69. - Code: 0x2
  70. Tag: DW_TAG_subprogram
  71. Children: DW_CHILDREN_no
  72. Attributes:
  73. - Attribute: DW_AT_low_pc
  74. Form: DW_FORM_addr
  75. - Attribute: DW_AT_high_pc
  76. Form: DW_FORM_data4
  77. - Attribute: DW_AT_declaration
  78. Form: DW_FORM_flag_present
  79. - Code: 0x3
  80. Tag: DW_TAG_subprogram
  81. Children: DW_CHILDREN_no
  82. Attributes:
  83. - Attribute: DW_AT_low_pc
  84. Form: DW_FORM_addr
  85. - Attribute: DW_AT_high_pc
  86. Form: DW_FORM_data4
  87. debug_info:
  88. # 0x0000000b: DW_TAG_compile_unit
  89. # DW_AT_name ("foo.c")
  90. #
  91. # 0x00000010: DW_TAG_subprogram
  92. # DW_AT_low_pc (0x0000000000001000)
  93. # DW_AT_high_pc (0x0000000000001010)
  94. # # This entry should be ignored because declaration=true.
  95. # DW_AT_declaration (true)
  96. #
  97. # 0x0000001d: DW_TAG_subprogram
  98. # DW_AT_low_pc (0x0000000000001010)
  99. # DW_AT_high_pc (0x0000000000001020)
  100. - Version: 4
  101. AbbrevTableID: 0
  102. AbbrOffset: 0x0
  103. AddrSize: 8
  104. Entries:
  105. - AbbrCode: 0x1
  106. Values:
  107. - Value: 0x0
  108. - AbbrCode: 0x2
  109. Values:
  110. - Value: 0x1000
  111. - Value: 0x10
  112. - AbbrCode: 0x3
  113. Values:
  114. - Value: 0x1010
  115. - Value: 0x10
  116. - AbbrCode: 0x0
  117. # 0x00000036: DW_TAG_compile_unit
  118. # DW_AT_name ("bar.c")
  119. #
  120. # 0x0000003b: DW_TAG_subprogram
  121. # DW_AT_low_pc (0x0000000000001000)
  122. # DW_AT_high_pc (0x0000000000001010)
  123. - Version: 4
  124. AbbrevTableID: 0
  125. AbbrOffset: 0x0
  126. AddrSize: 8
  127. Entries:
  128. - AbbrCode: 0x1
  129. Values:
  130. - Value: 0x6
  131. - AbbrCode: 0x3
  132. Values:
  133. - Value: 0x1000
  134. - Value: 0x10
  135. - AbbrCode: 0x0
  136. ...
  137. # CHECK: VM MAP:
  138. # CHECK: 0000-1000 4096 [-- Nothing mapped --]
  139. # CHECK: 1000-1010 16 bar.c
  140. # CHECK: 1010-1020 16 foo.c