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

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
@@ -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

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
@@ -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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 11 additions & 11 deletions
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

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)