From 3ff636729d067801039b3a37618f6ce0dd1c3d24 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 3 Feb 2023 08:45:44 -0800 Subject: [lldb] Accept negative indexes in __getitem__ To the Python bindings, add support for Python-like negative indexes. While was using `script`, I tried to access a thread's bottom frame with `thread.frame[-1]`, but that failed. This change updates the `__getitem__` implementations to support negative indexes as one would expect in Python. Differential Revision: https://reviews.llvm.org/D143282 --- lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lldb/test/API/python_api/breakpoint') diff --git a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py index 014065e51919..da6c8959f34f 100644 --- a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py +++ b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py @@ -62,6 +62,9 @@ class BreakpointAPITestCase(TestBase): location = breakpoint.GetLocationAtIndex(0) self.assertTrue(location.IsValid()) + # Test negative index access. + self.assertTrue(breakpoint.location[-1].IsValid()) + # Make sure the breakpoint's target is right: self.assertEqual(target, breakpoint.GetTarget(), "Breakpoint reports its target correctly") -- cgit v1.2.3