[Lldb-commits] [lldb] r336147 - [lldbsuite, windows] Don't crash LLDB when we try to retrieve a register on Windows
Stella Stamenova via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 2 14:50:32 PDT 2018
Author: stella.stamenova
Date: Mon Jul 2 14:50:31 2018
New Revision: 336147
URL: http://llvm.org/viewvc/llvm-project?rev=336147&view=rev
Log:
[lldbsuite, windows] Don't crash LLDB when we try to retrieve a register on Windows
Summary:
1) When ReadRegister is called with a null register into on Windows, rather than crashing due to an access violation, simply return false. Not all registers and properties will be read or calculated correctly, but that is consistent with other platforms that also return false in that case
2) Update a couple of tests to reference pr37995 as their reason for failure since it is much more accurate. Support for floating point registers doesn't exist on Windows at all, rather than having issues.
Reviewers: asmith, labath, zturner
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D48844
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py?rev=336147&r1=336146&r2=336147&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py Mon Jul 2 14:50:31 2018
@@ -22,6 +22,7 @@ class TestYMMRegister(TestBase):
@skipIfTargetAndroid()
@skipIf(archs=no_match(['i386', 'x86_64']))
@expectedFailureAll(oslist=["linux"], bugnumber="rdar://30523153")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
def test(self):
self.build(dictionary={"CFLAGS_EXTRAS": "-march=haswell"})
self.setTearDownCleanup()
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py?rev=336147&r1=336146&r2=336147&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py Mon Jul 2 14:50:31 2018
@@ -59,7 +59,7 @@ class RegisterCommandsTestCase(TestBase)
# problem
@skipIfTargetAndroid(archs=["i386"])
@skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))
- @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
def test_fp_register_write(self):
"""Test commands that write to registers, in particular floating-point registers."""
self.build()
@@ -71,7 +71,7 @@ class RegisterCommandsTestCase(TestBase)
@skipIfFreeBSD # llvm.org/pr25057
@skipIf(archs=no_match(['amd64', 'i386', 'x86_64']))
@skipIfOutOfTreeDebugserver
- @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
def test_fp_special_purpose_register_read(self):
"""Test commands that read fpu special purpose registers."""
self.build()
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py?rev=336147&r1=336146&r2=336147&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py Mon Jul 2 14:50:31 2018
@@ -9,25 +9,26 @@ import os
import time
import re
import lldb
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-from lldbsuite.test import decorators
+from lldbsuite.test import lldbutil
+
class TestTrivialABI(TestBase):
mydir = TestBase.compute_mydir(__file__)
-
NO_DEBUG_INFO_TESTCASE = True
- @decorators.skipUnlessSupportedTypeAttribute("trivial_abi")
+ @skipUnlessSupportedTypeAttribute("trivial_abi")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
def test_call_trivial(self):
"""Test that we can print a variable & call a function with a trivial ABI class."""
self.build()
self.main_source_file = lldb.SBFileSpec("main.cpp")
self.expr_test(True)
- @decorators.skipUnlessSupportedTypeAttribute("trivial_abi")
- @decorators.expectedFailureAll(bugnumber="llvm.org/pr36870")
+ @skipUnlessSupportedTypeAttribute("trivial_abi")
+ @expectedFailureAll(bugnumber="llvm.org/pr36870")
def test_call_nontrivial(self):
"""Test that we can print a variable & call a function on the same class w/o the trivial ABI marker."""
self.build()
@@ -43,7 +44,7 @@ class TestTrivialABI(TestBase):
ivar = test_var.GetChildMemberWithName("ivar")
self.assertTrue(test_var.GetError().Success(), "Failed to fetch ivar")
self.assertEqual(ivar_value, ivar.GetValueAsSigned(), "Got the right value for ivar")
-
+
def check_frame(self, thread):
frame = thread.frames[0]
inVal_var = frame.FindVariable("inVal")
@@ -56,7 +57,7 @@ class TestTrivialABI(TestBase):
thread.StepOut()
outVal_ret = thread.GetStopReturnValue()
self.check_value(outVal_ret, 30)
-
+
def expr_test(self, trivial):
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
"Set a breakpoint here", self.main_source_file)
@@ -71,5 +72,3 @@ class TestTrivialABI(TestBase):
self.assertEqual(len(threads), 1, "Hit my breakpoint the second time.")
self.check_frame(threads[0])
-
-
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp?rev=336147&r1=336146&r2=336147&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp Mon Jul 2 14:50:31 2018
@@ -206,6 +206,9 @@ bool RegisterContextWindows_x64::ReadReg
if (!CacheAllRegisterValues())
return false;
+ if (reg_info == nullptr)
+ return false;
+
switch (reg_info->kinds[eRegisterKindLLDB]) {
case lldb_rax_x86_64:
reg_value.SetUInt64(m_context.Rax);
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp?rev=336147&r1=336146&r2=336147&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp Mon Jul 2 14:50:31 2018
@@ -176,6 +176,9 @@ bool RegisterContextWindows_x86::ReadReg
if (!CacheAllRegisterValues())
return false;
+ if (reg_info == nullptr)
+ return false;
+
uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
switch (reg) {
case lldb_eax_i386:
More information about the lldb-commits
mailing list