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

gdb: unrecognised option '--nh' #13

Closed
andrewmichaelsmith opened this issue Mar 31, 2014 · 6 comments
Closed

gdb: unrecognised option '--nh' #13

andrewmichaelsmith opened this issue Mar 31, 2014 · 6 comments

Comments

@andrewmichaelsmith
Copy link

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/>.
@TehMillhouse
Copy link
Contributor

Of all the flags that are given to gdb, I wouldn't have expected --nh to be a problem on other distros. For the time being, could you try the following for starting the debugger:

import pyringe
pyringe.inferior._GDB_ARGS.remove('--nh')
pyringe.interact()

I'll try to think of a generic way to get this to work, in the meantime, knowing which flags cause problems on some distros will help.

@andrewmichaelsmith
Copy link
Author

Thanks, that workaround did the trick. I'll try it on some other distros and let you know if I come across any more.

@mckelvin
Copy link

mckelvin commented Apr 2, 2014

I come across the same issue, but the trick does not works.

In [1]: import pyringe

In [2]: pyringe.inferior._GDB_ARGS
Out[2]: ['gdb', '--nh', '--nw', '--quiet', '--batch-silent']

In [3]: pyringe.inferior._GDB_ARGS.remove('--nh')

In [4]: 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(10987)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/inferior.py", line 418, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/inferior.py", line 390, in __init__
    self.StartGdb()
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/inferior.py", line 437, in StartGdb
    self._gdb.Attach(self.position)
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/inferior.py", line 181, in <lambda>
    return lambda *args, **kwargs: self._Execute(name, *args, **kwargs)
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/inferior.py", line 277, in _Execute
    result_string = self._Recv(timeout)
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/inferior.py", line 362, in _Recv
    raise ProxyError(exc_text)
ProxyError:
-----------------------------------
Error occurred within GdbService:
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 652, in <module>
    serv.EvalLoop()
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 274, in EvalLoop
    while self._AcceptRPC():
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 293, in _AcceptRPC
    rpc_result = getattr(self, request['func'])(*request['args'])
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 429, in Attach
    self.selected_tstate = self._ThreadPtrs(pos)[0]
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 454, in _ThreadPtrs
    self.EnsureGdbPosition(position[0], None, None)
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 333, in EnsureGdbPosition
    if not self.IsAttached():
  File "/home/username/.local/lib64/python2.7/site-packages/pyringe/payload/gdb_service.py", line 366, in IsAttached
    inf = gdb.selected_inferior()
AttributeError: 'module' object has no attribute 'selected_inferior'

GNU gdb (Gentoo 7.3.1 p2) 7.3.1
Linux hostname 3.0.36-gentoo

@TehMillhouse
Copy link
Contributor

@mckelvin Your issue seems to be a different one. Digging in the gdb release schedule and the gdb changelog (first copy I could find online, search for the patch "PR Python/12692"), it looks like while python scripting was introduced in gdb 7.3, significant portions of the python API were only added after its release.

I will bump the required version of gdb to 7.4. Try getting a more recent version of gdb, that should fix the issue you're seeing.

@devunt
Copy link

devunt commented Apr 6, 2014

--nh flag was introduced in gdb 7.6.1 stable (actually 7.6-1 unstable), but Ubuntu precise's official repo have gdb 7.4

@TehMillhouse
Copy link
Contributor

@devunt Thanks for tracking this change down. I finally got around to adding a quick version check. Shouldn't be an issue anymore since 8fce35c.

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