2001-01-23 12:25:19 -04:00
|
|
|
# -*- ksh -*-
|
|
|
|
#
|
|
|
|
# If you use the GNU debugger gdb to debug the Python C runtime, you
|
|
|
|
# might find some of the following commands useful. Copy this to your
|
|
|
|
# ~/.gdbinit file and it'll get loaded into gdb automatically when you
|
|
|
|
# start it up. Then, at the gdb prompt you can do things like:
|
|
|
|
#
|
|
|
|
# (gdb) pyo apyobjectptr
|
|
|
|
# <module 'foobar' (built-in)>
|
|
|
|
# refcounts: 1
|
|
|
|
# address : 84a7a2c
|
|
|
|
# $1 = void
|
|
|
|
# (gdb)
|
|
|
|
|
|
|
|
# Prints a representation of the object to stderr, along with the
|
|
|
|
# number of reference counts it current has and the hex address the
|
|
|
|
# object is allocated at. The argument must be a PyObject*
|
|
|
|
define pyo
|
2001-01-24 00:18:13 -04:00
|
|
|
print _PyObject_Dump($arg0)
|
2001-01-23 12:25:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Prints a representation of the object to stderr, along with the
|
|
|
|
# number of reference counts it current has and the hex address the
|
|
|
|
# object is allocated at. The argument must be a PyGC_Head*
|
|
|
|
define pyg
|
2001-01-24 00:18:13 -04:00
|
|
|
print _PyGC_Dump($arg0)
|
2001-01-23 12:25:19 -04:00
|
|
|
end
|
2003-10-03 17:56:15 -03:00
|
|
|
|
2004-04-02 10:51:13 -04:00
|
|
|
# print the local variables of the current frame
|
|
|
|
define pylocals
|
|
|
|
set $_i = 0
|
Merged revisions 73206,73232,73299,73683,74020,74185,74544,74643,74647,74817,74838-74839,74865,74946,75402,75459,75604,75696 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73206 | georg.brandl | 2009-06-04 11:15:12 +0200 (Do, 04 Jun 2009) | 1 line
#3584: ignore trailing newlines when placing the caret for a SyntaxError location.
........
r73232 | georg.brandl | 2009-06-04 20:59:58 +0200 (Do, 04 Jun 2009) | 1 line
Add test for #3684.
........
r73299 | georg.brandl | 2009-06-08 20:41:36 +0200 (Mo, 08 Jun 2009) | 1 line
Typo fix.
........
r73683 | georg.brandl | 2009-06-29 16:44:49 +0200 (Mo, 29 Jun 2009) | 1 line
Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint.
........
r74020 | georg.brandl | 2009-07-16 09:18:07 +0200 (Do, 16 Jul 2009) | 1 line
#5910: fix kqueue for calls with more than one event.
........
r74185 | georg.brandl | 2009-07-23 11:17:09 +0200 (Do, 23 Jul 2009) | 1 line
Fix the "pylocals" gdb command.
........
r74544 | georg.brandl | 2009-08-24 19:12:30 +0200 (Mo, 24 Aug 2009) | 1 line
#6775: fix python.org URLs in README.
........
r74643 | georg.brandl | 2009-09-04 08:59:20 +0200 (Fr, 04 Sep 2009) | 2 lines
Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module.
........
r74647 | georg.brandl | 2009-09-04 10:17:04 +0200 (Fr, 04 Sep 2009) | 2 lines
Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented.
........
r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line
Make deprecation notices as visible as warnings are right now.
........
r74838 | georg.brandl | 2009-09-16 18:22:12 +0200 (Mi, 16 Sep 2009) | 1 line
Remove some more boilerplate from the actual tests in test_pdb.
........
r74839 | georg.brandl | 2009-09-16 18:36:39 +0200 (Mi, 16 Sep 2009) | 1 line
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
........
r74865 | georg.brandl | 2009-09-17 09:49:37 +0200 (Do, 17 Sep 2009) | 1 line
#6912: add "with" block support to pindent.
........
r74946 | georg.brandl | 2009-09-19 10:43:16 +0200 (Sa, 19 Sep 2009) | 1 line
Update bug tracker reference.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
2009-10-27 12:39:53 -03:00
|
|
|
while $_i < f->f_code->co_nlocals
|
2004-04-02 10:51:13 -04:00
|
|
|
if f->f_localsplus + $_i != 0
|
|
|
|
set $_names = co->co_varnames
|
|
|
|
set $_name = PyString_AsString(PyTuple_GetItem($_names, $_i))
|
|
|
|
printf "%s:\n", $_name
|
|
|
|
# side effect of calling _PyObject_Dump is to dump the object's
|
|
|
|
# info - assigning just prevents gdb from printing the
|
|
|
|
# NULL return value
|
|
|
|
set $_val = _PyObject_Dump(f->f_localsplus[$_i])
|
|
|
|
end
|
|
|
|
set $_i = $_i + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-01-08 17:56:43 -04:00
|
|
|
# A rewrite of the Python interpreter's line number calculator in GDB's
|
|
|
|
# command language
|
|
|
|
define lineno
|
2005-09-05 13:16:49 -03:00
|
|
|
set $__continue = 1
|
2005-01-08 17:56:43 -04:00
|
|
|
set $__co = f->f_code
|
|
|
|
set $__lasti = f->f_lasti
|
|
|
|
set $__sz = ((PyStringObject *)$__co->co_lnotab)->ob_size/2
|
|
|
|
set $__p = (unsigned char *)((PyStringObject *)$__co->co_lnotab)->ob_sval
|
|
|
|
set $__li = $__co->co_firstlineno
|
|
|
|
set $__ad = 0
|
2005-09-05 13:16:49 -03:00
|
|
|
while ($__sz-1 >= 0 && $__continue)
|
2005-01-08 17:56:43 -04:00
|
|
|
set $__sz = $__sz - 1
|
|
|
|
set $__ad = $__ad + *$__p
|
|
|
|
set $__p = $__p + 1
|
|
|
|
if ($__ad > $__lasti)
|
2005-09-05 13:16:49 -03:00
|
|
|
set $__continue = 0
|
2005-01-08 17:56:43 -04:00
|
|
|
end
|
|
|
|
set $__li = $__li + *$__p
|
|
|
|
set $__p = $__p + 1
|
|
|
|
end
|
|
|
|
printf "%d", $__li
|
|
|
|
end
|
|
|
|
|
2004-11-17 12:04:15 -04:00
|
|
|
# print the current frame - verbose
|
|
|
|
define pyframev
|
|
|
|
pyframe
|
|
|
|
pylocals
|
|
|
|
end
|
|
|
|
|
2004-04-02 10:51:13 -04:00
|
|
|
define pyframe
|
2004-11-17 12:04:15 -04:00
|
|
|
set $__fn = (char *)((PyStringObject *)co->co_filename)->ob_sval
|
|
|
|
set $__n = (char *)((PyStringObject *)co->co_name)->ob_sval
|
2005-01-08 17:56:43 -04:00
|
|
|
printf "%s (", $__fn
|
|
|
|
lineno
|
|
|
|
printf "): %s\n", $__n
|
|
|
|
### Uncomment these lines when using from within Emacs/XEmacs so it will
|
|
|
|
### automatically track/display the current Python source line
|
|
|
|
# printf "%c%c%s:", 032, 032, $__fn
|
|
|
|
# lineno
|
|
|
|
# printf ":1\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
### Use these at your own risk. It appears that a bug in gdb causes it
|
|
|
|
### to crash in certain circumstances.
|
|
|
|
|
|
|
|
#define up
|
|
|
|
# up-silently 1
|
|
|
|
# printframe
|
|
|
|
#end
|
|
|
|
|
|
|
|
#define down
|
|
|
|
# down-silently 1
|
|
|
|
# printframe
|
|
|
|
#end
|
|
|
|
|
|
|
|
define printframe
|
2005-08-12 21:28:41 -03:00
|
|
|
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
|
2005-01-08 17:56:43 -04:00
|
|
|
pyframe
|
|
|
|
else
|
|
|
|
frame
|
|
|
|
end
|
2004-04-02 10:51:13 -04:00
|
|
|
end
|
|
|
|
|
2004-04-02 10:53:55 -04:00
|
|
|
# Here's a somewhat fragile way to print the entire Python stack from gdb.
|
|
|
|
# It's fragile because the tests for the value of $pc depend on the layout
|
|
|
|
# of specific functions in the C source code.
|
|
|
|
|
|
|
|
# Explanation of while and if tests: We want to pop up the stack until we
|
|
|
|
# land in Py_Main (this is probably an incorrect assumption in an embedded
|
|
|
|
# interpreter, but the test can be extended by an interested party). If
|
|
|
|
# Py_Main <= $pc <= Py_GetArgcArv is true, $pc is in Py_Main(), so the while
|
|
|
|
# tests succeeds as long as it's not true. In a similar fashion the if
|
2005-01-08 17:56:43 -04:00
|
|
|
# statement tests to see if we are in PyEval_EvalFrame().
|
2004-04-02 10:53:55 -04:00
|
|
|
|
2004-04-02 10:51:13 -04:00
|
|
|
# print the entire Python call stack
|
|
|
|
define pystack
|
|
|
|
while $pc < Py_Main || $pc > Py_GetArgcArgv
|
2004-08-07 17:11:22 -03:00
|
|
|
if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx
|
2004-04-02 10:51:13 -04:00
|
|
|
pyframe
|
|
|
|
end
|
|
|
|
up-silently 1
|
|
|
|
end
|
|
|
|
select-frame 0
|
|
|
|
end
|
2004-11-17 12:04:15 -04:00
|
|
|
|
|
|
|
# print the entire Python call stack - verbose mode
|
|
|
|
define pystackv
|
|
|
|
while $pc < Py_Main || $pc > Py_GetArgcArgv
|
|
|
|
if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx
|
|
|
|
pyframev
|
|
|
|
end
|
|
|
|
up-silently 1
|
|
|
|
end
|
|
|
|
select-frame 0
|
|
|
|
end
|
Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70866 | georg.brandl | 2009-03-31 21:06:57 +0200 (Di, 31 Mär 2009) | 1 line
#4882: document named group behavior a bit better.
........
r70867 | georg.brandl | 2009-03-31 21:10:35 +0200 (Di, 31 Mär 2009) | 1 line
#1096310: document usage of sys.__std*__ a bit better.
........
r70868 | georg.brandl | 2009-03-31 21:12:17 +0200 (Di, 31 Mär 2009) | 1 line
#5190: export make_option in __all__.
........
r70870 | georg.brandl | 2009-03-31 21:26:24 +0200 (Di, 31 Mär 2009) | 1 line
#4411: document mro() and __mro__. (I hope I got it right.)
........
r70871 | georg.brandl | 2009-03-31 21:30:56 +0200 (Di, 31 Mär 2009) | 1 line
#5618: fix typo.
........
r70893 | georg.brandl | 2009-03-31 22:56:32 +0200 (Di, 31 Mär 2009) | 1 line
#1530012: move TQS section before raw strings.
........
r70896 | georg.brandl | 2009-03-31 23:15:33 +0200 (Di, 31 Mär 2009) | 1 line
#5598: document DocFileSuite *args argument.
........
r70902 | georg.brandl | 2009-03-31 23:43:03 +0200 (Di, 31 Mär 2009) | 1 line
#1675026: add a note about a strange Windows problem, and remove notes about AtheOS.
........
r70905 | georg.brandl | 2009-04-01 00:03:40 +0200 (Mi, 01 Apr 2009) | 1 line
#5563: more documentation for bdist_msi.
........
r70907 | georg.brandl | 2009-04-01 00:18:19 +0200 (Mi, 01 Apr 2009) | 1 line
#3427: document correct return type for urlopen().info().
........
r70912 | georg.brandl | 2009-04-01 00:35:46 +0200 (Mi, 01 Apr 2009) | 1 line
#5617: add a handy function to print a unicode string to gdbinit.
........
r70915 | georg.brandl | 2009-04-01 00:40:16 +0200 (Mi, 01 Apr 2009) | 1 line
#5018: remove confusing paragraph.
........
r70927 | georg.brandl | 2009-04-01 01:01:27 +0200 (Mi, 01 Apr 2009) | 1 line
Dont shout to users.
........
r70933 | georg.brandl | 2009-04-01 02:04:33 +0200 (Mi, 01 Apr 2009) | 2 lines
Issue #5635: Fix running test_sys with tracing enabled.
........
r70940 | georg.brandl | 2009-04-01 06:21:14 +0200 (Mi, 01 Apr 2009) | 2 lines
The SimpleXMLRPCServer's CGI handler now runs like a pony.
........
r70944 | georg.brandl | 2009-04-01 06:32:39 +0200 (Mi, 01 Apr 2009) | 1 line
#5631: add upload to list of possible commands, which is presented in --help-commands.
........
r70954 | georg.brandl | 2009-04-01 17:23:43 +0200 (Mi, 01 Apr 2009) | 1 line
Fix test_xmlrpc and make the CGI handler work with no CONTENT_LENGTH.
........
r70963 | georg.brandl | 2009-04-01 19:46:01 +0200 (Mi, 01 Apr 2009) | 1 line
#5655: fix docstring oversight.
........
r70998 | georg.brandl | 2009-04-01 23:54:21 +0200 (Mi, 01 Apr 2009) | 1 line
In Pdb, stop assigning values to __builtin__._ which interferes with the one commonly installed by gettext.
........
r71056 | georg.brandl | 2009-04-02 19:43:07 +0200 (Do, 02 Apr 2009) | 2 lines
Actually the displayhook should print the repr.
........
2009-04-05 18:21:05 -03:00
|
|
|
|
|
|
|
# generally useful macro to print a Unicode string
|
|
|
|
def pu
|
|
|
|
set $uni = $arg0
|
|
|
|
set $i = 0
|
|
|
|
while (*$uni && $i++<100)
|
|
|
|
if (*$uni < 0x80)
|
|
|
|
print *(char*)$uni++
|
|
|
|
else
|
|
|
|
print /x *(short*)$uni++
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|