u
is the PDB command to traverse stack frames. You are in the 'uppermost' frame already. help u
will tell you more about it:
u(p) Move the current frame one level up in the stack trace (to an older frame).
The command is closely related to d(own)
and w(here)
:
d(own) Move the current frame one level down in the stack trace (to a newer frame). w(here) Print a stack trace, with the most recent frame at the bottom. An arrow indicates the "current frame", which determines the context of most commands. 'bt' is an alias for this command.
If you want to print the variable u
, prefix it with a !
to have it not interpreted by the debugger as a debug command:
!u
!u.url
or use print()
:
print(u)
From the help pdb
output:
Commands that the debugger doesn't recognize are assumed to be Python statements and are executed in the context of the program being debugged. Python statements can also be prefixed with an exclamation point ('!').
Oldest frame
is the frame in the stack where your program started; it is the oldest in time; the Newest frame
, the other end of the stack, is where Python is executing code and is the current frame of execution, where Python would continue if you hit the c(ontinue)
command.
A little demo with a recursive function:
>>> def foo():
... foo()
...
>>> import pdb
>>> pdb.run('foo()')
> <string>(1)<module>()
(Pdb) s
--Call--
> <stdin>(1)foo()
(Pdb) s
> <stdin>(2)foo()
(Pdb) s
--Call--
> <stdin>(1)foo()
(Pdb) s
> <stdin>(2)foo()
(Pdb) s
--Call--
> <stdin>(1)foo()
(Pdb) w
/Users/mj/Development/Libraries/buildout.python/parts/opt/lib/python2.7/bdb.py(400)run()
-> exec cmd in globals, locals
<string>(1)<module>()
<stdin>(2)foo()
<stdin>(2)foo()
> <stdin>(1)foo()
(Pdb) u
> <stdin>(2)foo()
(Pdb) u
> <stdin>(2)foo()
(Pdb) u
> <string>(1)<module>()
(Pdb) u
> /Users/mj/Development/Libraries/buildout.python/parts/opt/lib/python2.7/bdb.py(400)run()
-> exec cmd in globals, locals
(Pdb) u
*** Oldest frame