All Projects → cs01 → Pygdbmi

cs01 / Pygdbmi

Licence: mit
A library to parse gdb mi output and interact with gdb subprocesses

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pygdbmi

Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (-2.16%)
Mutual labels:  backend, frontend
Cppcmb
A generic C++17 parser-combinator library with a natural grammar notation.
Stars: ✭ 108 (-22.3%)
Mutual labels:  parser-library, parser
Spring Boot Mongodb Angular Todo App
A Sample App built using Spring Boot, Angular and MongoDB
Stars: ✭ 84 (-39.57%)
Mutual labels:  backend, frontend
Bank
🏦 Full Stack Web Application similar to financial software that is used in banking institutions | React.js and Node.js
Stars: ✭ 1,158 (+733.09%)
Mutual labels:  backend, frontend
Todomvc Ddd Cqrs Eventsourcing
Implementation of basic Todo app via tastejs/todomvc in C#/Typescript with eventsourcing, cqrs, and domain driven design
Stars: ✭ 134 (-3.6%)
Mutual labels:  backend, frontend
Bug Tracker Pern Ts
Bug Tracking app with project members support. Made with PERN stack + TypeScript.
Stars: ✭ 79 (-43.17%)
Mutual labels:  backend, frontend
Mediawiki
MediaWiki API wrapper in python http://pymediawiki.readthedocs.io/en/latest/
Stars: ✭ 89 (-35.97%)
Mutual labels:  parser-library, parser
Node Javascript Ecommerce
Build ECommece Like Amazona Using Vanilla JS
Stars: ✭ 57 (-58.99%)
Mutual labels:  backend, frontend
Spring Boot Vuejs
Example project showing how to build a Spring Boot App providing a GUI with Vue.js
Stars: ✭ 1,818 (+1207.91%)
Mutual labels:  backend, frontend
Eshoponcontainersddd
Fork of dotnet-architecture/eShopOnContainers in full DDD/CQRS design using my own patterns
Stars: ✭ 126 (-9.35%)
Mutual labels:  backend, frontend
Elm Street
🌳 Crossing the road between Haskell and Elm
Stars: ✭ 65 (-53.24%)
Mutual labels:  backend, frontend
Mern Authentication
MERN stack authentication boilerplate: password reset, email verification, server sessions, redux, hooks and docker for dev and prod.
Stars: ✭ 129 (-7.19%)
Mutual labels:  backend, frontend
Dev Practice
Practice your skills with these ideas.
Stars: ✭ 1,127 (+710.79%)
Mutual labels:  backend, frontend
Blog
阿翔的个人技术博客,博文写在 Issues 里,如有收获请 star 鼓励~
Stars: ✭ 135 (-2.88%)
Mutual labels:  backend, frontend
Layr
Dramatically simplify full‑stack development
Stars: ✭ 1,111 (+699.28%)
Mutual labels:  backend, frontend
Hiring
Create WOW Moments. Create superfans.
Stars: ✭ 85 (-38.85%)
Mutual labels:  backend, frontend
Tech Logo Memo Game
🖱️🖱️🖕🖕🤯🤯🤯technology logo memory game, including frontend and backend
Stars: ✭ 49 (-64.75%)
Mutual labels:  backend, frontend
Gdbgui
Browser-based frontend to gdb (gnu debugger). Add breakpoints, view the stack, visualize data structures, and more in C, C++, Go, Rust, and Fortran. Run gdbgui from the terminal and a new tab will open in your browser.
Stars: ✭ 8,339 (+5899.28%)
Mutual labels:  gdb, frontend
Java Petitparser
Dynamic parser combinators in Java.
Stars: ✭ 118 (-15.11%)
Mutual labels:  parser-library, parser
Awesome Interview
Collection of awesome interview references.
Stars: ✭ 1,683 (+1110.79%)
Mutual labels:  backend, frontend

pygdbmi - Get Structured Output from GDB's Machine Interface

Test status PyPI version

Documentation https://cs01.github.io/pygdbmi

Source Code https://github.com/cs01/pygdbmi


Python (py) gdb machine interface (mi)

GDB/MI is a line based machine oriented text interface to GDB and is activated by specifying using the --interpreter command line option (see Mode Options). It is specifically intended to support the development of systems which use the debugger as just one small component of a larger system.

What's in the box?

  1. A function to parse gdb machine interface string output and return structured data types (Python dicts) that are JSON serializable. Useful for writing the backend to a gdb frontend. For example, gdbgui uses pygdbmi on the backend.
  2. A Python class to control and interact with gdb as a subprocess

To get machine interface output from gdb, run gdb with the --interpreter=mi2 flag like so:

gdb --interpreter=mi2

Installation

pip install pygdbmi

Compatibility

Operating Systems

Cross platform support for Linux, macOS and Windows

  • Linux/Unix

    Ubuntu 14.04 and 16.04 have been tested to work. Other versions likely work as well.

  • macOS

    Note: the error please check gdb is codesigned - see taskgated(8) can be fixed by codesigning gdb with these instructions. If the error is not fixed, please create an issue in github.

  • Windows

    Windows 10 has been tested to work with MinGW and cygwin.

