Git Product home page Git Product logo

pyringe's Introduction

DISCLAIMER: This is not an official google project, this is just something I wrote while at Google.

Pyringe

What this is

Pyringe is a python debugger capable of attaching to running processes, inspecting their state and even of injecting python code into them while they're running. With pyringe, you can list threads, get tracebacks, inspect locals/globals/builtins of running functions, all without having to prepare your program for it.

What this is not

A "Google project". It's my internship project that got open-sourced. Sorry for the confusion.

What do I need?

Pyringe internally uses gdb to do a lot of its heavy lifting, so you will need a fairly recent build of gdb (version 7.4 onwards, and only if gdb was configured with --with-python). You will also need the symbols for whatever build of python you're running.
On Fedora, the package you're looking for is python-debuginfo, on Debian it's called python2.7-dbg (adjust according to version). Arch Linux users: see issue #5, Ubuntu users can only debug the python-dbg binary (see issue #19).
Having Colorama will get you output in boldface, but it's optional.

How do I get it?

Get it from the Github repo, PyPI, or via pip (pip install pyringe).

Is this Python3-friendly?

Short answer: No, sorry. Long answer:
There's three potentially different versions of python in play here:

  1. The version running pyringe
  2. The version being debugged
  3. The version of libpythonXX.so your build of gdb was linked against

2 Is currently the dealbreaker here. Cpython has changed a bit in the meantime[1], and making all features work while debugging python3 will have to take a back seat for now until the more glaring issues have been taken care of.
As for 1 and 3, the 2to3 tool may be able to handle it automatically. But then, as long as 2 hasn't been taken care of, this isn't really a use case in the first place.

[1] - For example, pendingbusy (which is used for injection) has been renamed to busy and been given a function-local scope, making it harder to interact with via gdb.

Will this work with PyPy?

Unfortunately, no. Since this makes use of some CPython internals and implementation details, only CPython is supported. If you don't know what PyPy or CPython are, you'll probably be fine.

Why not PDB?

PDB is great. Use it where applicable! But sometimes it isn't.
Like when python itself crashes, gets stuck in some C extension, or you want to inspect data without stopping a program. In such cases, PDB (and all other debuggers that run within the interpreter itself) are next to useless, and without pyringe you'd be left with having to debug using print statements. Pyringe is just quite convenient in these cases.

I injected a change to a local var into a function and it's not showing up!

This is a known limitation. Things like inject('var = 2') won't work, but inject('var[1] = 1337') should. This is because most of the time, python internally uses a fast path for looking up local variables that doesn't actually perform the dictionary lookup in locals(). In general, code you inject into processes with pyringe is very different from a normal python function call.

How do I use it?

You can start the debugger by executing python -m pyringe. Alternatively:

import pyringe
pyringe.interact()

If that reminds you of the code module, good; this is intentional.
After starting the debugger, you'll be greeted by what behaves almost like a regular python REPL.
Try the following:

==> pid:[None] #threads:[0] current thread:[None]
>>> help()
Available commands:
 attach: Attach to the process with the given pid.
 bt: Get a backtrace of the current position.
 [...]
==> pid:[None] #threads:[0] current thread:[None]
>>> attach(12679)
==> pid:[12679] #threads:[11] current thread:[140108099462912]
>>> threads()
[140108099462912, 140108107855616, 140108116248323, 140108124641024, 140108133033728, 140108224739072, 140108233131776, 140108141426432, 140108241524480, 140108249917184, 140108269324032]

The IDs you see here correspond to what threading.current_thread().ident would tell you.
All debugger functions are just regular python functions that have been exposed to the REPL, so you can do things like the following.

==> pid:[12679] #threads:[11] current thread:[140108099462912]
>>> for tid in threads():
...   if not tid % 10:
...     thread(tid)
...     bt()
... 
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 524, in __bootstrap
    self.__bootstrap_inner()
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./test.py", line 46, in Idle
    Thread_2_Func(1)
  File "./test.py", line 40, in Wait
    time.sleep(n)
==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> 

You can access the inferior's locals and inspect them like so:

==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> inflocals()
{'a': <proxy of A object at remote 0x1d9b290>, 'LOL': 'success!', 'b': <proxy of B object at remote 0x1d988c0>, 'n': 1}
==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> p('a')
<proxy of A object at remote 0x1d9b290>
==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> p('a').attr
'Some_magic_string'
==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> 

And sure enough, the definition of a's class reads:

