jankratochvil created this revision.
jankratochvil added reviewers: mgorny, labath, JDevlieghere.
jankratochvil added a project: LLDB.
Herald added subscribers: steven.zhang, shchenz.
jankratochvil requested review of this revision.

Hardware watchpoints availability differs between hardware (and it also depends 
on Linux kernel version).
On `POWER9, altivec supported, 2.2 (pvr 004e 1202)` the testsuite had 67 FAILs, 
with this patch it has 23 FAILs (probably no longer watchpoint related).
The problem is UNSUPPORTED keyword can list only a triple and some PowerPC 
hardware can do hw watchpoints. Therefore I had to implement the UNSUPPORTED 
category in code.
67 FAILs: 
https://people.redhat.com/jkratoch/lldb-4b8962940322fe732126ec583013ecb5b6a1112e-ppc64le.log
23 FAILs: 
https://people.redhat.com/jkratoch/lldb-4b8962940322fe732126ec583013ecb5b6a1112e-fix-ppc64le.log


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102140

Files:
  lldb/packages/Python/lldbsuite/test/concurrent_base.py
  lldb/test/API/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/test/API/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/test/API/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
  lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/test/API/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  lldb/test/API/functionalities/completion/TestCompletion.py
  lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py
  lldb/test/API/python_api/watchpoint/TestWatchpointIgnoreCount.py
  lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
  lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/test/Shell/Subprocess/Inputs/check-follow-parent-wp.lldbinit
  lldb/test/Shell/Subprocess/clone-follow-parent-wp.test
  lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
  lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test

Index: lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test
===================================================================
--- lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test
+++ lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test
@@ -2,7 +2,9 @@
 # UNSUPPORTED: system-windows
 # UNSUPPORTED: system-darwin
 # RUN: %clangxx_host -g %p/Inputs/fork.cpp -DTEST_FORK=vfork -o %t
-# RUN: %lldb -b -s %s %t | FileCheck %s
+# RUN: (%lldb -b -s %p/Inputs/check-follow-parent-wp.lldbinit %t || true) 2>&1 \
+# RUN:     | FileCheck %p/Inputs/check-follow-parent-wp.lldbinit \
+# RUN:   || %lldb -b -s %s %t | FileCheck %s
 process launch -s
 watchpoint set variable -w write g_val
 # CHECK: Watchpoint created:
Index: lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
===================================================================
--- lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
+++ lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
@@ -1,7 +1,9 @@
 # REQUIRES: native && dbregs-set
 # UNSUPPORTED: system-windows
 # RUN: %clangxx_host -g %p/Inputs/fork.cpp -DTEST_FORK=fork -o %t
-# RUN: %lldb -b -s %s %t | FileCheck %s
+# RUN: (%lldb -b -s %p/Inputs/check-follow-parent-wp.lldbinit %t || true) 2>&1 \
+# RUN:     | FileCheck %p/Inputs/check-follow-parent-wp.lldbinit \
+# RUN:   || %lldb -b -s %s %t | FileCheck %s
 process launch -s
 watchpoint set variable -w write g_val
 # CHECK: Watchpoint created:
Index: lldb/test/Shell/Subprocess/clone-follow-parent-wp.test
===================================================================
--- lldb/test/Shell/Subprocess/clone-follow-parent-wp.test
+++ lldb/test/Shell/Subprocess/clone-follow-parent-wp.test
@@ -2,7 +2,9 @@
 # clone() tests fails on arm64 Linux, PR #49899
 # UNSUPPORTED: system-linux && target-aarch64
 # RUN: %clangxx_host -g %p/Inputs/fork.cpp -DTEST_CLONE -o %t
-# RUN: %lldb -b -s %s %t | FileCheck %s
+# RUN: (%lldb -b -s %p/Inputs/check-follow-parent-wp.lldbinit %t || true) 2>&1 \
+# RUN:     | FileCheck %p/Inputs/check-follow-parent-wp.lldbinit \
+# RUN:   || %lldb -b -s %s %t | FileCheck %s
 process launch -s
 watchpoint set variable -w write g_val
 # CHECK: Watchpoint created:
Index: lldb/test/Shell/Subprocess/Inputs/check-follow-parent-wp.lldbinit
===================================================================
--- /dev/null
+++ lldb/test/Shell/Subprocess/Inputs/check-follow-parent-wp.lldbinit
@@ -0,0 +1,3 @@
+process launch -s
+watchpoint set variable g_val
+# CHECK: error: Target supports (0) hardware watchpoint slots.
Index: lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
===================================================================
--- lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -64,6 +64,8 @@
         error = lldb.SBError()
         watchpoint = target.WatchAddress(
             value.GetValueAsUnsigned(), 1, False, True, error)
