From 0bcb2902ec21393d71c94e63aa6733cb5311a0cc Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Tue, 17 Jun 2014 15:52:45 +0200 Subject: Revert "Revert "Fix access to FP registers when visiting stack"" This reverts commit 8ebd94ab2e0d9867a7d384f00fa4cab24235216f. Fixes StackVisitor::GetVReg to read register value in a uintptr_t local and cast it into uint32_t pointer argument. Bug: 15433097 Change-Id: I4e13ed5446e823e9ec50fbc378b16be5b17b2294 --- runtime/arch/x86/context_x86.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'runtime/arch/x86/context_x86.cc') diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index 8c98d910c5..37049cfd7b 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -24,11 +24,11 @@ namespace art { namespace x86 { -static const uintptr_t gZero = 0; +static constexpr uintptr_t gZero = 0; void X86Context::Reset() { for (size_t i = 0; i < kNumberOfCpuRegisters; i++) { - gprs_[i] = NULL; + gprs_[i] = nullptr; } gprs_[ESP] = &esp_; // Initialize registers with easy to spot debug values. @@ -57,15 +57,19 @@ void X86Context::SmashCallerSaves() { // This needs to be 0 because we want a null/zero return value. gprs_[EAX] = const_cast(&gZero); gprs_[EDX] = const_cast(&gZero); - gprs_[ECX] = NULL; - gprs_[EBX] = NULL; + gprs_[ECX] = nullptr; + gprs_[EBX] = nullptr; } -void X86Context::SetGPR(uint32_t reg, uintptr_t value) { +bool X86Context::SetGPR(uint32_t reg, uintptr_t value) { CHECK_LT(reg, static_cast(kNumberOfCpuRegisters)); CHECK_NE(gprs_[reg], &gZero); - CHECK(gprs_[reg] != NULL); - *gprs_[reg] = value; + if (gprs_[reg] != nullptr) { + *gprs_[reg] = value; + return true; + } else { + return false; + } } void X86Context::DoLongJump() { @@ -74,7 +78,7 @@ void X86Context::DoLongJump() { // the top for the stack pointer that doesn't get popped in a pop-all. volatile uintptr_t gprs[kNumberOfCpuRegisters + 1]; for (size_t i = 0; i < kNumberOfCpuRegisters; ++i) { - gprs[kNumberOfCpuRegisters - i - 1] = gprs_[i] != NULL ? *gprs_[i] : X86Context::kBadGprBase + i; + gprs[kNumberOfCpuRegisters - i - 1] = gprs_[i] != nullptr ? *gprs_[i] : X86Context::kBadGprBase + i; } // We want to load the stack pointer one slot below so that the ret will pop eip. uintptr_t esp = gprs[kNumberOfCpuRegisters - ESP - 1] - kWordSize; -- cgit v1.2.3-59-g8ed1b