)]}'
{
  "commit": "a5118a18db47c8ccaf4995fbb62e2a1eb377fa3e",
  "tree": "639e2747cc99ba81309d392cc73cff872d0793d9",
  "parents": [
    "23bade95de322dead7fbd33368dce271c2911773"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Mar 10 11:18:18 2022 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Mon Mar 14 14:08:05 2022 +0000"
  },
  "message": "gdb/gdbarch: compare some fields against 0 verify_gdbarch\n\nAfter the previous commit, which removes the predicate function\ngdbarch_register_type_p, I noticed that the gdbarch-\u003eregister_type\nfield was not checked at in the verify_gdbarch function.\n\nMore than not being checked, the field wasn\u0027t mentioned at all.\n\nI find this strange, I would expect that every field would at least be\nmentioned - we already generate comments for some fields saying that\nthis field is _not_ being checked, so the fact that this field isn\u0027t\nbeing checked looks (to me), like this field is somehow slipping\nthrough the cracks.\n\nThe comment at the top of gdbarch-components.py tries to explain how\nthe validation is done.  I didn\u0027t understand this comment completely,\nbut, I think this final sentence:\n\n  \"Otherwise, the check is done against 0 (really NULL for function\n  pointers, but same idea).\"\n\nMeans that, if non of the other cases apply, then the field should be\nchecked against 0, with 0 indicating that the field is invalid (was\nnot set by the tdep code).  However, this is clearly not being done.\n\nLooking in gdbarch.py at the code to generate verify_gdbarch we do\nfind that there is a case that is not handled, the case where the\n\u0027invalid\u0027 field is set true True, but non of the other cases apply.\n\nIn this commit I propose two changes:\n\n 1. Handle the case where the \u0027invalid\u0027 field of a property is set to\n True, this should perform a check for the field of gdbarch still\n being set to 0, and\n\n 2. If the if/else series that generates verify_gdbarch doesn\u0027t handle\n a property then we should raise an exception.  This means that if a\n property is added which isn\u0027t handled, we should no longer silently\n ignore it.\n\nAfter doing this, I re-generated the gdbarch files and saw that the\nfollowing gdbarch fields now had new validation checks:\n\n  register_type\n  believe_pcc_promotion\n  register_to_value\n  value_to_register\n  frame_red_zone_size\n  displaced_step_restore_all_in_ptid\n  solib_symbols_extension\n\nLooking at how these are currently set in the various -tdep.c files, I\nbelieve the only one of these that is required to be set for all\narchitectures is the register_type field.\n\nAnd so, for all of the other fields, I\u0027ve changed the property\ndefinition on gdbarch-components.py, setting the \u0027invalid\u0027 field to\nFalse.\n\nNow, after re-generation, the register_type field is checked against\n0, thus an architecture that doesn\u0027t set_gdbarch_register_type will\nnow fail during validation.  For all the other fields we skip the\nvalidation, in which case, it is find for an architecture to not set\nthis field.\n\nMy expectation is that there should be no user visible changes after\nthis commit.  Certainly for all fields except register_type, all I\u0027ve\nreally done is cause some extra comments to be generated, so I think\nthat\u0027s clearly fine.\n\nFor the register_type field, my claim is that any architecture that\ndidn\u0027t provide this would fail when creating its register cache, and I\ncouldn\u0027t spot an architecture that doesn\u0027t provide this hook.  As\nsuch, I think this change should be fine too.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "aa0b36825933073174d4a903c82f97e5d632bc7e",
      "old_mode": 33188,
      "old_path": "gdb/gdbarch-components.py",
      "new_id": "c820ddae7645871f210559a46051e7f9708cf37d",
      "new_mode": 33188,
      "new_path": "gdb/gdbarch-components.py"
    },
    {
      "type": "modify",
      "old_id": "28e1fbc2c7148f60e88e44be058a89ed39037128",
      "old_mode": 33188,
      "old_path": "gdb/gdbarch.c",
      "new_id": "9fdcf1505fe24ba2ded89b9bba9a6f1546c8cb95",
      "new_mode": 33188,
      "new_path": "gdb/gdbarch.c"
    },
    {
      "type": "modify",
      "old_id": "3bd6400355e3589f75c12a97543e7bfc25ad1adf",
      "old_mode": 33261,
      "old_path": "gdb/gdbarch.py",
      "new_id": "c89d19ccbcfb5b2f3c50c6f56b23e87210d042c5",
      "new_mode": 33261,
      "new_path": "gdb/gdbarch.py"
    }
  ]
}
