)]}'
{
  "commit": "e6da5aefd46143872f59cb0d88c36a6fd55b2bf3",
  "tree": "ae49ed4afb7bdde27b74a90c54f100e71166dd2b",
  "parents": [
    "17508220c32b7774027f364e5ba8579966ba404d"
  ],
  "author": {
    "name": "Pedro Alves",
    "email": "palves@redhat.com",
    "time": "Wed Jan 14 12:43:30 2015 +0000"
  },
  "committer": {
    "name": "Pedro Alves",
    "email": "palves@redhat.com",
    "time": "Wed Jan 14 12:43:30 2015 +0000"
  },
  "message": "PR cli/17828: -batch -ex r breaks terminal\n\nCommit d3d4baed (PR python/17372 - Python hangs when displaying\nhelp()) had the side effect of causing \u0027gdb -batch\u0027 to leave the\nterminal in the wrong state if the program was run.  E.g,.\n\n $ echo \u0027main(){*(int*)0\u003d0;}\u0027 | gcc -x c -; ./gdb/gdb -batch -ex r ./a.out\n Program received signal SIGSEGV, Segmentation fault.\n 0x00000000004004ff in main ()\n $\n\nIf you start typing the next command, seemingly nothing happens - GDB\nleft the terminal with echo disabled.\n\nThe issue is that that \"r\" ends up in fetch_inferior_event, which\ncalls reinstall_readline_callback_handler_cleanup, which causes\nreadline to prep the terminal (raw, echo disabled).  But \"-batch\"\ncauses GDB to exit before the top level event loop is first started,\nand then nothing de-preps the terminal.\n\nThe reinstall_readline_callback_handler_cleanup function\u0027s intro\ncomment mentions:\n\n \"Need to do this as we go back to the event loop, ready to process\n further input.\"\n\nbut the implementation forgets the case of when the interpreter is\nsync, which indicates we won\u0027t return to the event loop yet, or as in\nthe case of -batch, we have not started it yet.\n\nThe fix is to not install the readline callback in that case.\n\nFor the test, in this case, checking that command echo still works is\nsufficient.  Comparing stty output before/after running GDB is even\nbetter.  Because stty may not be available, the test tries both ways.\nIn any case, since expect\u0027s spawn (what we use to start gdb) creates a\nnew pseudo tty, another expect spawn or tcl exec after GDB exits would\nnot see the wrong terminal settings.  So instead, the test spawns a\nshell and runs stty and GDB in it.\n\nTested on x86_64 Fedora 20.\n\ngdb/\n2015-01-14  Pedro Alves  \u003cpalves@redhat.com\u003e\n\n\tPR cli/17828\n\t* infrun.c (reinstall_readline_callback_handler_cleanup): Don\u0027t\n\treinstall if the interpreter is sync.\n\ngdb/testsuite/\n2015-01-14  Pedro Alves  \u003cpalves@redhat.com\u003e\n\n\tPR cli/17828\n\t* gdb.base/batch-preserve-term-settings.c: New file.\n\t* gdb.base/batch-preserve-term-settings.exp: New file.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "1f821bab20200d53dafb64ed0083d0fad9cf4435",
      "old_mode": 33188,
      "old_path": "gdb/ChangeLog",
      "new_id": "640775c06070a9f879165af14f831c446c1e4666",
      "new_mode": 33188,
      "new_path": "gdb/ChangeLog"
    },
    {
      "type": "modify",
      "old_id": "2fe7d2977a9cc323131e24470328695115e38ef9",
      "old_mode": 33188,
      "old_path": "gdb/infrun.c",
      "new_id": "78c19ba05c32f45a6881fd7fb1892170d11c86c8",
      "new_mode": 33188,
      "new_path": "gdb/infrun.c"
    },
    {
      "type": "modify",
      "old_id": "b96bccd82ce89b734a65cbccf0b4b3bfd338a693",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/ChangeLog",
      "new_id": "4c9f3b76d292e1c9bd5f67208d19f4edcd157546",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/ChangeLog"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "7e362b2940ebfe609e15c73623b65a6f1d68dbb5",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/batch-preserve-term-settings.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "834e7a94fe56d2de37b6ccde0adcef47b3d50a0f",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/batch-preserve-term-settings.exp"
    }
  ]
}
