)]}'
{
  "commit": "31ada87f91b4c5306d81c8a896df9764c32941f3",
  "tree": "b385cdad80903f8f9f82d9016cf50560ccacf670",
  "parents": [
    "328f42d85b8eb1f3f97e5a1ec97e444a6dd72e33"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Nov 06 22:18:55 2024 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Fri Nov 08 10:44:43 2024 +0000"
  },
  "message": "gdb: fixes and tests for the \u0027edit\u0027 command\n\nThis commit was inspired by this mailing list post:\n\n  https://inbox.sourceware.org/gdb-patches/osmtfvf5xe3yx4n7oirukidym4cik7lehhy4re5mxpset2qgwt@6qlboxhqiwgm\n\nWhen reviewing that patch, the first thing I wanted to do was add some\ntests for the \u0027edit\u0027 command because, as far as I can tell, there are\nno real tests right now.\n\nThe approach I\u0027ve taken for testing is to override the EDITOR\nenvironment variable, setting this to just \u0027echo\u0027.  Now when the\n\u0027edit\u0027 command is run, instead of entering an interactive editor, the\nshell instead echos back the arguments that GDB is trying to pass to\nthe editor.  The output might look like this:\n\n  (gdb) edit\n  +22 /tmp/gdb/testsuite/gdb.base/edit-cmd.c\n  (gdb)\n\nWe can then test this like any other normal command.  I then wrote\nsome basic tests covering a few situations like, using \u0027edit\u0027 before\nthe inferior is started.  Using \u0027edit\u0027 without any arguments, and\nusing \u0027edit\u0027 with a line number argument.\n\nThere are plenty of cases that are still not tested, for example, the\ntest program only has a single source file for example.  But we can\nalways add more tests later.\n\nI then used these tests to validate the fix proposed in the above\npatch.\n\nThe patch above does indeed fix some cases, specifically, when GDB\nstops at a location (e.g. a breakpoint location) and then the \u0027edit\u0027\ncommand without any arguments is fixed.  But using the \u0027list\u0027 command\nto show some other location, and then \u0027edit\u0027 to edit the just listed\nlocation broken before and after the above patch.\n\nI am instead proposing this alternative patch which I think fixes more\ncases.  When GDB stops at a location then \u0027edit\u0027 with no arguments\nshould correctly edit the current line.  And using \u0027list XX\u0027 to list a\nspecific location, followed by \u0027edit\u0027 should also now edit the just\nlisted location.\n\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d17669\n\nCo-Authored-By: Lluís Batlle i Rossell \u003cviric@viric.name\u003e\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "65ac7d6e7fb7535187171f5763e298e236240c64",
      "old_mode": 33188,
      "old_path": "gdb/cli/cli-cmds.c",
      "new_id": "225615f021084e22311ed8ccca5224a0f8c50cbf",
      "new_mode": 33188,
      "new_path": "gdb/cli/cli-cmds.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "fb0f70db51c6dbe5e91a04cd8b0bfd486f46bdf1",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/basic-edit-cmd.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "116daf9e3b79a0bd79e5821d3a252dcadfe6ffd9",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/basic-edit-cmd.exp"
    }
  ]
}
