Skip to content

Commit b90d785

Browse files
committed
Go over "step" documentation
1 parent 7f61503 commit b90d785

3 files changed

Lines changed: 63 additions & 18 deletions

File tree

docs/commands/running/jump.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ function without running more code in the current frame.
2222
.. seealso::
2323

2424
:ref:`skip <skip>`,
25-
:ref:`next <next>`, :ref:`step <step>` :ref:`continue <continue>`, and
25+
:ref:`next <next>`, :ref:`step <step>`, :ref:`continue <continue>`, and
2626
:ref:`finish <finish>` provide other ways to progress.
2727

28-
:ref:`eval <eval>` can be used to run Python code without changing the
29-
execution line.
28+
:ref:`eval <eval>` can be used to run Python code without changing the execution line.

docs/commands/running/step.rst

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,67 @@ Execute the current line, stopping at the next event.
1010

1111
With an integer argument, step that many times.
1212

13-
*event* is list of an event name which is one of: `call`,
14-
`return`, `line`, `exception` `c-call`, `c-return` or `c-exception`.
13+
*event* is list of an event name which is one of: ``call``,
14+
``return``, ``line``, ``exception``, ``c-call``, ``c-return``, or ``c-exception``.
15+
16+
1517
If specified, only those stepping events will be considered. If no
1618
list of event names is given, then any event triggers a stop when the
17-
count is 0.
19+
count is zero.
1820

19-
There is however another way to specify a *single* event, by
20-
suffixing one of the symbols `<`, `>`, or `!` after the command or on
21-
an alias of that. A suffix of `+` on a command or an alias forces a
22-
move to another line, while a suffix of `-` disables this requirement.
23-
A suffix of `>` will continue until the next call. (`finish` will run
24-
run until the return for that call.)
21+
There is however another way to specify an event: you can suffix one
22+
of the symbols ``<``, ``>``, or ``!`` after the command or on an alias
23+
of that. A suffix of ``+`` on a command or an alias forces a move to
24+
another line, while a suffix of ``-`` disables this requirement. A
25+
suffix of ``>`` will continue until the next call. ``finish`` will run
26+
run until the return for that call, in contrast to ``step<`` continues to the
27+
return of *any* call which might occur inside a nested call.
2528

26-
If no suffix is given, the debugger setting `different-line`
29+
If no suffix is given, the debugger setting ``different-line``
2730
determines this behavior.
2831

32+
An example. Use ``step>`` to skip over a number of statements to get a call that is coming up:
33+
34+
::
35+
36+
(trepan3k) list
37+
29 # Make: a <= b
38+
30 if a > b:
39+
31 (a, b) = (b, a)
40+
32 pass
41+
33
42+
34 --> if a <= 0:
43+
35 return None
44+
36 if a == 1 or b-a == 0:
45+
37 return a
46+
38 return gcd(b-a, a)
47+
48+
If we know that ``a >=1 and b != 0``, then by running ``step>`` we will
49+
skip over all of the testing and proceed into the ``gcd()`` call:
50+
51+
::
52+
53+
(trepan3k) step>
54+
(/tmp/python3-trepan/test/example/gcd.py:26): gcd
55+
-> 26 def gcd(a,b):
56+
a = 3
57+
b = 3
58+
(trepan3k)
59+
60+
Now if we want to continue execution to the return, run ``step<``:
61+
62+
::
63+
64+
(trepan3k) step<
65+
step<
66+
(/tmp/python3-trepan/test/example/gcd.py:37 @62): gcd
67+
<- 37 return a
68+
R=> 3
69+
70+
Note that ``finish`` does the same thing as ``step<`` and might even be more reliable here.
71+
72+
For ``step>``, ``break`` is sometimes better.
73+
2974
Step Examples:
3075
++++++++++++++
3176

trepan/processor/command/step.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009, 2013, 2015, 2020 Rocky Bernstein
2+
# Copyright (C) 2009, 2013, 2015, 2020, 2024 Rocky Bernstein
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -27,14 +27,15 @@ class StepCommand(DebuggerCommand):
2727
2828
With an integer argument, step that many times.
2929
30-
*event* is list of an event name which is one of: `call`,
31-
`return`, `line`, `exception` `c-call`, `c-return` or `c-exception`.
30+
*event* is list of an event name which is one of: "call",
31+
"return", "line", "exception", "c-call`, "c-return" or "c-exception".
32+
3233
If specified, only those stepping events will be considered. If no
3334
list of event names is given, then any event triggers a stop when the
3435
count is 0.
3536
36-
There is however another way to specify a *single* event, by
37-
suffixing one of the symbols `<`, `>`, or `!` after the command or on
37+
There is however another way to specify an event: you can
38+
suffix one of the symbols `<`, `>`, or `!` after the command or on
3839
an alias of that. A suffix of `+` on a command or an alias forces a
3940
move to another line, while a suffix of `-` disables this requirement.
4041
A suffix of `>` will continue until the next call. (`finish` will run

0 commit comments

Comments
 (0)