+        if not watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(value and watchpoint,
                         "Successfully found the pointer and set a watchpoint")
         self.DebugSBValue(value)
@@ -139,5 +141,7 @@
         watchpoint = target.WatchAddress(
             value.GetValueAsUnsigned(), 365, False, True, error)
         self.assertFalse(watchpoint)
+        if error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.expect(error.GetCString(), exe=False,
                     substrs=['watch size of %d is not supported' % 365])
Index: lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
===================================================================
--- lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
+++ lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
@@ -64,6 +64,8 @@
         # Watch for write to *g_char_ptr.
         error = lldb.SBError()
         watchpoint = value.WatchPointee(True, False, True, error)
+        if not watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(value and watchpoint,
                         "Successfully found the pointer and set a watchpoint")
         self.DebugSBValue(value)
Index: lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
===================================================================
--- lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
+++ lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
@@ -64,6 +64,8 @@
         value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
         error = lldb.SBError()
         watchpoint = value.Watch(True, False, True, error)
+        if not watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(value and watchpoint,
                         "Successfully found the variable and set a watchpoint")
         self.DebugSBValue(value)
Index: lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
===================================================================
--- lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
+++ lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
@@ -61,6 +61,8 @@
         value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
         error = lldb.SBError()
         watchpoint = value.Watch(True, False, True, error)
+        if not watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(value and watchpoint,
                         "Successfully found the variable and set a watchpoint")
         self.DebugSBValue(value)
Index: lldb/test/API/python_api/watchpoint/TestWatchpointIgnoreCount.py
===================================================================
--- lldb/test/API/python_api/watchpoint/TestWatchpointIgnoreCount.py
+++ lldb/test/API/python_api/watchpoint/TestWatchpointIgnoreCount.py
@@ -58,6 +58,8 @@
         value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
         error = lldb.SBError()
         watchpoint = value.Watch(True, True, True, error)
+        if not watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(value and watchpoint,
                         "Successfully found the variable and set a watchpoint")
         self.DebugSBValue(value)
Index: lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py
===================================================================
--- lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py
+++ lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py
@@ -58,6 +58,8 @@
         value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
         error = lldb.SBError()
         watchpoint = value.Watch(True, True, True, error)
+        if not watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(value and watchpoint,
                         "Successfully found the variable and set a watchpoint")
         self.DebugSBValue(value)
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -304,7 +304,12 @@
         self.build()
         lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
 
-        self.runCmd('watchpoint set variable ptr_fooo')
+        try:
+            self.runCmd('watchpoint set variable ptr_fooo')
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                return
+            raise
         for subcommand in subcommands:
             self.complete_from_to('watchpoint ' + subcommand + ' ', ['1'])
 
Index: lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
+++ lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
@@ -71,15 +71,20 @@
 
             # Set a read_write type watchpoint arrayName
             watch_loc = arrayName + "[" + str(i) + "]"
-            self.expect(
-                "watchpoint set variable -w read_write " +
-                watch_loc,
-                WATCHPOINT_CREATED,
-                substrs=[
-                    'Watchpoint created',
-                    'size = ' +
-                    watchsize,
-                    'type = rw'])
+            try:
+                self.expect(
+                    "watchpoint set variable -w read_write " +
+                    watch_loc,
+                    WATCHPOINT_CREATED,
+                    substrs=[
+                        'Watchpoint created',
+                        'size = ' +
+                        watchsize,
+                        'type = rw'])
+            except:
+                if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                    self.skipTest('Watchpoints are not supported')
+                raise
 
             # Use the '-v' option to do verbose listing of the watchpoint.
             # The hit count should be 0 initially.
Index: lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -59,16 +59,21 @@
         # with offset as 7.
         # The main.cpp, by design, misbehaves by not following the agreed upon
         # protocol of only accessing the allowable index range of [0, 6].
