Problem using py-bt, py-locals, etc. during GDB debugging [solved]

drevicko at gmail.com drevicko at gmail.com
Wed Feb 20 21:39:50 EST 2013


On Friday, December 7, 2012 11:22:12 AM UTC+11, Mark Shroyer wrote:
> 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.

How did you track this down? I tried your fix, and tried setting the radix to 10, but the problem persists. Perhaps something completely different is happening in my case ("unable to ...." isn't very useful debug information ;)



More information about the Python-list mailing list