Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34440
| Date | 2012-12-06 19:22 -0500 |
|---|---|
| From | Mark Shroyer <mshroyer@awaredigital.com> |
| Subject | Re: Problem using py-bt, py-locals, etc. during GDB debugging [solved] |
| References | <20121206213941.GA5363@mshroyer-d> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.594.1354839735.29569.python-list@python.org> (permalink) |
On Thu, Dec 06, 2012 at 04:39:41PM -0500, Mark Shroyer wrote:
> I'm having trouble with the py-bt, py-locals, etc. GDB commands (from
> Python's python-gdb.py) while using GDB 7.4 to debug Python 2.7.3; I was
> wondering if anyone here could offer advice.
>
> Briefly, py-bt seems to identify the python stack frames correctly, but
> shows "(unable to read python frame information)" for each, and likewise
> py-locals fails with "Unable to read information on python frame".
OK, I took a closer look at this and I've identified the issue; posting
my fix here in case someone else Googles this.
The problem in my case was that the python-gdb.py extension makes some
fragile assumptions about the format of values it receives from GDB, and
I had the line "set output-radix 16" in my .gdbinit, ultimately
resulting in the extension attempting to convert the string
representation of a hexadecimal number into an integer.
So there are two easy workarounds:
1. set output-radix 10 in GDB, or
2. Patch Python 2.7.3's python-gdb.py as follows:
=== 8< =================================
--- python-gdb.py.orig 2012-12-06 15:12:18.666760664 -0500
+++ python-gdb.py 2012-12-06 19:17:19.588356874 -0500
@@ -1074,7 +1074,11 @@
def int_from_int(gdbval):
- return int(str(gdbval))
+ int_str = str(gdbval)
+ if int_str.startswith("0x"):
+ return int(int_str[2:], 16)
+ else:
+ return int(int_str)
def stringify(val):
=== 8< =================================
I haven't checked to see whether this also applies to the GDB extension
for Python 3, though.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Problem using py-bt, py-locals, etc. during GDB debugging [solved] Mark Shroyer <mshroyer@awaredigital.com> - 2012-12-06 19:22 -0500
csiph-web