[Lldb-commits] [lldb] r304138 - Added new API to SBStructuredData class
Author: abhishek Date: Mon May 29 03:25:46 2017 New Revision: 304138 URL: http://llvm.org/viewvc/llvm-project?rev=304138&view=rev Log: Added new API to SBStructuredData class Summary: - Added API to access data types -- integer, double, array, string, boolean and dictionary data types -- Earlier user had to parse through the string output to get these values - Added Test cases for API testing - Added new StructuredDataType enum in public include file -- Replaced locally-defined enum in StructuredData.h with this new one -- Modified other internal files using this locally-defined enum Signed-off-by: Abhishek Aggarwal Reviewers: clayborg, lldb-commits Reviewed By: clayborg Subscribers: labath Differential Revision: https://reviews.llvm.org/D33434 Added: lldb/trunk/packages/Python/lldbsuite/test/python_api/sbstructureddata/ lldb/trunk/packages/Python/lldbsuite/test/python_api/sbstructureddata/TestStructuredDataAPI.py Modified: lldb/trunk/include/lldb/API/SBStructuredData.h lldb/trunk/include/lldb/Core/StructuredData.h lldb/trunk/include/lldb/Core/StructuredDataImpl.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/scripts/interface/SBStructuredData.i lldb/trunk/source/API/SBStructuredData.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Core/FormatEntity.cpp lldb/trunk/source/Core/StructuredData.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp Modified: lldb/trunk/include/lldb/API/SBStructuredData.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStructuredData.h?rev=304138&r1=304137&r2=304138&view=diff == --- lldb/trunk/include/lldb/API/SBStructuredData.h (original) +++ lldb/trunk/include/lldb/API/SBStructuredData.h Mon May 29 03:25:46 2017 @@ -37,11 +37,70 @@ public: lldb::SBError GetDescription(lldb::SBStream &stream) const; + //-- + /// Return the type of data in this data structure + //-- + lldb::StructuredDataType GetType() const; + + //-- + /// Return the size (i.e. number of elements) in this data structure + /// if it is an array or dictionary type. For other types, 0 will be + // returned. + //-- + size_t GetSize() const; + + //-- + /// Return the value corresponding to a key if this data structure + /// is a dictionary type. + //-- + lldb::SBStructuredData GetValueForKey(const char *key) const; + + //-- + /// Return the value corresponding to an index if this data structure + /// is array. + //-- + lldb::SBStructuredData GetItemAtIndex(size_t idx) const; + + //-- + /// Return the integer value if this data structure is an integer type. + //-- + uint64_t GetIntegerValue(uint64_t fail_value = 0) const; + + //-- + /// Return the floating point value if this data structure is a floating + /// type. + //-- + double GetFloatValue(double fail_value = 0.0) const; + + //-- + /// Return the boolean value if this data structure is a boolean type. + //-- + bool GetBooleanValue(bool fail_value = false) const; + + //-- + /// Provides the string value if this data structure is a string type. + /// + /// @param[out] dst + /// pointer where the string value will be written. In case it is null, + /// nothing will be written at @dst. + /// + /// @param[in] dst_len + /// max number of characters that can be written at @dst. In case it is + /// zero, nothing will be written at @dst. If this length is not enough + /// to write the complete string value, (dst_len-1) bytes of the string + /// value will be written at @dst followed by a null character. + /// + /// @return + /// Returns the byte size needed to completely write the string value at + /// @dst in all cases. + //-- + size_t GetStringValue(char *dst, size_t dst_len) const; + protected: fri
[Lldb-commits] [lldb] r304147 - Replaced StructuredData::Type with eStructuredDataType
Author: abhishek Date: Mon May 29 06:13:30 2017 New Revision: 304147 URL: http://llvm.org/viewvc/llvm-project?rev=304147&view=rev Log: Replaced StructuredData::Type with eStructuredDataType ...missing from r304138 "Added new API to SBStructuredData class" Modified: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Modified: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp?rev=304147&r1=304146&r2=304147&view=diff == --- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (original) +++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Mon May 29 06:13:30 2017 @@ -11,6 +11,7 @@ #include "GDBRemoteTestUtils.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" +#include "lldb/lldb-enumerations.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" #include "lldb/Core/TraceOptions.h" @@ -554,7 +555,7 @@ TEST_F(GDBRemoteCommunicationClientTest, llvm::StringRef trace_tech_value; ASSERT_TRUE(custom_params); - ASSERT_EQ(custom_params->GetType(), StructuredData::Type::eTypeDictionary); + ASSERT_EQ(custom_params->GetType(), eStructuredDataTypeDictionary); ASSERT_TRUE( custom_params->GetValueForKeyAsInteger("psb", psb_value)); ASSERT_EQ(psb_value, 1); @@ -594,4 +595,4 @@ TEST_F(GDBRemoteCommunicationClientTest, HandlePacket(server, expected_packet, incorrect_custom_params1+ incorrect_custom_params2); ASSERT_FALSE(result4.get().Success()); -} \ No newline at end of file +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r310266 - Fixed build failure for revision r310261
Author: abhishek Date: Mon Aug 7 08:53:30 2017 New Revision: 310266 URL: http://llvm.org/viewvc/llvm-project?rev=310266&view=rev Log: Fixed build failure for revision r310261 -- Build was failing for freebsd Modified: lldb/trunk/tools/intel-features/CMakeLists.txt Modified: lldb/trunk/tools/intel-features/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/intel-features/CMakeLists.txt?rev=310266&r1=310265&r2=310266&view=diff == --- lldb/trunk/tools/intel-features/CMakeLists.txt (original) +++ lldb/trunk/tools/intel-features/CMakeLists.txt Mon Aug 7 08:53:30 2017 @@ -45,6 +45,10 @@ if (NOT LLDB_DISABLE_PYTHON AND LLDB_BUI add_subdirectory(scripts) endif() +if (NOT CLI_WRAPPER_PREPROCESSORS) + return() +endif() + set_source_files_properties(cli-wrapper.cpp PROPERTIES COMPILE_FLAGS ${CLI_WRAPPER_PREPROCESSORS}) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r310270 - Fixed build failure for revision r310261
Author: abhishek Date: Mon Aug 7 10:15:26 2017 New Revision: 310270 URL: http://llvm.org/viewvc/llvm-project?rev=310270&view=rev Log: Fixed build failure for revision r310261 -- Was failing for Linux Modified: lldb/trunk/tools/intel-features/cli-wrapper.cpp Modified: lldb/trunk/tools/intel-features/cli-wrapper.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/intel-features/cli-wrapper.cpp?rev=310270&r1=310269&r2=310270&view=diff == --- lldb/trunk/tools/intel-features/cli-wrapper.cpp (original) +++ lldb/trunk/tools/intel-features/cli-wrapper.cpp Mon Aug 7 10:15:26 2017 @@ -15,8 +15,14 @@ // //===--===// +#ifdef BUILD_INTEL_MPX #include "intel-mpx/cli-wrapper-mpxtable.h" +#endif + +#ifdef BUILD_INTEL_PT #include "intel-pt/cli-wrapper-pt.h" +#endif + #include "lldb/API/SBDebugger.h" namespace lldb { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r310341 - Checking in files accidentally missed in later diffs of revision r310261
Author: abhishek Date: Tue Aug 8 02:25:50 2017 New Revision: 310341 URL: http://llvm.org/viewvc/llvm-project?rev=310341&view=rev Log: Checking in files accidentally missed in later diffs of revision r310261 -- 2 files were missing in this commit which should have been there. These files were submitted initially for review and were reviewed. However, while updating the revision with newer diffs, I accidentally forgot to include them in newer diffs. So commiting now. Added: lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.h Added: lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp?rev=310341&view=auto == --- lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp (added) +++ lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp Tue Aug 8 02:25:50 2017 @@ -0,0 +1,583 @@ +//===-- cli-wrapper-pt.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +// CLI Wrapper of PTDecoder Tool to enable it to be used through LLDB's CLI. The +// wrapper provides a new command called processor-trace with 4 child +// subcommands as follows: +// processor-trace start +// processor-trace stop +// processor-trace show-trace-options +// processor-trace show-instr-log +// +//===--===// + +#include +#include +#include +#include +#include + +#include "PTDecoder.h" +#include "cli-wrapper-pt.h" +#include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" + +static bool GetProcess(lldb::SBDebugger &debugger, + lldb::SBCommandReturnObject &result, + lldb::SBProcess &process) { + if (!debugger.IsValid()) { +result.Printf("error: invalid debugger\n"); +result.SetStatus(lldb::eReturnStatusFailed); +return false; + } + + lldb::SBTarget target = debugger.GetSelectedTarget(); + if (!target.IsValid()) { +result.Printf("error: invalid target inside debugger\n"); +result.SetStatus(lldb::eReturnStatusFailed); +return false; + } + + process = target.GetProcess(); + if (!process.IsValid() || + (process.GetState() == lldb::StateType::eStateDetached) || + (process.GetState() == lldb::StateType::eStateExited) || + (process.GetState() == lldb::StateType::eStateInvalid)) { +result.Printf("error: invalid process inside debugger's target\n"); +result.SetStatus(lldb::eReturnStatusFailed); +return false; + } + + return true; +} + +static bool ParseCommandOption(char **command, + lldb::SBCommandReturnObject &result, + uint32_t &index, const std::string &arg, + uint32_t &parsed_result) { + char *endptr; + if (!command[++index]) { +result.Printf("error: option \"%s\" requires an argument\n", arg.c_str()); +result.SetStatus(lldb::eReturnStatusFailed); +return false; + } + + errno = 0; + unsigned long output = strtoul(command[index], &endptr, 0); + if ((errno != 0) || (*endptr != '\0')) { +result.Printf("error: invalid value \"%s\" provided for option \"%s\"\n", + command[index], arg.c_str()); +result.SetStatus(lldb::eReturnStatusFailed); +return false; + } + if (output > UINT32_MAX) { +result.Printf("error: value \"%s\" for option \"%s\" exceeds UINT32_MAX\n", + command[index], arg.c_str()); +result.SetStatus(lldb::eReturnStatusFailed); +return false; + } + parsed_result = (uint32_t)output; + return true; +} + +static bool ParseCommandArgThread(char **command, + lldb::SBCommandReturnObject &result, + lldb::SBProcess &process, uint32_t &index, + lldb::tid_t &thread_id) { + char *endptr; + if (!strcmp(command[index], "all")) +thread_id = LLDB_INVALID_THREAD_ID; + else { +uint32_t thread_index_id; +errno = 0; +unsigned long output = strtoul(command[index], &endptr, 0); +if ((errno != 0) || (*endptr != '\0') || (output > UINT32_MAX)) { + result.Printf("error: invalid thread specification: \"%s\"\n", +command[index]); + result.SetStatus(lldb::eReturnStatusFailed); + return false; +} +thread_index_id = (uint32_t)output; + +lldb::SBThread thread = process.Ge
[Lldb-commits] [lldb] r249379 - Bug 25050: X87 FPU Special Purpose Registers
Author: abhishek Date: Tue Oct 6 02:04:03 2015 New Revision: 249379 URL: http://llvm.org/viewvc/llvm-project?rev=249379&view=rev Log: Bug 25050: X87 FPU Special Purpose Registers Summary: - For x86_64-FreeBSD Platform: -- LLDB now provides correct values of X87 FPU Special Purpose Registers like fstat, ftag, fctrl etc.. Signed-off-by: Abhishek Aggarwal Reviewers: emaste, mikesart, clayborg Subscribers: emaste Differential Revision: http://reviews.llvm.org/D13434 Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp?rev=249379&r1=249378&r2=249379&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp Tue Oct 6 02:04:03 2015 @@ -58,6 +58,9 @@ RegisterContextPOSIXProcessMonitor_x86_6 lldb_private::RegisterInfoInterface *register_info) : RegisterContextPOSIX_x86(thread, concrete_frame_idx, register_info) { +// Store byte offset of fctrl (i.e. first register of FPR) wrt 'UserArea' +const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl"); +m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset; } ProcessMonitor & @@ -254,8 +257,15 @@ RegisterContextPOSIXProcessMonitor_x86_6 } // Get pointer to m_fpr.xstate.fxsave variable and set the data from it. -assert (reg_info->byte_offset < sizeof(m_fpr)); -uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset; +// Byte offsets of all registers are calculated wrt 'UserArea' structure. +// However, ReadFPR() reads fpu registers {using ptrace(PT_GETFPREGS,..)} +// and stores them in 'm_fpr' (of type FPR structure). To extract values of fpu +// registers, m_fpr should be read at byte offsets calculated wrt to FPR structure. + +// Since, FPR structure is also one of the member of UserArea structure. +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea) +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr)); +uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { case 2: @@ -308,8 +318,15 @@ RegisterContextPOSIXProcessMonitor_x86_6 else { // Get pointer to m_fpr.xstate.fxsave variable and set the data to it. -assert (reg_info->byte_offset < sizeof(m_fpr)); -uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset; +// Byte offsets of all registers are calculated wrt 'UserArea' structure. +// However, WriteFPR() takes m_fpr (of type FPR structure) and writes only fpu +// registers using ptrace(PT_SETFPREGS,..) API. Hence fpu registers should +// be written in m_fpr at byte offsets calculated wrt FPR structure. + +// Since, FPR structure is also one of the member of UserArea structure. +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea) +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr)); +uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { case 2: Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h?rev=249379&r1=249378&r2=249379&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h Tue Oct 6 02:04:03 2015 @@ -91,6 +91,7 @@ protected: private: ProcessMonitor & GetMonitor(); +uint32_t m_fctrl_offset_in_userarea; // Offset of 'fctrl' in 'UserArea' Structure }; #endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r250022 - X86: Change FTAG register size in FXSAVE structure
Author: abhishek Date: Mon Oct 12 04:57:00 2015 New Revision: 250022 URL: http://llvm.org/viewvc/llvm-project?rev=250022&view=rev Log: X86: Change FTAG register size in FXSAVE structure Summary: - Changed from 16 bits to 8 bits for Intel Architecture -- FXSAVE structure now conforms with the layout of FXSAVE area specified by IA Architecture Software Developer Manual - Modified Linux and FreeBSD specific files to support this change -- MacOSX already uses 8 bits for ftag register - Modified TestRegisters.py and a.cpp: -- Change allows 8 bit comparison of ftag values -- Change resolves Bug 24733: Removed XFAIL for Clang as the test works and passes for Clang compiler as well -- Change provides a Generic/Better way of testing Bug 24457 and Bug 25050 by using 'int3' inline assembly in inferior Signed-off-by: Abhishek Aggarwal Reviewers: ovyalov, jingham, clayborg Subscribers: tfiala, emaste Differential Revision: http://reviews.llvm.org/D13587 Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h lldb/trunk/test/functionalities/register/TestRegisters.py lldb/trunk/test/functionalities/register/a.cpp Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp?rev=250022&r1=250021&r2=250022&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp Mon Oct 12 04:57:00 2015 @@ -268,6 +268,9 @@ RegisterContextPOSIXProcessMonitor_x86_6 uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { +case 1: +value.SetUInt8(*(uint8_t *)src); +return true; case 2: value.SetUInt16(*(uint16_t *)src); return true; @@ -329,6 +332,9 @@ RegisterContextPOSIXProcessMonitor_x86_6 uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { +case 1: +*(uint8_t *)dst = value.GetAsUInt8(); +break; case 2: *(uint16_t *)dst = value.GetAsUInt16(); break; Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=250022&r1=250021&r2=250022&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Mon Oct 12 04:57:00 2015 @@ -575,6 +575,9 @@ NativeRegisterContextLinux_x86_64::ReadR uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { +case 1: +reg_value.SetUInt8(*(uint8_t *)src); +break; case 2: reg_value.SetUInt16(*(uint16_t *)src); break; @@ -644,6 +647,9 @@ NativeRegisterContextLinux_x86_64::Write uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { +case 1: +*(uint8_t *)dst = reg_value.GetAsUInt8(); +break; case 2: *(uint16_t *)dst = reg_value.GetAsUInt16(); break; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp?rev=250022&r1=250021&r2=250022&view=diff == --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp Mon Oct 12 04:57:00 2015 @@ -38,7 +38,8 @@ struct FPR_i386 { uint16_t fctrl; // FPU Control Word (fcw) uint16_t fstat; // FPU Status Word (fsw) -uint16_t ftag; // FPU Tag Word (ftw) +uint8_t ftag; // FPU Tag Word (ftw) +uint8_t reserved_1; // Reserved
[Lldb-commits] [lldb] r253026 - Fix to solve Bug 23139 & Bug 23560
Author: abhishek Date: Fri Nov 13 04:47:49 2015 New Revision: 253026 URL: http://llvm.org/viewvc/llvm-project?rev=253026&view=rev Log: Fix to solve Bug 23139 & Bug 23560 Summary: - Reason of both bugs: 1. For the very first frame, Unwinder doesn't check the validity of Full UnwindPlan before creating StackFrame from it: When 'process launch' command is run after setting a breakpoint in inferior, the Unwinder runs and saves only Frame 0 (the frame in which breakpoint was set) in thread's StackFrameList i.e. m_curr_frames_sp. However, it doesn't check the validity of the Full UnwindPlan for this frame by unwinding 2 more frames further. 2. Unwinder doesn't update the CFA value of Cursor when Full UnwindPlan fails and FallBack UnwindPlan succeeds in providing valid CFA values for frames: Sometimes during unwinding of stack frames, the Full UnwindPlan inside the RegisterContextLLDB object may fail to provide valid CFA values for these frames. Then the Fallback UnwindPlan is used to unwind the frames. If the Fallback UnwindPlan succeeds, then it provides a valid new CFA value. The RegisterContextLLDB::m_cfa field of Cursor object is updated during the Fallback UnwindPlan execution. However, UnwindLLDB misses the implementation to update the 'cfa' field of this Cursor with this valid new CFA value. - This patch fixes both these issues. - Remove XFAIL in test files corresponding to these 2 Bugs Change-Id: I932ea407545ceee2d628f946ecc61a4806d4cc86 Signed-off-by: Abhishek Aggarwal Reviewers: jingham, lldb-commits, jasonmolenda Subscribers: lldb-commits, ovyalov, tberghammer Differential Revision: http://reviews.llvm.org/D14226 Modified: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Modified: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py?rev=253026&r1=253025&r2=253026&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py Fri Nov 13 04:47:49 2015 @@ -17,7 +17,6 @@ class SBBreakpointCallbackCase(TestBase) @skipIfRemote @skipIfNoSBHeaders @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) -@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"]) def test_breakpoint_callback(self): """Test the that SBBreakpoint callback is invoked when a breakpoint is hit. """ self.build_and_test('driver.cpp test_breakpoint_callback.cpp', @@ -27,7 +26,6 @@ class SBBreakpointCallbackCase(TestBase) @skipIfNoSBHeaders @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) @expectedFlakeyFreeBSD -@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"]) def test_sb_api_listener_event_description(self): """ Test the description of an SBListener breakpoint event is valid.""" self.build_and_test('driver.cpp listener_test.cpp test_listener_event_description.cpp', @@ -39,7 +37,6 @@ class SBBreakpointCallbackCase(TestBase) @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) @expectedFlakeyFreeBSD @expectedFlakeyLinux # Driver occasionally returns '1' as exit status -@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"]) def test_sb_api_listener_event_process_state(self): """ Test that a registered SBListener receives events when a process changes state. Modified: lldb/trunk/packages/Python/l
[Lldb-commits] [lldb] r254499 - PTRACE ABI to read FXSAVE area for 32-bit inferior
Author: abhishek Date: Wed Dec 2 03:40:17 2015 New Revision: 254499 URL: http://llvm.org/viewvc/llvm-project?rev=254499&view=rev Log: PTRACE ABI to read FXSAVE area for 32-bit inferior Summary: - Problem occurs when: -- 32-bit inferiors run on x86_32 machine and the architecture doesn't have AVX feature -- This causes FPRType to be set to eFPRTypeFXSAVE -- PTRACE_GETFPREGS was being used to read FXSAVE area -- For 32-bit inferiors running on x86_32 machine, PTRACE_GETFPREGS reads FSAVE area and not FXSAVE area - Changed ptrace API to PTRACE_GETREGSET for 32-bit inferiors -- This reads FPR data in FXSAVE format. -- For 64-bit inferiors, no change has been made. - Modified XFAIL for TestReturnValue.py -- Earlier, this test was passing for Linux OS -- Now, it passes for Android OS as well Change-Id: Ieed72bc969b79516fc7b263b32493aa1e7a1a2ac Signed-off-by: Abhishek Aggarwal Reviewers: ovyalov, jingham, lldb-commits, tberghammer, labath Subscribers: jevinskie, labath, tberghammer, danalbert Differential Revision: http://reviews.llvm.org/D15042 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py?rev=254499&r1=254498&r2=254499&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py Wed Dec 2 03:40:17 2015 @@ -16,7 +16,7 @@ class ReturnValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -@expectedFailurei386 +@expectedFailureAll(oslist=["macosx","freebsd"], archs=["i386"]) @expectedFailureWindows("llvm.org/pr24778") @add_test_categories(['pyapi']) def test_with_python(self): Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=254499&r1=254498&r2=254499&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Wed Dec 2 03:40:17 2015 @@ -327,6 +327,9 @@ namespace #ifndef NT_X86_XSTATE #define NT_X86_XSTATE 0x202 #endif +#ifndef NT_PRXFPREG +#define NT_PRXFPREG 0x46e62b7f +#endif NativeRegisterContextLinux* NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(const ArchSpec& target_arch, @@ -832,6 +835,7 @@ NativeRegisterContextLinux_x86_64::IsGPR NativeRegisterContextLinux_x86_64::FPRType NativeRegisterContextLinux_x86_64::GetFPRType () const { +Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); if (m_fpr_type == eFPRTypeNotValid) { // TODO: Use assembly to call cpuid on the inferior and query ebx or ecx. @@ -842,9 +846,15 @@ NativeRegisterContextLinux_x86_64::GetFP { // Fall back to general floating point with no AVX support. m_fpr_type = eFPRTypeFXSAVE; + +// Check if FXSAVE area can be read. +if (const_cast(this)->ReadFPR().Fail()) +{ +if (log) +log->Printf("NativeRegisterContextLinux_x86_64::%s ptrace APIs failed to read XSAVE/FXSAVE area", __FUNCTION__); +} } } - return m_fpr_type; } @@ -868,10 +878,24 @@ Error NativeRegisterContextLinux_x86_64::WriteFPR() { const FPRType fpr_type = GetFPRType (); +const lldb_private::ArchSpec& target_arch = GetRegisterInfoInterface().GetTargetArchitecture(); switch (fpr_type) { case FPRType::eFPRTypeFXSAVE: -return NativeRegisterContextLinux::WriteFPR(); +// For 32-bit inferiors on x86_32/x86_64 architectures, +// FXSAVE area can be written using PTRACE_SETREGSET ptrace api +// For 64-bit inferiors on x86_64 architectures, +// FXSAVE area can be written using PTRACE_SETFPREGS ptrace api +switch (target_arch.GetMachine ()) +{ +case llvm::Triple::x86: +return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG); +case llvm::Triple::x86_64: +return NativeRegisterContextLinux::WriteFPR(); +default: +assert(false && "Unhandled target architecture."); +break; +} case FPRType::eFPRTypeXSAVE: return WriteRe
[Lldb-commits] [lldb] r277125 - Improve code of loading plugins that provide cmnds
Author: abhishek Date: Fri Jul 29 02:46:32 2016 New Revision: 277125 URL: http://llvm.org/viewvc/llvm-project?rev=277125&view=rev Log: Improve code of loading plugins that provide cmnds Summary: - Modified code that enables writing new user-defined commands and use them through LLDB CLI. Modifications are: -- Define the 'syntax' for each user-defined command --- Added an argument in SBCommandInterpreter::AddCommand() and SBCommand::AddCommand() API --- Allow passing syntax for each user-defined command --- Earlier, only 'help' could be defined and passed for commands -- Passed 'number of arguments' entered on CLI for user-defined commands --- Added an argument (number of options) in SBCommandPluginInterface::DoExecute() API to know the number of arguments passed for commands -- In CommandPluginInterfaceImplementation class: --- Make the data member m_backend a shared_ptr --- Avoids memory leaks of dynamically allocated SBCommandPluginInterface instances created in lldb::PluginInitialize() API Signed-off-by: Abhishek Aggarwal Reviewers: jingham, granata.enrico, clayborg Subscribers: labath, lldb-commits Differential Revision: https://reviews.llvm.org/D22863 Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/source/API/SBCommandInterpreter.cpp Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=277125&r1=277124&r2=277125&view=diff == --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Fri Jul 29 02:46:32 2016 @@ -141,6 +141,9 @@ public: lldb::SBCommand AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help); +lldb::SBCommand +AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help, const char* syntax); + void SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); @@ -308,6 +311,9 @@ public: lldb::SBCommand AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr); +lldb::SBCommand +AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help, const char* syntax); + private: friend class SBDebugger; friend class SBCommandInterpreter; Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=277125&r1=277124&r2=277125&view=diff == --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Fri Jul 29 02:46:32 2016 @@ -153,7 +153,7 @@ protected: sb_return.Release(); return ret; } -lldb::SBCommandPluginInterface* m_backend; +std::shared_ptr m_backend; }; SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter *interpreter) : @@ -605,6 +605,17 @@ SBCommandInterpreter::AddCommand (const return lldb::SBCommand(); } +lldb::SBCommand +SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help, const char* syntax) +{ +lldb::CommandObjectSP new_command_sp; +new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name, impl, help, syntax)); + +if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) +return lldb::SBCommand(new_command_sp); +return lldb::SBCommand(); +} + SBCommand::SBCommand() = default; SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp) @@ -677,6 +688,21 @@ SBCommand::AddCommand (const char* name, return lldb::SBCommand(); } +lldb::SBCommand +SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help, const char* syntax) +{ +if (!IsValid ()) +return lldb::SBCommand(); +if (!m_opaque_sp->IsMultiwordObject()) +return lldb::SBCommand(); +lldb::CommandObjectSP new_command_sp; +new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help, syntax)); +if (new_command_sp && m_opaque_sp->LoadSubCommand(name,new_command_sp)) +return lldb::SBCommand(new_command_sp); +return lldb::SBCommand(); +} + + uint32_t SBCommand::GetFlags () { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r280924 - LLDB: API for iPermission of object file's sections
Author: abhishek Date: Thu Sep 8 07:22:56 2016 New Revision: 280924 URL: http://llvm.org/viewvc/llvm-project?rev=280924&view=rev Log: LLDB: API for iPermission of object file's sections Summary: - Added an API to public interface that provides permissions (RWX) of individual sections of an object file - Earlier, there was no way to find out this information through SB APIs - A possible use case of this API is: when a user wants to know the sections that have executable machine instructions and want to write a tool on top of LLDB based on this information - Differential Revision: https://reviews.llvm.org/D24251 Modified: lldb/trunk/include/lldb/API/SBSection.h lldb/trunk/scripts/interface/SBSection.i lldb/trunk/source/API/SBSection.cpp Modified: lldb/trunk/include/lldb/API/SBSection.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=280924&r1=280923&r2=280924&view=diff == --- lldb/trunk/include/lldb/API/SBSection.h (original) +++ lldb/trunk/include/lldb/API/SBSection.h Thu Sep 8 07:22:56 2016 @@ -54,6 +54,21 @@ public: SectionType GetSectionType(); //-- + /// Gets the permissions (RWX) of the section of the object file + /// + /// Returns a mask of bits of enum lldb::Permissions for this section. + /// Sections for which permissions are not defined, 0 is returned for + /// them. The binary representation of this value corresponds to [XRW] + /// i.e. for a section having read and execute permissions, the value + /// returned is 6 + /// + /// @return + /// Returns an unsigned value for Permissions for the section. + //-- + uint32_t + GetPermissions() const; + + //-- /// Return the size of a target's byte represented by this section /// in numbers of host bytes. Note that certain architectures have /// varying minimum addressable unit (i.e. byte) size for their Modified: lldb/trunk/scripts/interface/SBSection.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBSection.i?rev=280924&r1=280923&r2=280924&view=diff == --- lldb/trunk/scripts/interface/SBSection.i (original) +++ lldb/trunk/scripts/interface/SBSection.i Thu Sep 8 07:22:56 2016 @@ -90,6 +90,9 @@ public: SectionType GetSectionType (); +uint32_t +GetPermissions() const; + %feature("docstring", " //-- /// Return the size of a target's byte represented by this section Modified: lldb/trunk/source/API/SBSection.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=280924&r1=280923&r2=280924&view=diff == --- lldb/trunk/source/API/SBSection.cpp (original) +++ lldb/trunk/source/API/SBSection.cpp Thu Sep 8 07:22:56 2016 @@ -188,6 +188,15 @@ SectionType SBSection::GetSectionType() return eSectionTypeInvalid; } +uint32_t +SBSection::GetPermissions() const +{ +SectionSP section_sp(GetSP()); +if (section_sp) +return section_sp->GetPermissions(); +return 0; +} + uint32_t SBSection::GetTargetByteSize() { SectionSP section_sp(GetSP()); if (section_sp.get()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r259344 - Set correct ThreadStopInfo in case of trace event
Author: abhishek Date: Mon Feb 1 03:01:42 2016 New Revision: 259344 URL: http://llvm.org/viewvc/llvm-project?rev=259344&view=rev Log: Set correct ThreadStopInfo in case of trace event Summary: - The patch solves Bug 23478 and Bug 19311. Resolving Bug 23478 also resolves Bug 23039. Correct ThreadStopInfo is set for Linux and FreeBSD platforms. - Summary: When a trace event is reported, we need to check whether the trace event lands at a breakpoint site. If it lands at a breakpoint site then set the thread's StopInfo with the reason 'breakpoint'. Else, set the reason to be 'Trace'. Change-Id: I0af9765e782fd74bc0cead41548486009f8abb87 Signed-off-by: Abhishek Aggarwal Reviewers: jingham, emaste, lldb-commits, clayborg, ovyalov Subscribers: emaste Differential Revision: http://reviews.llvm.org/D16720 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py?rev=259344&r1=259343&r2=259344&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py Mon Feb 1 03:01:42 2016 @@ -15,7 +15,6 @@ class ConsecutiveBreakpointsTestCase(Tes mydir = TestBase.compute_mydir(__file__) -@expectedFailureAll("llvm.org/pr23478", oslist = not_in(["macosx"])) def test (self): self.build () self.consecutive_breakpoints_tests() Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py?rev=259344&r1=259343&r2=259344&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py Mon Feb 1 03:01:42 2016 @@ -31,10 +31,7 @@ class DynamicValueChildCountTestCase(Tes self.main_sixth_call_line = line_number('pass-to-base.cpp', '// Break here and check b has 0 children again') -@expectedFailureLinux("llvm.org/pr23039") -@expectedFailureFreeBSD("llvm.org/pr19311") # continue at a breakpoint does not work @expectedFailureWindows("llvm.org/pr24663") -@expectedFailurei386("to be figured out") @add_test_categories(['pyapi']) def test_get_dynamic_vals(self): """Test fetching C++ dynamic values from pointers & references.""" Modified: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp?rev=259344&r1=259343&r2=259344&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Mon Feb 1 03:01:42 2016 @@ -558,22 +558,49 @@ FreeBSDThread::WatchNotify(const Process void FreeBSDThread::TraceNotify(const ProcessMessage &message) { -POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol(); -if (reg_ctx) +Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); + +// Try to resolve the breakpoint object corresponding to the current PC. +assert(GetRegisterContext()); +lldb::addr_t pc = GetRegisterContext()->GetPC(); +if (log) +log->Printf ("FreeBSDThread::%s () PC=0x%8.8" PRIx64, __FUNCTION__, pc); +lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc)); + +// If the current pc is a breakpoint site then set the StopInfo to Breakpoint. +// Otherwise, set the StopInfo to Watchpoint or Trace. +if (bp_site) { -uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints(); -uint32_t wp_idx; -for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++) +
[Lldb-commits] [lldb] r246841 - SysV ABI for i386 Architecture
Author: abhishek Date: Fri Sep 4 02:44:05 2015 New Revision: 246841 URL: http://llvm.org/viewvc/llvm-project?rev=246841&view=rev Log: SysV ABI for i386 Architecture Summary: - Capability to force return user specified values from inside of a function on lldb command terminal - Support for Integral, Pointer and Floating Point values Signed-off-by: Abhishek Aggarwal Reviewers: jingham, clayborg Subscribers: tberghammer Differential Revision: http://reviews.llvm.org/D12595 Modified: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp (contents, props changed) Modified: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp?rev=246841&r1=246840&r2=246841&view=diff == --- lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp Fri Sep 4 02:44:05 2015 @@ -418,8 +418,149 @@ Error ABISysV_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) { Error error; -//ToDo: Yet to be implemented -error.SetErrorString("ABISysV_i386::SetReturnValueObject(): Not implemented yet"); +if (!new_value_sp) +{ +error.SetErrorString("Empty value object for return value."); +return error; +} + +CompilerType clang_type = new_value_sp->GetCompilerType(); +if (!clang_type) +{ +error.SetErrorString ("Null clang type for return value."); +return error; +} + +const uint32_t type_flags = clang_type.GetTypeInfo (); +Thread *thread = frame_sp->GetThread().get(); +RegisterContext *reg_ctx = thread->GetRegisterContext().get(); +DataExtractor data; +Error data_error; +size_t num_bytes = new_value_sp->GetData(data, data_error); +bool register_write_successful = true; + +if (data_error.Fail()) +{ +error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); +return error; +} + +// Following "IF ELSE" block categorizes various 'Fundamental Data Types'. +// The terminology 'Fundamental Data Types' used here is adopted from +// Table 2.1 of the reference document (specified on top of this file) + +if (type_flags & eTypeIsPointer) // 'Pointer' +{ +if(num_bytes != sizeof(uint32_t)) +{ +error.SetErrorString("Pointer to be returned is not 4 bytes wide"); +return error; +} +lldb::offset_t offset = 0; +const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); +uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); +register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value); +} +else if ((type_flags & eTypeIsScalar) || (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point' +{ +lldb::offset_t offset = 0; +const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); + +if (type_flags & eTypeIsInteger)// 'Integral' except enum +{ +switch (num_bytes) +{ +default: +break; +case 16: +// For clang::BuiltinType::UInt128 & Int128 +// ToDo: Need to decide how to handle it +break; +case 8: +{ +uint32_t raw_value_low = data.GetMaxU32(&offset, 4); +const RegisterInfo *edx_info = reg_ctx->GetRegisterInfoByName("edx", 0); +uint32_t raw_value_high = data.GetMaxU32(&offset, num_bytes - offset); +register_write_successful = (reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value_low) && + reg_ctx->WriteRegisterFromUnsigned (edx_info, raw_value_high)); +break; +} +case 4: +case 2: +case 1: +{ +uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); +register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value); +break; +} +} +} +else if (type_flags & eTypeIsEnumeration)// handles enum +{ +uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); +register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value); +} +else if (type_flags & eTypeIsFloat) // 'Floating Point' +{ +RegisterValue st0_value, fstat_value, ftag_value; +const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0); +const RegisterInfo *fstat_info = reg_
[Lldb-commits] [lldb] r246955 - Bug 24457 - X87 FPU Special Purpose Registers
Author: abhishek Date: Mon Sep 7 02:40:16 2015 New Revision: 246955 URL: http://llvm.org/viewvc/llvm-project?rev=246955&view=rev Log: 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 Reviewers: ashok.thirumurthi, granata.enrico, tfiala, clayborg Differential Revision: http://reviews.llvm.org/D12592 Added: lldb/trunk/test/functionalities/register/a.cpp (with props) Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (contents, props changed) lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h lldb/trunk/test/functionalities/register/Makefile (contents, props changed) lldb/trunk/test/functionalities/register/TestRegisters.py (contents, props changed) lldb/trunk/test/functionalities/register/main.cpp (contents, props changed) Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=246955&r1=246954&r2=246955&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Mon Sep 7 02:40:16 2015 @@ -422,6 +422,10 @@ NativeRegisterContextLinux_x86_64::Nativ // Clear out the FPR state. ::memset(&m_fpr, 0, sizeof(FPR)); + +// Store byte offset of fctrl (i.e. first register of FPR) +const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl"); +m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset; } // CONSIDER after local and llgs debugging are merged, register set support can @@ -559,8 +563,16 @@ NativeRegisterContextLinux_x86_64::ReadR } // Get pointer to m_fpr.xstate.fxsave variable and set the data from it. -assert (reg_info->byte_offset < sizeof(m_fpr)); -uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset; + +// Byte offsets of all registers are calculated wrt 'UserArea' structure. +// However, ReadFPR() reads fpu registers {using ptrace(PTRACE_GETFPREGS,..)} +// and stores them in 'm_fpr' (of type FPR structure). To extract values of fpu +// registers, m_fpr should be read at byte offsets calculated wrt to FPR structure. + +// Since, FPR structure is also one of the member of UserArea structure. +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea) +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr)); +uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { case 2: @@ -620,8 +632,16 @@ NativeRegisterContextLinux_x86_64::Write else { // Get pointer to m_fpr.xstate.fxsave variable and set the data to it. -assert (reg_info->byte_offset < sizeof(m_fpr)); -uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset; + +// Byte offsets of all registers are calculated wrt 'UserArea' structure. +// However, WriteFPR() takes m_fpr (of type FPR structure) and writes only fpu +// registers using ptrace(PTRACE_SETFPREGS,..) API. Hence fpu registers should +// be written in m_fpr at byte offsets calculated wrt FPR structure. + +// Since, FPR structure is also one of the member of UserArea structure. +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea) +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr)); +uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea; switch (reg_info->byte_size) { case 2: Propchange: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp -- svn:executable = * Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h?rev=246955&r1=246954&r2=246955&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h Mon S
[Lldb-commits] [lldb] r247000 - Bug 24733: TestRegisters.py for Clang inferiors
Author: abhishek Date: Tue Sep 8 05:19:37 2015 New Revision: 247000 URL: http://llvm.org/viewvc/llvm-project?rev=247000&view=rev Log: Bug 24733: TestRegisters.py for Clang inferiors Summary: - Bug 24457 can now be tested for inferiors compiled by clang compiler also. - A generic test case for GCC and Clang inferiors: -- Works even when Clang and GCC produce different assembly for the same inferior. - Refer Differential Revision: http://reviews.llvm.org/D12677 Signed-off-by: Abhishek Aggarwal Modified: lldb/trunk/test/functionalities/register/TestRegisters.py lldb/trunk/test/functionalities/register/a.cpp Modified: lldb/trunk/test/functionalities/register/TestRegisters.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/register/TestRegisters.py?rev=247000&r1=246999&r2=247000&view=diff == --- lldb/trunk/test/functionalities/register/TestRegisters.py (original) +++ lldb/trunk/test/functionalities/register/TestRegisters.py Tue Sep 8 05:19:37 2015 @@ -37,7 +37,6 @@ class RegisterCommandsTestCase(TestBase) self.fp_register_write() @expectedFailureAndroid(archs=["i386"]) # "register read fstat" always return 0x -@expectedFailureClang("llvm.org/pr24733") 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']: @@ -169,15 +168,14 @@ class RegisterCommandsTestCase(TestBase) 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) +# Check stop reason; Should be SIGTRAP +stop_reason = 'stop reason = signal SIGTRAP' +self.expect("thread list", STOPPED_DUE_TO_SIGNAL, + substrs = ['stopped', stop_reason]) + process = target.GetProcess() self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) Modified: lldb/trunk/test/functionalities/register/a.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/register/a.cpp?rev=247000&r1=246999&r2=247000&view=diff == --- lldb/trunk/test/functionalities/register/a.cpp (original) +++ lldb/trunk/test/functionalities/register/a.cpp Tue Sep 8 05:19:37 2015 @@ -13,6 +13,7 @@ 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__ ( +"int3 ;" "flds %1 ;" "flds %2 ;" "flds %3 ;" ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits