@@ -137,9 +137,8 @@ void RegisterContextUnwind::InitializeZerothFrame() {
137
137
// (which would be a no-op in frame 0 where we get it from the register set,
138
138
// but still a good idea to make the call here for other ABIs that may
139
139
// exist.)
140
- ABI *abi = process->GetABI ().get ();
141
- if (abi)
142
- current_pc = abi->FixCodeAddress (current_pc);
140
+ if (ABISP abi_sp = process->GetABI ())
141
+ current_pc = abi_sp->FixCodeAddress (current_pc);
143
142
144
143
UnwindPlanSP lang_runtime_plan_sp = LanguageRuntime::GetRuntimeUnwindPlan (
145
144
m_thread, this , m_behaves_like_zeroth_frame);
@@ -355,17 +354,23 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
355
354
356
355
// Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs
357
356
// this will strip bit zero in case we read a PC from memory or from the LR.
358
- ABI *abi = process->GetABI (). get ();
359
- if (abi )
360
- pc = abi ->FixCodeAddress (pc);
357
+ ABISP abi_sp = process->GetABI ();
358
+ if (abi_sp )
359
+ pc = abi_sp ->FixCodeAddress (pc);
361
360
362
361
if (log) {
363
362
UnwindLogMsg (" pc = 0x%" PRIx64, pc);
364
363
addr_t reg_val;
365
- if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
364
+ if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
365
+ if (abi_sp)
366
+ reg_val = abi_sp->FixDataAddress (reg_val);
366
367
UnwindLogMsg (" fp = 0x%" PRIx64, reg_val);
367
- if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
368
+ }
369
+ if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
370
+ if (abi_sp)
371
+ reg_val = abi_sp->FixDataAddress (reg_val);
368
372
UnwindLogMsg (" sp = 0x%" PRIx64, reg_val);
373
+ }
369
374
}
370
375
371
376
// A pc of 0x0 means it's the end of the stack crawl unless we're above a trap
@@ -424,11 +429,11 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
424
429
}
425
430
}
426
431
427
- if (abi ) {
432
+ if (abi_sp ) {
428
433
m_fast_unwind_plan_sp.reset ();
429
434
m_full_unwind_plan_sp =
430
435
std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
431
- abi ->CreateDefaultUnwindPlan (*m_full_unwind_plan_sp);
436
+ abi_sp ->CreateDefaultUnwindPlan (*m_full_unwind_plan_sp);
432
437
if (m_frame_type != eSkipFrame) // don't override eSkipFrame
433
438
{
434
439
m_frame_type = eNormalFrame;
@@ -1751,8 +1756,8 @@ bool RegisterContextUnwind::TryFallbackUnwindPlan() {
1751
1756
if (ReadRegisterValueFromRegisterLocation (regloc, reg_info, reg_value)) {
1752
1757
old_caller_pc_value = reg_value.GetAsUInt64 ();
1753
1758
if (ProcessSP process_sp = m_thread.GetProcess ()) {
1754
- if (ABISP abi = process_sp->GetABI ())
1755
- old_caller_pc_value = abi ->FixCodeAddress (old_caller_pc_value);
1759
+ if (ABISP abi_sp = process_sp->GetABI ())
1760
+ old_caller_pc_value = abi_sp ->FixCodeAddress (old_caller_pc_value);
1756
1761
}
1757
1762
}
1758
1763
}
@@ -1811,8 +1816,8 @@ bool RegisterContextUnwind::TryFallbackUnwindPlan() {
1811
1816
reg_value)) {
1812
1817
new_caller_pc_value = reg_value.GetAsUInt64 ();
1813
1818
if (ProcessSP process_sp = m_thread.GetProcess ()) {
1814
- if (ABISP abi = process_sp->GetABI ())
1815
- new_caller_pc_value = abi ->FixCodeAddress (new_caller_pc_value);
1819
+ if (ABISP abi_sp = process_sp->GetABI ())
1820
+ new_caller_pc_value = abi_sp ->FixCodeAddress (new_caller_pc_value);
1816
1821
}
1817
1822
}
1818
1823
}
@@ -1953,6 +1958,7 @@ bool RegisterContextUnwind::ReadFrameAddress(
1953
1958
1954
1959
address = LLDB_INVALID_ADDRESS;
1955
1960
addr_t cfa_reg_contents;
1961
+ ABISP abi_sp = m_thread.GetProcess ()->GetABI ();
1956
1962
1957
1963
switch (fa.GetValueType ()) {
1958
1964
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
@@ -1963,11 +1969,13 @@ bool RegisterContextUnwind::ReadFrameAddress(
1963
1969
GetRegisterInfoAtIndex (cfa_reg.GetAsKind (eRegisterKindLLDB));
1964
1970
RegisterValue reg_value;
1965
1971
if (reg_info) {
1972
+ if (abi_sp)
1973
+ cfa_reg_contents = abi_sp->FixDataAddress (cfa_reg_contents);
1966
1974
Status error = ReadRegisterValueFromMemory (
1967
1975
reg_info, cfa_reg_contents, reg_info->byte_size , reg_value);
1968
1976
if (error.Success ()) {
1969
1977
address = reg_value.GetAsUInt64 ();
1970
- if (ABISP abi_sp = m_thread. GetProcess ()-> GetABI () )
1978
+ if (abi_sp)
1971
1979
address = abi_sp->FixCodeAddress (address);
1972
1980
UnwindLogMsg (
1973
1981
" CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
@@ -1989,6 +1997,8 @@ bool RegisterContextUnwind::ReadFrameAddress(
1989
1997
RegisterNumber cfa_reg (m_thread, row_register_kind,
1990
1998
fa.GetRegisterNumber ());
1991
1999
if (ReadGPRValue (cfa_reg, cfa_reg_contents)) {
2000
+ if (abi_sp)
2001
+ cfa_reg_contents = abi_sp->FixDataAddress (cfa_reg_contents);
1992
2002
if (cfa_reg_contents == LLDB_INVALID_ADDRESS || cfa_reg_contents == 0 ||
1993
2003
cfa_reg_contents == 1 ) {
1994
2004
UnwindLogMsg (
@@ -2076,6 +2086,8 @@ lldb::addr_t RegisterContextUnwind::GetReturnAddressHint(int32_t plan_offset) {
2076
2086
return LLDB_INVALID_ADDRESS;
2077
2087
if (!m_sym_ctx.module_sp || !m_sym_ctx.symbol )
2078
2088
return LLDB_INVALID_ADDRESS;
2089
+ if (ABISP abi_sp = m_thread.GetProcess ()->GetABI ())
2090
+ hint = abi_sp->FixCodeAddress (hint);
2079
2091
2080
2092
hint += plan_offset;
2081
2093
@@ -2133,28 +2145,38 @@ bool RegisterContextUnwind::ReadGPRValue(lldb::RegisterKind register_kind,
2133
2145
return false ;
2134
2146
}
2135
2147
2148
+ uint32_t generic_regnum = LLDB_INVALID_REGNUM;
2149
+ if (register_kind == eRegisterKindGeneric)
2150
+ generic_regnum = regnum;
2151
+ else
2152
+ m_thread.GetRegisterContext ()->ConvertBetweenRegisterKinds (
2153
+ register_kind, regnum, eRegisterKindGeneric, generic_regnum);
2154
+ ABISP abi_sp = m_thread.GetProcess ()->GetABI ();
2155
+
2136
2156
RegisterValue reg_value;
2137
2157
// if this is frame 0 (currently executing frame), get the requested reg
2138
2158
// contents from the actual thread registers
2139
2159
if (IsFrameZero ()) {
2140
2160
if (m_thread.GetRegisterContext ()->ReadRegister (reg_info, reg_value)) {
2141
2161
value = reg_value.GetAsUInt64 ();
2162
+ if (abi_sp && generic_regnum != LLDB_INVALID_REGNUM) {
2163
+ if (generic_regnum == LLDB_REGNUM_GENERIC_PC ||
2164
+ generic_regnum == LLDB_REGNUM_GENERIC_RA)
2165
+ value = abi_sp->FixCodeAddress (value);
2166
+ if (generic_regnum == LLDB_REGNUM_GENERIC_SP ||
2167
+ generic_regnum == LLDB_REGNUM_GENERIC_FP)
2168
+ value = abi_sp->FixDataAddress (value);
2169
+ }
2142
2170
return true ;
2143
2171
}
2144
2172
return false ;
2145
2173
}
2146
2174
2147
2175
bool pc_register = false ;
2148
- uint32_t generic_regnum;
2149
- if (register_kind == eRegisterKindGeneric &&
2150
- (regnum == LLDB_REGNUM_GENERIC_PC || regnum == LLDB_REGNUM_GENERIC_RA)) {
2176
+ if ( generic_regnum != LLDB_INVALID_REGNUM &&
2177
+ (generic_regnum == LLDB_REGNUM_GENERIC_PC ||
2178
+ generic_regnum == LLDB_REGNUM_GENERIC_RA))
2151
2179
pc_register = true ;
2152
- } else if (m_thread.GetRegisterContext ()->ConvertBetweenRegisterKinds (
2153
- register_kind, regnum, eRegisterKindGeneric, generic_regnum) &&
2154
- (generic_regnum == LLDB_REGNUM_GENERIC_PC ||
2155
- generic_regnum == LLDB_REGNUM_GENERIC_RA)) {
2156
- pc_register = true ;
2157
- }
2158
2180
2159
2181
lldb_private::UnwindLLDB::RegisterLocation regloc;
2160
2182
if (!m_parent_unwind.SearchForSavedLocationForRegister (
@@ -2164,9 +2186,8 @@ bool RegisterContextUnwind::ReadGPRValue(lldb::RegisterKind register_kind,
2164
2186
if (ReadRegisterValueFromRegisterLocation (regloc, reg_info, reg_value)) {
2165
2187
value = reg_value.GetAsUInt64 ();
2166
2188
if (pc_register) {
2167
- if (ProcessSP process_sp = m_thread.GetProcess ()) {
2168
- if (ABISP abi = process_sp->GetABI ())
2169
- value = abi->FixCodeAddress (value);
2189
+ if (ABISP abi_sp = m_thread.GetProcess ()->GetABI ()) {
2190
+ value = abi_sp->FixCodeAddress (value);
2170
2191
}
2171
2192
}
2172
2193
return true ;
@@ -2215,10 +2236,8 @@ bool RegisterContextUnwind::ReadRegister(const RegisterInfo *reg_info,
2215
2236
if (is_pc_regnum && value.GetType () == RegisterValue::eTypeUInt64) {
2216
2237
addr_t reg_value = value.GetAsUInt64 (LLDB_INVALID_ADDRESS);
2217
2238
if (reg_value != LLDB_INVALID_ADDRESS) {
2218
- if (ProcessSP process_sp = m_thread.GetProcess ()) {
2219
- if (ABISP abi = process_sp->GetABI ())
2220
- value = abi->FixCodeAddress (reg_value);
2221
- }
2239
+ if (ABISP abi_sp = m_thread.GetProcess ()->GetABI ())
2240
+ value = abi_sp->FixCodeAddress (reg_value);
2222
2241
}
2223
2242
}
2224
2243
}
@@ -2300,9 +2319,8 @@ bool RegisterContextUnwind::GetStartPC(addr_t &start_pc) {
2300
2319
ProcessSP process_sp (m_thread.GetProcess ());
2301
2320
if (process_sp)
2302
2321
{
2303
- ABI *abi = process_sp->GetABI ().get ();
2304
- if (abi)
2305
- start_pc = abi->FixCodeAddress (start_pc);
2322
+ if (ABISP abi_sp = process_sp->GetABI ())
2323
+ start_pc = abi_sp->FixCodeAddress (start_pc);
2306
2324
}
2307
2325
}
2308
2326
return read_successfully;
@@ -2330,13 +2348,8 @@ bool RegisterContextUnwind::ReadPC(addr_t &pc) {
2330
2348
// through a NULL pointer -- we want to be able to unwind past that frame
2331
2349
// to help find the bug.
2332
2350
2333
- ProcessSP process_sp (m_thread.GetProcess ());
2334
- if (process_sp)
2335
- {
2336
- ABI *abi = process_sp->GetABI ().get ();
2337
- if (abi)
2338
- pc = abi->FixCodeAddress (pc);
2339
- }
2351
+ if (ABISP abi_sp = m_thread.GetProcess ()->GetABI ())
2352
+ pc = abi_sp->FixCodeAddress (pc);
2340
2353
2341
2354
return !(m_all_registers_available == false &&
2342
2355
above_trap_handler == false && (pc == 0 || pc == 1 ));
0 commit comments