)]}'
{
  "commit": "c44008bda2fdc743312b0f6e56198ea0a8cfd079",
  "tree": "8d83bd4b779096ab9064155d6dd9034fd1b4e4b7",
  "parents": [
    "f8ed9c5722d465f5a3dd5c6cb5616e3d92014727"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Wed Jun 26 08:49:40 2024 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Wed Jun 26 08:49:40 2024 +0200"
  },
  "message": "[gdb/testsuite] Fix timeout in gdb.base/bg-execution-repeat.exp\n\nI ran into the following test failure with test-case\ngdb.base/bg-execution-repeat.exp:\n...\n(gdb) PASS: gdb.base/bg-execution-repeat.exp: c\u0026: repeat bg command\n^M\nBreakpoint 2, foo () at bg-execution-repeat.c:23^M\n23        return 0; /* set break here */^M\nprint 1^M\n$1 \u003d 1^M\n(gdb) PASS: gdb.base/bg-execution-repeat.exp: c\u0026: input still accepted\nFAIL: gdb.base/bg-execution-repeat.exp: c\u0026: breakpoint hit 2 (timeout)\n...\n\nThe failure can be easily reproduced by adding a sleep 5 here:\n...\n+    sleep 5\n     gdb_test \"print 1\" \" \u003d 1\" \"input still accepted\"\n...\n\nThere\u0027s a race in the test-case, between:\n- the command handled in the foreground: the \"print 1\" command, and\n- the command handled in the background: the continue command.\n\nThe current way of dealing with this is by putting the inferior to sleep for 5\nseconds:\n...\n  foo ();\n  sleep (5);\n  foo ();\n...\nwith the aim that the \"print 1\" command will win the race.\n\nThis method is both slow and unreliable.\n\nFix this by making the inferior wait till the \"print 1\" command is done.\n\nThis reduces running time from ~11s to ~1s.\n\nI also verified that the test-case still triggers on the original problem by\napplying this gdb/infcmd.c patch:\n...\n-strip_bg_char (const char *args, int *bg_char_p)\n+strip_bg_char (const char *_args, int *bg_char_p)\n {\n-  const char *p;\n+  char *args \u003d const_cast\u003cchar *\u003e(_args);\n+  char *p;\n\n   if (args \u003d\u003d nullptr || *args \u003d\u003d \u0027\\0\u0027)\n     {\n@@ -210,6 +211,7 @@ strip_bg_char (const char *args, int *bg_char_p)\n       p--;\n       while (p \u003e args \u0026\u0026 isspace (p[-1]))\n \tp--;\n+      *p \u003d \u0027\\0\u0027;\n...\n\nTested on x86_64-linux, with make-check-all.sh.\n\nPR testsuite/31794\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d31794\n\nReviewed-By: Guinevere Larsen \u003cblarsen@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2caa7d442f669d1b7d9099ef1078e336845798df",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/bg-execution-repeat.c",
      "new_id": "d5b48ee4f9430e155a6266a323c70ac38e9cc502",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/bg-execution-repeat.c"
    },
    {
      "type": "modify",
      "old_id": "a4cc7daa70219d9e99c000cc8c95195d817eca64",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/bg-execution-repeat.exp",
      "new_id": "35ddb34cd8f330c8b9f0b7ae74ef850a2f469b2f",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/bg-execution-repeat.exp"
    }
  ]
}
