)]}'
{
  "commit": "1a98bb552d752d1dbedc8fdae504629d21d776f2",
  "tree": "e963b0bc4faa6aec5a34a72b33dcaee274e5da8a",
  "parents": [
    "702991711a91bd47b209289562843a11e7009396"
  ],
  "author": {
    "name": "Lancelot SIX",
    "email": "lsix@lancelotsix.com",
    "time": "Tue Sep 14 23:37:25 2021 +0100"
  },
  "committer": {
    "name": "Lancelot SIX",
    "email": "lsix@lancelotsix.com",
    "time": "Sun Oct 03 17:53:16 2021 +0100"
  },
  "message": "gdb: Setting setter return a bool to tell if the value changed\n\nGDB can notify observers when a parameter is changed.\n\nTo do that, do_set_command (in gdb/cli/cli-setshow.c) compares the new\nvalue against the old one before updating it, and based on that notifies\nobservers.  This looks like something like:\n\n    int valuechanged \u003d 0;\n    switch (cmd-\u003evar.type ())\n    {\n    case var_integer:\n      {\n        LONGEST new_val \u003d parse_and_eval_long (arg)\n        if (new_val !\u003d cmd-\u003evar.get\u003cint\u003e ())\n        {\n          cmd-\u003evar.get\u003cint\u003e (new_val);\n          value_changes \u003d 1;\n        }\n      }\n    case var_uinteger:\n    case var_zuinteger:\n      {\n        unsigned int val\n          \u003d parse_cli_var_uinteger (c-\u003evar-\u003etype (), \u0026arg, true);\n        if (c-\u003evar-\u003eget\u003cunsigned int\u003e () !\u003d val)\n          {\n            c-\u003evar-\u003eset\u003cunsigned int\u003e (val);\n            option_changed \u003d true;\n          }\n      }\n    case...\n      /* And so on for all possible var_types.  */\n    }\n\nThis comparison is done for each possible var_type, which leads to\nunnecessary logic duplication.\n\nIn this patch I propose to move all those checks in one place within the\nsetting setter method.  This limits the code duplication and simplifies\nthe do_set_command implementation.\n\nThis patch also changes slightly the way a value change is detected.\nInstead of comparing the user provided value against the current value\nof the setting, we compare the value of the setting before and after the\nset operation.  This is meant to handle edge cases where trying to set\nan unrecognized value would be equivalent to a noop (the actual value\nremains unchanged).  Doing this requires that the original value needs\nto be copied before the update, which can be non trivial for\nstd::string.\n\nThere should be no user visible change introduced by this commit.\n\nTested on x86_64 GNU/Linux.\n\n[1] https://review.lttng.org/c/binutils-gdb/+/5831/41\n\nChange-Id: If064b9cede3eb56275aacd2b286f74eceb1aed11\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8d29c0c3fc2fdd76a7940cef6935ce5faf8fceba",
      "old_mode": 33188,
      "old_path": "gdb/cli/cli-setshow.c",
      "new_id": "42c2b15b3928d73e075a0f3b71d5ff6eaa8fa469",
      "new_mode": 33188,
      "new_path": "gdb/cli/cli-setshow.c"
    },
    {
      "type": "modify",
      "old_id": "2abfbc497b9885093dd10d634b49b8ae121242ed",
      "old_mode": 33188,
      "old_path": "gdb/command.h",
      "new_id": "7c226f193b805d5f076c89cf29193c18b4f58e41",
      "new_mode": 33188,
      "new_path": "gdb/command.h"
    }
  ]
}
