Skip to content

Commit 6530bc3

Browse files
32bit support P1 (#96)
1 parent 998f509 commit 6530bc3

File tree

5 files changed

+26
-57
lines changed

5 files changed

+26
-57
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ void ObjectFileXCOFF::Terminate() {
6262
PluginManager::UnregisterPlugin(CreateInstance);
6363
}
6464

65-
bool UGLY_FLAG_FOR_AIX __attribute__((weak)) = false;
66-
6765
ObjectFile *ObjectFileXCOFF::CreateInstance(const lldb::ModuleSP &module_sp,
6866
DataBufferSP data_sp,
6967
lldb::offset_t data_offset,
@@ -97,7 +95,6 @@ ObjectFile *ObjectFileXCOFF::CreateInstance(const lldb::ModuleSP &module_sp,
9795
if (!objfile_up->ParseHeader())
9896
return nullptr;
9997

100-
UGLY_FLAG_FOR_AIX = true;
10198
return objfile_up.release();
10299
}
103100

@@ -517,7 +514,10 @@ lldb_private::Address ObjectFileXCOFF::GetEntryPointAddress() {
517514
section_list->FindSectionContainingFileAddress(vm_addr));
518515
if (section_sp) {
519516
lldb::offset_t offset_ptr = section_sp->GetFileOffset() + (vm_addr - section_sp->GetFileAddress());
520-
vm_addr = m_data.GetU64(&offset_ptr);
517+
if(m_binary->is64Bit())
518+
vm_addr = m_data.GetU64(&offset_ptr);
519+
else
520+
vm_addr = m_data.GetU32(&offset_ptr);
521521
}
522522

523523
if (!section_list)

lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,13 +1729,20 @@ void NativeProcessAIX::ThreadWasCreated(NativeThreadAIX &thread) {
17291729

17301730
static void GetRegister(lldb::pid_t pid, long long addr, void *buf) {
17311731
uint64_t val = 0;
1732-
ptrace64(PT_READ_GPR, pid, addr, 0, (int *)&val);
1732+
uint32_t ret = 0;
1733+
ret = ptrace64(PT_READ_GPR, pid, addr, 0, (int *)&val);
1734+
// For 32bit application, ptrace64() return the value and val parameter
1735+
// of no use
1736+
if(val == 0)
1737+
val = ret;
17331738
*(uint64_t *)buf = llvm::byteswap<uint64_t>(val);
17341739
}
17351740

17361741
static void SetRegister(lldb::pid_t pid, long long addr, void *buf) {
17371742
uint64_t val = llvm::byteswap<uint64_t>(*(uint64_t *)buf);
1738-
ptrace64(PT_WRITE_GPR, pid, addr, 0, (int *)&val);
1743+
// For 32bit, ptrace64() expects the value as the 4th arg(data)
1744+
// For 64bit, ptrace64() expects the value as the 5th arg(pointer to the buffer)
1745+
ptrace64(PT_WRITE_GPR, pid, addr, val, (int *)&val);
17391746
}
17401747

17411748
static void GetFPRegister(lldb::pid_t pid, long long addr, void *buf) {

lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
7878
case DW_FORM_line_strp:
7979
case DW_FORM_sec_offset:
8080
//FIXME: For AIX
81-
m_value.uval = data.GetMaxU64(offset_ptr, 4);
81+
assert(m_unit); // Unit must be valid
82+
ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize();
83+
m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
8284
break;
8385
case DW_FORM_addrx1:
8486
case DW_FORM_strx1:
@@ -120,11 +122,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
120122
break;
121123
case DW_FORM_ref_addr:
122124
assert(m_unit);
123-
if (m_unit->GetVersion() <= 2)
124-
ref_addr_size = m_unit->GetAddressByteSize();
125-
else
126-
ref_addr_size = 4;
127-
//FIXME: For AIX
125+
ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize();
128126
m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
129127
break;
130128
case DW_FORM_indirect:
@@ -167,7 +165,7 @@ static FormSize g_form_sizes[] = {
167165
{1, 1}, // 0x0b DW_FORM_data1
168166
{1, 1}, // 0x0c DW_FORM_flag
169167
{0, 0}, // 0x0d DW_FORM_sdata
170-
{1, 4}, // 0x0e DW_FORM_strp
168+
{0, 0}, // 0x0e DW_FORM_strp
171169
{0, 0}, // 0x0f DW_FORM_udata
172170
{0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
173171
// for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
@@ -177,15 +175,15 @@ static FormSize g_form_sizes[] = {
177175
{1, 8}, // 0x14 DW_FORM_ref8
178176
{0, 0}, // 0x15 DW_FORM_ref_udata
179177
{0, 0}, // 0x16 DW_FORM_indirect
180-
{1, 4}, // 0x17 DW_FORM_sec_offset
178+
{0, 0}, // 0x17 DW_FORM_sec_offset
181179
{0, 0}, // 0x18 DW_FORM_exprloc
182180
{1, 0}, // 0x19 DW_FORM_flag_present
183181
{0, 0}, // 0x1a DW_FORM_strx (ULEB128)
184182
{0, 0}, // 0x1b DW_FORM_addrx (ULEB128)
185183
{1, 4}, // 0x1c DW_FORM_ref_sup4
186184
{0, 0}, // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for DWARF64)
187185
{1, 16}, // 0x1e DW_FORM_data16
188-
{1, 4}, // 0x1f DW_FORM_line_strp
186+
{0, 0}, // 0x1f DW_FORM_line_strp
189187
{1, 8}, // 0x20 DW_FORM_ref_sig8
190188
};
191189

@@ -248,13 +246,9 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
248246
return true;
249247

250248
case DW_FORM_ref_addr:
251-
ref_addr_size = 4;
252249
assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
253250
// get this wrong
254-
if (unit->GetVersion() <= 2)
255-
ref_addr_size = unit->GetAddressByteSize();
256-
else
257-
ref_addr_size = 4;
251+
ref_addr_size = unit->GetFormParams().getRefAddrByteSize();
258252
*offset_ptr += ref_addr_size;
259253
return true;
260254

@@ -290,7 +284,8 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
290284
case DW_FORM_sec_offset:
291285
case DW_FORM_strp:
292286
case DW_FORM_line_strp:
293-
*offset_ptr += 4;
287+
ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize();
288+
*offset_ptr += ref_addr_size;
294289
return true;
295290

296291
// 4 byte values
@@ -507,8 +502,6 @@ dw_addr_t DWARFFormValue::Address() const {
507502
&offset, index_size);
508503
}
509504

510-
bool UGLY_FLAG_FOR_AIX __attribute__((weak)) = false;
511-
512505
std::pair<DWARFUnit *, uint64_t>
513506
DWARFFormValue::ReferencedUnitAndOffset() const {
514507
uint64_t value = m_value.uval;
@@ -521,8 +514,6 @@ DWARFFormValue::ReferencedUnitAndOffset() const {
521514
assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
522515
// unit relative or we will get this wrong
523516
value += m_unit->GetOffset();
524-
if (UGLY_FLAG_FOR_AIX)
525-
value -= 8;
526517
if (!m_unit->ContainsDIEOffset(value)) {
527518
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
528519
"DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value);
@@ -549,7 +540,6 @@ DWARFFormValue::ReferencedUnitAndOffset() const {
549540
return {nullptr, 0};
550541
return {tu, tu->GetTypeOffset()};
551542
}
552-
553543
default:
554544
return {nullptr, 0};
555545
}

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,24 +1081,7 @@ const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
10811081
: m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
10821082
}
10831083

1084-
uint32_t DWARFUnit::GetHeaderByteSize() const {
1085-
switch (m_header.getUnitType()) {
1086-
case llvm::dwarf::DW_UT_compile:
1087-
if (UGLY_FLAG_FOR_AIX)
1088-
return 11 + 4/*GetDWARFSizeOfOffset*/;
1089-
else
1090-
return GetVersion() < 5 ? 11 : 12;
1091-
case llvm::dwarf::DW_UT_partial:
1092-
return GetVersion() < 5 ? 11 : 12;
1093-
case llvm::dwarf::DW_UT_skeleton:
1094-
case llvm::dwarf::DW_UT_split_compile:
1095-
return 20;
1096-
case llvm::dwarf::DW_UT_type:
1097-
case llvm::dwarf::DW_UT_split_type:
1098-
return GetVersion() < 5 ? 23 : 24;
1099-
}
1100-
llvm_unreachable("invalid UnitType.");
1101-
}
1084+
uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }
11021085

11031086
std::optional<uint64_t>
11041087
DWARFUnit::GetStringOffsetSectionItem(uint32_t index) const {

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,10 @@ Expected<uint64_t> DWARFUnit::getStringOffsetSectionItem(uint32_t Index) const {
251251
return DA.getRelocatedValue(ItemSize, &Offset);
252252
}
253253

254-
bool UGLY_FLAG_FOR_AIX __attribute__((weak)) = false;
255-
256254
Error DWARFUnitHeader::extract(DWARFContext &Context,
257255
const DWARFDataExtractor &debug_info,
258256
uint64_t *offset_ptr,
259257
DWARFSectionKind SectionKind) {
260-
if (UGLY_FLAG_FOR_AIX) {
261-
// FIXME: hack to get version
262-
*offset_ptr += 8;
263-
}
264258
Offset = *offset_ptr;
265259
Error Err = Error::success();
266260
IndexEntry = nullptr;
@@ -273,13 +267,8 @@ Error DWARFUnitHeader::extract(DWARFContext &Context,
273267
AbbrOffset = debug_info.getRelocatedValue(
274268
FormParams.getDwarfOffsetByteSize(), offset_ptr, nullptr, &Err);
275269
} else {
276-
if (UGLY_FLAG_FOR_AIX) {
277-
AbbrOffset = debug_info.getRelocatedValue(
278-
8, offset_ptr, nullptr, &Err);
279-
} else {
280-
AbbrOffset = debug_info.getRelocatedValue(
281-
FormParams.getDwarfOffsetByteSize(), offset_ptr, nullptr, &Err);
282-
}
270+
AbbrOffset = debug_info.getRelocatedValue(
271+
FormParams.getDwarfOffsetByteSize(), offset_ptr, nullptr, &Err);
283272
FormParams.AddrSize = debug_info.getU8(offset_ptr, &Err);
284273
// Fake a unit type based on the section type. This isn't perfect,
285274
// but distinguishing compile and type units is generally enough.

0 commit comments

Comments
 (0)