-        self.expect(
-            "watchpoint set expression -w write -s 1 -- g_char_ptr + 7",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 1',
-                'type = w'])
-        self.runCmd("expr unsigned val = g_char_ptr[7]; val")
-        self.expect(self.res.GetOutput().splitlines()[0], exe=False,
-                    endstr=' = 0')
+        try:
+            self.expect(
+                "watchpoint set expression -w write -s 1 -- g_char_ptr + 7",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 1',
+                    'type = w'])
+            self.runCmd("expr unsigned val = g_char_ptr[7]; val")
+            self.expect(self.res.GetOutput().splitlines()[0], exe=False,
+                        endstr=' = 0')
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Use the '-v' option to do verbose listing of the watchpoint.
         # The hit count should be 0 initially.
Index: lldb/test/API/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
+++ lldb/test/API/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
@@ -41,7 +41,12 @@
         self.runCmd("run", RUN_SUCCEEDED)
 
         # Value of a vector variable should be displayed correctly
-        self.expect(
-            "watchpoint set variable global_vector",
-            WATCHPOINT_CREATED,
-            substrs=['new value: (1, 2, 3, 4)'])
+        try:
+            self.expect(
+                "watchpoint set variable global_vector",
+                WATCHPOINT_CREATED,
+                substrs=['new value: (1, 2, 3, 4)'])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
Index: lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
+++ lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
@@ -64,6 +64,8 @@
         error = lldb.SBError()
         local_watch = local_var.Watch(True, False, True, error)
         if not error.Success():
+            if error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+                self.skipTest('Watchpoints are not supported')
             self.fail(
                 "Failed to make watchpoint for local_var: %s" %
                 (error.GetCString()))
Index: lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
+++ lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
@@ -47,6 +47,8 @@
 
         ret_val = lldb.SBCommandReturnObject()
         self.dbg.GetCommandInterpreter().HandleCommand("watchpoint set variable -w write global_var", ret_val)
+        if not ret_val.Succeeded() and '\nerror: Target supports (0) hardware watchpoint slots.\n' in ret_val.GetError():
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(ret_val.Succeeded(), "Watchpoint set variable did not return success.")
 
         wp = self.target.FindWatchpointByID(1)
Index: lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
+++ lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
@@ -21,6 +21,8 @@
 
         error = lldb.SBError()
         first_watch = first_var.Watch(True, False, True, error)
+        if not first_watch and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         if not error.Success():
             self.fail(
                 "Failed to make watchpoint for x1: %s" %
Index: lldb/test/API/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
+++ lldb/test/API/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
@@ -54,16 +54,21 @@
 
         # Now let's set a write-type watchpoint for 'global'.
         # With a condition of 'global==5'.
-        self.expect(
-            "watchpoint set variable -w write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         self.runCmd("watchpoint modify -c 'global==5'")
 
Index: lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
+++ lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
@@ -54,16 +54,21 @@
                              'stop reason = breakpoint'])
 
         # Now let's set a write-type watchpoint for 'global'.
-        self.expect(
-            "watchpoint set variable -w write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         self.runCmd(
             'watchpoint command add -s python 1 -o \'frame.EvaluateExpression("cookie = 777")\'')
@@ -117,16 +122,21 @@
                              'stop reason = breakpoint'])
 
         # Now let's set a write-type watchpoint for 'global'.
-        self.expect(
-            "watchpoint set variable -w write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         cmd_script_file = os.path.join(self.getSourceDir(),
                                        "watchpoint_command.py")
Index: lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
+++ lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
@@ -53,16 +53,21 @@
                              'stop reason = breakpoint'])
 
         # Now let's set a write-type watchpoint for 'global'.
-        self.expect(
-            "watchpoint set variable -w write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         self.runCmd('watchpoint command add 1 -o "expr -- cookie = 777"')
 
@@ -117,16 +122,21 @@
                              'stop reason = breakpoint'])
 
         # Now let's set a write-type watchpoint for 'global'.
