[Lldb-commits] [PATCH] D111920: Test untested variants of BreakpointCreateBySourceRegex

2021-10-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: aprantl, JDevlieghere.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add tests for the other variants of BreakpointCreateBySourceRegex.

  

I added some tests for the case where the breakpoints take immediately
to the extant test case, and made a new test case for when the source
regex breakpoint will be set in a dlopen-ed library.

  

I also noticed when doing this that "lldbutil.run_to_source_breakpoint
can't handle the case where the breakpoint will be in a dlopen-ed
library, since it requires the breakpoint to have at least 1 location
before run.  I fixed that by adding a parameter to say whether a
before run location is expected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111920

Files:
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile
  
lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py
  lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/b.cpp
  lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/main.cpp
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
  lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py
@@ -17,6 +17,12 @@
 se_string = se_value.GetStringValue(100)
 side_effect.fancier = se_string
 
+def a_list_function(frame, bp_loc, extra_args, dict):
+se_value = extra_args.GetValueForKey("side_effect")
+se_string = se_value.GetStringValue(100)
+side_effect.from_list = se_string
+
+
 def empty_extra_args(frame, bp_loc, extra_args, dict):
 if extra_args.IsValid():
 side_effect.not_so_fancy = "Extra args should not be valid"
Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
@@ -54,6 +54,17 @@
 "Set break point at this line.", self.main_source_spec)
 self.assertTrue(fancier_bkpt, VALID_BREAKPOINT)
 
+# Also test the list version of this:
+file_list = lldb.SBFileSpecList()
+file_list.Append(self.main_source_spec)
+module_list = lldb.SBFileSpecList()
+module_list.Append(self.target.GetExecutable())
+
+list_bkpt = self.target.BreakpointCreateBySourceRegex(
+"Set break point at this line.", module_list, file_list)
+self.assertTrue(list_bkpt, VALID_BREAKPOINT)
+
+
 not_so_fancy_bkpt = self.target.BreakpointCreateBySourceRegex(
 "Set break point at this line.", self.main_source_spec)
 self.assertTrue(not_so_fancy_bkpt, VALID_BREAKPOINT)
@@ -114,13 +125,21 @@
 error = not_so_fancy_bkpt.SetScriptCallbackFunction("bktptcmd.empty_extra_args", empty_args)
 self.assertTrue(error.Success(), "Failed to add callback %s"%(error.GetCString()))
 
+# Do list breakpoint like fancy:
+stream.Clear()
+stream.Print('{"side_effect" : "I come from list input"}')
+extra_args.SetFromJSON(stream)
+error = list_bkpt.SetScriptCallbackFunction("bktptcmd.a_list_function", extra_args)
+self.assertTrue(error.Success(), "Failed to add callback %s"%(error.GetCString()))
+
 # Clear out canary variables
 side_effect.bktptcmd = None
 side_effect.callback = None
 side_effect.fancy= None
 side_effect.fancier  = None
 side_effect.not_so_fancy = None
-
+side_effect.a_list_function = None
+
 # Now launch the process, and do not stop at entry point.
 self.process = self.target.LaunchSimple(
 None, None, self.get_process_working_directory())
@@ -133,11 +152,13 @@
 self.assertEquals(len(threads), 1, "Stopped at inner breakpoint.")
 self.thread = threads[0]
 
+print("* Num Locations: {0} ; Hit Count {1}".format(list_bkpt.GetNumLocations(), list_bkpt.GetHitCount()))
 self.assertEquals("callback was here", side_effect.callback)
 self.assertEquals("function was here", side_effect.bktptcmd)
 self.assertEquals("I am fancy", side_effect.fancy)
 self.assertEquals("I am fancier", side_effect.fancier)
 self.assertEquals("Not so fancy", side_effect.not_so_fancy)