class Example(object):
  cl_attr = False
  def __init__(self):
    self.attr = 'Some_magic_string'

There's limits to how far this proxying of objects goes, and everything that isn't trivial data will show up as strings (like '<function at remote 0x1d957d0>').
You can inject python code into running programs. Of course, there are caveats but... see for yourself:

==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> inject('import threading')
==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> inject('print threading.current_thread().ident')
==> pid:[12679] #threads:[11] current thread:[140108241524480]
>>> 

The output of my program in this case reads:

140108241524480

If you need additional pointers, just try using python's help (pyhelp() in the debugger) on debugger commands.

pyringe's People

Contributors

tehmillhouse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyringe's Issues

syntax error in libpython.py

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 ?

Debug Symbols on Ubuntu

Having installed python2.7-dbg, the automatic loading of the symbol file isn't working:

Pyringe (Python 2.7.3) on linux2
For a list of debugger commands, try "help()". (python's help is available as pyhelp.)
==> pid:[None] #threads:[0] current thread:[None]
>>> attach(8298)
WARNING:root:Failed to automatically load symbol file, some functionality will be unavailable until symbol file is provided.
==> pid:[8298] #threads:[0] current thread:[None]

It seems that the default SYMBOL_FILE is relative to payload, and it seems to not be present. Changing the default to, say, the binary or shared object files installed by the python2.7-dbg package then fails to pass the sanity check.

Am I missing something obvious? Does the python (in our case, a daemon) have to have been invoked with python-dbg (we were under the impression that was not the case)?

WindowsError: [Error 2] The system cannot find the file specified

When attempting to inject into either a process that runs on python, or a normal python.exe interpreter, I get the error:

  File "<console>", line 1, in <module>  
  File "C:\Python27\lib\site-packages\pyringe\repl.py", line 157, in Attach
    self.inferior.Reinit(pid)  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 480, in Reinit  
    self.__init__(pid, auto_symfile_loading)  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 452, in __init__  
    self.StartGdb()  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 498, in StartGdb  
    self._gdb = GdbProxy()  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 134, in __init__  
    gdb_version = GdbProxy.Version()  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 237, in Version  
    output = subprocess.check_output(['gdb', '--version']).split('\n')[0]  
  File "C:\Python27\lib\subprocess.py", line 212, in check_output  
    process = Popen(stdout=PIPE, *popenargs, **kwargs)  
  File "C:\Python27\lib\subprocess.py", line 390, in __init__  
    errread, errwrite)  
  File "C:\Python27\lib\subprocess.py", line 640, in _execute_child  
    startupinfo)  
WindowsError: [Error 2] The system cannot find the file specified  
WARNING:root:Inferior is not running.

I'm running Windows 10 on Python 2.7.13.

Immediate SyntaxError on attach

Attempting to attach to a process, I get this error:

