[Lldb-commits] [lldb] ac031c8 - Revert "[lldb] Set return status to failed when adding a command error" (and fixups)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 14 05:11:01 PDT 2021


Author: David Spickett
Date: 2021-06-14T12:09:42Z
New Revision: ac031c8db2ce454a9b08f23192ce698e8bde4447

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

LOG: Revert "[lldb] Set return status to failed when adding a command error" (and fixups)

This reverts commit f583029da3d6dbabe82f48b160227eb0120abd33,
0f94d68a2e15d50796439f20bcb508b95931d2ae and
a2363c0cf9b6a9a81c76ac652da667f73845d38b.

Due to test failures from incorrect SB API usage.

Added: 
    lldb/test/Shell/Commands/command-backtrace.test

Modified: 
    lldb/source/Interpreter/CommandReturnObject.cpp
    lldb/test/API/commands/register/register/register_command/TestRegisters.py

Removed: 
    lldb/test/Shell/Commands/command-backtrace-parser-1.test
    lldb/test/Shell/Commands/command-backtrace-parser-2.test


################################################################################
diff  --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index 531c1f246bd86..c3f32a4c45a9e 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -44,8 +44,6 @@ CommandReturnObject::CommandReturnObject(bool colors)
     : m_out_stream(colors), m_err_stream(colors) {}
 
 void CommandReturnObject::AppendErrorWithFormat(const char *format, ...) {
-  SetStatus(eReturnStatusFailed);
-
   if (!format)
     return;
   va_list args;
@@ -100,7 +98,6 @@ void CommandReturnObject::AppendWarning(llvm::StringRef in_string) {
 void CommandReturnObject::AppendError(llvm::StringRef in_string) {
   if (in_string.empty())
     return;
-  SetStatus(eReturnStatusFailed);
   error(GetErrorStream()) << in_string.rtrim() << '\n';
 }
 
@@ -117,6 +114,7 @@ void CommandReturnObject::SetError(llvm::StringRef error_str) {
     return;
 
   AppendError(error_str);
+  SetStatus(eReturnStatusFailed);
 }
 
 // Similar to AppendError, but do not prepend 'Status: ' to message, and don't
@@ -126,7 +124,6 @@ void CommandReturnObject::AppendRawError(llvm::StringRef in_string) {
   if (in_string.empty())
     return;
   GetErrorStream() << in_string;
-  SetStatus(eReturnStatusFailed);
 }
 
 void CommandReturnObject::SetStatus(ReturnStatus status) { m_status = status; }

diff  --git a/lldb/test/API/commands/register/register/register_command/TestRegisters.py b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
index cd0cb6d46fc2a..5ec46c175e621 100644
--- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -41,18 +41,13 @@ def test_register_commands(self):
         self.expect("register read -a", MISSING_EXPECTED_REGISTERS,
                     substrs=['registers were unavailable'], matching=False)
 
-        all_registers = self.res.GetOutput()
-
         if self.getArchitecture() in ['amd64', 'i386', 'x86_64']:
             self.runCmd("register read xmm0")
-            if "ymm15 = " in all_registers:
-              self.runCmd("register read ymm15")  # may be available
-            if "bnd0 = " in all_registers:
-              self.runCmd("register read bnd0")  # may be available
+            self.runCmd("register read ymm15")  # may be available
+            self.runCmd("register read bnd0")  # may be available
         elif self.getArchitecture() in ['arm', 'armv7', 'armv7k', 'arm64', 'arm64e', 'arm64_32']:
             self.runCmd("register read s0")
-            if "q15 = " in all_registers:
-              self.runCmd("register read q15")  # may be available
+            self.runCmd("register read q15")  # may be available
 
         self.expect(
             "register read -s 4",
@@ -402,13 +397,8 @@ def fp_register_write(self):
             # Returns an SBValueList.
             registerSets = currentFrame.GetRegisters()
             for registerSet in registerSets:
-                set_name = registerSet.GetName().lower()
-                if 'advanced vector extensions' in set_name:
+                if 'advanced vector extensions' in registerSet.GetName().lower():
                     has_avx = True
-                # Darwin reports AVX registers as part of "Floating Point Registers"
-                elif self.platformIsDarwin() and 'floating point registers' in set_name:
-                    has_avx = registerSet.GetFirstValueByName('ymm0').IsValid()
-
                 # FreeBSD/NetBSD reports missing register sets 
diff erently
                 # at the moment and triggers false positive here.
                 # TODO: remove FreeBSD/NetBSD exception when we make unsupported
@@ -423,8 +413,7 @@ def fp_register_write(self):
                 self.write_and_read(currentFrame, "ymm7", new_value)
                 self.expect("expr $ymm0", substrs=['vector_type'])
             else:
-                self.expect("register read ymm0", substrs=["Invalid register name 'ymm0'"],
-                            error=True)
+                self.runCmd("register read ymm0")
 
             if has_mpx:
                 # Test write and read for bnd0.
@@ -439,8 +428,7 @@ def fp_register_write(self):
                 self.write_and_read(currentFrame, "bndstatus", new_value)
                 self.expect("expr $bndstatus", substrs = ['vector_type'])
             else:
-                self.expect("register read bnd0", substrs=["Invalid register name 'bnd0'"],
-                            error=True)
+                self.runCmd("register read bnd0")
 
     def convenience_registers(self):
         """Test convenience registers."""
@@ -462,7 +450,7 @@ def convenience_registers(self):
         # Now write rax with a unique bit pattern and test that eax indeed
         # represents the lower half of rax.
         self.runCmd("register write rax 0x1234567887654321")
-        self.expect("register read rax",
+        self.expect("register read rax 0x1234567887654321",
                     substrs=['0x1234567887654321'])
 
     def convenience_registers_with_process_attach(self, test_16bit_regs):

diff  --git a/lldb/test/Shell/Commands/command-backtrace-parser-1.test b/lldb/test/Shell/Commands/command-backtrace-parser-1.test
deleted file mode 100644
index 339c6664b3726..0000000000000
--- a/lldb/test/Shell/Commands/command-backtrace-parser-1.test
+++ /dev/null
@@ -1,6 +0,0 @@
-# RUN: %lldb -s %s 2>&1 | FileCheck %s
-
-# Make sure this is not rejected by the parser as invalid syntax.
-# Blank characters after the '1' are important, as we're testing the parser.
-bt 1      
-# CHECK: error: invalid target

diff  --git a/lldb/test/Shell/Commands/command-backtrace-parser-2.test b/lldb/test/Shell/Commands/command-backtrace.test
similarity index 50%
rename from lldb/test/Shell/Commands/command-backtrace-parser-2.test
rename to lldb/test/Shell/Commands/command-backtrace.test
index 5f91cf30ac719..2816f5f2e33ce 100644
--- a/lldb/test/Shell/Commands/command-backtrace-parser-2.test
+++ b/lldb/test/Shell/Commands/command-backtrace.test
@@ -1,5 +1,11 @@
+# Check basic functionality of command bt.
 # RUN: %lldb -s %s 2>&1 | FileCheck %s
 
+# Make sure this is not rejected by the parser as invalid syntax.
+# Blank characters after the '1' are important, as we're testing the parser.
+bt 1      
+# CHECK: error: invalid target
+
 # Make sure this is not rejected by the parser as invalid syntax.
 # Blank characters after the 'all' are important, as we're testing the parser.
 bt all       


        


More information about the lldb-commits mailing list