Skip to content

Commit aa24fc7

Browse files
Added comments and test cases
1 parent fcbdd41 commit aa24fc7

File tree

3 files changed

+202
-6
lines changed

3 files changed

+202
-6
lines changed

lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,18 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
216216
}
217217

218218
llvm::StringRef symbolName = name_or_err.get();
219-
// Remove the dot prefix from symbol names before adding to symtab. '.text'
220-
// -> 'text'
219+
// Remove the . prefix added during compilation. This prefix is usually
220+
// added to differentiate between reference to the code and function
221+
// descriptor. For symtab, Adding .func will only allow user to put bp on
222+
// .func, which is not known to the user, instead of func.
221223
llvm::StringRef name_no_dot =
222224
symbolName.starts_with(".") ? symbolName.drop_front() : symbolName;
223225
auto storageClass = xcoff_sym_ref.getStorageClass();
224-
// If its the hidden ext TOC symbol, add it directly,
225-
// for all other C_HIDEXT symbols, proceed to other checks.
226+
// C_HIDEXT symbols are not needed to be exposed, with the exception of TOC
227+
// which is responsible for storing references to global data
226228
if (storageClass == XCOFF::C_HIDEXT && symbolName != "TOC") {
227229

228-
// We do not need to add entries with 0 or >1 auxiliary data
230+
// Zero or muliple aux entries may suggest ambiguous data
229231
if (xcoff_sym_ref.getNumberOfAuxEntries() != 1)
230232
continue;
231233

@@ -239,11 +241,14 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
239241
const llvm::object::XCOFFCsectAuxRef csect_aux = aux_csect_or_err.get();
240242

241243
// Only add hidden ext entries which come under Program Code, skip others
244+
// as they are not relevant as debugging data.
242245
if (csect_aux.getStorageMappingClass() != XCOFF::XMC_PR)
243246
continue;
244247

245248
// This does not apply to 32-bit,
246-
// Only add csect symbols identified by the aux entry, skip others
249+
// Only add csect symbols identified by the aux entry, as they are
250+
// needed to reference section information. Skip others as they are not
251+
// relevant to debugging data.
247252
if (m_binary->is64Bit())
248253
if (csect_aux.getAuxType64() != XCOFF::AUX_CSECT)
249254
continue;

lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
# CHECK-NEXT: Type: dwarf-abbrev
3030
# CHECK-NEXT: Permissions: r--
3131

32+
# Symbol table testing
33+
# RUN: %lldb %t -o "image dump symtab" -o exit | FileCheck %s --check-prefix=CHECK-SYMBOL
34+
# CHECK-SYMBOL:Index UserID DSX Type File Address/Value Load Address Size Flags Name
35+
# CHECK-SYMBOL:[ 0] 4294967295 Invalid 0xffffffffffffffff 0x0000000000000000 0x00000000 errno
36+
# CHECK-SYMBOL:[ 1] 4294967295 Code 0x0000000100000500 0x0000000000000398 0x00000000 __threads_init
37+
# CHECK-SYMBOL:[ 2] 4294967295 Data 0x0000000110000a70 0x0000000000000060 0x00000000 __threads_init
38+
# CHECK-SYMBOL:[ 3] 4294967295 Invalid 0x0000000110000ad0 0x00000000000000b0 0x00000000 TOC
39+
# CHECK-SYMBOL:[ 4] 4294967295 Invalid 0x0000000100000898 0x00000000100001d8 0x00000000 text
40+
# CHECK-SYMBOL:[ 5] 4294967295 Code 0x0000000100000898 0x00000000100001d8 0x00000000 main
41+
3242
--- !XCOFF
3343
FileHeader:
3444
MagicNumber: 0x1F7
@@ -104,5 +114,90 @@ Sections:
104114
NumberOfLineNumbers: 0x0
105115
Flags: [ STYP_DWARF ]
106116
SectionData: 01110125
117+
Symbols:
118+
- Name: errno
119+
Value: 0x0
120+
Section: N_UNDEF
121+
Type: 0x0
122+
StorageClass: C_EXT
123+
NumberOfAuxEntries: 1
124+
AuxEntries:
125+
- Type: AUX_CSECT
126+
ParameterHashIndex: 0
127+
TypeChkSectNum: 0
128+
SymbolAlignmentAndType: 0
129+
StorageMappingClass: XMC_RW
130+
SectionOrLengthLo: 0
131+
SectionOrLengthHi: 0
132+
- Name: .__threads_init
133+
Value: 0x100000500
134+
Section: .text
135+
Type: 0x20
136+
StorageClass: C_EXT
137+
NumberOfAuxEntries: 1
138+
AuxEntries:
139+
- Type: AUX_CSECT
140+
ParameterHashIndex: 0
141+
TypeChkSectNum: 0
142+
SymbolAlignmentAndType: 2
143+
StorageMappingClass: XMC_PR
144+
SectionOrLengthLo: 80
145+
SectionOrLengthHi: 0
146+
- Name: __threads_init
147+
Value: 0x110000A70
148+
Section: .data
149+
Type: 0x0
150+
StorageClass: C_EXT
151+
NumberOfAuxEntries: 1
152+
AuxEntries:
153+
- Type: AUX_CSECT
154+
ParameterHashIndex: 0
155+
TypeChkSectNum: 0
156+
SymbolAlignmentAndType: 25
157+
StorageMappingClass: XMC_DS
158+
SectionOrLengthLo: 24
159+
SectionOrLengthHi: 0
160+
- Name: TOC
161+
Value: 0x110000AD0
162+
Section: .data
163+
Type: 0x0
164+
StorageClass: C_HIDEXT
165+
NumberOfAuxEntries: 1
166+
AuxEntries:
167+
- Type: AUX_CSECT
168+
ParameterHashIndex: 0
169+
TypeChkSectNum: 0
170+
SymbolAlignmentAndType: 25
171+
StorageMappingClass: XMC_TC0
172+
SectionOrLengthLo: 0
173+
SectionOrLengthHi: 0
174+
- Name: .text
175+
Value: 0x100000898
176+
Section: .text
177+
Type: 0x0
178+
StorageClass: C_HIDEXT
179+
NumberOfAuxEntries: 1
180+
AuxEntries:
181+
- Type: AUX_CSECT
182+
ParameterHashIndex: 0
183+
TypeChkSectNum: 0
184+
SymbolAlignmentAndType: 17
185+
StorageMappingClass: XMC_PR
186+
SectionOrLengthLo: 58
187+
SectionOrLengthHi: 0
188+
- Name: .main
189+
Value: 0x100000898
190+
Section: .text
191+
Type: 0x0
192+
StorageClass: C_EXT
193+
NumberOfAuxEntries: 1
194+
AuxEntries:
195+
- Type: AUX_CSECT
196+
ParameterHashIndex: 0
197+
TypeChkSectNum: 0
198+
SymbolAlignmentAndType: 2
199+
StorageMappingClass: XMC_PR
200+
SectionOrLengthLo: 135
201+
SectionOrLengthHi: 0
107202
StringTable: {}
108203
...

lldb/test/Shell/ObjectFile/XCOFF/basic-info32.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
# CHECK-NEXT: Type: dwarf-abbrev
3030
# CHECK-NEXT: Permissions: r--
3131

32+
33+
# RUN: %lldb %t -o "image dump symtab" -o exit | FileCheck %s --check-prefix=CHECK-SYMBOL
34+
# CHECK-SYMBOL:Index UserID DSX Type File Address/Value Load Address Size Flags Name
35+
#[ 0] 4294967295 Invalid 0xffffffffffffffff 0x0000000000000000 0x00000000 errno
36+
# CHECK-SYMBOL:[ 1] 4294967295 Code 0x0000000010000320 0x0000000000000420 0x00000000 __threads_init
37+
# CHECK-SYMBOL:[ 2] 4294967295 Data 0x0000000020000920 0x000000000000003c 0x00000000 __threads_init
38+
# CHECK-SYMBOL:[ 3] 4294967295 Invalid 0x000000002000095c 0x0000000000000060 0x00000000 TOC
39+
# CHECK-SYMBOL:[ 4] 4294967295 Invalid 0x0000000010000740 0x000000000000003a 0x00000000 text
40+
# CHECK-SYMBOL:[ 5] 4294967295 Invalid 0x0000000010000740 0x000000000000003a 0x00000000 main
41+
3242
--- !XCOFF
3343
FileHeader:
3444
MagicNumber: 0x1DF
@@ -106,5 +116,91 @@ Sections:
106116
NumberOfLineNumbers: 0x0
107117
Flags: [ STYP_DWARF ]
108118
SectionData: 01110125
119+
Symbols:
120+
- Name: errno
121+
Value: 0x0
122+
Section: N_UNDEF
123+
Type: 0x0
124+
StorageClass: C_EXT
125+
NumberOfAuxEntries: 1
126+
AuxEntries:
127+
- Type: AUX_CSECT
128+
ParameterHashIndex: 0
129+
TypeChkSectNum: 0
130+
StorageMappingClass: XMC_RW
131+
SectionOrLength: 0
132+
StabInfoIndex: 0
133+
StabSectNum: 0
134+
- Name: .__threads_init
135+
Value: 0x10000320
136+
Section: .text
137+
Type: 0x20
138+
StorageClass: C_EXT
139+
NumberOfAuxEntries: 1
140+
AuxEntries:
141+
- Type: AUX_CSECT
142+
ParameterHashIndex: 0
143+
TypeChkSectNum: 0
144+
StorageMappingClass: XMC_PR
145+
SectionOrLength: 84
146+
StabInfoIndex: 0
147+
StabSectNum: 0
148+
- Name: __threads_init
149+
Value: 0x20000920
150+
Section: .data
151+
Type: 0x0
152+
StorageClass: C_EXT
153+
NumberOfAuxEntries: 1
154+
AuxEntries:
155+
- Type: AUX_CSECT
156+
ParameterHashIndex: 0
157+
TypeChkSectNum: 0
158+
StorageMappingClass: XMC_DS
159+
SectionOrLength: 12
160+
StabInfoIndex: 0
161+
StabSectNum: 0
162+
- Name: TOC
163+
Value: 0x2000095C
164+
Section: .data
165+
Type: 0x0
166+
StorageClass: C_HIDEXT
167+
NumberOfAuxEntries: 1
168+
AuxEntries:
169+
- Type: AUX_CSECT
170+
ParameterHashIndex: 0
171+
TypeChkSectNum: 0
172+
StorageMappingClass: XMC_TC0
173+
SectionOrLength: 0
174+
StabInfoIndex: 0
175+
StabSectNum: 0
176+
- Name: .text
177+
Value: 0x10000740
178+
Section: .text
179+
Type: 0x0
180+
StorageClass: C_HIDEXT
181+
NumberOfAuxEntries: 1
182+
AuxEntries:
183+
- Type: AUX_CSECT
184+
ParameterHashIndex: 0
185+
TypeChkSectNum: 0
186+
StorageMappingClass: XMC_PR
187+
SectionOrLength: 58
188+
StabInfoIndex: 0
189+
StabSectNum: 0
190+
- Name: .main
191+
Value: 0x10000740
192+
Section: .text
193+
Type: 0x0
194+
StorageClass: C_EXT
195+
NumberOfAuxEntries: 1
196+
AuxEntries:
197+
- Type: AUX_CSECT
198+
ParameterHashIndex: 0
199+
TypeChkSectNum: 0
200+
StorageMappingClass: XMC_PR
201+
SectionOrLength: 137
202+
StabInfoIndex: 0
203+
StabSectNum: 0
204+
109205
StringTable: {}
110206
...

0 commit comments

Comments
 (0)