Skip to content

Commit b804516

Browse files
[lldb][AIX] 1. Avoid namespace collision on other platforms (llvm#104679)
This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. llvm#101657 The complete changes for porting are present in this draft PR: llvm#102601 The changes on this PR are intended to avoid namespace collision for certain typedefs between lldb and other platforms: 1. tid_t --> lldb::tid_t 2. offset_t --> lldb::offset_t
1 parent a6d81cd commit b804516

File tree

19 files changed

+51
-47
lines changed

19 files changed

+51
-47
lines changed

lldb/source/API/SBBreakpoint.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ uint32_t SBBreakpoint::GetIgnoreCount() const {
342342
return count;
343343
}
344344

345-
void SBBreakpoint::SetThreadID(tid_t tid) {
345+
void SBBreakpoint::SetThreadID(lldb::tid_t tid) {
346346
LLDB_INSTRUMENT_VA(this, tid);
347347

348348
BreakpointSP bkpt_sp = GetSP();
@@ -353,10 +353,10 @@ void SBBreakpoint::SetThreadID(tid_t tid) {
353353
}
354354
}
355355

356-
tid_t SBBreakpoint::GetThreadID() {
356+
lldb::tid_t SBBreakpoint::GetThreadID() {
357357
LLDB_INSTRUMENT_VA(this);
358358

359-
tid_t tid = LLDB_INVALID_THREAD_ID;
359+
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
360360
BreakpointSP bkpt_sp = GetSP();
361361
if (bkpt_sp) {
362362
std::lock_guard<std::recursive_mutex> guard(

lldb/source/API/SBBreakpointLocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) {
302302
return has_commands;
303303
}
304304

305-
void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
305+
void SBBreakpointLocation::SetThreadID(lldb::tid_t thread_id) {
306306
LLDB_INSTRUMENT_VA(this, thread_id);
307307

308308
BreakpointLocationSP loc_sp = GetSP();
@@ -313,10 +313,10 @@ void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
313313
}
314314
}
315315

316-
tid_t SBBreakpointLocation::GetThreadID() {
316+
lldb::tid_t SBBreakpointLocation::GetThreadID() {
317317
LLDB_INSTRUMENT_VA(this);
318318

319-
tid_t tid = LLDB_INVALID_THREAD_ID;
319+
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
320320
BreakpointLocationSP loc_sp = GetSP();
321321
if (loc_sp) {
322322
std::lock_guard<std::recursive_mutex> guard(

lldb/source/API/SBBreakpointName.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ bool SBBreakpointName::GetAutoContinue() {
347347
return bp_name->GetOptions().IsAutoContinue();
348348
}
349349

350-
void SBBreakpointName::SetThreadID(tid_t tid) {
350+
void SBBreakpointName::SetThreadID(lldb::tid_t tid) {
351351
LLDB_INSTRUMENT_VA(this, tid);
352352

353353
BreakpointName *bp_name = GetBreakpointName();
@@ -361,7 +361,7 @@ void SBBreakpointName::SetThreadID(tid_t tid) {
361361
UpdateName(*bp_name);
362362
}
363363

364-
tid_t SBBreakpointName::GetThreadID() {
364+
lldb::tid_t SBBreakpointName::GetThreadID() {
365365
LLDB_INSTRUMENT_VA(this);
366366

367367
BreakpointName *bp_name = GetBreakpointName();

lldb/source/Expression/DWARFExpression.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
130130

131131
/// Return the length in bytes of the set of operands for \p op. No guarantees
132132
/// are made on the state of \p data after this call.
133-
static offset_t GetOpcodeDataSize(const DataExtractor &data,
134-
const lldb::offset_t data_offset,
135-
const uint8_t op, const DWARFUnit *dwarf_cu) {
133+
static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
134+
const lldb::offset_t data_offset,
135+
const uint8_t op,
136+
const DWARFUnit *dwarf_cu) {
136137
lldb::offset_t offset = data_offset;
137138
switch (op) {
138139
case DW_OP_addr:
@@ -358,7 +359,7 @@ lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu,
358359
error = true;
359360
break;
360361
}
361-
const offset_t op_arg_size =
362+
const lldb::offset_t op_arg_size =
362363
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
363364
if (op_arg_size == LLDB_INVALID_OFFSET) {
364365
error = true;
@@ -418,7 +419,7 @@ bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu,
418419
m_data.SetData(encoder.GetDataBuffer());
419420
return true;
420421
}
421-
const offset_t op_arg_size =
422+
const lldb::offset_t op_arg_size =
422423
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
423424
if (op_arg_size == LLDB_INVALID_OFFSET)
424425
break;
@@ -435,7 +436,7 @@ bool DWARFExpression::ContainsThreadLocalStorage(
435436

436437
if (op == DW_OP_form_tls_address || op == DW_OP_GNU_push_tls_address)
437438
return true;
438-
const offset_t op_arg_size =
439+
const lldb::offset_t op_arg_size =
439440
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
440441
if (op_arg_size == LLDB_INVALID_OFFSET)
441442
return false;
@@ -515,7 +516,7 @@ bool DWARFExpression::LinkThreadLocalStorage(
515516
}
516517

517518
if (!decoded_data) {
518-
const offset_t op_arg_size =
519+
const lldb::offset_t op_arg_size =
519520
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
520521
if (op_arg_size == LLDB_INVALID_OFFSET)
521522
return false;

lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ class ReturnValueExtractor {
641641

642642
DataExtractor de(&raw_data, sizeof(raw_data), m_byte_order, m_addr_size);
643643

644-
offset_t offset = 0;
644+
lldb::offset_t offset = 0;
645645
std::optional<uint64_t> byte_size = type.GetByteSize(m_process_sp.get());
646646
if (!byte_size)
647647
return {};

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints(Process *process) {
256256
if (process->ReadMemoryFromInferior (kernel_addresses_64[i], uval, 8, read_err) == 8)
257257
{
258258
DataExtractor data (&uval, 8, process->GetByteOrder(), process->GetAddressByteSize());
259-
offset_t offset = 0;
259+
lldb::offset_t offset = 0;
260260
uint64_t addr = data.GetU64 (&offset);
261261
if (CheckForKernelImageAtAddress(addr, process).IsValid()) {
262262
return addr;
@@ -270,7 +270,7 @@ DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints(Process *process) {
270270
if (process->ReadMemoryFromInferior (kernel_addresses_32[i], uval, 4, read_err) == 4)
271271
{
272272
DataExtractor data (&uval, 4, process->GetByteOrder(), process->GetAddressByteSize());
273-
offset_t offset = 0;
273+
lldb::offset_t offset = 0;
274274
uint32_t addr = data.GetU32 (&offset);
275275
if (CheckForKernelImageAtAddress(addr, process).IsValid()) {
276276
return addr;

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp,
11511151
// TLS data for the pthread_key on a specific thread yet. If we have we
11521152
// can re-use it since its location will not change unless the process
11531153
// execs.
1154-
const tid_t tid = thread_sp->GetID();
1154+
const lldb::tid_t tid = thread_sp->GetID();
11551155
auto tid_pos = m_tid_to_tls_map.find(tid);
11561156
if (tid_pos != m_tid_to_tls_map.end()) {
11571157
auto tls_pos = tid_pos->second.find(key);

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
261261

262262
StructuredData::ObjectSP thread_id_obj =
263263
info->GetObjectForDotSeparatedPath("tid");
264-
tid_t tid = thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
264+
lldb::tid_t tid =
265+
thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
265266

266267
// We gather symbolication addresses above, so no need for HistoryThread to
267268
// try to infer the call addresses.

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -770,15 +770,15 @@ std::string InstrumentationRuntimeTSan::GetLocationDescription(
770770
Sprintf("Location is a %ld-byte heap object at 0x%llx", size, addr);
771771
}
772772
} else if (type == "stack") {
773-
tid_t tid = loc->GetAsDictionary()
774-
->GetValueForKey("thread_id")
775-
->GetUnsignedIntegerValue();
773+
lldb::tid_t tid = loc->GetAsDictionary()
774+
->GetValueForKey("thread_id")
775+
->GetUnsignedIntegerValue();
776776

777777
result = Sprintf("Location is stack of thread %d", tid);
778778
} else if (type == "tls") {
779-
tid_t tid = loc->GetAsDictionary()
780-
->GetValueForKey("thread_id")
781-
->GetUnsignedIntegerValue();
779+
lldb::tid_t tid = loc->GetAsDictionary()
780+
->GetValueForKey("thread_id")
781+
->GetUnsignedIntegerValue();
782782

783783
result = Sprintf("Location is TLS of thread %d", tid);
784784
} else if (type == "fd") {
@@ -948,7 +948,7 @@ static std::string GenerateThreadName(const std::string &path,
948948
if (path == "mops") {
949949
size_t size =
950950
o->GetObjectForDotSeparatedPath("size")->GetUnsignedIntegerValue();
951-
tid_t thread_id =
951+
lldb::tid_t thread_id =
952952
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
953953
bool is_write =
954954
o->GetObjectForDotSeparatedPath("is_write")->GetBooleanValue();
@@ -979,15 +979,15 @@ static std::string GenerateThreadName(const std::string &path,
979979
}
980980

981981
if (path == "threads") {
982-
tid_t thread_id =
982+
lldb::tid_t thread_id =
983983
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
984984
result = Sprintf("Thread %zu created", thread_id);
985985
}
986986

987987
if (path == "locs") {
988988
std::string type = std::string(
989989
o->GetAsDictionary()->GetValueForKey("type")->GetStringValue());
990-
tid_t thread_id =
990+
lldb::tid_t thread_id =
991991
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
992992
int fd = o->GetObjectForDotSeparatedPath("file_descriptor")
993993
->GetSignedIntegerValue();
@@ -1007,7 +1007,7 @@ static std::string GenerateThreadName(const std::string &path,
10071007
}
10081008

10091009
if (path == "stacks") {
1010-
tid_t thread_id =
1010+
lldb::tid_t thread_id =
10111011
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
10121012
result = Sprintf("Thread %" PRIu64, thread_id);
10131013
}
@@ -1034,7 +1034,7 @@ static void AddThreadsForPath(const std::string &path,
10341034

10351035
StructuredData::ObjectSP thread_id_obj =
10361036
o->GetObjectForDotSeparatedPath("thread_os_id");
1037-
tid_t tid =
1037+
lldb::tid_t tid =
10381038
thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
10391039

10401040
ThreadSP new_thread_sp =

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ InstrumentationRuntimeUBSan::GetBacktracesFromExtendedStopInfo(
321321

322322
StructuredData::ObjectSP thread_id_obj =
323323
info->GetObjectForDotSeparatedPath("tid");
324-
tid_t tid = thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
324+
lldb::tid_t tid =
325+
thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
325326

326327
// We gather symbolication addresses above, so no need for HistoryThread to
327328
// try to infer the call addresses.

lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp,
107107
return;
108108

109109
int count = count_sp->GetValueAsUnsigned(0);
110-
tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1;
110+
lldb::tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1;
111111

112112
if (count <= 0)
113113
return;

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5673,7 +5673,8 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
56735673
return false;
56745674
}
56755675

5676-
bool ObjectFileMachO::GetCorefileThreadExtraInfos(std::vector<tid_t> &tids) {
5676+
bool ObjectFileMachO::GetCorefileThreadExtraInfos(
5677+
std::vector<lldb::tid_t> &tids) {
56775678
tids.clear();
56785679
ModuleSP module_sp(GetModule());
56795680
if (module_sp) {
@@ -5724,8 +5725,8 @@ bool ObjectFileMachO::GetCorefileThreadExtraInfos(std::vector<tid_t> &tids) {
57245725
return false;
57255726
}
57265727
StructuredData::Dictionary *thread = *maybe_thread;
5727-
tid_t tid = LLDB_INVALID_THREAD_ID;
5728-
if (thread->GetValueForKeyAsInteger<tid_t>("thread_id", tid))
5728+
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
5729+
if (thread->GetValueForKeyAsInteger<lldb::tid_t>("thread_id", tid))
57295730
if (tid == 0)
57305731
tid = LLDB_INVALID_THREAD_ID;
57315732
tids.push_back(tid);

lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ ThreadSP OperatingSystemPython::CreateThreadFromThreadInfo(
227227
ThreadList &old_thread_list, std::vector<bool> &core_used_map,
228228
bool *did_create_ptr) {
229229
ThreadSP thread_sp;
230-
tid_t tid = LLDB_INVALID_THREAD_ID;
230+
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
231231
if (!thread_dict.GetValueForKeyAsInteger("tid", tid))
232232
return ThreadSP();
233233

lldb/source/Plugins/Process/Utility/ThreadMemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using namespace lldb;
2121
using namespace lldb_private;
2222

23-
ThreadMemory::ThreadMemory(Process &process, tid_t tid,
23+
ThreadMemory::ThreadMemory(Process &process, lldb::tid_t tid,
2424
const ValueObjectSP &thread_info_valobj_sp)
2525
: Thread(process, tid), m_backing_thread_sp(),
2626
m_thread_info_valobj_sp(thread_info_valobj_sp), m_name(), m_queue(),

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ bool ProcessGDBRemote::DoUpdateThreadList(ThreadList &old_thread_list,
15131513
ThreadList old_thread_list_copy(old_thread_list);
15141514
if (num_thread_ids > 0) {
15151515
for (size_t i = 0; i < num_thread_ids; ++i) {
1516-
tid_t tid = m_thread_ids[i];
1516+
lldb::tid_t tid = m_thread_ids[i];
15171517
ThreadSP thread_sp(
15181518
old_thread_list_copy.RemoveThreadByProtocolID(tid, false));
15191519
if (!thread_sp) {

lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,19 +593,19 @@ bool ProcessMachCore::DoUpdateThreadList(ThreadList &old_thread_list,
593593
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
594594

595595
if (core_objfile) {
596-
std::set<tid_t> used_tids;
596+
std::set<lldb::tid_t> used_tids;
597597
const uint32_t num_threads = core_objfile->GetNumThreadContexts();
598-
std::vector<tid_t> tids;
598+
std::vector<lldb::tid_t> tids;
599599
if (core_objfile->GetCorefileThreadExtraInfos(tids)) {
600600
assert(tids.size() == num_threads);
601601

602602
// Find highest tid value.
603-
tid_t highest_tid = 0;
603+
lldb::tid_t highest_tid = 0;
604604
for (uint32_t i = 0; i < num_threads; i++) {
605605
if (tids[i] != LLDB_INVALID_THREAD_ID && tids[i] > highest_tid)
606606
highest_tid = tids[i];
607607
}
608-
tid_t current_unused_tid = highest_tid + 1;
608+
lldb::tid_t current_unused_tid = highest_tid + 1;
609609
for (uint32_t i = 0; i < num_threads; i++) {
610610
if (tids[i] == LLDB_INVALID_THREAD_ID) {
611611
tids[i] = current_unused_tid++;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ uint32_t DWARFUnit::GetHeaderByteSize() const {
10231023

10241024
std::optional<uint64_t>
10251025
DWARFUnit::GetStringOffsetSectionItem(uint32_t index) const {
1026-
offset_t offset = GetStrOffsetsBase() + index * 4;
1026+
lldb::offset_t offset = GetStrOffsetsBase() + index * 4;
10271027
return m_dwarf.GetDWARFContext().getOrLoadStrOffsetsData().GetU32(&offset);
10281028
}
10291029

lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ lldb::addr_t AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction(
216216

217217
AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo
218218
AppleGetThreadItemInfoHandler::GetThreadItemInfo(Thread &thread,
219-
tid_t thread_id,
219+
lldb::tid_t thread_id,
220220
addr_t page_to_free,
221221
uint64_t page_to_free_size,
222222
Status &error) {

lldb/source/Symbol/DWARFCallFrameInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using namespace lldb_private::dwarf;
3333
// Used for calls when the value type is specified by a DWARF EH Frame pointer
3434
// encoding.
3535
static uint64_t
36-
GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr,
36+
GetGNUEHPointer(const DataExtractor &DE, lldb::offset_t *offset_ptr,
3737
uint32_t eh_ptr_enc, addr_t pc_rel_addr, addr_t text_addr,
3838
addr_t data_addr) //, BSDRelocs *data_relocs) const
3939
{
@@ -588,7 +588,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
588588
if (cie->augmentation[0] == 'z') {
589589
uint32_t aug_data_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
590590
if (aug_data_len != 0 && cie->lsda_addr_encoding != DW_EH_PE_omit) {
591-
offset_t saved_offset = offset;
591+
lldb::offset_t saved_offset = offset;
592592
lsda_data_file_address =
593593
GetGNUEHPointer(m_cfi_data, &offset, cie->lsda_addr_encoding,
594594
pc_rel_addr, text_addr, data_addr);

0 commit comments

Comments
 (0)