Skip to content

Commit 3034689

Browse files
TeemperorRaphael Isemann
authored andcommitted
[lldb] Reland 370734: Test 'frame select -r' and fix that INT32_MIN breaks the option parser
The problem with r370734 was that it removed the code for resetting the options in OptionParsingStarting. This caused that once a 'frame select -r ...' command was executed, we kept the relative index argument for all following 'frame select ...' invocations (even the ones with an absolute index as they are the same command object). See rdar://55791276. This relands the patch but keeps the code that resets the command options before execution. llvm-svn: 373201
1 parent 47dc189 commit 3034689

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

lldb/packages/Python/lldbsuite/test/commands/frame/select/TestFrameSelect.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,42 @@ def test_relative(self):
3636

3737
self.expect("frame select -r 100")
3838
self.expect("frame select -r 1", error=True, substrs=["Already at the top of the stack."])
39+
40+
@no_debug_info_test
41+
@skipIfWindows
42+
def test_mixing_relative_and_abs(self):
43+
self.build()
44+
45+
lldbutil.run_to_source_breakpoint(self,
46+
"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
47+
48+
# The function associated with each frame index can change depending
49+
# on the function calling main (e.g. `start`), so this only tests that
50+
# the frame index number is correct. We test the actual functions
51+
# in the relative test.
52+
53+
# Jump to the top of the stack.
54+
self.expect("frame select 0", substrs=["frame #0"])
55+
56+
# Run some relative commands.
57+
self.expect("up", substrs=["frame #1"])
58+
self.expect("frame select -r 1", substrs=["frame #2"])
59+
self.expect("frame select -r -1", substrs=["frame #1"])
60+
61+
# Test that absolute indices still work.
62+
self.expect("frame select 2", substrs=["frame #2"])
63+
self.expect("frame select 1", substrs=["frame #1"])
64+
self.expect("frame select 3", substrs=["frame #3"])
65+
self.expect("frame select 0", substrs=["frame #0"])
66+
self.expect("frame select 1", substrs=["frame #1"])
67+
68+
# Run some other relative frame select commands.
69+
self.expect("down", substrs=["frame #0"])
70+
self.expect("frame select -r 1", substrs=["frame #1"])
71+
self.expect("frame select -r -1", substrs=["frame #0"])
72+
73+
# Test that absolute indices still work.
74+
self.expect("frame select 2", substrs=["frame #2"])
75+
self.expect("frame select 1", substrs=["frame #1"])
76+
self.expect("frame select 3", substrs=["frame #3"])
77+
self.expect("frame select 0", substrs=["frame #0"])

lldb/source/Commands/CommandObjectFrame.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ class CommandObjectFrameSelect : public CommandObjectParsed {
263263
return error;
264264
}
265265

266-
void OptionParsingStarting(ExecutionContext *execution_context) override {}
267-
266+
void OptionParsingStarting(ExecutionContext *execution_context) override {
267+
relative_frame_offset.reset();
268+
}
269+
268270
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
269271
return llvm::makeArrayRef(g_frame_select_options);
270272
}

0 commit comments

Comments
 (0)