)]}'
{
  "commit": "15e15b2d9cd3b1db68f99cd3b047352142ddfd1c",
  "tree": "6bc04a49dbf8d60839ec0d73638eee4803acd559",
  "parents": [
    "e4ae302562aba1bd166919d76341fb631e2d470a"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "andrew.burgess@embecosm.com",
    "time": "Fri Sep 17 18:12:34 2021 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Jun 15 09:44:54 2022 +0100"
  },
  "message": "gdb/python: implement the print_insn extension language hook\n\nThis commit extends the Python API to include disassembler support.\n\nThe motivation for this commit was to provide an API by which the user\ncould write Python scripts that would augment the output of the\ndisassembler.\n\nTo achieve this I have followed the model of the existing libopcodes\ndisassembler, that is, instructions are disassembled one by one.  This\ndoes restrict the type of things that it is possible to do from a\nPython script, i.e. all additional output has to fit on a single line,\nbut this was all I needed, and creating something more complex would,\nI think, require greater changes to how GDB\u0027s internal disassembler\noperates.\n\nThe disassembler API is contained in the new gdb.disassembler module,\nwhich defines the following classes:\n\n  DisassembleInfo\n\n      Similar to libopcodes disassemble_info structure, has read-only\n  properties: address, architecture, and progspace.  And has methods:\n  __init__, read_memory, and is_valid.\n\n      Each time GDB wants an instruction disassembled, an instance of\n  this class is passed to a user written disassembler function, by\n  reading the properties, and calling the methods (and other support\n  methods in the gdb.disassembler module) the user can perform and\n  return the disassembly.\n\n  Disassembler\n\n      This is a base-class which user written disassemblers should\n  inherit from.  This base class provides base implementations of\n  __init__ and __call__ which the user written disassembler should\n  override.\n\n  DisassemblerResult\n\n      This class can be used to hold the result of a call to the\n  disassembler, it\u0027s really just a wrapper around a string (the text\n  of the disassembled instruction) and a length (in bytes).  The user\n  can return an instance of this class from Disassembler.__call__ to\n  represent the newly disassembled instruction.\n\nThe gdb.disassembler module also provides the following functions:\n\n  register_disassembler\n\n      This function registers an instance of a Disassembler sub-class\n  as a disassembler, either for one specific architecture, or, as a\n  global disassembler for all architectures.\n\n  builtin_disassemble\n\n      This provides access to GDB\u0027s builtin disassembler.  A common\n  use case that I see is augmenting the existing disassembler output.\n  The user code can call this function to have GDB disassemble the\n  instruction in the normal way.  The user gets back a\n  DisassemblerResult object, which they can then read in order to\n  augment the disassembler output in any way they wish.\n\n      This function also provides a mechanism to intercept the\n  disassemblers reads of memory, thus the user can adjust what GDB\n  sees when it is disassembling.\n\nThe included documentation provides a more detailed description of the\nAPI.\n\nThere is also a new CLI command added:\n\n  maint info python-disassemblers\n\nThis command is defined in the Python gdb.disassemblers module, and\ncan be used to list the currently registered Python disassemblers.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d80087749dec133da2f3189e82aa878d7e66f716",
      "old_mode": 33188,
      "old_path": "gdb/Makefile.in",
      "new_id": "911daa2607bbc23bd722b3256def17a477f547c2",
      "new_mode": 33188,
      "new_path": "gdb/Makefile.in"
    },
    {
      "type": "modify",
      "old_id": "0efcce7d3efc392ac57b5937dc66410096b542df",
      "old_mode": 33188,
      "old_path": "gdb/NEWS",
      "new_id": "ac9a1aacd343843ec03f4244109b0fab6c13783e",
      "new_mode": 33188,
      "new_path": "gdb/NEWS"
    },
    {
      "type": "modify",
      "old_id": "b606fc654b59e95f7e4a5d1e06e9bb47de90d286",
      "old_mode": 33188,
      "old_path": "gdb/data-directory/Makefile.in",
      "new_id": "cf5226f39616d0f53068100fde7386116204ae6c",
      "new_mode": 33188,
      "new_path": "gdb/data-directory/Makefile.in"
    },
    {
      "type": "modify",
      "old_id": "3a8cf3f1b6bdd0d292bd368b6e942ee986522e4d",
      "old_mode": 33188,
      "old_path": "gdb/doc/gdb.texinfo",
      "new_id": "2178b476f5316bd901f8cc59bbe649fec220d865",
      "new_mode": 33188,
      "new_path": "gdb/doc/gdb.texinfo"
    },
    {
      "type": "modify",
      "old_id": "aaf7666e0be47cbd12421a47365f7dac51d466de",
      "old_mode": 33188,
      "old_path": "gdb/doc/python.texi",
      "new_id": "75804ef975e5165ba54a8a04be194f1356b6b977",
      "new_mode": 33188,
      "new_path": "gdb/doc/python.texi"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "5a2d94a5fac5e41652632c58d6dfa4942356b2fa",
      "new_mode": 33188,
      "new_path": "gdb/python/lib/gdb/disassembler.py"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "4c78ca350c27ceb30427edcd05b1e0ea32d9eafe",
      "new_mode": 33188,
      "new_path": "gdb/python/py-disasm.c"
    },
    {
      "type": "modify",
      "old_id": "da2e79101a6a901a22f9833170dc422897711409",
      "old_mode": 33188,
      "old_path": "gdb/python/python-internal.h",
      "new_id": "5ff9989af83cd255263f81535e0e884d4ee91366",
      "new_mode": 33188,
      "new_path": "gdb/python/python-internal.h"
    },
    {
      "type": "modify",
      "old_id": "97de5f5cee5e72d85e5edae42ad79ac675596c0c",
      "old_mode": 33188,
      "old_path": "gdb/python/python.c",
      "new_id": "079c260fc7f3c900c9cb5a3ce20c605fc7ff5d78",
      "new_mode": 33188,
      "new_path": "gdb/python/python.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ee0bb157f4dd1abd1bc9fc0058e869e7af641cde",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-disasm.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "1b9cd4465ac994149f3b950e0b586942b77080e3",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-disasm.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ff7ffdb97d9f76067925606b2572659d63b97d51",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-disasm.py"
    }
  ]
}
