1

I am getting the below error when tried to use gdb for debugging python extensions code .I created gdbinit file in my home directory copied gdbinit file from MISC/gdbinit

(gdb) source gdbinit  
(gdb) python  
Undefined command: "python".  Try "help".  

I don't know where i am going wrong .I have gdb6.3 version .

1

2 Answers 2

3

I think you've gotten lost somewhere. gdb is not particularly useful for debugging Python code.

On the faint chance that you're actually trying to debug a Python C extension or something, use run to start the Python interpreter (after selecting the Python interpreter using file /usr/bin/python or similar). See http://wiki.python.org/moin/DebuggingWithGdb for details.

Sign up to request clarification or add additional context in comments.

1 Comment

sorry,I am trying to debug Python extensions using the gdb debugger. I have used pdb debugger for debugging pure python code .I am following the link wiki.python.org/moin/DebuggingWithGdb but something I am doing wrong not sure .What is required to get a Python interpreter with Debugging symbol for RedHat .How can i ensure about this
2

You would need gdb 7.0 to debug a Python program. Python support was not added until that version of gdb.

5 Comments

Is gdb7.0 and higher versions support python 2.7 ?
@jaysh Yeah, I believe 2.6 and 2.7 are the versions of python currently supported
I gone through this link misspent.wordpress.com/2012/03/24/… Here they have mentioned about Python 3.2 version usage with gdb .I am not sure we can use gdb7.0 with Python 2.4 or python2.7
@jaysh should work fine, from gdb/README "The oldest version of Python supported by GDB is 2.4." apparently I misremembered this as 2.6. As for your link python version 3.2 adds pretty printers that can be used from gdb when doing e.g 'print somePyListObject' I don't believe gdb's python support works with python 3.x though, so these scripts probably actually run in an older version of python than 3.x. So to use those scripts in particular you probably need both 2.something and 3.2.
Thanks Matt and all will be trying and let you know if its work for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.