diff options
| -rw-r--r-- | lldb/source/Core/RegisterValue.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 4 | ||||
| -rw-r--r-- | lldb/test/functionalities/register/Makefile | 5 | ||||
| -rw-r--r-- | lldb/test/functionalities/register/TestRegisters.py | 55 | ||||
| -rw-r--r-- | lldb/test/functionalities/register/main.cpp | 18 |
5 files changed, 85 insertions, 0 deletions
diff --git a/lldb/source/Core/RegisterValue.cpp b/lldb/source/Core/RegisterValue.cpp index c474f9323ac..5e3844125b1 100644 --- a/lldb/source/Core/RegisterValue.cpp +++ b/lldb/source/Core/RegisterValue.cpp @@ -202,6 +202,9 @@ RegisterValue::SetFromMemoryData (const RegisterInfo *reg_info, else if (value_type == eTypeBytes) { m_data.buffer.byte_order = src_byte_order; + // Make sure to set the buffer length of the destination buffer to avoid + // problems due to uninitalized variables. + m_data.buffer.length = src_len; } const uint32_t bytes_copied = src_data.CopyByteOrderedData (0, // src offset diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index f73ceda6ae4..4bf55357b39 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -697,6 +697,10 @@ ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast, Encoding break; case eEncodingVector: + // Sanity check that bit_size is a multiple of 8's. + if (bit_size && !(bit_size & 0x7u)) + return ast->getExtVectorType (ast->UnsignedCharTy, bit_size/8).getAsOpaquePtr(); + break; default: break; } diff --git a/lldb/test/functionalities/register/Makefile b/lldb/test/functionalities/register/Makefile new file mode 100644 index 00000000000..8a7102e347a --- /dev/null +++ b/lldb/test/functionalities/register/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/lldb/test/functionalities/register/TestRegisters.py b/lldb/test/functionalities/register/TestRegisters.py new file mode 100644 index 00000000000..80e82d6c355 --- /dev/null +++ b/lldb/test/functionalities/register/TestRegisters.py @@ -0,0 +1,55 @@ +""" +Test the 'memory read' command. +""" + +import os, time +import re +import unittest2 +import lldb +from lldbtest import * + +class MemoryReadTestCase(TestBase): + + mydir = os.path.join("functionalities", "memory", "read") + + @unittest2.skipUnless(os.uname()[4] in ['x86_64'], "requires x86_64") + def test_register_commands(self): + """Test commands related to registers, in particular xmm registers.""" + self.buildDefault() + self.register_commands() + + def register_commands(self): + """Test commands related to registers, in particular xmm registers.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break in main(). + self.expect("breakpoint set -n main", + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = 'main'") + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', 'stop reason = breakpoint']) + + # Test some register-related commands. + + self.runCmd("register read -a") + self.runCmd("register read xmm0") + + # rdar://problem/10611315 + # expression command doesn't handle xmm or stmm registers... + self.expect("expr $xmm0", + substrs = ['vector_type']) + + self.expect("expr (unsigned int)$xmm0[0]", + substrs = ['unsigned int']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/functionalities/register/main.cpp b/lldb/test/functionalities/register/main.cpp new file mode 100644 index 00000000000..92095866663 --- /dev/null +++ b/lldb/test/functionalities/register/main.cpp @@ -0,0 +1,18 @@ +//===-- main.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> + +int main (int argc, char const *argv[]) +{ + char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0}; + double my_double = 1234.5678; + printf("my_string=%s\n", my_string); + printf("my_double=%g\n", my_double); + return 0; +} |