-        self.expect(
-            "watchpoint set variable -w write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         self.runCmd('watchpoint command add 1 -o "watchpoint disable 1"')
 
Index: lldb/test/API/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
+++ lldb/test/API/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
@@ -59,16 +59,21 @@
 
         # Now let's set a read_write-type watchpoint for 'global'.
         # There should be two watchpoint hits (see main.c).
-        self.expect(
-            "watchpoint set variable -w read_write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = rw',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w read_write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = rw',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Use the '-v' option to do verbose listing of the watchpoint.
         # The hit count should be 0 initially.
@@ -112,16 +117,21 @@
 
         # Now let's set a read_write-type watchpoint for 'global'.
         # There should be two watchpoint hits (see main.c).
-        self.expect(
-            "watchpoint set variable -w read_write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = rw',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w read_write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = rw',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Delete the watchpoint immediately, but set auto-confirm to true
         # first.
@@ -186,16 +196,21 @@
 
         # Now let's set a read_write-type watchpoint for 'global'.
         # There should be two watchpoint hits (see main.c).
-        self.expect(
-            "watchpoint set variable -w read_write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = rw',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w read_write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = rw',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Set the ignore count of the watchpoint immediately.
         self.expect("watchpoint ignore -i 2",
@@ -243,16 +258,21 @@
 
         # Now let's set a read_write-type watchpoint for 'global'.
         # There should be two watchpoint hits (see main.c).
-        self.expect(
-            "watchpoint set variable -w read_write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = rw',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w read_write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = rw',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Use the '-v' option to do verbose listing of the watchpoint.
         # The hit count should be 0 initially.
@@ -312,16 +332,21 @@
 
         # Now let's set a read_write-type watchpoint for 'global'.
         # There should be two watchpoint hits (see main.c).
-        self.expect(
-            "watchpoint set variable -w read_write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = rw',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w read_write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = rw',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Immediately, we disable the watchpoint.  We won't be stopping due to a
         # watchpoint after this.
Index: lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
===================================================================
--- lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
+++ lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -54,6 +54,8 @@
 
         # resolve_location=True, read=True, write=False
         read_watchpoint = read_value.Watch(True, True, False, error)
+        if not read_watchpoint and error.GetCString() == 'Target supports (0) hardware watchpoint slots.\n':
+            self.skipTest('Watchpoints are not supported')
         self.assertTrue(error.Success(),
                         "Error while setting watchpoint: %s" %
                         error.GetCString())
Index: lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
===================================================================
--- lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
+++ lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
@@ -35,13 +35,18 @@
         lldbutil.run_to_source_breakpoint(self, line, self.main_spec)
 
         # Now let's set a write-type watchpoint for variable 'g_val'.
-        self.expect(
-            "watchpoint set variable -w write g_val",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w'])
+        try:
+            self.expect(
+                "watchpoint set variable -w write g_val",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w'])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Use the '-v' option to do verbose listing of the watchpoint.
         # The hit count should be 0 initially.
@@ -70,13 +75,18 @@
         lldbutil.run_to_source_breakpoint(self, "After running the thread", self.main_spec)
 
         # Now let's set a write-type watchpoint for variable 'g_val'.
-        self.expect(
-            "watchpoint set variable -w write g_val",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w'])
+        try:
+            self.expect(
+                "watchpoint set variable -w write g_val",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w'])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Use the '-v' option to do verbose listing of the watchpoint.
         # The hit count should be 0 initially.
Index: lldb/test/API/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
===================================================================
--- lldb/test/API/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
+++ lldb/test/API/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
@@ -53,16 +53,21 @@
 
         # Now let's set a write-type watchpoint for 'global'.
         # There should be only one watchpoint hit (see main.c).
-        self.expect(
-            "watchpoint set variable -w write global",
-            WATCHPOINT_CREATED,
-            substrs=[
-                'Watchpoint created',
-                'size = 4',
-                'type = w',
-                '%s:%d' %
-                (self.source,
-                 self.decl)])
+        try:
+            self.expect(
+                "watchpoint set variable -w write global",
+                WATCHPOINT_CREATED,
+                substrs=[
+                    'Watchpoint created',
+                    'size = 4',
+                    'type = w',
+                    '%s:%d' %
+                    (self.source,
+                     self.decl)])
+        except:
+            if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                self.skipTest('Watchpoints are not supported')
+            raise
 
         # Use the '-v' option to do verbose listing of the watchpoint.
         # The hit count should be 0 initially.
Index: lldb/packages/Python/lldbsuite/test/concurrent_base.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/concurrent_base.py
+++ lldb/packages/Python/lldbsuite/test/concurrent_base.py
@@ -144,7 +144,13 @@
 
         # Initialize the (single) watchpoint on the global variable (g_watchme)
         if num_watchpoint_threads + num_delay_watchpoint_threads > 0:
-            self.runCmd("watchpoint set variable g_watchme")
+            try:
+                self.runCmd("watchpoint set variable g_watchme")
+            except:
+                if "\nerror: Target supports (0) hardware watchpoint slots.\n" in self.res.GetError():
+                    self.skipTest('Watchpoints are not supported')
+                raise
+
             for w in self.inferior_target.watchpoint_iter():
                 self.thread_watchpoint = w
                 self.assertTrue(
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to