Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

syntax error in libpython.py #22

Open
sdharav opened this issue Sep 9, 2015 · 8 comments
Open

syntax error in libpython.py #22

sdharav opened this issue Sep 9, 2015 · 8 comments

Comments

@sdharav
Copy link

sdharav commented Sep 9, 2015

I have installed pyringe in my Ubuntu 14.04 which has GDB 7.7.1. Everything installed fine but when start it and attach the process id I get the following error.

File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/pyringe/repl.py", line 161, in Attach
self.inferior.Reinit(pid)
File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 484, in Reinit
self.init(pid, auto_symfile_loading, architecture=self.arch)
File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 456, in init
self.StartGdb()
File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 503, in StartGdb
self._gdb.Attach(self.position)
File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 200, in
return lambda _args, *_kwargs: self._Execute(name, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 342, in _Execute
result_string = self._Recv(timeout)
File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 427, in _Recv
raise ProxyError(exc_text)
ProxyError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pyringe/payload/gdb_service.py", line 34, in

*here it gives the syntax error **** in the libpython file
import libpython
File "/usr/local/lib/python2.7/dist-packages/pyringe/payload/libpython.py", line 58
Py_TPFLAGS_HEAPTYPE = (1L << 9)

Why am I getting that error ?

@TehMillhouse
Copy link
Contributor

As a first piece of information: Though you've correctly installed the pyringe package (i.e. you've installed it as a python2.7 package), as the README states, this isn't the only thing that must be in python2.

I don't have a Ubuntu VM handy right now, but from looking at the current Ubuntu Trusty gdb 7.7.1 package I can tell it depends on libpython3.4, which means point 3 of that listing in the README is the pain point for you.

To get pyringe to work on that Ubuntu release, you'll need to find a version of gdb that still uses libpython2.x.

@sdharav
Copy link
Author

sdharav commented Sep 9, 2015

if I dont the version of the gdb which uses libpython2.x then should I need to use python3.x ?

@TehMillhouse
Copy link
Contributor

You can't use python3.x with pyringe either, since no part of it is written with python3 support in mind. Neither the part running in the local python process, nor the stubs running within gdb, nor the debugging library (libpython.py from the cpython project) in the version included with pyringe.

It's a shame, but it was only ever intended to debug python2 programs. If you can't find a suitable build of gdb, you're out of luck and can't use pyringe. :(

@sdharav
Copy link
Author

sdharav commented Sep 9, 2015

is there any way to find a suitable gdb for that ??

@TehMillhouse
Copy link
Contributor

You'll have to do that yourself. While the Ubuntu package listing usually lists dependencies for each package (you'll need one that depends on libpython2), I'm not sure whether they even list old versions of packages.

I found this listing by googling, but I don't know which one's the latest that still links to libpython2. Godspeed.

@sdharav
Copy link
Author

sdharav commented Sep 10, 2015

Thank you, let me try it.

@Mofef
Copy link

Mofef commented Feb 22, 2019

In case someone runs into this nowadays:

Debian has a gdb-python2 package that is just gdb linked against python 2.7. On Ubuntu 16.04 I could install the jesse-backport version with dpkg and resolve dependencies afterwards by doing apt-get install -f.
It might as well work on other Ubuntu versions. Otherwise, try a different version or install dependencies from the same debian source and try again apt-get install -f until it can resolve the rest for you.

Good luck!

@nzjrs
Copy link

nzjrs commented Oct 1, 2019

If anyone finds this bug, and you want this to work with Python 2.7.15 then you should replace libpython.py in the source tree with the copy from https://github.com/python/cpython/blob/2.7/Tools/gdb/libpython.py

(tested Ubuntu 18.04.3)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants