{ "info": { "author": "Di Paola Martin, Di Tomaso Nicolas", "author_email": "no-email@example.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Debuggers" ], "description": "|Build Status|\n\nPython GDB MI Parser\n====================\n\n`MI `__ or\nMachine Interface is the new interface to interact with GDB, the GNU\nDebugger, from another program.\n\nThe output of the GDB Machine Interface is line oriented, text based. It\nis compound of small elements that range from strings to dictionaries\n\n``python-gdb-mi`` is simple and quite robust parser for Python 2.x/3.x\nthat can take those lines and transform them into python objects ready\nto be serialized if need to JSON.\n\nOverview\n--------\n\nA GDB MI text can be like this:\n\n.. code:: python\n\n >>> text = '^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x08048564\",func=\"main\",file=\"myprog.c\",fullname=\"/home/nickrob/myprog.c\",line=\"68\",thread-groups=[\"i1\"],times=\"0\"}\\n'\n\nThis is the kind of message that GDB will print when a breakpoint is\nset.\n\nTo parse it, we need to send this line to our ``Output`` parser using\nthe ``parse_line`` method:\n\n.. code:: python\n\n >>> from gdb_mi import Output\n\n >>> out = Output()\n\n >>> record = out.parse_line(text)\n >>> record #doctest: +NORMALIZE_WHITESPACE\n {'klass': 'done',\n 'results': {'bkpts': [{'addr': '0x08048564',\n 'disp': 'keep',\n 'enabled': 'y',\n 'file': 'myprog.c',\n 'fullname': '/home/nickrob/myprog.c',\n 'func': 'main',\n 'line': '68',\n 'number': '1',\n 'thread-groups': ['i1'],\n 'times': '0',\n 'type': 'breakpoint'}]},\n 'token': None,\n 'type': 'Sync'}\n\nIf the output from GDB is not a complete line, ``Output`` can handle it\nanyways doing some buffering. Use ``parse`` instead of ``parse_line`` to\nfeed ``Output``:\n\n.. code:: python\n\n >>> out.parse(text[:10]) # incomplete line, None returned\n\n >>> out.parse(text[10:]) # enough data, parse it! doctest: +NORMALIZE_WHITESPACE\n {'klass': 'done',\n 'results': {'bkpts': [{'addr': '0x08048564',\n 'disp': 'keep',\n 'enabled': 'y',\n 'file': 'myprog.c',\n 'fullname': '/home/nickrob/myprog.c',\n 'func': 'main',\n 'line': '68',\n 'number': '1',\n 'thread-groups': ['i1'],\n 'times': '0',\n 'type': 'breakpoint'}]},\n 'token': None,\n 'type': 'Sync'}\n\nParsing Results\n---------------\n\nThree types of objects can be returned by ``parse_line`` and ``parse``:\n\n- ``Stream`` that represents an `output\n record `__\n from: the console, the target and the log.\n- ``Record`` that represents or a synchronous `result\n record `__\n and or an out of band `asynchronous\n record `__,\n used to notify of changes that have happen.\n- ``(gdb)`` a literal string that represents an empty prompt line.\n\nBoth, ``Stream`` and ``Record`` have a ``as_native`` method to transform\nthem into a composition of Python's dicts and lists.\n\nStreams\n~~~~~~~\n\n.. code:: python\n\n >>> from gdb_mi import Stream\n\n >>> text = '~\"GDB rocks!\"\\n'\n >>> stream = out.parse_line(text)\n >>> stream # same as pprint.pprint(stream.as_native())\n {'stream': 'GDB rocks!', 'type': 'Console'}\n\n >>> isinstance(stream, Stream)\n True\n\nThe ``type`` attribute is `one of the\nfollowing `__,\nfrom the GDB MI's documentation: - ``Console``: output that should be\ndisplayed as is in the console. It is the textual response to a CLI\ncommand. - ``Target``: output produced by the target program. - ``Log``:\noutput text coming from GDB\u2019s internals, for instance messages that\nshould be displayed as part of an error log.\n\nRecords\n~~~~~~~\n\nWe have already seen an example of a ``Record``, in that case it was a\nsynchronous ``result record``:\n\n.. code:: python\n\n >>> from gdb_mi import Record\n\n >>> isinstance(record, Record)\n True\n\n >>> record.klass, record.type\n ('done', 'Sync')\n\nThe ``klass`` attribute is `one of the\nfollowing `__:\n``done``, ``running``, ``connected``, ``error`` or ``exit``.\n\nThe ``type`` attribute is ``Sync`` for a ``synchronous result record``.\n\nHere are an example of an ``asynchronous record``:\n\n.. code:: python\n\n >>> text = '42*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"1\",thread-id=\"0\",frame={addr=\"0x08048564\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\"0xbfc4d4d4\"}],file=\"myprog.c\",fullname=\"/home/nickrob/myprog.c\",line=\"68\"}\\n'\n >>> record = out.parse_line(text)\n >>> record #doctest: +NORMALIZE_WHITESPACE\n {'klass': 'stopped',\n 'results': {'bkptno': '1',\n 'disp': 'keep',\n 'frame': {'addr': '0x08048564',\n 'args': [{'name': 'argc', 'value': '1'},\n {'name': 'argv', 'value': '0xbfc4d4d4'}],\n 'file': 'myprog.c',\n 'fullname': '/home/nickrob/myprog.c',\n 'func': 'main',\n 'line': '68'},\n 'reason': 'breakpoint-hit',\n 'thread-id': '0'},\n 'token': 42,\n 'type': 'Exec'}\n\n >>> isinstance(record, Record)\n True\n\n >>> record.klass, record.type\n ('stopped', 'Exec')\n\nFor an ``asynchronous record``, the attribute ``type`` is `one of the\nfollowing `__\nfor ``AsyncRecord``\\ s: ``Exec``, ``Status`` or ``Notify``.\n\n>From the GDB MI's documentation: - ``Exec``: asynchronous state change\non the target (stopped, started, disappeared). - ``Status``: on-going\nstatus information about the progress of a slow operation. It can be\ndiscarded. - ``Notify``: supplementary information that the client\nshould handle (e.g., a new breakpoint information).\n\nBoth kind of records, synchronous and asynchronous, have two additional\nattributes: - ``token``: used by GDB to match the request and the\nresponse. - ``results``: the data contained in the message, it will\ndepend of the GDB message.\n\nInterference from Target\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you do not redirect the target's output nor send it to a new console\nrunning the GDB ``set new-console on`` command, the output of the target\nwill interfere an confuse the parser.\n\nUnfortunately there is nothing that we can do. Even if we ignore the\nmessage we cannot be sure when a message is safe to be discarded.\n\nFor example, the following C code generates an ambiguous output:\n\n.. code:: c\n\n printf(\"~looks like a GDB stream but it isn't\\n\");\n\nEven if you think that it is improbable, here is a quite common problem:\n\n.. code:: c\n\n printf(\"normal output 42\"); /* no newline at the end */\n fflush(stdout); /* but we flush to the console anyway */\n\nNow imagine that GDB hits a breakpoint after the ``fflush`` instruction,\nwhat we will see is:\n\n.. code:: python\n\n >>> text = 'normal output 4242*stopped,reason=\"breakpoint-hit\",\\n'\n\nThe problem is that all those strings are glued together which can lead\nto *nasty bugs*. We could try to use some regexps but it would be too\nfragile (is the ``token`` 42 or 4242?).\n\nInstead we try to warn you if you try to parse something like that:\n\n.. code:: python\n\n >>> out.parse_line(text) #doctest: +IGNORE_EXCEPTION_DETAIL\n Traceback (most recent call last):\n ParsingError: Invalid input. Maybe the target's output is interfering with the GDB MI's messages. Try to redirect the target's output to elsewhere or run GDB's 'set new-console on' command. Found at 0 position.\n Original message:\n normal output 4242*stopped,reason=\"breakpoint-hit\",\n\nInstall\n-------\n\nJust run:\n\n::\n\n $ pip install python-gdb-mi\n\nYou will find the ``python-gdb-mi`` package at\n`PyPI `__\n\nWorkarounds for GDB MI's issues\n-------------------------------\n\nThere are some issues in the output of GDB. ``python-gdb-mi`` tries to\nfix them implementing some minor changes in the GDB's output as\nworkarounds.\n\nSee the issues and the implemented fixes in the `workarounds\ndoctest `__\n\nHacking/Contributing\n--------------------\n\nGo ahead! Clone the repository, do a small fix/enhancement, run\n``make test`` to ensure that everything is working as expected and then\npropose your Pull Request!\n\n.. |Build Status| image:: https://travis-ci.org/hydra-dbg/python-gdb-mi.svg?branch=master\n :target: https://travis-ci.org/hydra-dbg/python-gdb-mi\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hydra-dbg/python-gdb-mi", "keywords": "debugger gdb", "license": "GNU LGPLv3", "maintainer": "", "maintainer_email": "", "name": "python-gdb-mi", "package_url": "https://pypi.org/project/python-gdb-mi/", "platform": "", "project_url": "https://pypi.org/project/python-gdb-mi/", "project_urls": { "Homepage": "https://github.com/hydra-dbg/python-gdb-mi" }, "release_url": "https://pypi.org/project/python-gdb-mi/1.0.1/", "requires_dist": null, "requires_python": ">=2.6", "summary": "A parser for GDB Machine Interface (MI) events.", "version": "1.0.1" }, "last_serial": 3292886, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "49a6260b1d6e845bef3ef0c4665b50cc", "sha256": "49de7bbea967439805b9dbdad354edf7897e37c4fe95b61364fd7615ca5d8804" }, "downloads": -1, "filename": "python_gdb_mi-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "49a6260b1d6e845bef3ef0c4665b50cc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.6", "size": 5253, "upload_time": "2017-10-30T14:12:44", "url": "https://files.pythonhosted.org/packages/f6/0a/f3567bd594182d6f976f6215e9fea8713b69c1473568dfb30502276e49cc/python_gdb_mi-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "20ef02e5448d68c77b95be91138bf2e8", "sha256": "022c40cd3eaa58717d37d2f7ffabe929c39c02ead2b6a9fc7a9e60b7170b3173" }, "downloads": -1, "filename": "python-gdb-mi-1.0.0.tar.gz", "has_sig": false, "md5_digest": "20ef02e5448d68c77b95be91138bf2e8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.6", "size": 4087, "upload_time": "2017-10-30T14:12:45", "url": "https://files.pythonhosted.org/packages/6a/a9/b1db725e99dc3db747c0ea2ae85b8c8d892a403e5267fd24f9bfd63d4ca7/python-gdb-mi-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "e129f586fdbd653b19c9d95dc96ce361", "sha256": "3b4597508334642752eece70542152e2998512a9607ee8165a98c53916e6a8c7" }, "downloads": -1, "filename": "python_gdb_mi-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e129f586fdbd653b19c9d95dc96ce361", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.6", "size": 11720, "upload_time": "2017-10-30T23:32:24", "url": "https://files.pythonhosted.org/packages/d2/b5/a291951c7250177f851eef99eb42da451d5246ec669e91cc626c92cfb6a6/python_gdb_mi-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8f94bde1946775a7d4baf8ad1be12ec1", "sha256": "ba42d388ef5dd72c36654a65d8c08a2f552f793520f9c31c76ce89a80e918391" }, "downloads": -1, "filename": "python-gdb-mi-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8f94bde1946775a7d4baf8ad1be12ec1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.6", "size": 8034, "upload_time": "2017-10-30T23:32:25", "url": "https://files.pythonhosted.org/packages/dc/6e/7a8aebc081bb708089395ee53201995e89fa41192bbd96f953d8d3c901a8/python-gdb-mi-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e129f586fdbd653b19c9d95dc96ce361", "sha256": "3b4597508334642752eece70542152e2998512a9607ee8165a98c53916e6a8c7" }, "downloads": -1, "filename": "python_gdb_mi-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e129f586fdbd653b19c9d95dc96ce361", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.6", "size": 11720, "upload_time": "2017-10-30T23:32:24", "url": "https://files.pythonhosted.org/packages/d2/b5/a291951c7250177f851eef99eb42da451d5246ec669e91cc626c92cfb6a6/python_gdb_mi-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8f94bde1946775a7d4baf8ad1be12ec1", "sha256": "ba42d388ef5dd72c36654a65d8c08a2f552f793520f9c31c76ce89a80e918391" }, "downloads": -1, "filename": "python-gdb-mi-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8f94bde1946775a7d4baf8ad1be12ec1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.6", "size": 8034, "upload_time": "2017-10-30T23:32:25", "url": "https://files.pythonhosted.org/packages/dc/6e/7a8aebc081bb708089395ee53201995e89fa41192bbd96f953d8d3c901a8/python-gdb-mi-1.0.1.tar.gz" } ] }