)]}'
{
  "commit": "9a03f2185347bd8f20da9bf535bc68a8d0f18ce8",
  "tree": "6ee5258b5bdbef602d17686512b7be04fe96f6ae",
  "parents": [
    "3a4c6f1aa958739705ee69526fdeed7c69d7243c"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Thu Mar 14 11:25:10 2024 +0100"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Thu Mar 14 11:25:10 2024 +0100"
  },
  "message": "[gdb/tdep] Fix gdb.base/watchpoint-unaligned.exp on aarch64\n\nOn aarch64-linux, with test-case gdb.base/watchpoint-unaligned.exp I run into:\n...\n(gdb) watch data.u.size8twice[1]^M\nHardware watchpoint 241: data.u.size8twice[1]^M\n(gdb) PASS: gdb.base/watchpoint-unaligned.exp: watch data.u.size8twice[1]\ncontinue^M\nContinuing.^M\nFAIL: gdb.base/watchpoint-unaligned.exp: continue (timeout)\nFAIL: gdb.base/watchpoint-unaligned.exp: size8twice write\n...\n\nThis happens as follows.\n\nWe start the exec and set an 8-byte hardware watchpoint on\ndata.u.size8twice[1] at address 0x440048:\n...\n(gdb) p sizeof (data.u.size8twice[1])\n$1 \u003d 8\n(gdb) p \u0026data.u.size8twice[1]\n$2 \u003d (uint64_t *) 0x440048 \u003cdata+16\u003e\n...\n\nWe continue execution, and a 16-byte write at address 0x440040 triggers the\nhardware watchpoint:\n...\n  4101c8:       a9000801        stp     x1, x2, [x0]\n...\n\nWhen checking whether a watchpoint has triggered in\naarch64_stopped_data_address, we check against address 0x440040 (passed in\nparameter addr_trap).  This behaviour is documented:\n...\n\t  /* ADDR_TRAP reports the first address of the memory range\n\t     accessed by the CPU, regardless of what was the memory\n\t     range watched.  ...  */\n...\nand consequently the matching logic compares against an addr_watch_aligned:\n...\n\t  \u0026\u0026 addr_trap \u003e\u003d addr_watch_aligned\n\t  \u0026\u0026 addr_trap \u003c addr_watch + len)\n...\n\nHowever, the comparison fails:\n...\n(gdb) p /x addr_watch_aligned\n$3 \u003d 0x440048\n(gdb) p addr_trap \u003e\u003d addr_watch_aligned\n$4 \u003d false\n...\n\nConsequently, aarch64_stopped_data_address returns false, and\nstopped_by_watchpoint returns false, and watchpoints_triggered returns 0,\nwhich make infrun think it\u0027s looking at a delayed hardware\nbreakpoint/watchpoint trap:\n...\n  [infrun] handle_signal_stop: stop_pc\u003d0x4101c8\n  [infrun] handle_signal_stop: delayed hardware breakpoint/watchpoint trap, ignoring\n...\nInfrun then ignores the trap and continues, but runs into the same situation\nagain and again, causing a hang which then causes the test timeout.\n\nFix this by allowing a match 8 bytes below addr_watch_aligned.  This\nintroduces the possibility for false positives, so we only do this for regular\n\"value changed\" watchpoints.\n\nAn earlier version of this patch worked by aligning addr_watch_aligned to 16\ninstead of 8:\n...\n-  const CORE_ADDR addr_watch_aligned \u003d align_down (state-\u003edr_addr_wp[i], 8);\n+  const CORE_ADDR addr_watch_aligned \u003d align_down (state-\u003edr_addr_wp[i], 16);\n...\nbut while that fixed the test-case, it didn\u0027t fix the problem completely, so\nextend the test-case to check more scenarios.\n\nTested on aarch64-linux.\n\nTested-By: Luis Machado \u003cluis.machado@arm.com\u003e\nApproved-By: Luis Machado \u003cluis.machado@arm.com\u003e\n\nPR tdep/29423\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d29423\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "6c72a8d6d9f18d59693da45e784b54926fc21f17",
      "old_mode": 33188,
      "old_path": "gdb/aarch64-nat.c",
      "new_id": "802bab6d6824997633ff3bc629b93089b4918751",
      "new_mode": 33188,
      "new_path": "gdb/aarch64-nat.c"
    },
    {
      "type": "modify",
      "old_id": "64728bb9ea348c066c13232f1ad1903e3f0fa29e",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/watchpoint-unaligned.c",
      "new_id": "6f709259b6c9d5db35ebaf881ec23295286b4c9b",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/watchpoint-unaligned.c"
    },
    {
      "type": "modify",
      "old_id": "8d985c03bfc37e43a06bdd7721019fbdf75b55ae",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/watchpoint-unaligned.exp",
      "new_id": "35e8868d39d0c74353f0d152ba0fa49af33d08ef",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/watchpoint-unaligned.exp"
    }
  ]
}
