Skip to content

Commit 27a1b26

Browse files
committed
Add test
1 parent 2cfc961 commit 27a1b26

File tree

3 files changed

+284
-0
lines changed

3 files changed

+284
-0
lines changed

lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,38 @@ def test_command_stats_api(self):
117117
self.assertNotIn("bt", command_stats)
118118
# Verify bt's regex command is not duplicatedly captured.
119119
self.assertNotIn("_regexp-bt", command_stats)
120+
121+
def test_command_stats_force(self):
122+
"""
123+
Test reporting all pssible debug info stats by force loading all debug
124+
info. For example, dwo files
125+
"""
126+
src_dir = self.getSourceDir()
127+
dwo_yaml_path = os.path.join(src_dir, "main.dwo.yaml")
128+
obj_yaml_path = os.path.join(src_dir, "main.o.yaml")
129+
dwo_path = self.getBuildArtifact("main.dwo")
130+
obj_path = self.getBuildArtifact("main.o")
131+
self.yaml2obj(dwo_yaml_path, dwo_path)
132+
self.yaml2obj(obj_yaml_path, obj_path)
133+
134+
# We need the current working directory to be set to the build directory
135+
os.chdir(self.getBuildDir())
136+
# Create a target with the object file we just created from YAML
137+
target = self.dbg.CreateTarget(obj_path)
138+
self.assertTrue(target, VALID_TARGET)
139+
140+
# Get statistics
141+
stats_options = lldb.SBStatisticsOptions()
142+
stats = target.GetStatistics(stats_options)
143+
stream = lldb.SBStream()
144+
stats.GetAsJSON(stream)
145+
debug_stats = json.loads(stream.GetData())
146+
self.assertEqual(debug_stats["totalDebugInfoByteSize"], 188)
147+
148+
# Get statistics with force loading
149+
stats_options.SetForceLoading(True)
150+
stats_force = target.GetStatistics(stats_options)
151+
stream_force = lldb.SBStream()
152+
stats_force.GetAsJSON(stream_force)
153+
debug_stats_force = json.loads(stream_force.GetData())
154+
self.assertEqual(debug_stats_force["totalDebugInfoByteSize"], 435)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--- !ELF
2+
FileHeader:
3+
Class: ELFCLASS64
4+
Data: ELFDATA2LSB
5+
Type: ET_REL
6+
Machine: EM_X86_64
7+
SectionHeaderStringTable: .strtab
8+
Sections:
9+
- Name: .debug_str.dwo
10+
Type: SHT_PROGBITS
11+
Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
12+
AddressAlign: 0x1
13+
EntSize: 0x1
14+
Content: 5F5A33666F6F7600666F6F006D61696E00696E7400636C616E672076657273696F6E2031372E302E36202843656E744F532031372E302E362D342E656C3929006D61696E2E637070006D61696E2E64776F00
15+
- Name: .debug_str_offsets.dwo
16+
Type: SHT_PROGBITS
17+
Flags: [ SHF_EXCLUDE ]
18+
AddressAlign: 0x1
19+
Content: 00000000080000000C00000011000000150000004000000049000000
20+
- Name: .debug_info.dwo
21+
Type: SHT_PROGBITS
22+
Flags: [ SHF_EXCLUDE ]
23+
AddressAlign: 0x1
24+
Content: 3500000004000000000008010421000506939F5FCB7816797B02000600000001560001010103011C0000000156020105340000000403050400
25+
- Name: .debug_abbrev.dwo
26+
Type: SHT_PROGBITS
27+
Flags: [ SHF_EXCLUDE ]
28+
AddressAlign: 0x1
29+
Content: 01110125823E130503823EB042823EB142070000022E0011813E120640186E823E03823E3A0B3B0B3F190000032E0011813E1206401803823E3A0B3B0B49133F19000004240003823E3E0B0B0B000000
30+
- Type: SectionHeaderTable
31+
Sections:
32+
- Name: .strtab
33+
- Name: .debug_str.dwo
34+
- Name: .debug_str_offsets.dwo
35+
- Name: .debug_info.dwo
36+
- Name: .debug_abbrev.dwo
37+
...
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
--- !ELF
2+
FileHeader:
3+
Class: ELFCLASS64
4+
Data: ELFDATA2LSB
5+
Type: ET_REL
6+
Machine: EM_X86_64
7+
SectionHeaderStringTable: .strtab
8+
Sections:
9+
- Name: .text
10+
Type: SHT_PROGBITS
11+
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
12+
AddressAlign: 0x10
13+
Content: 554889E55DC3662E0F1F840000000000554889E54883EC10C745FC00000000E80000000031C04883C4105DC3
14+
- Name: .debug_abbrev
15+
Type: SHT_PROGBITS
16+
AddressAlign: 0x1
17+
Content: 01110010171B0EB44219B0420EB1420711011206B34217000000
18+
- Name: .debug_info
19+
Type: SHT_PROGBITS
20+
AddressAlign: 0x1
21+
Content: 2C0000000400000000000801000000000000000000000000939F5FCB7816797B00000000000000002C00000000000000
22+
- Name: .debug_addr
23+
Type: SHT_PROGBITS
24+
AddressAlign: 0x1
25+
Content: '00000000000000000000000000000000'
26+
- Name: .debug_gnu_pubnames
27+
Type: SHT_PROGBITS
28+
AddressAlign: 0x1
29+
Content: 21000000020000000000300000001900000030666F6F0025000000306D61696E0000000000
30+
- Name: .debug_gnu_pubtypes
31+
Type: SHT_PROGBITS
32+
AddressAlign: 0x1
33+
Content: '17000000020000000000300000003400000090696E740000000000'
34+
- Name: .comment
35+
Type: SHT_PROGBITS
36+
Flags: [ SHF_MERGE, SHF_STRINGS ]
37+
AddressAlign: 0x1
38+
EntSize: 0x1
39+
Content: 00636C616E672076657273696F6E2031372E302E36202843656E744F532031372E302E362D342E656C392900
40+
- Name: .note.GNU-stack
41+
Type: SHT_PROGBITS
42+
AddressAlign: 0x1
43+
- Name: .eh_frame
44+
Type: SHT_X86_64_UNWIND
45+
Flags: [ SHF_ALLOC ]
46+
AddressAlign: 0x8
47+
Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000000000000600000000410E108602430D06410C07080000001C0000003C000000000000001C00000000410E108602430D06570C0708000000
48+
- Name: .debug_line
49+
Type: SHT_PROGBITS
50+
AddressAlign: 0x1
51+
Content: 47000000040020000000010101FB0E0D000101010100000001000001006D61696E2E637070000000000000090200000000000000000105050A0B4B0500BD05050AE559060B2E0206000101
52+
- Name: .rela.text
53+
Type: SHT_RELA
54+
Flags: [ SHF_INFO_LINK ]
55+
Link: .symtab
56+
AddressAlign: 0x8
57+
Info: .text
58+
Relocations:
59+
- Offset: 0x20
60+
Symbol: _Z3foov
61+
Type: R_X86_64_PLT32
62+
Addend: -4
63+
- Name: .rela.debug_info
64+
Type: SHT_RELA
65+
Flags: [ SHF_INFO_LINK ]
66+
Link: .symtab
67+
AddressAlign: 0x8
68+
Info: .debug_info
69+
Relocations:
70+
- Offset: 0x6
71+
Symbol: .debug_abbrev
72+
Type: R_X86_64_32
73+
- Offset: 0xC
74+
Symbol: .debug_line
75+
Type: R_X86_64_32
76+
- Offset: 0x10
77+
Symbol: .debug_str
78+
Type: R_X86_64_32
79+
- Offset: 0x14
80+
Symbol: .debug_str
81+
Type: R_X86_64_32
82+
Addend: 14
83+
- Offset: 0x20
84+
Symbol: .text
85+
Type: R_X86_64_64
86+
- Offset: 0x2C
87+
Symbol: .debug_addr
88+
Type: R_X86_64_32
89+
- Name: .rela.debug_addr
90+
Type: SHT_RELA
91+
Flags: [ SHF_INFO_LINK ]
92+
Link: .symtab
93+
AddressAlign: 0x8
94+
Info: .debug_addr
95+
Relocations:
96+
- Symbol: .text
97+
Type: R_X86_64_64
98+
- Offset: 0x8
99+
Symbol: .text
100+
Type: R_X86_64_64
101+
Addend: 16
102+
- Name: .rela.debug_gnu_pubnames
103+
Type: SHT_RELA
104+
Flags: [ SHF_INFO_LINK ]
105+
Link: .symtab
106+
AddressAlign: 0x8
107+
Info: .debug_gnu_pubnames
108+
Relocations:
109+
- Offset: 0x6
110+
Symbol: .debug_info
111+
Type: R_X86_64_32
112+
- Name: .rela.debug_gnu_pubtypes
113+
Type: SHT_RELA
114+
Flags: [ SHF_INFO_LINK ]
115+
Link: .symtab
116+
AddressAlign: 0x8
117+
Info: .debug_gnu_pubtypes
118+
Relocations:
119+
- Offset: 0x6
120+
Symbol: .debug_info
121+
Type: R_X86_64_32
122+
- Name: .rela.eh_frame
123+
Type: SHT_RELA
124+
Flags: [ SHF_INFO_LINK ]
125+
Link: .symtab
126+
AddressAlign: 0x8
127+
Info: .eh_frame
128+
Relocations:
129+
- Offset: 0x20
130+
Symbol: .text
131+
Type: R_X86_64_PC32
132+
- Offset: 0x40
133+
Symbol: .text
134+
Type: R_X86_64_PC32
135+
Addend: 16
136+
- Name: .rela.debug_line
137+
Type: SHT_RELA
138+
Flags: [ SHF_INFO_LINK ]
139+
Link: .symtab
140+
AddressAlign: 0x8
141+
Info: .debug_line
142+
Relocations:
143+
- Offset: 0x2D
144+
Symbol: .text
145+
Type: R_X86_64_64
146+
- Name: .llvm_addrsig
147+
Type: SHT_LLVM_ADDRSIG
148+
Flags: [ SHF_EXCLUDE ]
149+
Link: .symtab
150+
AddressAlign: 0x1
151+
Symbols: [ _Z3foov ]
152+
- Type: SectionHeaderTable
153+
Sections:
154+
- Name: .strtab
155+
- Name: .text
156+
- Name: .rela.text
157+
- Name: .debug_abbrev
158+
- Name: .debug_info
159+
- Name: .rela.debug_info
160+
- Name: .debug_str
161+
- Name: .debug_addr
162+
- Name: .rela.debug_addr
163+
- Name: .debug_gnu_pubnames
164+
- Name: .rela.debug_gnu_pubnames
165+
- Name: .debug_gnu_pubtypes
166+
- Name: .rela.debug_gnu_pubtypes
167+
- Name: .comment
168+
- Name: .note.GNU-stack
169+
- Name: .eh_frame
170+
- Name: .rela.eh_frame
171+
- Name: .debug_line
172+
- Name: .rela.debug_line
173+
- Name: .llvm_addrsig
174+
- Name: .symtab
175+
Symbols:
176+
- Name: main.cpp
177+
Type: STT_FILE
178+
Index: SHN_ABS
179+
- Name: .text
180+
Type: STT_SECTION
181+
Section: .text
182+
- Name: .debug_abbrev
183+
Type: STT_SECTION
184+
Section: .debug_abbrev
185+
- Name: .debug_info
186+
Type: STT_SECTION
187+
Section: .debug_info
188+
- Name: .debug_str
189+
Type: STT_SECTION
190+
Section: .debug_str
191+
- Name: .debug_addr
192+
Type: STT_SECTION
193+
Section: .debug_addr
194+
- Name: .debug_line
195+
Type: STT_SECTION
196+
Section: .debug_line
197+
- Name: _Z3foov
198+
Type: STT_FUNC
199+
Section: .text
200+
Binding: STB_GLOBAL
201+
Size: 0x6
202+
- Name: main
203+
Type: STT_FUNC
204+
Section: .text
205+
Binding: STB_GLOBAL
206+
Value: 0x10
207+
Size: 0x1C
208+
DWARF:
209+
debug_str:
210+
- '/tmp/test_dwo'
211+
- main.dwo
212+
...

0 commit comments

Comments
 (0)