)]}'
{
  "commit": "d344cef4bf500f01ae326c2bd844a736de50fa41",
  "tree": "496b2e2d1feda0fc4a9ec13fceaa660f6ecda243",
  "parents": [
    "02c7fce1ad07412838cd1e97d1c8ee34c59a3c60"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Mar 30 11:21:32 2023 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Apr 06 15:04:17 2023 +0100"
  },
  "message": "gdb/python: allow Frame.read_var to accept named arguments\n\nThis commit allows Frame.read_var to accept named arguments, and also\nimproves (I think) some of the error messages emitted when values of\nthe wrong type are passed to this function.\n\nThe read_var method takes two arguments, one a variable, which is\neither a gdb.Symbol or a string, while the second, optional, argument\nis always a gdb.Block.\n\nI\u0027m now using \u0027O!\u0027 as the format specifier for the second argument,\nwhich allows the argument type to be checked early on.  Currently, if\nthe second argument is of the wrong type then we get this error:\n\n  (gdb) python print(gdb.selected_frame().read_var(\"a1\", \"xxx\"))\n  Traceback (most recent call last):\n    File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\n  RuntimeError: Second argument must be block.\n  Error while executing Python code.\n  (gdb)\n\nAfter this commit, we now get an error like this:\n\n  (gdb) python print(gdb.selected_frame().read_var(\"a1\", \"xxx\"))\n  Traceback (most recent call last):\n    File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\n  TypeError: argument 2 must be gdb.Block, not str\n  Error while executing Python code.\n  (gdb)\n\nChanges are:\n\n  1. Exception type is TypeError not RuntimeError, this is unfortunate\n  as user code _could_ be relying on this, but I think the improvement\n  is worth the risk, user code relying on the exact exception type is\n  likely to be pretty rare,\n\n  2. New error message gives argument position and expected argument\n  type, as well as the type that was passed.\n\nIf the first argument, the variable, has the wrong type then the\nprevious exception was already a TypeError, however, I\u0027ve updated the\ntext of the exception to more closely match the \"standard\" error\nmessage we see above.  If the first argument has the wrong type then\nbefore this commit we saw this:\n\n  (gdb) python print(gdb.selected_frame().read_var(123))\n  Traceback (most recent call last):\n    File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\n  TypeError: Argument must be a symbol or string.\n  Error while executing Python code.\n  (gdb)\n\nAnd after we see this:\n\n  (gdb) python print(gdb.selected_frame().read_var(123))\n  Traceback (most recent call last):\n    File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\n  TypeError: argument 1 must be gdb.Symbol or str, not int\n  Error while executing Python code.\n  (gdb)\n\nFor existing code that doesn\u0027t use named arguments and doesn\u0027t rely on\nexceptions, there will be no changes after this commit.\n\nReviewed-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3a033ac75709d47183f11c6d8cf0f3e144d84e54",
      "old_mode": 33188,
      "old_path": "gdb/python/py-frame.c",
      "new_id": "082358effab4f6c43aca690c7cee5d57bb705323",
      "new_mode": 33188,
      "new_path": "gdb/python/py-frame.c"
    },
    {
      "type": "modify",
      "old_id": "07997326d09a57c15203cc17dba5b75ccc73ce75",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/py-frame.exp",
      "new_id": "16177c8a5f824ce0ade80cac0a68c85731a3ff41",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-frame.exp"
    }
  ]
}
