Author: Pavel Labath Date: 2020-05-11T16:37:34+02:00 New Revision: ba898282bc204f78016c2e7779dc5cde37e10fd1
URL: https://github.com/llvm/llvm-project/commit/ba898282bc204f78016c2e7779dc5cde37e10fd1 DIFF: https://github.com/llvm/llvm-project/commit/ba898282bc204f78016c2e7779dc5cde37e10fd1.diff LOG: [lldb/test] Make "inline" tests handle multiple statements at the same location Summary: The test machinery translates each continuous block of "//%" comments into a single breakpoint. If there's no code between the blocks the breakpoints will end up at the same location in the program. When the process stops at a breakpoint lldb correctly reports all breakpoint IDs, but the test machinery only looks at the first one. This results in a very dangerous situation as it means some checks can be silently stopped. This patch fixes that by making the test machinery iterate through all breakpoints at a given location and execute all commands. Reviewers: vsk, JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D79563 Added: Modified: lldb/packages/Python/lldbsuite/test/lldbinline.py lldb/test/API/commands/expression/dollar-in-variable/main.c Removed: ################################################################################ diff --git a/lldb/packages/Python/lldbsuite/test/lldbinline.py b/lldb/packages/Python/lldbsuite/test/lldbinline.py index 3df26356d908..5ef7aaac42f7 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbinline.py +++ b/lldb/packages/Python/lldbsuite/test/lldbinline.py @@ -126,6 +126,13 @@ def _test(self): def execute_user_command(self, __command): exec(__command, globals(), locals()) + def _get_breakpoint_ids(self, thread): + ids = set() + for i in range(0, thread.GetStopReasonDataCount(), 2): + ids.add(thread.GetStopReasonDataAtIndex(i)) + self.assertGreater(len(ids), 0) + return sorted(ids) + def do_test(self): exe = self.getBuildArtifact("a.out") source_files = [f for f in os.listdir(self.getSourceDir()) @@ -145,8 +152,8 @@ def do_test(self): hit_breakpoints += 1 thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) - breakpoint_id = thread.GetStopReasonDataAtIndex(0) - parser.handle_breakpoint(self, breakpoint_id) + for bp_id in self._get_breakpoint_ids(thread): + parser.handle_breakpoint(self, bp_id) process.Continue() self.assertTrue(hit_breakpoints > 0, diff --git a/lldb/test/API/commands/expression/dollar-in-variable/main.c b/lldb/test/API/commands/expression/dollar-in-variable/main.c index e5fec25b35b8..97c939b68edf 100644 --- a/lldb/test/API/commands/expression/dollar-in-variable/main.c +++ b/lldb/test/API/commands/expression/dollar-in-variable/main.c @@ -17,5 +17,6 @@ int main() { //%self.expect("expr $foo", substrs=['(int)', ' = 12']) //%self.expect("expr $R0", substrs=['(int)', ' = 13']) //%self.expect("expr int $foo = 123", error=True, substrs=["declaration conflicts"]) - return 0; //%self.expect("expr $0", substrs=['(int)', ' = 14']) + //%self.expect("expr $0", substrs=['(int)', ' = 11']) + return 0; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits