Add WhereDepth user preference to control depth of initial stack trace in break loops#6261
Add WhereDepth user preference to control depth of initial stack trace in break loops#6261limakzi wants to merge 2 commits intogap-system:masterfrom
WhereDepth user preference to control depth of initial stack trace in break loops#6261Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new core GAP user preference (WhereDepth) to control the default stack depth used by Where / WhereWithVars when called with no explicit argument (notably via the default OnBreak handler), keeping the default behavior at 5.
Changes:
- Declare new
WhereDepthuser preference (default5, non-negative integer). - Use
UserPreference("WhereDepth")as the default depth inWhereandWhereWithVars. - Add an installation test that verifies the preference exists and can be changed.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/init.g |
Declares the new WhereDepth user preference with default/check logic. |
lib/error.g |
Switches Where / WhereWithVars default depth from constant 5 to UserPreference("WhereDepth"). |
tst/testinstall/error.tst |
Adds a basic regression test for reading/setting WhereDepth. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WhereDepth user preference to control depth of initial stack trace in break loops
fingolfin
left a comment
There was a problem hiding this comment.
Actually, this also needs to adjust the Where documentation, which currently states
If not given, nr defaults to 5.
66a05f7 to
bc114ff
Compare
| # | ||
| # WhereDepth user preference | ||
| # | ||
| gap> UserPreference("WhereDepth"); |
There was a problem hiding this comment.
This may fail if the user changed the preference
There was a problem hiding this comment.
No, it doesn't test default, it queries the current setting, which may or may not be the default value. On my computer it most likely will not be the default value 5 but rather something like 30
| gap> SetUserPreference("WhereDepth", 10); | ||
| gap> UserPreference("WhereDepth"); | ||
| 10 | ||
| gap> SetUserPreference("WhereDepth", 0); | ||
| gap> UserPreference("WhereDepth"); | ||
| 0 | ||
| gap> SetUserPreference("WhereDepth", 5); | ||
| gap> UserPreference("WhereDepth"); |
There was a problem hiding this comment.
Isn't this really just testing the UserPreference system, not WhereDepth? that doesn't strike me as super useful.
Instead, the place to test this ought to be in tst/testspecial/backtrace.g or tst/testspecial/backtrace2.g or so (actually... probably in tst/testspecial/stack-trace-depth.g but that only gets added in PR #6263 -- so now I am thinking about adding it right away in a PR of its own, with the "old" Where, so that (a) you can use it here, (b) one sees how the output compares from old to new in my PR.
And that also reminds me of another issue: all those tests producing backtraces will break if the user running the test suite has a custom WhereDepth set. This will affect me as I will immediately set WhereDepth to 30 or so .
To solve this, tst/testspecial/run_gap.sh needs to be edited to do SetUserPreference("WhereDepth", 5); (it already changes UseColorsInTerminal so it should be easy to do this)
Co-authored-by: Max Horn <max@quendi.de>
Adds a
WhereDepthuser preference that controls the default number of stack frames shown byWhereandWhereWithVarswhen called without an explicit depth argument (i.e. in the defaultOnBreakhandler).Previously this was hardcoded to 5.
The default remains 5, so existing behaviour is unchanged.
Fixes #6210