)]}'
{
  "commit": "c7bdb38bafacde3d4bf4fa21951c577380259750",
  "tree": "8e6d5b17bc4e03c08a04de686ca5a4c4f812e91b",
  "parents": [
    "42f297ad36a13a7774fede3a8119e6c56ef6d318"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Fri Sep 15 18:40:21 2023 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Sep 28 15:33:13 2023 +0100"
  },
  "message": "gdb: use reopen_exec_file from reread_symbols\n\nThis commit fixes an issue that was discovered while writing the tests\nfor the previous commit.\n\nI noticed that, when GDB restarts an inferior, the executable_changed\nevent would trigger twice.  The first notification would originate\nfrom:\n\n  #0  exec_file_attach (filename\u003d0x4046680 \"/tmp/hello.x\", from_tty\u003d0) at ../../src/gdb/exec.c:513\n  #1  0x00000000006f3adb in reopen_exec_file () at ../../src/gdb/corefile.c:122\n  #2  0x0000000000e6a3f2 in generic_mourn_inferior () at ../../src/gdb/target.c:3682\n  #3  0x0000000000995121 in inf_child_target::mourn_inferior (this\u003d0x2fe95c0 \u003cthe_amd64_linux_nat_target\u003e) at ../../src/gdb/inf-child.c:192\n  #4  0x0000000000995cff in inf_ptrace_target::mourn_inferior (this\u003d0x2fe95c0 \u003cthe_amd64_linux_nat_target\u003e) at ../../src/gdb/inf-ptrace.c:125\n  #5  0x0000000000a32472 in linux_nat_target::mourn_inferior (this\u003d0x2fe95c0 \u003cthe_amd64_linux_nat_target\u003e) at ../../src/gdb/linux-nat.c:3609\n  #6  0x0000000000e68a40 in target_mourn_inferior (ptid\u003d...) at ../../src/gdb/target.c:2761\n  #7  0x0000000000a323ec in linux_nat_target::kill (this\u003d0x2fe95c0 \u003cthe_amd64_linux_nat_target\u003e) at ../../src/gdb/linux-nat.c:3593\n  #8  0x0000000000e64d1c in target_kill () at ../../src/gdb/target.c:924\n  #9  0x00000000009a19bc in kill_if_already_running (from_tty\u003d1) at ../../src/gdb/infcmd.c:328\n  #10 0x00000000009a1a6f in run_command_1 (args\u003d0x0, from_tty\u003d1, run_how\u003dRUN_STOP_AT_MAIN) at ../../src/gdb/infcmd.c:381\n  #11 0x00000000009a20a5 in start_command (args\u003d0x0, from_tty\u003d1) at ../../src/gdb/infcmd.c:527\n  #12 0x000000000068dc5d in do_simple_func (args\u003d0x0, from_tty\u003d1, c\u003d0x35c7200) at ../../src/gdb/cli/cli-decode.c:95\n\nWhile the second originates from:\n\n  #0  exec_file_attach (filename\u003d0x3d7a1d0 \"/tmp/hello.x\", from_tty\u003d0) at ../../src/gdb/exec.c:513\n  #1  0x0000000000dfe525 in reread_symbols (from_tty\u003d1) at ../../src/gdb/symfile.c:2517\n  #2  0x00000000009a1a98 in run_command_1 (args\u003d0x0, from_tty\u003d1, run_how\u003dRUN_STOP_AT_MAIN) at ../../src/gdb/infcmd.c:398\n  #3  0x00000000009a20a5 in start_command (args\u003d0x0, from_tty\u003d1) at ../../src/gdb/infcmd.c:527\n  #4  0x000000000068dc5d in do_simple_func (args\u003d0x0, from_tty\u003d1, c\u003d0x35c7200) at ../../src/gdb/cli/cli-decode.c:95\n\nIn the first case the call to exec_file_attach first passes through\nreopen_exec_file.  The reopen_exec_file performs a modification time\ncheck on the executable file, and only calls exec_file_attach if the\nexecutable has changed on disk since it was last loaded.\n\nHowever, in the second case things work a little differently.  In this\ncase GDB is really trying to reread the debug symbol.  As such, we\niterate over the objfiles list, and for each of those we check the\nmodification time, if the file on disk has changed then we reload the\ndebug symbols from that file.\n\nHowever, there is an additional check, if the objfile has the same\nname as the executable then we will call exec_file_attach, but we do\nso without checking the cached modification time that indicates when\nthe executable was last reloaded, as a result, we reload the\nexecutable twice.\n\nIn this commit I propose that reread_symbols be changed to\nunconditionally call reopen_exec_file before performing the objfile\niteration.  This will ensure that, if the executable has changed, then\nthe executable will be reloaded, however, if the executable has\nalready been recently reloaded, we will not reload it for a second\ntime.\n\nAfter handling the executable, GDB can then iterate over the objfiles\nlist and reload them in the normal way.\n\nWith this done I now see the executable reloaded only once when GDB\nrestarts an inferior, which means I can remove the kfail that I added\nto the gdb.python/py-exec-file.exp test in the previous commit.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "47e815448ed6a617f01f34ec41a1577b05ae2671",
      "old_mode": 33188,
      "old_path": "gdb/symfile.c",
      "new_id": "cc35a5389ee34d292cfd45ad8977deb2462cdb7c",
      "new_mode": 33188,
      "new_path": "gdb/symfile.c"
    },
    {
      "type": "modify",
      "old_id": "5ad3cd7e50f31856b0ded189b37d6d917337861a",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/py-exec-file.exp",
      "new_id": "7aa19a867d72820b13bf6021cd729e3714e2dc5d",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/py-exec-file.exp"
    }
  ]
}
