)]}'
{
  "commit": "a2757c4ed693cef4ecc4dcdcb2518353eb6b3c3f",
  "tree": "cc8e1e5c872fb3c59bd0e934749f4cfd317f9d2d",
  "parents": [
    "f4be26838dc9937a4ae3e9cf4fbec50efd7786a2"
  ],
  "author": {
    "name": "Jan Vrany",
    "email": "jan.vrany@labware.com",
    "time": "Wed Mar 16 15:08:22 2022 +0000"
  },
  "committer": {
    "name": "Jan Vrany",
    "email": "jan.vrany@labware.com",
    "time": "Wed Mar 16 15:08:22 2022 +0000"
  },
  "message": "gdb/mi: consistently notify user when GDB/MI client uses -thread-select\n\nGDB notifies users about user selected thread changes somewhat\ninconsistently as mentioned on gdb-patches mailing list here:\n\n  https://sourceware.org/pipermail/gdb-patches/2022-February/185989.html\n\nConsider GDB debugging a multi-threaded inferior with both CLI and GDB/MI\ninterfaces connected to separate terminals.\n\nAssuming inferior is stopped and thread 1 is selected, when a thread\n2 is selected using \u0027-thread-select 2\u0027 command on GDB/MI terminal:\n\n    -thread-select 2\n    ^done,new-thread-id\u003d\"2\",frame\u003d{level\u003d\"0\",addr\u003d\"0x00005555555551cd\",func\u003d\"child_sub_function\",args\u003d[],file\u003d\"/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c\",fullname\u003d\"/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c\",line\u003d\"30\",arch\u003d\"i386:x86-64\"}\n    (gdb)\n\nand on CLI terminal we get the notification (as expected):\n\n    [Switching to thread 2 (Thread 0x7ffff7daa640 (LWP 389659))]\n    #0  child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n    30        volatile int dummy \u003d 0;\n\nHowever, now that thread 2 is selected, if thread 1 is selected\nusing \u0027thread-select --thread 1 1\u0027 command on GDB/MI terminal\nterminal:\n\n   -thread-select --thread 1 1\n   ^done,new-thread-id\u003d\"1\",frame\u003d{level\u003d\"0\",addr\u003d\"0x0000555555555294\",func\u003d\"main\",args\u003d[],file\u003d\"/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c\",fullname\u003d\"/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c\",line\u003d\"66\",arch\u003d\"i386:x86-64\"}\n   (gdb)\n\nbut no notification is printed on CLI terminal, despite the fact\nthat user selected thread has changed.\n\nThe problem is that when `-thread-select --thread 1 1` is executed\nthen thread is switched to thread 1 before mi_cmd_thread_select () is\ncalled, therefore the condition \"inferior_ptid !\u003d previous_ptid\"\nthere does not hold.\n\nTo address this problem, we have to move notification logic up to\nmi_cmd_execute () where --thread option is processed and notify\nuser selected contents observers there if context changes.\n\nHowever, this in itself breaks GDB/MI because it would cause context\nnotification to be sent on MI channel. This is because by the time\nwe notify, MI notification suppression is already restored (done in\nmi_command::invoke(). Therefore we had to lift notification suppression\nlogic also up to mi_cmd_execute (). This change in made distinction\nbetween mi_command::invoke() and mi_command::do_invoke() unnecessary\nas all mi_command::invoke() did (after the change) was to call\ndo_invoke(). So this patches removes do_invoke() and moves the command\nexecution logic directly to invoke().\n\nWith this change, all gdb.mi tests pass, tested on x86_64-linux.\n\nCo-authored-by: Andrew Burgess \u003caburgess@redhat.com\u003e\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d20631\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "1be8aa81c3d109efb3fce9a013c6f508dcb197a3",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-cmd-stack.c",
      "new_id": "e894411765ade83da80125c270a0fe73cbdbe9ae",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-cmd-stack.c"
    },
    {
      "type": "modify",
      "old_id": "38fbe0d8a327ae4f954c341ae61bdb4f95531610",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-cmds.c",
      "new_id": "60fec0a0b85b454af9f32e84032f53d898068cf7",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-cmds.c"
    },
    {
      "type": "modify",
      "old_id": "47b90a260640470496906b35ece41aeac4e15ed0",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-cmds.h",
      "new_id": "05b702f83ec2208d78d421090923da1a449b8dd7",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-cmds.h"
    },
    {
      "type": "modify",
      "old_id": "73380f5e668d001ac25397e27e52e3f84220452c",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-main.c",
      "new_id": "abd033b22ae344f25e71164d4113ebc803041555",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-main.c"
    },
    {
      "type": "modify",
      "old_id": "4665fcc75c75c6fcf2318ec83405323ba8a80577",
      "old_mode": 33188,
      "old_path": "gdb/python/py-micmd.c",
      "new_id": "399e89b029844e03c7006d4292e026021a2aa4d6",
      "new_mode": 33188,
      "new_path": "gdb/python/py-micmd.c"
    },
    {
      "type": "modify",
      "old_id": "8855ed8fe70cae9be90061f8ad714a2831850866",
      "old_mode": 33188,
      "old_path": "gdb/stack.c",
      "new_id": "10da88b88e597044767d2ed33bae8d1f76915dc9",
      "new_mode": 33188,
      "new_path": "gdb/stack.c"
    },
    {
      "type": "modify",
      "old_id": "c49d2e2cbef7b58be67fc068ac771e04484126fa",
      "old_mode": 33188,
      "old_path": "gdb/stack.h",
      "new_id": "f78aedf1c85e861b25bbd0c754e24ec85d7575cf",
      "new_mode": 33188,
      "new_path": "gdb/stack.h"
    },
    {
      "type": "modify",
      "old_id": "3b4ff0bf2e42aefcdbc2032612b8fa63f28d4c42",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.mi/user-selected-context-sync.exp",
      "new_id": "9444ca5acf4c2a67742b9998ae4f861eadd15e41",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.mi/user-selected-context-sync.exp"
    }
  ]
}
