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.

0 commit comments

Comments
 (0)