)]}'
{
  "commit": "be6a2dca1505a4597fa3de71a85e7957d8d470ff",
  "tree": "e513776cc43f3b64403e13e5071aa4cb1aeacbda",
  "parents": [
    "2939f92abde7b98ed58710ab2719c9750ea4acad"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Tue Nov 08 18:47:24 2022 +0100"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Tue Nov 08 18:47:24 2022 +0100"
  },
  "message": "[gdb/cli] Make quit really quit after remote connection closed\n\nConsider a hello world a.out, started using gdbserver:\n...\n$ gdbserver --once 127.0.0.1:2345 ./a.out\nProcess ./a.out created; pid \u003d 15743\nListening on port 2345\n...\nthat we can connect to using gdb:\n...\n$ gdb -ex \"target remote 127.0.0.1:2345\"\nRemote debugging using 127.0.0.1:2345\nReading /home/vries/a.out from remote target...\n  ...\n0x00007ffff7dd4550 in _start () from target:/lib64/ld-linux-x86-64.so.2\n(gdb)\n...\n\nAfter that, we can for instance quit with confirmation:\n...\n(gdb) quit\nA debugging session is active.\n\n        Inferior 1 [process 16691] will be killed.\n\nQuit anyway? (y or n) y\n$\n...\n\nOr, kill with confirmation and quit:\n...\n(gdb) kill\nKill the program being debugged? (y or n) y\n[Inferior 1 (process 16829) killed]\n(gdb) quit\n$\n...\n\nOr, monitor exit, kill with confirmation, and quit:\n...\n(gdb) monitor exit\n(gdb) kill\nKill the program being debugged? (y or n) y\nRemote connection closed\n(gdb) quit\n$\n...\n\nBut when doing monitor exit followed by quit with confirmation, we get the gdb\nprompt back, requiring us to do quit once more:\n...\n(gdb) monitor exit\n(gdb) quit\nA debugging session is active.\n\n        Inferior 1 [process 16944] will be killed.\n\nQuit anyway? (y or n) y\nRemote connection closed\n(gdb) quit\n$\n...\n\nSo, the first quit didn\u0027t quit.  This happens as follows:\n- quit_command calls query_if_trace_running\n- a TARGET_CLOSE_ERROR is thrown\n- it\u0027s caught in remote_target::get_trace_status, but then\n  rethrown because it\u0027s TARGET_CLOSE_ERROR\n- catch_command_errors catches the error, at which point the quit command\n  has been aborted.\n\nThe TARGET_CLOSE_ERROR is defined as:\n...\n  /* Target throwing an error has been closed.  Current command should be\n     aborted as the inferior state is no longer valid.  */\n  TARGET_CLOSE_ERROR,\n...\nso in a way this is expected behaviour.  But aborting quit because the inferior\nstate (which we\u0027ve already confirmed we\u0027re not interested in) is no longer\nvalid, and having to type quit again seems pointless.\n\nFurthermore, the purpose of not catching errors thrown by\nquery_if_trace_running as per commit 2f9d54cfcef (\"make -gdb-exit call\ndisconnect_tracing too, and don\u0027t lose history if the target errors on\n\"quit\"\"), was to make sure that error (_(\"Not confirmed.\") had effect.\n\nFix this in quit_command by catching only the TARGET_CLOSE_ERROR exception\nduring query_if_trace_running and reporting it:\n...\n(gdb) monitor exit\n(gdb) quit\nA debugging session is active.\n\n        Inferior 1 [process 19219] will be killed.\n\nQuit anyway? (y or n) y\nRemote connection closed\n$\n...\n\nTested on x86_64-linux.\n\nPR server/15746\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d15746\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fe4041662efdf6dc52cfc54b23b0f9045fe2f19f",
      "old_mode": 33188,
      "old_path": "gdb/cli/cli-cmds.c",
      "new_id": "bcfd3641ef53fac5faa0c8aa739d0fff7b27dea9",
      "new_mode": 33188,
      "new_path": "gdb/cli/cli-cmds.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "fdf24520989eea2d589700cf25bc7c22282306d1",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.server/monitor-exit-quit.exp"
    }
  ]
}