+self.assertEquals("I come 

[Lldb-commits] [PATCH] D111910: Fix Xcode project for debugserver

2021-10-15 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4594f8116543: Fix Xcode project for debugserver (authored by 
Lawrence D\Anna lawrence_da...@apple.com, committed 
by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111910/new/

https://reviews.llvm.org/D111910

Files:
  lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj


Index: lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
===
--- lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -91,7 +91,7 @@
23071D4A5DAE0016ABC0 /* CMakeLists.txt */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 
CMakeLists.txt; sourceTree = ""; };
233B4EA51D2DB54300E98261 /* JSON.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = JSON.cpp; sourceTree = ""; };
233B4EA61D2DB54300E98261 /* JSON.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
JSON.h; sourceTree = ""; };
-   233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = StringConvert.cpp; path = ../../../source/Host/common/StringConvert.cpp; 
sourceTree = ""; };
+   233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = StringConvert.cpp; sourceTree = ""; };
23D1B0271D497E8B00FF831B /* OsLogger.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = OsLogger.cpp; sourceTree = ""; };
23D1B0281D497E8B00FF831B /* OsLogger.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
OsLogger.h; sourceTree = ""; };
260828DE0CBAF7F400F95054 /* DNBRuntimeAction.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
DNBRuntimeAction.h; sourceTree = ""; };


Index: lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
===
--- lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -91,7 +91,7 @@
 		23071D4A5DAE0016ABC0 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; };
 		233B4EA51D2DB54300E98261 /* JSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSON.cpp; sourceTree = ""; };
 		233B4EA61D2DB54300E98261 /* JSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSON.h; sourceTree = ""; };
-		233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringConvert.cpp; path = ../../../source/Host/common/StringConvert.cpp; sourceTree = ""; };
+		233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConvert.cpp; sourceTree = ""; };
 		23D1B0271D497E8B00FF831B /* OsLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OsLogger.cpp; sourceTree = ""; };
 		23D1B0281D497E8B00FF831B /* OsLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OsLogger.h; sourceTree = ""; };
 		260828DE0CBAF7F400F95054 /* DNBRuntimeAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNBRuntimeAction.h; sourceTree = ""; };
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4594f81 - Fix Xcode project for debugserver

2021-10-15 Thread Lawrence D'Anna via lldb-commits

Author: Lawrence D'\''Anna
Date: 2021-10-15T15:08:06-07:00
New Revision: 4594f81165433c681cc4f09ed50b662b1a237137

URL: 
https://github.com/llvm/llvm-project/commit/4594f81165433c681cc4f09ed50b662b1a237137
DIFF: 
https://github.com/llvm/llvm-project/commit/4594f81165433c681cc4f09ed50b662b1a237137.diff

LOG: Fix Xcode project for debugserver

It seems StringConvert.cpp was moved, and the Xcode project file
wasn't updated.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D111910

Added: 


Modified: 
lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj

Removed: 




diff  --git a/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj 
b/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
index df466d0c98d7b..1ff26818a7eb8 100644
--- a/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ b/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -91,7 +91,7 @@
23071D4A5DAE0016ABC0 /* CMakeLists.txt */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 
CMakeLists.txt; sourceTree = ""; };
233B4EA51D2DB54300E98261 /* JSON.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = JSON.cpp; sourceTree = ""; };
233B4EA61D2DB54300E98261 /* JSON.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
JSON.h; sourceTree = ""; };
-   233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = StringConvert.cpp; path = ../../../source/Host/common/StringConvert.cpp; 
sourceTree = ""; };
+   233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = StringConvert.cpp; sourceTree = ""; };
23D1B0271D497E8B00FF831B /* OsLogger.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = OsLogger.cpp; sourceTree = ""; };
23D1B0281D497E8B00FF831B /* OsLogger.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
OsLogger.h; sourceTree = ""; };
260828DE0CBAF7F400F95054 /* DNBRuntimeAction.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
DNBRuntimeAction.h; sourceTree = ""; };



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111910: Fix Xcode project for debugserver

2021-10-15 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: jasonmolenda, JDevlieghere.
lawrence_danna requested review of this revision.
Herald added a project: LLDB.

It seems StringConvert.cpp was moved, and the Xcode project file
wasn't updated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111910

Files:
  lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj


Index: lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
===
--- lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -91,7 +91,7 @@
23071D4A5DAE0016ABC0 /* CMakeLists.txt */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 
CMakeLists.txt; sourceTree = ""; };
233B4EA51D2DB54300E98261 /* JSON.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = JSON.cpp; sourceTree = ""; };
233B4EA61D2DB54300E98261 /* JSON.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
JSON.h; sourceTree = ""; };
-   233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = StringConvert.cpp; path = ../../../source/Host/common/StringConvert.cpp; 
sourceTree = ""; };
+   233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = StringConvert.cpp; sourceTree = ""; };
23D1B0271D497E8B00FF831B /* OsLogger.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = OsLogger.cpp; sourceTree = ""; };
23D1B0281D497E8B00FF831B /* OsLogger.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
OsLogger.h; sourceTree = ""; };
260828DE0CBAF7F400F95054 /* DNBRuntimeAction.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
DNBRuntimeAction.h; sourceTree = ""; };


Index: lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
===
--- lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -91,7 +91,7 @@
 		23071D4A5DAE0016ABC0 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; };
 		233B4EA51D2DB54300E98261 /* JSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSON.cpp; sourceTree = ""; };
 		233B4EA61D2DB54300E98261 /* JSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSON.h; sourceTree = ""; };
-		233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringConvert.cpp; path = ../../../source/Host/common/StringConvert.cpp; sourceTree = ""; };
+		233B4EA81D2DB96A00E98261 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConvert.cpp; sourceTree = ""; };
 		23D1B0271D497E8B00FF831B /* OsLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OsLogger.cpp; sourceTree = ""; };
 		23D1B0281D497E8B00FF831B /* OsLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OsLogger.h; sourceTree = ""; };
 		260828DE0CBAF7F400F95054 /* DNBRuntimeAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNBRuntimeAction.h; sourceTree = ""; };
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111908: [lldb] [Utility] Remove Status::WasInterrupted() along with its only use

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
mgorny requested review of this revision.

Remove Status::WasInterrupted() that checks whether the underlying error
code matches EINTR.  ProcessGDBRemote::ConnectToDebugserver() is its
only call site, and it does not seem correct there.  After all, EINTR
is precisely when we want to retry, not stop retrying.  Furthermore,
it should not really matter since we should be catching EINTR
immediately via llvm::sys::RetryAfterSignal() but that's another story.


https://reviews.llvm.org/D111908

Files:
  lldb/include/lldb/Utility/Status.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Utility/Status.cpp


Index: lldb/source/Utility/Status.cpp
===
--- lldb/source/Utility/Status.cpp
+++ lldb/source/Utility/Status.cpp
@@ -287,10 +287,6 @@
 // return value.
 bool Status::Success() const { return m_code == 0; }
 
-bool Status::WasInterrupted() const {
-  return (m_type == eErrorTypePOSIX && m_code == EINTR);
-}
-
 void llvm::format_provider::format(
 const lldb_private::Status , llvm::raw_ostream ,
 llvm::StringRef Options) {
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -843,9 +843,6 @@
 if (conn_up->Connect(connect_url, ) == eConnectionStatusSuccess) 
{
   m_gdb_comm.SetConnection(std::move(conn_up));
   break;
-} else if (error.WasInterrupted()) {
-  // If we were interrupted, don't keep retrying.
-  break;
 }
 
 retry_count++;
Index: lldb/include/lldb/Utility/Status.h
===
--- lldb/include/lldb/Utility/Status.h
+++ lldb/include/lldb/Utility/Status.h
@@ -184,16 +184,6 @@
   /// success (non-erro), \b false otherwise.
   bool Success() const;
 
-  /// Test for a failure due to a generic interrupt.
-  ///
-  /// Returns true if the error code in this object was caused by an
-  /// interrupt. At present only supports Posix EINTR.
-  ///
-  /// \return
-  /// \b true if this object contains an value that describes
-  /// failure due to interrupt, \b false otherwise.
-  bool WasInterrupted() const;
-
 protected:
   /// Member variables
   ValueType m_code = 0; ///< Status code as an integer value.


Index: lldb/source/Utility/Status.cpp
===
--- lldb/source/Utility/Status.cpp
+++ lldb/source/Utility/Status.cpp
@@ -287,10 +287,6 @@
 // return value.
 bool Status::Success() const { return m_code == 0; }
 
-bool Status::WasInterrupted() const {
-  return (m_type == eErrorTypePOSIX && m_code == EINTR);
-}
-
 void llvm::format_provider::format(
 const lldb_private::Status , llvm::raw_ostream ,
 llvm::StringRef Options) {
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -843,9 +843,6 @@
 if (conn_up->Connect(connect_url, ) == eConnectionStatusSuccess) {
   m_gdb_comm.SetConnection(std::move(conn_up));
   break;
-} else if (error.WasInterrupted()) {
-  // If we were interrupted, don't keep retrying.
-  break;
 }
 
 retry_count++;
Index: lldb/include/lldb/Utility/Status.h
===
--- lldb/include/lldb/Utility/Status.h
+++ lldb/include/lldb/Utility/Status.h
@@ -184,16 +184,6 @@
   /// success (non-erro), \b false otherwise.
   bool Success() const;
 
-  /// Test for a failure due to a generic interrupt.
-  ///
-  /// Returns true if the error code in this object was caused by an
-  /// interrupt. At present only supports Posix EINTR.
-  ///
-  /// \return
-  /// \b true if this object contains an value that describes
-  /// failure due to interrupt, \b false otherwise.
-  bool WasInterrupted() const;
-
 protected:
   /// Member variables
   ValueType m_code = 0; ///< Status code as an integer value.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Actually, they aren't testing the same "sort" of thing, it's exactly the same 
test: "was the breakpoint hit once".  But those tests are also really 
inaccurate as they just ask whether any breakpoint has a hit count of 1.  It 
would be really easy to edit a test,  add another breakpoint that gets hit 
before you get to this self.expect.  In that case, this test would stop testing 
what it was intended to test.

I know you didn't add these expects, but if you have the time it would be great 
to add lldbutils.GetBreakpointCount(breakpoint_no) and then actually pass the 
right breakpoint to the test...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111899/new/

https://reviews.llvm.org/D111899

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

All these tests are testing the same sort of thing.  It would be better to make 
an lldbutil function that does this test and convert all these tests over to 
that.  This sort of change is exactly why we don't want code that's poking at 
command results to find info about things like breakpoints scattered all over 
the testsuite.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111899/new/

https://reviews.llvm.org/D111899

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108937: [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 380058.
mgorny retitled this revision from "[lldb] [Process/gdb-remote] Support 
combining xmm* and ymm*h regs into ymm*" to "[lldb] [ABI/X86] Support combining 
xmm* and ymm*h regs into ymm*".
mgorny added a comment.

Rebase to use the new `ABIX86::AugmentRegisterInfo()` API.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108937/new/

https://reviews.llvm.org/D108937

Files:
  lldb/include/lldb/lldb-private-types.h
  lldb/source/Plugins/ABI/X86/ABIX86.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -199,6 +199,29 @@
 self.match("register read st0",
["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"])
 
+self.runCmd("register write xmm0 \"{0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 "
+"0xf8 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xb1 0xb2 0xb3 0xb4 0xb5 "
+"0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf 0xc0}"])
+
+self.runCmd("register write ymm0h \"{0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 "
+"0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xef 0xee 0xed 0xec 0xeb "
+"0xea 0xe9 0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}"])
+
+self.runCmd("register write ymm0 \"{0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 "
+"0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 "
+"0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec "
+"0xed 0xee 0xef}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 "
+"0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 "
+"0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}"])
+
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
@@ -361,6 +384,29 @@
 self.match("register read st0",
["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"])
 
+self.runCmd("register write xmm0 \"{0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 "
+"0xf8 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xb1 0xb2 0xb3 0xb4 0xb5 "
+"0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf 0xc0}"])
+
+self.runCmd("register write ymm0h \"{0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 "
+"0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xef 0xee 0xed 0xec 0xeb "
+"0xea 0xe9 0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}"])
+
+self.runCmd("register write ymm0 \"{0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 "
+"0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 "
+"0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec "
+"0xed 0xee 0xef}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 "
+"0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 "
+"0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}"])
+
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("AArch64")
Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -463,20 +463,11 @@
 m_sets[set].registers = m_set_reg_nums[set].data();
   }
 
-  // sort and unique all value registers and make sure each is terminated with
-  // LLDB_INVALID_REGNUM
+  // make sure value_regs are terminated with LLDB_INVALID_REGNUM
 
   for (reg_to_regs_map::iterator pos = m_value_regs_map.begin(),
  

[Lldb-commits] [PATCH] D91508: [LLDB/Lua] add support for one-liner breakpoint callback

2021-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

FWIW, I had debugged the issue described here and posted about it on Discord, 
but never got around to posting it here. I think the MSVC build error above 
gets fixed by this patch:

  diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  index f14e2732f6eb..788072cffd87 100644
  --- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  @@ -24,6 +24,7 @@ using namespace lldb;
   #if _MSC_VER
   #pragma warning (push)
   #pragma warning (disable : 4190)
  +llvm::Expected unusedFuncForInstantiatingExpectedBool() { return true; 
}
   #endif
  
   extern "C" llvm::Expected LLDBSwigLuaBreakpointCallbackFunction(

Here's a minimal showcase of the root issue:

  $ cat cpp-ret-c.cpp 
  template class MyClass {
  public:
  T a;
  };
  extern "C" MyClass unmangledFunction();
  $ cl -c cpp-ret-c.cpp 
  cpp-ret-c.cpp
  cpp-ret-c.cpp(5): error C2526: 'unmangledFunction': C linkage function cannot 
return C++ class 'MyClass' 
  cpp-ret-c.cpp(5): note: see declaration of 'MyClass'
  $ cat cpp-ret-c2.cpp 
  template class MyClass {
  public:
  T a;
  };
  MyClass unusedFunc() { return MyClass{0}; }
  extern "C" MyClass unmangledFunction();
  $ cl -c cpp-ret-c2.cpp
  cpp-ret-c2.cpp

So this construct, in MSVC, requires that the problematic return type template 
already has been instantiated somewhere else first. The case in the python 
plugin works, but it has been copied to the Lua plugin too, where it fails.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91508/new/

https://reviews.llvm.org/D91508

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-15 Thread Nikolay Chokoev via Phabricator via lldb-commits
georgiev created this revision.
georgiev added a reviewer: LLDB.
georgiev requested review of this revision.

LLDB now shows additional string 'hardware' when a hardware breakpoint is hit. 
Current test fail for those kind of breakpoints, as they match exact string, 
which doesn't include 'hardware'.
The proposed solution is a regex match with an optional include of 'hardware' 
string (zero or one).


https://reviews.llvm.org/D111899

Files:
  lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py
  lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
  lldb/test/API/functionalities/breakpoint/cpp_exception/Makefile
  lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
  lldb/test/API/functionalities/memory/find/TestMemoryFind.py
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py
  lldb/test/API/lang/c/anonymous/TestAnonymous.py
  lldb/test/API/lang/c/array_types/TestArrayTypes.py
  lldb/test/API/lang/c/bitfields/TestBitfields.py
  lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
  lldb/test/API/lang/c/const_variables/TestConstVariables.py
  lldb/test/API/lang/c/enum_types/TestEnumTypes.py
  lldb/test/API/lang/c/forward/TestForwardDeclaration.py
  lldb/test/API/lang/c/function_types/TestFunctionTypes.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/c/local_variables/TestLocalVariables.py
  lldb/test/API/lang/c/modules/TestCModules.py
  lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
  lldb/test/API/lang/c/set_values/TestSetValues.py
  lldb/test/API/lang/c/shared_lib/TestSharedLib.py
  
lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
  lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py
  lldb/test/API/lang/cpp/inlines/TestInlines.py
  lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py
  lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
  lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
  lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
  lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
  lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
  lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
  lldb/test/API/lang/objc/modules/TestObjCModules.py
  lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
  lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
  
lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py

Index: lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
===
--- lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
+++ lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
@@ -41,7 +41,7 @@
 
 # The breakpoint should have a hit count of 1.
 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+patterns=[' resolved,( hardware,)? hit count = 1'])
 
 d1 = self.frame().FindVariable("d1")
 d1.SetPreferSyntheticValue(True)
Index: lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
===
--- lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
+++ lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
@@ -34,13 +34,13 @@
 
 # Run and stop at Foo
 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+patterns=[' resolved,( hardware,)? hit count = 1'])
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+patterns=[' resolved,( hardware,)? hit count = 1'])
 
 # This should display correctly.
 self.expect(
@@ -72,13 +72,13 @@
 
 # Run and stop at Foo
 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+patterns=[' resolved,( hardware,)? hit count = 1'])
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+patterns=[' 

[Lldb-commits] [lldb] ff4c98c - [lldb] Harden TestCompletion against new settings in 'target.process'

2021-10-15 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-15T18:50:21+02:00
New Revision: ff4c98c05559e498300bd3ad55272ac2a8d10dbc

URL: 
https://github.com/llvm/llvm-project/commit/ff4c98c05559e498300bd3ad55272ac2a8d10dbc
DIFF: 
https://github.com/llvm/llvm-project/commit/ff4c98c05559e498300bd3ad55272ac2a8d10dbc.diff

LOG: [lldb] Harden TestCompletion against new settings in 'target.process'

This test starts failing when people add a setting starting with
`target.process.t` which of course can easily happen. Make it a bit more
resistant by only requiring that `target.process.thr` has a unique completion.

Added: 


Modified: 
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 8332048313a9..1688612c5785 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -396,7 +396,7 @@ def test_settings_set_target_process(self):
 def test_settings_set_target_process_dot(self):
 """Test that 'settings set target.process.t' completes to 'settings 
set target.process.thread.'."""
 self.complete_from_to(
-'settings set target.process.t',
+'settings set target.process.thr',
 'settings set target.process.thread.')
 
 def test_settings_set_target_process_thread_dot(self):



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 03a8e70 - [lldb] Add test for struct merging in scratch ASTContext

2021-10-15 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-15T17:20:03+02:00
New Revision: 03a8e70a192f382ae700d761e46e2299a38f58db

URL: 
https://github.com/llvm/llvm-project/commit/03a8e70a192f382ae700d761e46e2299a38f58db
DIFF: 
https://github.com/llvm/llvm-project/commit/03a8e70a192f382ae700d761e46e2299a38f58db.diff

LOG: [lldb] Add test for struct merging in scratch ASTContext

Added: 
lldb/test/API/lang/cpp/scratch-context-merging/structs/Makefile

lldb/test/API/lang/cpp/scratch-context-merging/structs/TestCppScratchContextMergingStructs.py
lldb/test/API/lang/cpp/scratch-context-merging/structs/main.cpp

Modified: 


Removed: 




diff  --git a/lldb/test/API/lang/cpp/scratch-context-merging/structs/Makefile 
b/lldb/test/API/lang/cpp/scratch-context-merging/structs/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/scratch-context-merging/structs/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/scratch-context-merging/structs/TestCppScratchContextMergingStructs.py
 
b/lldb/test/API/lang/cpp/scratch-context-merging/structs/TestCppScratchContextMergingStructs.py
new file mode 100644
index 0..5cd51d671090a
--- /dev/null
+++ 
b/lldb/test/API/lang/cpp/scratch-context-merging/structs/TestCppScratchContextMergingStructs.py
@@ -0,0 +1,129 @@
+"""
+This tests LLDB's ability to merge structs into the shared per-target Clang
+ASTContext.
+
+This just focuses on indirect imports (i.e., a declaration gets imported from
+the lldb::Module AST into the expression AST and then the declaration gets
+imported to the scratch AST because it is part of the ValueObject type of the
+result) and direct imports (i.e., a declaration gets directly imported from a
+lldb::Module AST to the scratch AST, e.g., via 'frame var').
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def common_setup(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp")
+)
+
+def do_pass(self, kind, var, expected_type, expected_children):
+if kind == "expression":
+self.expect_expr(
+var, result_type=expected_type, 
result_children=expected_children
+)
+elif kind == "path":
+self.expect_var_path(var, type=expected_type, 
children=expected_children)
+else:
+self.fail("Unknown var evaluation kind: " + var)
+
+def pull_in_and_merge(self, var, type, children):
+"""
+Pulls in the specified variable into the scratch AST. Afterwards tries
+merging the declaration. The method of pulling the declaration into the
+scratch AST is defined by the first_pass/second_pass instance 
variables.
+"""
+
+# This pulls in the declaration into the scratch AST.
+self.do_pass(self.first_pass, var, type, children)
+# This pulls in the declaration a second time and forces us to merge 
with
+# the existing declaration (or reuse the existing declaration).
+self.do_pass(self.second_pass, var, type, children)
+
+def do_tests(self):
+""" Just forwards all the variables/types/childrens to 
pull_in_and_merge. """
+self.pull_in_and_merge(
+"decl_in_func", type="DeclInFunc", 
children=[ValueCheck(name="member")]
+)
+self.pull_in_and_merge(
+"top_level_struct",
+type="TopLevelStruct",
+children=[ValueCheck(name="member")],
+)
+self.pull_in_and_merge(
+"inner_struct",
+type="OuterStruct::InnerStruct",
+children=[ValueCheck(name="member")],
+)
+self.pull_in_and_merge(
+"typedef_struct",
+type="TypedefStruct",
+children=[ValueCheck(name="member")],
+)
+self.pull_in_and_merge(
+"namespace_struct",
+type="NS::NamespaceStruct",
+children=[ValueCheck(name="member")],
+)
+self.pull_in_and_merge(
+"unnamed_namespace_struct",
+type="UnnamedNamespaceStruct",
+children=[ValueCheck(name="member")],
+)
+self.pull_in_and_merge(
+"extern_c_struct",
+type="ExternCStruct",
+children=[ValueCheck(name="member")],
+)
+
+@no_debug_info_test
+def test_direct_and_indirect(self):
+"""
+First variable paths pull in a declaration directly. Then the 
expression
+evaluator pulls the declaration in indirectly.
+"""
+self.common_setup()
+self.first_pass = "path"
+

[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Host/common/Terminal.cpp:76
+  struct termios _termios = data->m_termios;
+  bool set_corectly = false;
+  if (enabled) {

My gut feeling is telling me that this can be simplified somehow… or we could 
assume `tcsetattr()` is cheap and just do the change unconditionally.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111890/new/

https://reviews.llvm.org/D111890

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error [WIP]

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 380011.
mgorny added a comment.

Move common code and error handling to `GetData()` and `SetData()` methods.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111890/new/

https://reviews.llvm.org/D111890

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Target/Process.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -51,11 +51,11 @@
 TEST_F(TerminalTest, SetEcho) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetEcho(true), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ECHO, 0U);
 
-  ASSERT_EQ(m_term.SetEcho(false), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ECHO, 0U);
 }
@@ -63,11 +63,11 @@
 TEST_F(TerminalTest, SetCanonical) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetCanonical(true), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ICANON, 0U);
 
-  ASSERT_EQ(m_term.SetCanonical(false), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -4353,8 +4353,9 @@
 const int read_fd = m_read_file.GetDescriptor();
 Terminal terminal(read_fd);
 TerminalState terminal_state(terminal, false);
-terminal.SetCanonical(false);
-terminal.SetEcho(false);
+// FIXME: error handling?
+llvm::consumeError(terminal.SetCanonical(false));
+llvm::consumeError(terminal.SetEcho(false));
 // FD_ZERO, FD_SET are not supported on windows
 #ifndef _WIN32
 const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -433,8 +433,9 @@
 TerminalState terminal_state(terminal);
 
 if (terminal.IsATerminal()) {
-  terminal.SetCanonical(false);
-  terminal.SetEcho(true);
+  // FIXME: error handling?
+  llvm::consumeError(terminal.SetCanonical(false));
+  llvm::consumeError(terminal.SetEcho(true));
 }
 
 ScriptInterpreterPythonImpl::Locker locker(
Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -21,71 +21,102 @@
 
 using namespace lldb_private;
 
+struct Terminal::Data {
+#if LLDB_ENABLE_TERMIOS
+  struct termios m_termios; ///< Cached terminal state information.
+#endif
+};
+
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
-bool Terminal::SetEcho(bool enabled) {
-  if (FileDescriptorIsValid()) {
+llvm::Expected Terminal::GetData() {
+  if (!FileDescriptorIsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid fd");
+
 #if LLDB_ENABLE_TERMIOS
-if (IsATerminal()) {
-  struct termios fd_termios;
-  if (::tcgetattr(m_fd, _termios) == 0) {
-bool set_corectly = false;
-if (enabled) {
-  if (fd_termios.c_lflag & ECHO)
-set_corectly = true;
-  else
-fd_termios.c_lflag |= ECHO;
-} else {
-  if (fd_termios.c_lflag & ECHO)
-fd_termios.c_lflag &= ~ECHO;
-  else
-set_corectly = true;
-}
-
-if (set_corectly)
-  return true;
-return ::tcsetattr(m_fd, TCSANOW, _termios) == 0;
-  }
-}
-#endif // #if LLDB_ENABLE_TERMIOS
-  }
-  return false;
+  if (!IsATerminal())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "fd not a terminal");
+
+  Data data;
+  if (::tcgetattr(m_fd, _termios) != 0)
+return llvm::createStringError(
+std::error_code(errno, std::generic_category()),
+"unable to get teletype attributes");
+  return data;
+#else // !LLDB_ENABLE_TERMIOS
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "termios support missing in LLDB");
+#endif // LLDB_ENABLE_TERMIOS
 }
 
-bool 

[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error [WIP]

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
mgorny requested review of this revision.

Note: this is just the initial patch, I'm doing more refactoring to dedupe the 
code a bit.


https://reviews.llvm.org/D111890

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Target/Process.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -51,11 +51,11 @@
 TEST_F(TerminalTest, SetEcho) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetEcho(true), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ECHO, 0U);
 
-  ASSERT_EQ(m_term.SetEcho(false), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ECHO, 0U);
 }
@@ -63,11 +63,11 @@
 TEST_F(TerminalTest, SetCanonical) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetCanonical(true), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ICANON, 0U);
 
-  ASSERT_EQ(m_term.SetCanonical(false), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -4353,8 +4353,9 @@
 const int read_fd = m_read_file.GetDescriptor();
 Terminal terminal(read_fd);
 TerminalState terminal_state(terminal, false);
-terminal.SetCanonical(false);
-terminal.SetEcho(false);
+// FIXME: error handling?
+llvm::consumeError(terminal.SetCanonical(false));
+llvm::consumeError(terminal.SetEcho(false));
 // FD_ZERO, FD_SET are not supported on windows
 #ifndef _WIN32
 const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -433,8 +433,9 @@
 TerminalState terminal_state(terminal);
 
 if (terminal.IsATerminal()) {
-  terminal.SetCanonical(false);
-  terminal.SetEcho(true);
+  // FIXME: error handling?
+  llvm::consumeError(terminal.SetCanonical(false));
+  llvm::consumeError(terminal.SetEcho(true));
 }
 
 ScriptInterpreterPythonImpl::Locker locker(
Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -23,62 +23,86 @@
 
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
-bool Terminal::SetEcho(bool enabled) {
-  if (FileDescriptorIsValid()) {
+llvm::Error Terminal::SetEcho(bool enabled) {
+  if (!FileDescriptorIsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid fd");
+
 #if LLDB_ENABLE_TERMIOS
-if (IsATerminal()) {
-  struct termios fd_termios;
-  if (::tcgetattr(m_fd, _termios) == 0) {
-bool set_corectly = false;
-if (enabled) {
-  if (fd_termios.c_lflag & ECHO)
-set_corectly = true;
-  else
-fd_termios.c_lflag |= ECHO;
-} else {
-  if (fd_termios.c_lflag & ECHO)
-fd_termios.c_lflag &= ~ECHO;
-  else
-set_corectly = true;
-}
-
-if (set_corectly)
-  return true;
-return ::tcsetattr(m_fd, TCSANOW, _termios) == 0;
-  }
-}
-#endif // #if LLDB_ENABLE_TERMIOS
+  if (!IsATerminal())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "fd not a terminal");
+
+  struct termios fd_termios;
+  if (::tcgetattr(m_fd, _termios) != 0)
+return llvm::createStringError(
+std::error_code(errno, std::generic_category()),
+"unable to get teletype attributes");
+
+  bool set_corectly = false;
+  if (enabled) {
+if (fd_termios.c_lflag & ECHO)
+  set_corectly = true;
+else
+  fd_termios.c_lflag |= ECHO;
+  } else {
+if (fd_termios.c_lflag & ECHO)
+  fd_termios.c_lflag &= ~ECHO;
+else
+  set_corectly = true;
   }
-  return false;
+
+  if (!set_corectly && ::tcsetattr(m_fd, TCSANOW, _termios) != 0)
+

[Lldb-commits] [lldb] 1583c41 - [lldb] [test] Add TestGDBServerTargetXML tests for x86 duplicate subregs

2021-10-15 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-15T16:04:16+02:00
New Revision: 1583c41d07a45a2daa1e9d8347dcea4329794657

URL: 
https://github.com/llvm/llvm-project/commit/1583c41d07a45a2daa1e9d8347dcea4329794657
DIFF: 
https://github.com/llvm/llvm-project/commit/1583c41d07a45a2daa1e9d8347dcea4329794657.diff

LOG: [lldb] [test] Add TestGDBServerTargetXML tests for x86 duplicate subregs

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 35ee8dc090df..0bb332402539 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -567,6 +567,148 @@ def haltReason(self):
 self.match("register read s31",
["s31 = 128"])
 
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("X86")
+def test_x86_64_no_duplicate_subregs(self):
+"""Test that duplicate subregisters are not added (on x86_64)."""
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # rcx
+"1112131415161718"  # rdx
+"2122232425262728"  # rsi
+"3132333435363738"  # rdi
+"4142434445464748"  # rbp
+"5152535455565758"  # rsp
+"6162636465666768"  # r8
+"7172737475767778"  # r9
+"8182838485868788"  # rip
+"91929394"  # eflags
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+  i386:x86-64
+  GNU/Linux
+  
+
+
+
+
+
+
+
+
+
+
+
+  
+""", False
+else:
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def haltReason(self):
+return 
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("basic_eh_frame.yaml")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+
+self.match("register read rcx",
+   ["rcx = 0x0807060504030201"])
+# ecx is supplied via target.xml
+self.match("register read ecx",
+   ["ecx = 0x04030201"])
+self.match("register read rdx",
+   ["rdx = 0x1817161514131211"])
+# edx should not be added
+self.match("register read edx",
+   ["error: Invalid register name 'edx'."],
+   error=True)
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("X86")
+def test_i386_no_duplicate_subregs(self):
+"""Test that duplicate subregisters are not added (on i386)."""
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"01020304"  # eax
+"11121314"  # ecx
+"21222324"  # edx
+"31323334"  # ebx
+"41424344"  # esp
+"51525354"  # ebp
+"61626364"  # esi
+"71727374"  # edi
+"81828384"  # eip
+"91929394"  # eflags
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+  i386
+  GNU/Linux
+  
+
+
+
+
+
+
+
+
+
+
+
+  
+""", False
+else:
+   

[Lldb-commits] [PATCH] D111715: [WIP] [lldb] change name demangling to be consistent between windows and linx

2021-10-15 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added a comment.

Thanks for improving this! Can you please add a few examples in the commit 
description like "before -> after", so it's more obvious what is changing here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111715/new/

https://reviews.llvm.org/D111715

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111877: [lldb] Return StringRef from PluginInterface::GetPluginName

2021-10-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

I'm wondering if some of those should be `std::string` instead, but this is in 
any case a step in the right direction so LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111877/new/

https://reviews.llvm.org/D111877

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e741890 - [lldb] [test] Simplify X86 TestGDBServerTargetXML logic to match AArch64

2021-10-15 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-15T14:15:50+02:00
New Revision: e7418906f5051da329ba0094635aeabd39bf6803

URL: 
https://github.com/llvm/llvm-project/commit/e7418906f5051da329ba0094635aeabd39bf6803
DIFF: 
https://github.com/llvm/llvm-project/commit/e7418906f5051da329ba0094635aeabd39bf6803.diff

LOG: [lldb] [test] Simplify X86 TestGDBServerTargetXML logic to match AArch64

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 59d1302e5502..35ee8dc090df 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -11,36 +11,36 @@ class TestGDBServerTargetXML(GDBRemoteTestBase):
 @skipIfLLVMTargetMissing("X86")
 def test_x86_64_regs(self):
 """Test grabbing various x86_64 registers from gdbserver."""
-reg_data = [
-"0102030405060708",  # rcx
-"1112131415161718",  # rdx
-"2122232425262728",  # rsi
-"3132333435363738",  # rdi
-"4142434445464748",  # rbp
-"5152535455565758",  # rsp
-"6162636465666768",  # r8
-"7172737475767778",  # r9
-"8182838485868788",  # rip
-"91929394",  # eflags
-"0102030405060708090a",  # st0
-"1112131415161718191a",  # st1
-] + 6 * [
-"2122232425262728292a"  # st2..st7
-] + [
-"8182838485868788898a8b8c8d8e8f90",  # xmm0
-"9192939495969798999a9b9c9d9e9fa0",  # xmm1
-] + 14 * [
-"a1a2a3a4a5a6a7a8a9aaabacadaeafb0",  # xmm2..xmm15
-] + [
-"",  # mxcsr
-] + [
-"b1b2b3b4b5b6b7b8b9babbbcbdbebfc0",  # ymm0h
-"c1c2c3c4c5c6c7c8c9cacbcccdcecfd0",  # ymm1h
-] + 14 * [
-"d1d2d3d4d5d6d7d8d9dadbdcdddedfe0",  # ymm2h..ymm15h
-]
-
 class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # rcx
+"1112131415161718"  # rdx
+"2122232425262728"  # rsi
+"3132333435363738"  # rdi
+"4142434445464748"  # rbp
+"5152535455565758"  # rsp
+"6162636465666768"  # r8
+"7172737475767778"  # r9
+"8182838485868788"  # rip
+"91929394"  # eflags
+"0102030405060708090a"  # st0
+"1112131415161718191a"  # st1
+) + 6 * (
+"2122232425262728292a"  # st2..st7
+) + (
+"8182838485868788898a8b8c8d8e8f90"  # xmm0
+"9192939495969798999a9b9c9d9e9fa0"  # xmm1
+) + 14 * (
+"a1a2a3a4a5a6a7a8a9aaabacadaeafb0"  # xmm2..xmm15
+) + (
+""  # mxcsr
+) + (
+"b1b2b3b4b5b6b7b8b9babbbcbdbebfc0"  # ymm0h
+"c1c2c3c4c5c6c7c8c9cacbcccdcecfd0"  # ymm1h
+) + 14 * (
+"d1d2d3d4d5d6d7d8d9dadbdcdddedfe0"  # ymm2h..ymm15h
+)
+
 def qXferRead(self, obj, annex, offset, length):
 if annex == "target.xml":
 return """
@@ -113,9 +113,10 @@ def readRegister(self, regnum):
 return ""
 
 def readRegisters(self):
-return "".join(reg_data)
+return self.reg_data
 
 def writeRegisters(self, reg_hex):
+self.reg_data = reg_hex
 return "OK"
 
 def haltReason(self):
@@ -169,22 +170,16 @@ def haltReason(self):
 
 # test writing into pseudo-registers
 self.runCmd("register write ecx 0xfffefdfc")
-reg_data[0] = "fcfdfeff05060708"
-self.assertPacketLogContains(["G" + "".join(reg_data)])
 self.match("register read rcx",
["rcx = 0x08070605fffefdfc"])
 
 self.runCmd("register write cx 0xfbfa")
-reg_data[0] = "fafbfeff05060708"
-self.assertPacketLogContains(["G" + "".join(reg_data)])
 self.match("register read ecx",
["ecx = 0xfffefbfa"])
 self.match("register read rcx",
["rcx = 0x08070605fffefbfa"])
 
 self.runCmd("register write ch 0xf9")
-reg_data[0] = "faf9feff05060708"
-self.assertPacketLogContains(["G" + "".join(reg_data)])
 self.match("register read cx",
["cx = 0xf9fa"])
 self.match("register read ecx",
@@ -193,8 +188,6 @@ def haltReason(self):
["rcx = 0x08070605fffef9fa"])
 
 self.runCmd("register write 

[Lldb-commits] [PATCH] D111881: [lldb] [ABI/AArch64] Do not add subregs if some of them are present

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf70f9620d9ab: [lldb] [ABI/AArch64] Do not add subregs if 
some of them are present (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111881/new/

https://reviews.llvm.org/D111881

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -582,3 +582,97 @@
 self.runCmd("register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
 self.match("register read s31",
["s31 = 128"])
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("AArch64")
+def test_aarch64_no_duplicate_subregs(self):
+"""Test that duplicate subregisters are not added."""
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # x0
+"1112131415161718"  # x1
+) + 27 * (
+"2122232425262728"  # x2..x28
+) + (
+"3132333435363738"  # x29 (fp)
+"4142434445464748"  # x30 (lr)
+"5152535455565758"  # x31 (sp)
+"6162636465666768"  # pc
+"71727374"  # cpsr
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+  aarch64
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+""", False
+else:
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def haltReason(self):
+return "T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("basic_eh_frame-aarch64.yaml")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+
+self.match("register read x0",
+   ["x0 = 0x0807060504030201"])
+# w0 comes from target.xml
+self.match("register read w0",
+   ["w0 = 0x04030201"])
+self.match("register read x1",
+   ["x1 = 0x1817161514131211"])
+# w1 should not be added
+self.match("register read w1",
+   ["error: Invalid register name 'w1'."],
+   error=True)
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -111,9 +111,6 @@
 
   std::array, 32> x_regs;
   std::array, 32> v_regs;
-  std::bitset<32> have_w_regs;
-  std::bitset<32> have_s_regs;
-  std::bitset<32> have_d_regs;
 
   for (auto it : llvm::enumerate(regs)) {
 lldb_private::DynamicRegisterInfo::Register  = it.value();
@@ -133,14 +130,11 @@
 
 if (get_reg("x"))
   x_regs[reg_num] = it.index();
-if (get_reg("v"))
+else if (get_reg("v"))
   v_regs[reg_num] = it.index();
-if (get_reg("w"))
-  have_w_regs[reg_num] = true;
-if (get_reg("s"))
-  

[Lldb-commits] [lldb] f70f962 - [lldb] [ABI/AArch64] Do not add subregs if some of them are present

2021-10-15 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-15T14:08:37+02:00
New Revision: f70f9620d9abff33cf1553fad6361dc4f3183a9b

URL: 
https://github.com/llvm/llvm-project/commit/f70f9620d9abff33cf1553fad6361dc4f3183a9b
DIFF: 
https://github.com/llvm/llvm-project/commit/f70f9620d9abff33cf1553fad6361dc4f3183a9b.diff

LOG: [lldb] [ABI/AArch64] Do not add subregs if some of them are present

Fix a bug introduced while refactoring ABIAArch64::AugmentRegisterInfo()
that caused subregisters to be added even if they were already present.
Instead, abort immediately if at least one subregister is found
(following ABIX86).  While at it, add a test for that.

Differential Revision: https://reviews.llvm.org/D111881

Added: 


Modified: 
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index da5de9bfa736d..f060d0362c679 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -111,9 +111,6 @@ void ABIAArch64::AugmentRegisterInfo(
 
   std::array, 32> x_regs;
   std::array, 32> v_regs;
-  std::bitset<32> have_w_regs;
-  std::bitset<32> have_s_regs;
-  std::bitset<32> have_d_regs;
 
   for (auto it : llvm::enumerate(regs)) {
 lldb_private::DynamicRegisterInfo::Register  = it.value();
@@ -133,14 +130,11 @@ void ABIAArch64::AugmentRegisterInfo(
 
 if (get_reg("x"))
   x_regs[reg_num] = it.index();
-if (get_reg("v"))
+else if (get_reg("v"))
   v_regs[reg_num] = it.index();
-if (get_reg("w"))
-  have_w_regs[reg_num] = true;
-if (get_reg("s"))
-  have_s_regs[reg_num] = true;
-if (get_reg("d"))
-  have_d_regs[reg_num] = true;
+// if we have at least one subregister, abort
+else if (get_reg("w") || get_reg("s") || get_reg("d"))
+  return;
   }
 
   // Create aliases for partial registers: wN for xN, and sN/dN for vN.

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 27aceb7378d1a..59d1302e55021 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -582,3 +582,97 @@ def haltReason(self):
 self.runCmd("register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 
0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
 self.match("register read s31",
["s31 = 128"])
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("AArch64")
+def test_aarch64_no_duplicate_subregs(self):
+"""Test that duplicate subregisters are not added."""
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # x0
+"1112131415161718"  # x1
+) + 27 * (
+"2122232425262728"  # x2..x28
+) + (
+"3132333435363738"  # x29 (fp)
+"4142434445464748"  # x30 (lr)
+"5152535455565758"  # x31 (sp)
+"6162636465666768"  # pc
+"71727374"  # cpsr
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+  aarch64
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+""", False
+else:
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return 

[Lldb-commits] [PATCH] D111881: [lldb] [ABI/AArch64] Do not add subregs if some of them are present

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
Herald added subscribers: pengfei, kristof.beyls.
mgorny requested review of this revision.

Fix a bug introduced while refactoring ABIAArch64::AugmentRegisterInfo()
that caused subregisters to be added even if they were already present.
Instead, abort immediately if at least one subregister is found
(following ABIX86).  While at it, add a test for that.


https://reviews.llvm.org/D111881

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -582,3 +582,97 @@
 self.runCmd("register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
 self.match("register read s31",
["s31 = 128"])
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("AArch64")
+def test_aarch64_no_duplicate_subregs(self):
+"""Test that duplicate subregisters are not added."""
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # x0
+"1112131415161718"  # x1
+) + 27 * (
+"2122232425262728"  # x2..x28
+) + (
+"3132333435363738"  # x29 (fp)
+"4142434445464748"  # x30 (lr)
+"5152535455565758"  # x31 (sp)
+"6162636465666768"  # pc
+"71727374"  # cpsr
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+  aarch64
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+""", False
+else:
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def haltReason(self):
+return "T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("basic_eh_frame-aarch64.yaml")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+
+self.match("register read x0",
+   ["x0 = 0x0807060504030201"])
+# w0 comes from target.xml
+self.match("register read w0",
+   ["w0 = 0x04030201"])
+self.match("register read x1",
+   ["x1 = 0x1817161514131211"])
+# w1 should not be added
+self.match("register read w1",
+   ["error: Invalid register name 'w1'."],
+   error=True)
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -111,9 +111,6 @@
 
   std::array, 32> x_regs;
   std::array, 32> v_regs;
-  std::bitset<32> have_w_regs;
-  std::bitset<32> have_s_regs;
-  std::bitset<32> have_d_regs;
 
   for (auto it : llvm::enumerate(regs)) {
 lldb_private::DynamicRegisterInfo::Register  = it.value();
@@ -133,14 +130,11 @@
 
 if (get_reg("x"))
   x_regs[reg_num] = it.index();
-if (get_reg("v"))
+else if (get_reg("v"))
   

[Lldb-commits] [PATCH] D108831: [lldb] [ABI/X86] Add pseudo-registers if missing

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2712d1814860: [lldb] [ABI/X86] Add pseudo-registers if 
missing (authored by mgorny).
Herald added a subscriber: thopre.
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D108831?vs=379921=379961#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108831/new/

https://reviews.llvm.org/D108831

Files:
  lldb/source/Plugins/ABI/X86/ABIX86.cpp
  lldb/source/Plugins/ABI/X86/ABIX86.h
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
  lldb/test/API/functionalities/gdb_remote_client/amd64-partial-regs.FileCheck

Index: lldb/test/API/functionalities/gdb_remote_client/amd64-partial-regs.FileCheck
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/amd64-partial-regs.FileCheck
@@ -0,0 +1,34 @@
+CHECK-DAG: ecx = 0x04030201
+CHECK-DAG: edx = 0x14131211
+CHECK-DAG: esi = 0x24232221
+CHECK-DAG: edi = 0x34333231
+CHECK-DAG: ebp = 0x44434241
+CHECK-DAG: esp = 0x54535251
+CHECK-DAG: r8d = 0x64636261
+CHECK-DAG: r9d = 0x74737271
+CHECK-DAG:  cx = 0x0201
+CHECK-DAG:  dx = 0x1211
+CHECK-DAG:  si = 0x2221
+CHECK-DAG:  di = 0x3231
+CHECK-DAG:  bp = 0x4241
+CHECK-DAG:  sp = 0x5251
+CHECK-DAG: r8w = 0x6261
+CHECK-DAG: r9w = 0x7271
+CHECK-DAG:  ch = 0x02
+CHECK-DAG:  dh = 0x12
+CHECK-DAG:  cl = 0x01
+CHECK-DAG:  dl = 0x11
+CHECK-DAG: sil = 0x21
+CHECK-DAG: dil = 0x31
+CHECK-DAG: bpl = 0x41
+CHECK-DAG: spl = 0x51
+CHECK-DAG: r8l = 0x61
+CHECK-DAG: r9l = 0x71
+CHECK-DAG: mm0 = 0x0807060504030201
+CHECK-DAG: mm1 = 0x1817161514131211
+CHECK-DAG: mm2 = 0x2827262524232221
+CHECK-DAG: mm3 = 0x2827262524232221
+CHECK-DAG: mm4 = 0x2827262524232221
+CHECK-DAG: mm5 = 0x2827262524232221
+CHECK-DAG: mm6 = 0x2827262524232221
+CHECK-DAG: mm7 = 0x2827262524232221
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -6,7 +6,6 @@
 
 
 class TestGDBServerTargetXML(GDBRemoteTestBase):
-
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
@@ -163,6 +162,52 @@
["xmm1 = {0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 "
 "0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0}"])
 
+# test pseudo-registers
+self.filecheck("register read --all",
+   os.path.join(os.path.dirname(__file__),
+"amd64-partial-regs.FileCheck"))
+
+# test writing into pseudo-registers
+self.runCmd("register write ecx 0xfffefdfc")
+reg_data[0] = "fcfdfeff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffefdfc"])
+
+self.runCmd("register write cx 0xfbfa")
+reg_data[0] = "fafbfeff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read ecx",
+   ["ecx = 0xfffefbfa"])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffefbfa"])
+
+self.runCmd("register write ch 0xf9")
+reg_data[0] = "faf9feff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read cx",
+   ["cx = 0xf9fa"])
+self.match("register read ecx",
+   ["ecx = 0xfffef9fa"])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffef9fa"])
+
+self.runCmd("register write cl 0xf8")
+reg_data[0] = "f8f9feff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read cx",
+   ["cx = 0xf9f8"])
+self.match("register read ecx",
+   ["ecx = 0xfffef9f8"])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffef9f8"])
+
+self.runCmd("register write mm0 0xfffefdfcfbfaf9f8")
+reg_data[10] = "f8f9fafbfcfdfeff090a"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read st0",
+   ["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"])
+
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
@@ -272,11 +317,25 @@
 # test generic aliases
 self.match("register read fp",
["ebp = 0x54535251"])
+self.match("register read sp",
+   ["esp = 0x44434241"])
 self.match("register read pc",
["eip = 0x84838281"])
 self.match("register read flags",
["eflags = 0x94939291"])
 
+

[Lldb-commits] [PATCH] D111489: [lldb] [DynamicRegisterInfo] Support value_regs with offset

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0d1705a9d623: [lldb] [DynamicRegisterInfo] Support 
value_regs with offset (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D111489?vs=378444=379960#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111489/new/

https://reviews.llvm.org/D111489

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/unittests/Target/DynamicRegisterInfoTest.cpp


Index: lldb/unittests/Target/DynamicRegisterInfoTest.cpp
===
--- lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -203,12 +203,23 @@
   };
   uint32_t eax = AddTestRegister("eax", "supplementary", 4, suppl_adder, 
{rax});
   uint32_t ax = AddTestRegister("ax", "supplementary", 2, suppl_adder, {rax});
+  uint32_t ah = AddTestRegister("ah", "supplementary", 1, suppl_adder, {rax});
   uint32_t al = AddTestRegister("al", "supplementary", 1, suppl_adder, {rax});
+  m_regs[ah].value_reg_offset = 1;
 
-  EXPECT_IN_REGS(rax, {}, {eax, ax, al});
-  EXPECT_IN_REGS(eax, {rax}, {rax, ax, al});
-  EXPECT_IN_REGS(ax, {rax}, {rax, eax, al});
-  EXPECT_IN_REGS(al, {rax}, {rax, eax, ax});
+  EXPECT_IN_REGS(rax, {}, {eax, ax, ah, al});
+  EXPECT_IN_REGS(eax, {rax}, {rax, ax, ah, al});
+  EXPECT_IN_REGS(ax, {rax}, {rax, eax, ah, al});
+  EXPECT_IN_REGS(ah, {rax}, {rax, eax, ax, al});
+  EXPECT_IN_REGS(al, {rax}, {rax, eax, ax, ah});
+
+  EXPECT_EQ(m_dyninfo.SetRegisterInfo(std::move(m_regs), ArchSpec()),
+m_regs.size());
+  EXPECT_IN_DYNINFO(rax, 0, {}, {eax, ax, ah, al});
+  EXPECT_IN_DYNINFO(eax, 0, {rax}, {rax, ax, ah, al});
+  EXPECT_IN_DYNINFO(ax, 0, {rax}, {rax, eax, ah, al});
+  EXPECT_IN_DYNINFO(ah, 1, {rax}, {rax, eax, ax, al});
+  EXPECT_IN_DYNINFO(al, 0, {rax}, {rax, eax, ax, ah});
 }
 
 TEST_F(DynamicRegisterInfoRegisterTest, SetRegisterInfo) {
Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -395,6 +395,10 @@
   m_value_regs_map[local_regnum] = std::move(reg.value_regs);
 if (!reg.invalidate_regs.empty())
   m_invalidate_regs_map[local_regnum] = std::move(reg.invalidate_regs);
+if (reg.value_reg_offset != 0) {
+  assert(reg.value_regs.size() == 1);
+  m_value_reg_offset_map[local_regnum] = reg.value_reg_offset;
+}
 
 struct RegisterInfo reg_info {
   reg.name.AsCString(), reg.alt_name.AsCString(), reg.byte_size,
@@ -679,8 +683,12 @@
   // as that of their corresponding primary register in value_regs list.
   if (reg.byte_offset == LLDB_INVALID_INDEX32) {
 uint32_t value_regnum = reg.value_regs[0];
-if (value_regnum != LLDB_INVALID_INDEX32)
+if (value_regnum != LLDB_INVALID_INDEX32) {
   reg.byte_offset = GetRegisterInfoAtIndex(value_regnum)->byte_offset;
+  auto it = m_value_reg_offset_map.find(reg.kinds[eRegisterKindLLDB]);
+  if (it != m_value_reg_offset_map.end())
+reg.byte_offset += it->second;
+}
   }
 }
 
Index: lldb/include/lldb/Target/DynamicRegisterInfo.h
===
--- lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -38,6 +38,7 @@
 uint32_t regnum_remote = LLDB_INVALID_REGNUM;
 std::vector value_regs;
 std::vector invalidate_regs;
+uint32_t value_reg_offset = 0;
   };
 
   DynamicRegisterInfo() = default;
@@ -101,6 +102,7 @@
   typedef std::vector set_reg_num_collection;
   typedef std::vector name_collection;
   typedef std::map reg_to_regs_map;
+  typedef std::map reg_offset_map;
 
   llvm::Expected ByteOffsetFromSlice(uint32_t index,
llvm::StringRef slice_str,
@@ -122,6 +124,7 @@
   name_collection m_set_names;
   reg_to_regs_map m_value_regs_map;
   reg_to_regs_map m_invalidate_regs_map;
+  reg_offset_map m_value_reg_offset_map;
   size_t m_reg_data_byte_size = 0u; // The number of bytes required to store
 // all registers
   bool m_finalized = false;


Index: lldb/unittests/Target/DynamicRegisterInfoTest.cpp
===
--- lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -203,12 +203,23 @@
   };
   uint32_t eax = AddTestRegister("eax", "supplementary", 4, suppl_adder, {rax});
   uint32_t ax = AddTestRegister("ax", "supplementary", 2, suppl_adder, {rax});
+  uint32_t ah = AddTestRegister("ah", "supplementary", 1, suppl_adder, 

[Lldb-commits] [lldb] 2712d18 - [lldb] [ABI/X86] Add pseudo-registers if missing

2021-10-15 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-15T12:55:03+02:00
New Revision: 2712d1814860600136546945f7a003dfe56f307a

URL: 
https://github.com/llvm/llvm-project/commit/2712d1814860600136546945f7a003dfe56f307a
DIFF: 
https://github.com/llvm/llvm-project/commit/2712d1814860600136546945f7a003dfe56f307a.diff

LOG: [lldb] [ABI/X86] Add pseudo-registers if missing

Differential Revision: https://reviews.llvm.org/D108831

Added: 
lldb/test/API/functionalities/gdb_remote_client/amd64-partial-regs.FileCheck

Modified: 
lldb/source/Plugins/ABI/X86/ABIX86.cpp
lldb/source/Plugins/ABI/X86/ABIX86.h
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp 
b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index c02680009e3ea..0286140e4e24c 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -6,12 +6,16 @@
 //
 
//===--===//
 
-#include "ABIX86.h"
 #include "ABIMacOSX_i386.h"
 #include "ABISysV_i386.h"
 #include "ABISysV_x86_64.h"
 #include "ABIWindows_x86_64.h"
+#include "ABIX86.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Target/Process.h"
+
+using namespace lldb;
+using namespace lldb_private;
 
 LLDB_PLUGIN_DEFINE(ABIX86)
 
@@ -28,3 +32,142 @@ void ABIX86::Terminate() {
   ABISysV_x86_64::Terminate();
   ABIWindows_x86_64::Terminate();
 }
+
+enum class RegKind {
+  GPR32 = 0,
+  GPR16,
+  GPR8h,
+  GPR8,
+
+  MM = 0,
+};
+
+typedef llvm::SmallDenseMap, 16>
+RegisterMap;
+
+static void addPartialRegisters(
+std::vector ,
+llvm::ArrayRef base_reg_indices, const RegisterMap _names,
+uint32_t base_size, RegKind name_index, lldb::Encoding encoding,
+lldb::Format format, uint32_t subreg_size, uint32_t subreg_offset = 0) {
+  for (uint32_t base_index : base_reg_indices) {
+if (base_index == LLDB_INVALID_REGNUM)
+  break;
+assert(base_index < regs.size());
+DynamicRegisterInfo::Register _reg = regs[base_index];
+llvm::StringRef subreg_name = reg_names.lookup(
+full_reg.name.GetStringRef())[static_cast(name_index)];
+if (subreg_name.empty() || full_reg.byte_size != base_size)
+  continue;
+
+lldb_private::DynamicRegisterInfo::Register subreg{
+lldb_private::ConstString(subreg_name),
+lldb_private::ConstString(),
+lldb_private::ConstString("supplementary registers"),
+subreg_size,
+LLDB_INVALID_INDEX32,
+encoding,
+format,
+LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,
+{base_index},
+{},
+subreg_offset};
+
+addSupplementaryRegister(regs, subreg);
+  }
+}
+
+void ABIX86::AugmentRegisterInfo(
+std::vector ) {
+  MCBasedABI::AugmentRegisterInfo(regs);
+
+  ProcessSP process_sp = GetProcessSP();
+  if (!process_sp)
+return;
+
+  uint32_t gpr_base_size =
+  process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
+  bool is64bit = gpr_base_size == 8;
+
+  typedef RegisterMap::value_type RegPair;
+#define GPR_BASE(basename) (is64bit ? "r" basename : "e" basename)
+  RegisterMap gpr_regs{{
+  RegPair(GPR_BASE("ax"), {"eax", "ax", "ah", "al"}),
+  RegPair(GPR_BASE("bx"), {"ebx", "bx", "bh", "bl"}),
+  RegPair(GPR_BASE("cx"), {"ecx", "cx", "ch", "cl"}),
+  RegPair(GPR_BASE("dx"), {"edx", "dx", "dh", "dl"}),
+  RegPair(GPR_BASE("si"), {"esi", "si", "", "sil"}),
+  RegPair(GPR_BASE("di"), {"edi", "di", "", "dil"}),
+  RegPair(GPR_BASE("bp"), {"ebp", "bp", "", "bpl"}),
+  RegPair(GPR_BASE("sp"), {"esp", "sp", "", "spl"}),
+  }};
+#undef GPR_BASE
+  if (is64bit) {
+#define R(base) RegPair(base, {base "d", base "w", "", base "l"})
+RegisterMap amd64_regs{{
+R("r8"),
+R("r9"),
+R("r10"),
+R("r11"),
+R("r12"),
+R("r13"),
+R("r14"),
+R("r15"),
+}};
+#undef R
+gpr_regs.insert(amd64_regs.begin(), amd64_regs.end());
+  }
+
+  RegisterMap st_regs{{
+  RegPair("st0", {"mm0"}),
+  RegPair("st1", {"mm1"}),
+  RegPair("st2", {"mm2"}),
+  RegPair("st3", {"mm3"}),
+  RegPair("st4", {"mm4"}),
+  RegPair("st5", {"mm5"}),
+  RegPair("st6", {"mm6"}),
+  RegPair("st7", {"mm7"}),
+  }};
+
+  // regs from gpr_basenames, in list order
+  std::vector gpr_base_reg_indices;
+  // st0..st7, in list order
+  std::vector st_reg_indices;
+  // map used for fast register lookups
+  llvm::SmallDenseSet subreg_name_set;
+
+  // put all subreg names into the lookup set
+  for (const RegisterMap  : {gpr_regs, st_regs}) {
+for (const RegPair  : regset)
+  subreg_name_set.insert(kv.second.begin(), kv.second.end());
+  }
+
+  for (const auto  : llvm::enumerate(regs)) {
+llvm::StringRef reg_name = 

[Lldb-commits] [lldb] 0d1705a - [lldb] [DynamicRegisterInfo] Support value_regs with offset

2021-10-15 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-15T12:55:02+02:00
New Revision: 0d1705a9d62301c84977abe6a986d9af1989072f

URL: 
https://github.com/llvm/llvm-project/commit/0d1705a9d62301c84977abe6a986d9af1989072f
DIFF: 
https://github.com/llvm/llvm-project/commit/0d1705a9d62301c84977abe6a986d9af1989072f.diff

LOG: [lldb] [DynamicRegisterInfo] Support value_regs with offset

Support specifying an offset for value_regs[0], and add the offset
to the computed derived register offset.  This makes it possible to
e.g. create the "ah" register on x86.

Differential Revision: https://reviews.llvm.org/D111489

Added: 


Modified: 
lldb/include/lldb/Target/DynamicRegisterInfo.h
lldb/source/Target/DynamicRegisterInfo.cpp
lldb/unittests/Target/DynamicRegisterInfoTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index df4c1a64cb339..e5395f0171afc 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -38,6 +38,7 @@ class DynamicRegisterInfo {
 uint32_t regnum_remote = LLDB_INVALID_REGNUM;
 std::vector value_regs;
 std::vector invalidate_regs;
+uint32_t value_reg_offset = 0;
   };
 
   DynamicRegisterInfo() = default;
@@ -101,6 +102,7 @@ class DynamicRegisterInfo {
   typedef std::vector set_reg_num_collection;
   typedef std::vector name_collection;
   typedef std::map reg_to_regs_map;
+  typedef std::map reg_offset_map;
 
   llvm::Expected ByteOffsetFromSlice(uint32_t index,
llvm::StringRef slice_str,
@@ -122,6 +124,7 @@ class DynamicRegisterInfo {
   name_collection m_set_names;
   reg_to_regs_map m_value_regs_map;
   reg_to_regs_map m_invalidate_regs_map;
+  reg_offset_map m_value_reg_offset_map;
   size_t m_reg_data_byte_size = 0u; // The number of bytes required to store
 // all registers
   bool m_finalized = false;

diff  --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index bd56c239a574c..d196c95c081d6 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -395,6 +395,10 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
   m_value_regs_map[local_regnum] = std::move(reg.value_regs);
 if (!reg.invalidate_regs.empty())
   m_invalidate_regs_map[local_regnum] = std::move(reg.invalidate_regs);
+if (reg.value_reg_offset != 0) {
+  assert(reg.value_regs.size() == 1);
+  m_value_reg_offset_map[local_regnum] = reg.value_reg_offset;
+}
 
 struct RegisterInfo reg_info {
   reg.name.AsCString(), reg.alt_name.AsCString(), reg.byte_size,
@@ -679,8 +683,12 @@ void DynamicRegisterInfo::ConfigureOffsets() {
   // as that of their corresponding primary register in value_regs list.
   if (reg.byte_offset == LLDB_INVALID_INDEX32) {
 uint32_t value_regnum = reg.value_regs[0];
-if (value_regnum != LLDB_INVALID_INDEX32)
+if (value_regnum != LLDB_INVALID_INDEX32) {
   reg.byte_offset = GetRegisterInfoAtIndex(value_regnum)->byte_offset;
+  auto it = m_value_reg_offset_map.find(reg.kinds[eRegisterKindLLDB]);
+  if (it != m_value_reg_offset_map.end())
+reg.byte_offset += it->second;
+}
   }
 }
 

diff  --git a/lldb/unittests/Target/DynamicRegisterInfoTest.cpp 
b/lldb/unittests/Target/DynamicRegisterInfoTest.cpp
index 94c533721ab9f..f027602d5a969 100644
--- a/lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ b/lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -203,12 +203,23 @@ TEST_F(DynamicRegisterInfoRegisterTest, 
addSupplementaryRegister) {
   };
   uint32_t eax = AddTestRegister("eax", "supplementary", 4, suppl_adder, 
{rax});
   uint32_t ax = AddTestRegister("ax", "supplementary", 2, suppl_adder, {rax});
+  uint32_t ah = AddTestRegister("ah", "supplementary", 1, suppl_adder, {rax});
   uint32_t al = AddTestRegister("al", "supplementary", 1, suppl_adder, {rax});
+  m_regs[ah].value_reg_offset = 1;
 
-  EXPECT_IN_REGS(rax, {}, {eax, ax, al});
-  EXPECT_IN_REGS(eax, {rax}, {rax, ax, al});
-  EXPECT_IN_REGS(ax, {rax}, {rax, eax, al});
-  EXPECT_IN_REGS(al, {rax}, {rax, eax, ax});
+  EXPECT_IN_REGS(rax, {}, {eax, ax, ah, al});
+  EXPECT_IN_REGS(eax, {rax}, {rax, ax, ah, al});
+  EXPECT_IN_REGS(ax, {rax}, {rax, eax, ah, al});
+  EXPECT_IN_REGS(ah, {rax}, {rax, eax, ax, al});
+  EXPECT_IN_REGS(al, {rax}, {rax, eax, ax, ah});
+
+  EXPECT_EQ(m_dyninfo.SetRegisterInfo(std::move(m_regs), ArchSpec()),
+m_regs.size());
+  EXPECT_IN_DYNINFO(rax, 0, {}, {eax, ax, ah, al});
+  EXPECT_IN_DYNINFO(eax, 0, {rax}, {rax, ax, ah, al});
+  EXPECT_IN_DYNINFO(ax, 0, {rax}, {rax, eax, ah, al});
+  EXPECT_IN_DYNINFO(ah, 1, {rax}, {rax, eax, ax, al});
+  EXPECT_IN_DYNINFO(al, 0, {rax}, {rax, eax, 

[Lldb-commits] [lldb] bc9b106 - [lldb] Fix an include in HostTest.cpp

2021-10-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-15T11:10:38+02:00
New Revision: bc9b106a5750cf05ddab1dfce2a77d73bcc7d44a

URL: 
https://github.com/llvm/llvm-project/commit/bc9b106a5750cf05ddab1dfce2a77d73bcc7d44a
DIFF: 
https://github.com/llvm/llvm-project/commit/bc9b106a5750cf05ddab1dfce2a77d73bcc7d44a.diff

LOG: [lldb] Fix an include in HostTest.cpp

The previous include was too broad, and its better if the host tests do
not depend on non-host libraries.

Added: 


Modified: 
lldb/unittests/Host/linux/HostTest.cpp

Removed: 




diff  --git a/lldb/unittests/Host/linux/HostTest.cpp 
b/lldb/unittests/Host/linux/HostTest.cpp
index 699ccba0a9849..78bbe470d6953 100644
--- a/lldb/unittests/Host/linux/HostTest.cpp
+++ b/lldb/unittests/Host/linux/HostTest.cpp
@@ -9,7 +9,7 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "gtest/gtest.h"
 
 using namespace lldb_private;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108831: [lldb] [ABI/X86] Add pseudo-registers if missing

2021-10-15 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I think we've managed to come to something that looks mostly reasonable.




Comment at: lldb/source/Plugins/ABI/X86/ABIX86.cpp:51
+std::vector ,
+llvm::ArrayRef base_reg_indices, RegisterMap reg_names,
+uint32_t base_size, RegKind name_index, lldb::Encoding encoding,

const RegisterMap& -- it's expensive to copy



Comment at: lldb/source/Plugins/ABI/X86/ABIX86.cpp:59
+DynamicRegisterInfo::Register _reg = regs[base_index];
+const llvm::StringRef _name =
+reg_names[full_reg.name.GetStringRef()][static_cast(name_index)];

drop const & -- it's cheap to copy :)



Comment at: lldb/source/Plugins/ABI/X86/ABIX86.cpp:92-94
+  bool is64bit =
+  process_sp->GetTarget().GetArchitecture().GetAddressByteSize() == 8;
+  uint32_t gpr_base_size = is64bit ? 8 : 4;

how about you reverse this, so you set gpr_base_size first, and then use that 
to initialize is64bit?



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py:343
 
+# test pseudo-registers
+self.match("register read cx",

Maybe also do a `register read --all` and check that all (sub)registers are 
present and have the expected values (you can try using `self.filecheck` for 
that).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108831/new/

https://reviews.llvm.org/D108831

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 35d7101 - Use Module's FileSpec for limiting binaries to set dyld breakpoint in

2021-10-15 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2021-10-14T23:58:23-07:00
New Revision: 35d710148b98e2ec52056271e7f9103620593b7a

URL: 
https://github.com/llvm/llvm-project/commit/35d710148b98e2ec52056271e7f9103620593b7a
DIFF: 
https://github.com/llvm/llvm-project/commit/35d710148b98e2ec52056271e7f9103620593b7a.diff

LOG: Use Module's FileSpec for limiting binaries to set dyld breakpoint in

When DynamicLoaderMacOS::SetNotificationBreakpoint sets the breakpoint
for new binaries being loaded/unloaded, it limits the scope of that
breakpoint to just dyld, so we don't re-evaluate the breakpoint for
every new binary loaded.  I wrote this to get the module's ObjectFile
FileSpec in an earlier change, but this is not correct.  If lldb
is debugging a remote system, and it had to read dyld out of memory
from the remote system, it will have no FileSpec on the lldb debugger
host.  We need to grab the Module's FileSpec, which in this case is
actually falling back to the PlatformFileSpec, the binary path on the
target system.

rdar://84199646

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 7a4294b43969..bedd100e147e 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -350,7 +350,7 @@ bool DynamicLoaderMacOS::SetNotificationBreakpoint() {
   LazyBool skip_prologue = eLazyBoolNo;
   FileSpecList *source_files = nullptr;
   FileSpecList dyld_filelist;
-  dyld_filelist.Append(dyld_sp->GetObjectFile()->GetFileSpec());
+  dyld_filelist.Append(dyld_sp->GetFileSpec());
 
   Breakpoint *breakpoint =
   m_process->GetTarget()



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 7c704c0 - [NFC] fix a typo

2021-10-15 Thread Shao-Ce SUN via lldb-commits

Author: Shao-Ce SUN
Date: 2021-10-15T14:51:49+08:00
New Revision: 7c704c0f53bd7f785ec99fc6bedd71569816a28c

URL: 
https://github.com/llvm/llvm-project/commit/7c704c0f53bd7f785ec99fc6bedd71569816a28c
DIFF: 
https://github.com/llvm/llvm-project/commit/7c704c0f53bd7f785ec99fc6bedd71569816a28c.diff

LOG: [NFC] fix a typo

Added: 


Modified: 
lldb/bindings/interface/SBSymbolContextList.i
lldb/test/API/python_api/target/TestTargetAPI.py
llvm/tools/llvm-mca/CodeRegionGenerator.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBSymbolContextList.i 
b/lldb/bindings/interface/SBSymbolContextList.i
index e9d4aa8d62db..14566b3e3720 100644
--- a/lldb/bindings/interface/SBSymbolContextList.i
+++ b/lldb/bindings/interface/SBSymbolContextList.i
@@ -14,7 +14,7 @@ namespace lldb {
 For example (from test/python_api/target/TestTargetAPI.py), ::
 
 def find_functions(self, exe_name):
-'''Exercise SBTaget.FindFunctions() API.'''
+'''Exercise SBTarget.FindFunctions() API.'''
 exe = os.path.join(os.getcwd(), exe_name)
 
 # Create a target by the debugger.

diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py 
b/lldb/test/API/python_api/target/TestTargetAPI.py
index 29e368224e81..0503aa8e4369 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -207,7 +207,7 @@ def find_data_section(self, target):
 return data_section
 
 def find_global_variables(self, exe_name):
-"""Exercise SBTaget.FindGlobalVariables() API."""
+"""Exercise SBTarget.FindGlobalVariables() API."""
 exe = self.getBuildArtifact(exe_name)
 
 # Create a target by the debugger.
@@ -272,7 +272,7 @@ def find_compile_units(self, exe):
 list[0].GetCompileUnit().GetFileSpec().GetFilename(), source_name)
 
 def find_functions(self, exe_name):
-"""Exercise SBTaget.FindFunctions() API."""
+"""Exercise SBTarget.FindFunctions() API."""
 exe = self.getBuildArtifact(exe_name)
 
 # Create a target by the debugger.
@@ -292,7 +292,7 @@ def find_functions(self, exe_name):
 self.assertEqual(sc.GetSymbol().GetName(), 'c')
 
 def get_description(self):
-"""Exercise SBTaget.GetDescription() API."""
+"""Exercise SBTarget.GetDescription() API."""
 exe = self.getBuildArtifact("a.out")
 
 # Create a target by the debugger.
@@ -321,7 +321,7 @@ def get_description(self):
 @skipIfRemote
 @no_debug_info_test
 def test_launch_new_process_and_redirect_stdout(self):
-"""Exercise SBTaget.Launch() API with redirected stdout."""
+"""Exercise SBTarget.Launch() API with redirected stdout."""
 self.build()
 exe = self.getBuildArtifact("a.out")
 
@@ -380,7 +380,7 @@ def test_launch_new_process_and_redirect_stdout(self):
 substrs=["a(1)", "b(2)", "a(3)"])
 
 def resolve_symbol_context_with_address(self):
-"""Exercise SBTaget.ResolveSymbolContextForAddress() API."""
+"""Exercise SBTarget.ResolveSymbolContextForAddress() API."""
 exe = self.getBuildArtifact("a.out")
 
 # Create a target by the debugger.

diff  --git a/llvm/tools/llvm-mca/CodeRegionGenerator.cpp 
b/llvm/tools/llvm-mca/CodeRegionGenerator.cpp
index 6ad2a65592b9..6cdd0ba797aa 100644
--- a/llvm/tools/llvm-mca/CodeRegionGenerator.cpp
+++ b/llvm/tools/llvm-mca/CodeRegionGenerator.cpp
@@ -114,7 +114,7 @@ Expected 
AsmCodeRegionGenerator::parseCodeRegions(
 
   // Need to initialize an MCTargetStreamer otherwise
   // certain asm directives will cause a segfault.
-  // Using nulls() so that anything emitted by the MCTagetStreamer
+  // Using nulls() so that anything emitted by the MCTargetStreamer
   // doesn't show up in the llvm-mca output.
   raw_ostream  = nulls();
   formatted_raw_ostream FOSRef(OSRef);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108831: [lldb] [ABI/X86] Add pseudo-registers if missing

2021-10-15 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 379921.
mgorny added a comment.

Use `ConstString::GetStringRef()` directly instead of converting through `const 
char *`. Not that it has any practical difference right now…


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108831/new/

https://reviews.llvm.org/D108831

Files:
  lldb/source/Plugins/ABI/X86/ABIX86.cpp
  lldb/source/Plugins/ABI/X86/ABIX86.h
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -163,6 +163,67 @@
["xmm1 = {0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 "
 "0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0}"])
 
+# test pseudo-registers
+self.match("register read ecx",
+   ["ecx = 0x04030201"])
+self.match("register read cx",
+   ["cx = 0x0201"])
+self.match("register read ch",
+   ["ch = 0x02"])
+self.match("register read cl",
+   ["cl = 0x01"])
+self.match("register read r8d",
+   ["r8d = 0x64636261"])
+self.match("register read r8w",
+   ["r8w = 0x6261"])
+self.match("register read r8l",
+   ["r8l = 0x61"])
+self.match("register read mm0",
+   ["mm0 = 0x0807060504030201"])
+self.match("register read mm1",
+   ["mm1 = 0x1817161514131211"])
+
+# test writing into pseudo-registers
+self.runCmd("register write ecx 0xfffefdfc")
+reg_data[0] = "fcfdfeff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffefdfc"])
+
+self.runCmd("register write cx 0xfbfa")
+reg_data[0] = "fafbfeff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read ecx",
+   ["ecx = 0xfffefbfa"])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffefbfa"])
+
+self.runCmd("register write ch 0xf9")
+reg_data[0] = "faf9feff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read cx",
+   ["cx = 0xf9fa"])
+self.match("register read ecx",
+   ["ecx = 0xfffef9fa"])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffef9fa"])
+
+self.runCmd("register write cl 0xf8")
+reg_data[0] = "f8f9feff05060708"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read cx",
+   ["cx = 0xf9f8"])
+self.match("register read ecx",
+   ["ecx = 0xfffef9f8"])
+self.match("register read rcx",
+   ["rcx = 0x08070605fffef9f8"])
+
+self.runCmd("register write mm0 0xfffefdfcfbfaf9f8")
+reg_data[10] = "f8f9fafbfcfdfeff090a"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read st0",
+   ["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"])
+
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
@@ -272,11 +333,25 @@
 # test generic aliases
 self.match("register read fp",
["ebp = 0x54535251"])
+self.match("register read sp",
+   ["esp = 0x44434241"])
 self.match("register read pc",
["eip = 0x84838281"])
 self.match("register read flags",
["eflags = 0x94939291"])
 
+# test pseudo-registers
+self.match("register read cx",
+   ["cx = 0x1211"])
+self.match("register read ch",
+   ["ch = 0x12"])
+self.match("register read cl",
+   ["cl = 0x11"])
+self.match("register read mm0",
+   ["mm0 = 0x0807060504030201"])
+self.match("register read mm1",
+   ["mm1 = 0x1817161514131211"])
+
 # both stX and xmmX should be displayed as vectors
 self.match("register read st0",
["st0 = {0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a}"])
@@ -289,6 +364,35 @@
["xmm1 = {0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 "
 "0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0}"])
 
+# test writing into pseudo-registers
+self.runCmd("register write cx 0xfbfa")
+reg_data[1] = "fafb1314"
+self.assertPacketLogContains(["G" + "".join(reg_data)])
+self.match("register read ecx",
+   ["ecx = 0x1413fbfa"])