gdb versions

  • gdb 7.6+ has been tested. Older versions may work as well.

Examples

gdb mi defines a syntax for its output that is suitable for machine readability and scripting: example output:

-> -break-insert main
<- ^done,bkpt={number="1",type="breakpoint",disp="keep",
enabled="y",addr="0x08048564",func="main",file="myprog.c",
fullname="/home/myprog.c",line="68",thread-groups=["i1"],
times="0"}
<- (gdb)

Use pygdbmi.gdbmiparser.parse_response to turn that string output into a JSON serializable dictionary

from pygdbmi import gdbmiparser
from pprint import pprint
response = gdbmiparser.parse_response('^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x08048564",func="main",file="myprog.c",fullname="/home/myprog.c",line="68",thread-groups=["i1"],times="0"')
pprint(response)
> {'message': 'done',
'payload': {'bkpt': {'addr': '0x08048564',
                      'disp': 'keep',
                      'enabled': 'y',
                      'file': 'myprog.c',
                      'fullname': '/home/myprog.c',
                      'func': 'main',
                      'line': '68',
                      'number': '1',
                      'thread-groups': ['i1'],
                      'times': '0',
                      'type': 'breakpoint'}},
 'type': 'result'}

Programmatic Control Over gdb

But how do you get the gdb output into Python in the first place? If you want, pygdbmi also has a class to control gdb as subprocess. You can write commands, and get structured output back:

from pygdbmi.gdbcontroller import GdbController
from pprint import pprint

# Start gdb process
gdbmi = GdbController()
print(gdbmi.get_subprocess_cmd())  # print actual command run as subprocess

# Load binary a.out and get structured response
response = gdbmi.write('-file-exec-file a.out')
pprint(response)
[{'message': u'thread-group-added',
  'payload': {u'id': u'i1'},
  'type': 'notify'},
 {'message': u'done', 'payload': None, 'type': 'result'}]

Now do whatever you want with gdb. All gdb commands, as well as gdb machine interface commands are acceptable. gdb mi commands give better structured output that is machine readable, rather than gdb console output. mi commands begin with a -.

response = gdbmi.write('-break-insert main')  # machine interface (MI) commands start with a '-'
response = gdbmi.write('break main')  # normal gdb commands work too, but the return value is slightly different
response = gdbmi.write('-exec-run')
response = gdbmi.write('run')
response = gdbmi.write('-exec-next', timeout_sec=0.1)  # the wait time can be modified from the default of 1 second
response = gdbmi.write('next')
response = gdbmi.write('next', raise_error_on_timeout=False)
response = gdbmi.write('next', raise_error_on_timeout=True, timeout_sec=0.01)
response = gdbmi.write('-exec-continue')
response = gdbmi.send_signal_to_gdb('SIGKILL')  # name of signal is okay
response = gdbmi.send_signal_to_gdb(2)  # value of signal is okay too
response = gdbmi.interrupt_gdb()  # sends SIGINT to gdb
response = gdbmi.write('continue')
response = gdbmi.exit()

Parsed Output Format

Each parsed gdb response consists of a list of dictionaries. Each dictionary has keys message, payload, token, and type.

  • message contains a textual message from gdb, which is not always present. When missing, this is None.
  • payload contains the content of gdb's output, which can contain any of the following: dictionary, list, string. This too is not always present, and can be None depending on the response.
  • token If an input command was prefixed with a (optional) token then the corresponding output for that command will also be prefixed by that same token. This field is only present for pygdbmi output types nofity and result. When missing, this is None.

The type is defined based on gdb's various mi output record types, and can be

  • result - the result of a gdb command, such as done, running, error, etc.
  • notify - additional async changes that have occurred, such as breakpoint modified
  • console - textual responses to cli commands
  • log - debugging messages from gdb's internals
  • output - output from target
  • target - output from remote target
  • done - when gdb has finished its output

Contributing

Documentation fixes, bug fixes, performance improvements, and functional improvements are welcome. You may want to create an issue before beginning work to make sure I am interested in merging it to the master branch.

pygdbmi uses nox for automation.

See available tasks with

nox -l

Run tests and lint with

nox -s tests
nox -s lint

Projects Using pygdbmi

  • gdbgui implements a browser-based frontend to gdb, using pygdbmi on the backend
  • PINCE is a gdb frontend that aims to provide a reverse engineering tool and a reusable library focused on games. It uses pygdbmi to parse gdb/mi based output for some functions
  • avatar² is an orchestration framework for reversing and analysing firmware of embedded devices. It utilizes pygdbmi for internal communication to different analysis targets.
  • Know of another project? Create a PR and add it here.

Authors

pygdbmi was written by Chad Smith with contributions from the community. Thanks especially to @mariusmue, @bobthekingofegypt, @mouuff, and @felipesere.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].