Skip to content

Commit c68920b

Browse files
DhruvSrivastavaXadrian-prantl
authored andcommitted
[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 (cherry picked from commit b804516)
1 parent b169f05 commit c68920b

File tree

19 files changed

+51
-47
lines changed

19 files changed

+51
-47
lines changed

lldb/source/API/SBBreakpoint.cpp

+3-3
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

+3-3
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

+2-2
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

+8-7
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
134134

135135
/// Return the length in bytes of the set of operands for \p op. No guarantees
136136
/// are made on the state of \p data after this call.
137-
static offset_t GetOpcodeDataSize(const DataExtractor &data,
138-
const lldb::offset_t data_offset,
139-
const uint8_t op, const DWARFUnit *dwarf_cu) {
137+
static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
138+
const lldb::offset_t data_offset,
139+
const uint8_t op,
140+
const DWARFUnit *dwarf_cu) {
140141
lldb::offset_t offset = data_offset;
141142
switch (op) {
142143
case DW_OP_addr:
@@ -362,7 +363,7 @@ lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu,
362363
error = true;
363364
break;
364365
}
365-
const offset_t op_arg_size =
366+
const lldb::offset_t op_arg_size =
366367
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
367368
if (op_arg_size == LLDB_INVALID_OFFSET) {
368369
error = true;
@@ -422,7 +423,7 @@ bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu,
422423
m_data.SetData(encoder.GetDataBuffer());
423424
return true;
424425
}
425-
const offset_t op_arg_size =
426+
const lldb::offset_t op_arg_size =
426427
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
427428
if (op_arg_size == LLDB_INVALID_OFFSET)
428429
break;
@@ -439,7 +440,7 @@ bool DWARFExpression::ContainsThreadLocalStorage(
439440

440441
if (op == DW_OP_form_tls_address || op == DW_OP_GNU_push_tls_address)
441442
return true;
442-
const offset_t op_arg_size =
443+
const lldb::offset_t op_arg_size =
443444
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
444445
if (op_arg_size == LLDB_INVALID_OFFSET)
445446
return false;
@@ -519,7 +520,7 @@ bool DWARFExpression::LinkThreadLocalStorage(
519520
}
520521

521522
if (!decoded_data) {
522-
const offset_t op_arg_size =
523+
const lldb::offset_t op_arg_size =
523524
GetOpcodeDataSize(m_data, offset, op, dwarf_cu);
524525
if (op_arg_size == LLDB_INVALID_OFFSET)
525526
return false;

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

+1-1
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

+2-2
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

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

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
365365

366366
StructuredData::ObjectSP thread_id_obj =
367367
info->GetObjectForDotSeparatedPath("tid");
368-
tid_t tid = thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
368+
lldb::tid_t tid =
369+
thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
369370

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

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -794,15 +794,15 @@ std::string InstrumentationRuntimeTSan::GetLocationDescription(
794794
Sprintf("Location is a %ld-byte heap object at 0x%llx", size, addr);
795795
}
796796
} else if (type == "stack") {
797-
tid_t tid = loc->GetAsDictionary()
798-
->GetValueForKey("thread_id")
799-
->GetUnsignedIntegerValue();
797+
lldb::tid_t tid = loc->GetAsDictionary()
798+
->GetValueForKey("thread_id")
799+
->GetUnsignedIntegerValue();
800800

801801
result = Sprintf("Location is stack of thread %d", tid);
802802
} else if (type == "tls") {
803-
tid_t tid = loc->GetAsDictionary()
804-
->GetValueForKey("thread_id")
805-
->GetUnsignedIntegerValue();
803+
lldb::tid_t tid = loc->GetAsDictionary()
804+
->GetValueForKey("thread_id")
805+
->GetUnsignedIntegerValue();
806806

807807
result = Sprintf("Location is TLS of thread %d", tid);
808808
} else if (type == "fd") {
@@ -976,7 +976,7 @@ static std::string GenerateThreadName(const std::string &path,
976976
if (path == "mops") {
977977
size_t size =
978978
o->GetObjectForDotSeparatedPath("size")->GetUnsignedIntegerValue();
979-
tid_t thread_id =
979+
lldb::tid_t thread_id =
980980
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
981981
bool is_write =
982982
o->GetObjectForDotSeparatedPath("is_write")->GetBooleanValue();
@@ -1007,15 +1007,15 @@ static std::string GenerateThreadName(const std::string &path,
10071007
}
10081008

10091009
if (path == "threads") {
1010-
tid_t thread_id =
1010+
lldb::tid_t thread_id =
10111011
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
10121012
result = Sprintf("Thread %zu created", thread_id);
10131013
}
10141014

10151015
if (path == "locs") {
10161016
std::string type = std::string(
10171017
o->GetAsDictionary()->GetValueForKey("type")->GetStringValue());
1018-
tid_t thread_id =
1018+
lldb::tid_t thread_id =
10191019
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
10201020
int fd = o->GetObjectForDotSeparatedPath("file_descriptor")
10211021
->GetSignedIntegerValue();
@@ -1035,7 +1035,7 @@ static std::string GenerateThreadName(const std::string &path,
10351035
}
10361036

10371037
if (path == "stacks") {
1038-
tid_t thread_id =
1038+
lldb::tid_t thread_id =
10391039
o->GetObjectForDotSeparatedPath("thread_id")->GetUnsignedIntegerValue();
10401040
result = Sprintf("Thread %" PRIu64, thread_id);
10411041
}
@@ -1062,7 +1062,7 @@ static void AddThreadsForPath(const std::string &path,
10621062

10631063
StructuredData::ObjectSP thread_id_obj =
10641064
o->GetObjectForDotSeparatedPath("thread_os_id");
1065-
tid_t tid =
1065+
lldb::tid_t tid =
10661066
thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
10671067

10681068
ThreadSP new_thread_sp =

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

+2-1
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

+1-1
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

+4-3
Original file line numberDiff line numberDiff line change
@@ -5701,7 +5701,8 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
57015701
return false;
57025702
}
57035703

5704-
bool ObjectFileMachO::GetCorefileThreadExtraInfos(std::vector<tid_t> &tids) {
5704+
bool ObjectFileMachO::GetCorefileThreadExtraInfos(
5705+
std::vector<lldb::tid_t> &tids) {
57055706
tids.clear();
57065707
ModuleSP module_sp(GetModule());
57075708
if (module_sp) {
@@ -5752,8 +5753,8 @@ bool ObjectFileMachO::GetCorefileThreadExtraInfos(std::vector<tid_t> &tids) {
57525753
return false;
57535754
}
57545755
StructuredData::Dictionary *thread = *maybe_thread;
5755-
tid_t tid = LLDB_INVALID_THREAD_ID;
5756-
if (thread->GetValueForKeyAsInteger<tid_t>("thread_id", tid))
5756+
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
5757+
if (thread->GetValueForKeyAsInteger<lldb::tid_t>("thread_id", tid))
57575758
if (tid == 0)
57585759
tid = LLDB_INVALID_THREAD_ID;
57595760
tids.push_back(tid);

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

+1-1
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

+1-1
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

+1-1
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -598,19 +598,19 @@ bool ProcessMachCore::DoUpdateThreadList(ThreadList &old_thread_list,
598598
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
599599

600600
if (core_objfile) {
601-
std::set<tid_t> used_tids;
601+
std::set<lldb::tid_t> used_tids;
602602
const uint32_t num_threads = core_objfile->GetNumThreadContexts();
603-
std::vector<tid_t> tids;
603+
std::vector<lldb::tid_t> tids;
604604
if (core_objfile->GetCorefileThreadExtraInfos(tids)) {
605605
assert(tids.size() == num_threads);
606606

607607
// Find highest tid value.
608-
tid_t highest_tid = 0;
608+
lldb::tid_t highest_tid = 0;
609609
for (uint32_t i = 0; i < num_threads; i++) {
610610
if (tids[i] != LLDB_INVALID_THREAD_ID && tids[i] > highest_tid)
611611
highest_tid = tids[i];
612612
}
613-
tid_t current_unused_tid = highest_tid + 1;
613+
lldb::tid_t current_unused_tid = highest_tid + 1;
614614
for (uint32_t i = 0; i < num_threads; i++) {
615615
if (tids[i] == LLDB_INVALID_THREAD_ID) {
616616
tids[i] = current_unused_tid++;

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

+1-1
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

+1-1
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

+2-2
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)