In [3]: pyringe.interact()
Pyringe (Python 2.7.5) on linux2
For a list of debugger commands, try "help()". (python's help is available as pyhelp.)
==> pid:[None] #threads:[0] current thread:[None]
In : attach(26802)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 418, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 390, in __init__
    self.StartGdb()
  File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 437, in StartGdb
    self._gdb.Attach(self.position)
  File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 181, in <lambda>
    return lambda *args, **kwargs: self._Execute(name, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 277, in _Execute
    result_string = self._Recv(timeout)
  File "/usr/local/lib/python2.7/dist-packages/pyringe/inferior.py", line 362, 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 <module>
    import libpython
  File "/usr/local/lib/python2.7/dist-packages/pyringe/payload/libpython.py", line 58
    Py_TPFLAGS_HEAPTYPE = (1L << 9)
                            ^
SyntaxError: invalid syntax

==> pid:[26802] #threads:[0] current thread:[None]

Support for debugging other versions of cpython

The currently included libpython.py is taken directly from cpython 2.7.3's source tree. Supporting other versions of python would only require multiple versions of libpython being available and a way of finding out which version is run as the inferior.

gdb: unrecognised option '--nh'

I've received the following when trying to attach to a process:

For a list of debugger commands, try "help()". (python's help is available as pyhelp.)
==> pid:[None] #threads:[0] current thread:[None]
>>> attach(31043)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/inferior.py", line 418, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/inferior.py", line 390, in __init__
    self.StartGdb()
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/inferior.py", line 437, in StartGdb
    self._gdb.Attach(self.position)
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/inferior.py", line 181, in <lambda>
    return lambda *args, **kwargs: self._Execute(name, *args, **kwargs)
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/inferior.py", line 277, in _Execute
    result_string = self._Recv(timeout)
  File "/home/asmith/.local/lib/python2.7/site-packages/pyringe/inferior.py", line 362, in _Recv
    raise ProxyError(exc_text)
ProxyError: gdb: unrecognised option '--nh'
Use `gdb --help' for a complete list of options.

I assume there's some gdb version mismatch:

GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>.

Fix 100% CPU when waiting for command completion.

When waiting for the gdb process to write its output, the current IPC mechanism ends up essentially in a busy waiting loop, causing high CPU usage.

Ideally, that IPC mechanism is to be replaced by a more generic version that can be reused by different parts of the debugger (cf. Issue #2)

Investigate PyFrame_FastToLocals

According to revelation, PyFrame_FastToLocals not only copies f_fastlocals to f_locals, but also disables use of the fastlocals optimization. This might enable removing the limitations to setting locals in injected code.

There's only one level of symbol file sanity

The debugger only differentiates between 'safe' and 'potentially unsafe' symbol files, and even when using symbol information deemed safe by the debugger, there may be problems. The debugger should have knowledge of finer granularity about which symbols (and by extension, which features) are available.

Python 3 friendly?

Seeing a print 'some string' statement in the code I gather that pyringe is python 2 only. However, it would be nice to see this announced on the frontpage and on PyPI.

Cheers.

Ability to open PDB via injected code

It should technically already possible to inject a PDB session (with some caveats, as always), but it's sort of tedious (manually creating an IPC channel (usually a socket) to the debugger, wrapping it in a file-like object, and starting pdb with that as its I/O channel).

There should be a function wrapping all of this into a single command.

attach(): AttributeError: 'module' object has no attribute 'poll'

When I try to attach to a Python process, I get the following traceback (OSX 10.9.2):

>>> attach(3938)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 418, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 390, in __init__
    self.StartGdb()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 436, in StartGdb
    self._gdb = GdbProxy()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 166, in __init__
    self._poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/__main__.py", line 19, in <module>
    pyringe.interact()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/__init__.py", line 25, in interact
    DebuggingConsole().interact()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/repl.py", line 208, in interact
    prompt = self.StatusLine() + '\n' + sys.ps1
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/repl.py", line 133, in StatusLine
    self.inferior.StartGdb()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 436, in StartGdb
    self._gdb = GdbProxy()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 166, in __init__
    self._poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'

GDB is installed (6.3.50).

Fall back to signal injection if symbol info is partial.

Depending on how stripped the python binary being used is, pendingcalls_to_do or pendingbusy may be unavailable. It'd be useful to fall back to injecting fake signals using Py_AddPendingCall(0,0) in such cases, even though it's more intrusive and less reliable.

attach failed

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/inferior.py", line 480, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/inferior.py", line 452, in __init__
    self.StartGdb()
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/inferior.py", line 499, in StartGdb
    self._gdb.Attach(self.position)
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/inferior.py", line 197, in <lambda>
    return lambda *args, **kwargs: self._Execute(name, *args, **kwargs)
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/inferior.py", line 339, in _Execute
    result_string = self._Recv(timeout)
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/inferior.py", line 424, in _Recv
    raise ProxyError(exc_text)
ProxyError: 
-----------------------------------
Error occurred within GdbService:
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/payload/gdb_service.py", line 652, in <module>
    serv.EvalLoop()
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/payload/gdb_service.py", line 274, in EvalLoop
    while self._AcceptRPC():
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/payload/gdb_service.py", line 293, in _AcceptRPC
    rpc_result = getattr(self, request['func'])(*request['args'])
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/payload/gdb_service.py", line 428, in Attach
    GdbCache.Refresh()
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/payload/gdb_service.py", line 66, in Refresh
    interp_head_name = GdbCache.FuzzySymbolLookup('interp_head')
  File "/home/yy/code/hzf/boss-be-v2/env/local/lib/python2.7/site-packages/pyringe/payload/gdb_service.py", line 101, in FuzzySymbolLookup
    return '\'%s\'' % mangled_name.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
==> pid:[3779] #threads:[0] current thread:[None]
>>>  

ModuleNotFoundError: No module named 'inferior'

  • OS: Ubuntu 19.04
  • Arch: Linux carrot 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
➜ apt install gdb python-dbg python2.7-dbg
➜ pip install --no-cache-dir pyringe
Collecting pyringe
  Using cached https://files.pythonhosted.org/packages/7c/c6/6cef124c38227ece01350414c7866727179d17f64b88b8bf513386c0e4be/pyringe-1.0.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jearzn7v/pyringe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jearzn7v/pyringe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-jearzn7v/pyringe/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-jearzn7v/pyringe/setup.py", line 18, in <module>
        import pyringe
      File "/tmp/pip-install-jearzn7v/pyringe/pyringe/__init__.py", line 17, in <module>
        import inferior
    ModuleNotFoundError: No module named 'inferior'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

However, installing via git repo worked fine, so it looks like it's an issue with the pip package and is due to missing dependencies / bad system setup:

➜ git clone https://github.com/google/pyringe.git
➜ cd pyringe
➜ python setup.py install
➜ python -m pyringe
Pyringe (Python 2.7.15) on linux2
For a list of debugger commands, try "help()". (python's help is available as pyhelp.)
==> pid:[None] #threads:[0] current thread:[None]
>>>

Failed to automatically load symbol file

I get this output:

 % python -m pyringe         
Pyringe (Python 2.7.3) on linux2
For a list of debugger commands, try "help()". (python's help is available as pyhelp.)
==> pid:[None] #threads:[0] current thread:[None]
>>> attach(30375)
WARNING:root:Failed to automatically load symbol file, some functionality will be unavailable until symbol file is provided.
==> pid:[30375] #threads:[0] current thread:[None]
>>> threads()
PositionError: Not attached to any process.
WARNING:root:Failed to automatically load symbol file, some functionality will be unavailable until symbol file is provided.
==> pid:[30375] #threads:[0] current thread:[None]
>>> 

How can I get more info about why it failed? There is too less information to debug this.

Arch Linux not supported

Due to the lack of a a 'python-devel'-like package on Arch Linux, there are no symbols available unless you compile python yourself.

attach failed with TimeoutError exception

I'm running pyringe to try to attach to one python process on Mac platform, and it fails all the time.

Using pyringe git HEAD code instead of PYPI package.
Gdb version: 8.1

Here is the trace:

Traceback (most recent call last):
File "", line 1, in
File "pyringe/repl.py", line 161, in Attach
self.inferior.Reinit(pid)
File "pyringe/inferior.py", line 484, in Reinit
self.init(pid, auto_symfile_loading, architecture=self.arch)
File "pyringe/inferior.py", line 456, in init
self.StartGdb()
File "pyringe/inferior.py", line 503, in StartGdb
self._gdb.Attach(self.position)
File "pyringe/inferior.py", line 200, in
return lambda *args, **kwargs: self._Execute(name, *args, **kwargs)
File "pyringe/inferior.py", line 342, in _Execute
result_string = self._Recv(timeout)
File "pyringe/inferior.py", line 429, in _Recv
raise TimeoutError()
TimeoutError
==> pid:[71164] #threads:[0] current thread:[None]

Pyringe falls over if something (GdbProxy?) reports a non-numeric version

$ python -m pyringe
Pyringe (Python 2.7.3) on linux2
For a list of debugger commands, try "help()". (python's help is available as pyhelp.)
==> pid:[None] #threads:[0] current thread:[None]
>>> attach(17014)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 464, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 436, in __init__
    self.StartGdb()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 482, in StartGdb
    self._gdb = GdbProxy()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 133, in __init__
    gdb_version = GdbProxy.Version()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 244, in Version
    major = int(version[0])
ValueError: invalid literal for int() with base 10: 'Red'
Traceback (most recent call last):
  File "/opt/python/current/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/python/current/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/__main__.py", line 19, in <module>
    pyringe.interact()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/__init__.py", line 25, in interact
    DebuggingConsole().interact()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/repl.py", line 208, in interact
    prompt = self.StatusLine() + '\n' + sys.ps1
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/repl.py", line 133, in StatusLine
    self.inferior.StartGdb()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 482, in StartGdb
    self._gdb = GdbProxy()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 133, in __init__
    gdb_version = GdbProxy.Version()
  File "/home/dtdev/dtenv/lib/python2.7/site-packages/pyringe/inferior.py", line 244, in Version
    major = int(version[0])
ValueError: invalid literal for int() with base 10: 'Red'
(dtenv)[ dtdev@dtdev-centos ~ ]
$ 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.