diff options
| author | Abhishek Aggarwal <abhishek.a.aggarwal@intel.com> | 2015-09-07 07:40:16 +0000 |
|---|---|---|
| committer | Abhishek Aggarwal <abhishek.a.aggarwal@intel.com> | 2015-09-07 07:40:16 +0000 |
| commit | 7f658edd61e017a3a0439412b8443a8fab014e8d (patch) | |
| tree | 614c75356e7fad77058f6c443767dfe025bba48c /lldb/test/functionalities | |
| parent | 907abf799db799b5a0bd36e2c767a778e8b26424 (diff) | |
| download | bcm5719-llvm-7f658edd61e017a3a0439412b8443a8fab014e8d.tar.gz bcm5719-llvm-7f658edd61e017a3a0439412b8443a8fab014e8d.zip | |
Bug 24457 - X87 FPU Special Purpose Registers
Summary:
- For 'register read --all' command on x86_64-Linux Platform:
-- Provide correct values of X87 FPU Special Purpose Registers
-- Both 32-bit & 64-bit inferiors give correct values on this
Platform
- Added a Test Vector:
-- To verify the expected behaviour of the command
Signed-off-by: Abhishek Aggarwal <abhishek.a.aggarwal@intel.com>
Reviewers: ashok.thirumurthi, granata.enrico, tfiala, clayborg
Differential Revision: http://reviews.llvm.org/D12592
llvm-svn: 246955
Diffstat (limited to 'lldb/test/functionalities')
| -rwxr-xr-x[-rw-r--r--] | lldb/test/functionalities/register/Makefile | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | lldb/test/functionalities/register/TestRegisters.py | 70 | ||||
| -rwxr-xr-x | lldb/test/functionalities/register/a.cpp | 40 | ||||
| -rwxr-xr-x[-rw-r--r--] | lldb/test/functionalities/register/main.cpp | 4 |
4 files changed, 115 insertions, 1 deletions
diff --git a/lldb/test/functionalities/register/Makefile b/lldb/test/functionalities/register/Makefile index 8a7102e347a..7144b25c58c 100644..100755 --- a/lldb/test/functionalities/register/Makefile +++ b/lldb/test/functionalities/register/Makefile @@ -1,5 +1,5 @@ LEVEL = ../../make -CXX_SOURCES := main.cpp +CXX_SOURCES := main.cpp a.cpp include $(LEVEL)/Makefile.rules diff --git a/lldb/test/functionalities/register/TestRegisters.py b/lldb/test/functionalities/register/TestRegisters.py index b78a2549edc..8abb5c642e6 100644..100755 --- a/lldb/test/functionalities/register/TestRegisters.py +++ b/lldb/test/functionalities/register/TestRegisters.py @@ -35,6 +35,13 @@ class RegisterCommandsTestCase(TestBase): self.buildDefault() self.fp_register_write() + def test_fp_special_purpose_register_read(self): + """Test commands that read fpu special purpose registers.""" + if not self.getArchitecture() in ['amd64', 'i386', 'x86_64']: + self.skipTest("This test requires x86 or x86_64 as the architecture for the inferior") + self.buildDefault() + self.fp_special_purpose_register_read() + def test_register_expressions(self): """Test expression evaluation with commands related to registers.""" if not self.getArchitecture() in ['amd64', 'i386', 'x86_64']: @@ -152,6 +159,69 @@ class RegisterCommandsTestCase(TestBase): self.expect("register read " + register, substrs = [register + ' = ', new_value]) + def fp_special_purpose_register_read(self): + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Find the line number to break inside a.cpp. + self.line = line_number('a.cpp', '// Set break point at this line.') + + # Set breakpoint + lldbutil.run_break_set_by_file_and_line (self, "a.cpp", self.line, num_expected_locations=1, loc_exact=True) + + # Launch the process, and do not stop at the entry point. + self.runCmd ("run", RUN_SUCCEEDED) + + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + thread = process.GetThreadAtIndex(0) + self.assertTrue(thread.IsValid(), "current thread is valid") + + currentFrame = thread.GetFrameAtIndex(0) + self.assertTrue(currentFrame.IsValid(), "current frame is valid") + + # Extract the value of fstat and ftag flag at the point just before + # we start pushing floating point values on st% register stack + value = currentFrame.FindValue("fstat", lldb.eValueTypeRegister) + error = lldb.SBError() + reg_value_fstat_initial = value.GetValueAsUnsigned(error, 0) + + self.assertTrue(error.Success(), "reading a value for fstat") + value = currentFrame.FindValue("ftag", lldb.eValueTypeRegister) + error = lldb.SBError() + reg_value_ftag_initial = value.GetValueAsUnsigned(error, 0) + + self.assertTrue(error.Success(), "reading a value for ftag") + fstat_top_pointer_initial = (reg_value_fstat_initial & 0x3800)>>11 + + # Execute 'si' aka 'thread step-inst' instruction 5 times and with + # every execution verify the value of fstat and ftag registers + for x in range(0,5): + # step into the next instruction to push a value on 'st' register stack + self.runCmd ("si", RUN_SUCCEEDED) + + # Verify fstat and save it to be used for verification in next execution of 'si' command + if not (reg_value_fstat_initial & 0x3800): + self.expect("register read fstat", + substrs = ['fstat' + ' = ', str("0x%0.4x" %((reg_value_fstat_initial & ~(0x3800))| 0x3800))]) + reg_value_fstat_initial = ((reg_value_fstat_initial & ~(0x3800))| 0x3800) + fstat_top_pointer_initial = 7 + else : + self.expect("register read fstat", + substrs = ['fstat' + ' = ', str("0x%0.4x" % (reg_value_fstat_initial - 0x0800))]) + reg_value_fstat_initial = (reg_value_fstat_initial - 0x0800) + fstat_top_pointer_initial -= 1 + + # Verify ftag and save it to be used for verification in next execution of 'si' command + self.expect("register read ftag", + substrs = ['ftag' + ' = ', str("0x%0.4x" % (reg_value_ftag_initial | (1<< fstat_top_pointer_initial)))]) + reg_value_ftag_initial = reg_value_ftag_initial | (1<< fstat_top_pointer_initial) + def fp_register_write(self): exe = os.path.join(os.getcwd(), "a.out") diff --git a/lldb/test/functionalities/register/a.cpp b/lldb/test/functionalities/register/a.cpp new file mode 100755 index 00000000000..7be6875fc05 --- /dev/null +++ b/lldb/test/functionalities/register/a.cpp @@ -0,0 +1,40 @@ +//===-- a.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include <stdio.h> + +long double +return_long_double (long double value) +{ + float a=2, b=4,c=8, d=16, e=32, f=64, k=128, l=256, add=0; +__asm__ ( "fld %1 ;" + "fld %2 ;" + "fld %3 ;" + "fld %4 ;" + "fld %5 ;" + "fld %6 ;" + "fld %7 ;" + "fadd ;" : "=g" (add) : "g" (a), "g" (b), "g" (c), "g" (d), "g" (e), "g" (f), "g" (k), "g" (l) ); // Set break point at this line. + return value; +} + +long double +outer_return_long_double (long double value) +{ + long double val = return_long_double(value); + val *= 2 ; + return val; +} + +long double +outermost_return_long_double (long double value) +{ + long double val = outer_return_long_double(value); + val *= 2 ; + return val; +} diff --git a/lldb/test/functionalities/register/main.cpp b/lldb/test/functionalities/register/main.cpp index d0e5dc159b6..876dd0833e5 100644..100755 --- a/lldb/test/functionalities/register/main.cpp +++ b/lldb/test/functionalities/register/main.cpp @@ -15,6 +15,8 @@ #include <chrono> #include <thread> +long double outermost_return_long_double (long double my_long_double); + int main (int argc, char const *argv[]) { #if defined(__linux__) @@ -32,6 +34,7 @@ int main (int argc, char const *argv[]) char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0}; double my_double = 1234.5678; + long double my_long_double = 1234.5678; // For simplicity assume that any cmdline argument means wait for attach. if (argc > 1) @@ -43,5 +46,6 @@ int main (int argc, char const *argv[]) printf("my_string=%s\n", my_string); printf("my_double=%g\n", my_double); + outermost_return_long_double (my_long_double); return 0; } |

