)]}'
{
  "commit": "bc45f5366eaf4e93cfd675a07a8cc5bb5522b184",
  "tree": "c11b5a96ac7acd42a890f3ac877488f9c371d92f",
  "parents": [
    "15a1e4e2a7dac11fdf338c70efc355348d8a6d49"
  ],
  "author": {
    "name": "Carl Love",
    "email": "cel@us.ibm.com",
    "time": "Mon Oct 31 14:44:17 2022 -0400"
  },
  "committer": {
    "name": "Carl Love",
    "email": "cel@us.ibm.com",
    "time": "Mon Oct 31 14:44:17 2022 -0400"
  },
  "message": "Remove REPARSE condition to force hardware resource checking when updating watchpoints\n\nCurrently the resource checking is done if REPARSE is true.  The hardware\nwatchpoint resource checking in update_watchpoint needs to be redone on\neach call to function update_watchpoints as the value chain may have\nchanged.  The number of hardware registers needed for a watchpoint can\nchange if the variable being watched changes.  This situation occurs in\nthis test when watching variable **global_ptr_ptr.  Initially when the\nwatch command is issued, only two addresses need to be watched as\n**global_ptr_ptr has not yet been initialized.  Once the value of\n**global_ptr_ptr is initialized the locations to be tracked increase to\nthree addresses.  However, update_watchpoints is not called again with\nREPARSE set to 1 to force the resource checking to be redone.  When the\ntest is run on Power 10, an internal gdb error occurs when the PowerPC\nroutine tries to setup the three hardware watchpoint address since the hw\nonly has two hardware watchpoint registers.  The error occurs because the\nresource checking was not redone in update_watchpoints after\n**global_ptr_ptr changed.\n\nThe following descibes the situation in detail that occurs on Power 10 with\ngdb running on the binary for gdb.base/watchpoint.c.\n\n1 break func4\n2 run\n3 watch *global_ptr\n4 next      execute source code:   buf[0] \u003d 3;\n5 next      execute source code:   global_ptr \u003d buf;\n6 next      execute source code:   buf[0] \u003d 7;\n7 delete 2  (delete watch *global_ptr)\n8 watch **global_ptr_ptr\n9 next       execute source code:   buf[1] \u003d 5;\n10 next      global_ptr_ptr \u003d \u0026global_ptr;\n11 next      buf[0] \u003d 9;\n\nIn step 8, the the watch **global_ptr_prt command calls update_watchpoint\nin breakpoint.c with REPARSE set to 1.  The function update_watchpoint\ncalls can_use_hardware_watchpoint to see if there are enough\nresources available to add the watchpoint since REPARSE is set to 1.  At\nthis point, **global_ptr_ptr has not been initialized so only two addresses\nare watched.  The val_chain contains the address for **global_ptr_ptr and 0\nsince **global_ptr_ptr has not been initialized.  The update_watchpoint\nupdates the breakpoint list as follows:\n\n  breakpoint 0\n   loc 0: b-\u003eaddress \u003d 0x100009c0\n  breakpoint 1\n   loc 1: b-\u003eaddress \u003d 0x7ffff7f838a0\n  breakpoint 2\n   loc 2: b-\u003eaddress \u003d 0x7ffff7b7fc54\n  breakpoint 3\n   loc 3: b-\u003eaddress \u003d 0x7ffff7a5788c\n  breakpoint 4\n   loc 4: b-\u003eaddress \u003d 0x0         \u003c-- location pointed to by global_ptr_ptr\n   loc 5: b-\u003eaddress \u003d 0x100200b8  \u003c-- global_ptr_ptr watchpoint\n  breakpoint 5\n   loc 6: b-\u003eaddress \u003d 0x7ffff7b7fc54\n\nIn step 10, the next command executes the source code\nglobal_ptr_ptr \u003d \u0026global_ptr.  This changes the set of locations to be\nwatched for the watchpoint **global_ptr_prt.  The list of addresses for the\nbreakpoint consist of the address for global_ptr_prt, global_ptr and buf.\nThe breakpoint list gets updated by update_watchpoint as follows:\n\n  breakpoint 0\n   loc 0: b-\u003eaddress \u003d 0x100009c0\n  breakpoint 1\n   loc 1: b-\u003eaddress \u003d 0x7ffff7f838a0\n  breakpoint 2\n   loc 2: b-\u003eaddress \u003d 0x7ffff7b7fc54\n  breakpoint 3\n   loc 3: b-\u003eaddress \u003d 0x7ffff7a5788c\n  breakpoint 4\n   loc 4: b-\u003eaddress \u003d 0x10020050           buf\n   loc 5: b-\u003eaddress \u003d 0x100200b0           watch *global_ptr\n   loc 6: b-\u003eaddress \u003d 0x100200b8           watch **global_ptr_ptr\n  breakpoint 5\n   loc 7: b-\u003eaddress \u003d 0x7ffff7b7fc54\n  breakpoint 6\n\nHowever, the hardware resource checking was not redone because\nupdate_breakpoint was called with REPARSE equal to  0.\n\nStep 11, execute the third next command.  The function\nppc_linux_nat_target::low_prepare_to_resume() attempts a ptrace\ncall to setup each of the three address for breakpoint 4.  The slot\nvalue returned for the third ptrace call is -1 indicating an error\nbecause there are only two hardware watchpoint registers available on\nPower 10.\n\nThis patch removes just the statement \"if (reparse)\" in function\nupdate_watchpoint to force the resources to be rechecked on every call to\nthe function.  This ensures that any changes to the val_chain resulting\nin needing more resources then available will be caught.\n\nThe patch has been tested on Power 8, Power 10 and X86-64.  Note the patch\nhas no effect on Power 9 since hardware watchpoint support is disabled on\nthat processor.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3082603236021b1caeddfa46e98ad018a0b189e6",
      "old_mode": 33188,
      "old_path": "gdb/breakpoint.c",
      "new_id": "490708938ecd4d6fcd29a9d4d7a35e391d28a68b",
      "new_mode": 33188,
      "new_path": "gdb/breakpoint.c"
    }
  ]
}
