)]}'
{
  "commit": "5c5e642dc0f6b223c2339d8dee64fbc63eee8e1a",
  "tree": "2219ab9fc23a0904a9d5d5f41d4fe721917ad6df",
  "parents": [
    "b70a487d5945b13e5ab503be4fc37b964819ec0e"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Sat Dec 02 11:36:43 2023 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Dec 13 08:54:06 2023 +0000"
  },
  "message": "gdb: improve error reporting for \u0027save gdb-index\u0027\n\nWhile making recent changes to \u0027save gdb-index\u0027 command I triggered\nsome errors -- of the kind a user might be expected to trigger if they\ndo something wrong -- and I didn\u0027t find GDB\u0027s output as helpful as it\nmight be.\n\nFor example:\n\n  $ gdb -q /tmp/hello.x\n  ...\n  (gdb) save gdb-index /non_existing_dir\n  Error while writing index for `/tmp/hello\u0027: mkstemp: No such file or directory.\n\nThat the error message mentions \u0027/tmp/hello\u0027, which does exist, but\ndoesn\u0027t mention \u0027/non_existing_dir\u0027, which doesn\u0027t is, I think,\nconfusing.\n\nAlso, I find the \u0027mkstemp\u0027 in the error message confusing for a user\nfacing error.  A user might not know what mkstemp means, and even if\nthey do, that it appears in the error message is an internal GDB\ndetail.  The user doesn\u0027t care what function failed, but wants to know\nwhat was wrong with their input, and what they should do to fix\nthings.\n\nSimilarly, for a directory that does exist, but can\u0027t be written to:\n\n  (gdb) save gdb-index /no_access_dir\n  Error while writing index for `/tmp/hello\u0027: mkstemp: Permission denied.\n\nIn this case, the \u0027Permission denied\u0027 might make the user thing there\nis a permissions issue with \u0027/tmp/hello\u0027, which is not the case.\n\nAfter this patch, the new errors are:\n\n  (gdb) save gdb-index /non_existing_dir\n  Error while writing index for `/tmp/hello\u0027: `/non_existing_dir\u0027: No such file or directory.\n\nand:\n\n  (gdb) save gdb-index /no_access_dir\n  Error while writing index for `/tmp/hello\u0027: `/no_access_dir\u0027: Permission denied.\n\nwe also have:\n\n  (gdb) save gdb-index /tmp/not_a_directory\n  Error while writing index for `/tmp/hello\u0027: `/tmp/not_a_directory\u0027: Is not a directory.\n\nI think these do a better job of guiding the user towards fixing the\nproblem.\n\nI\u0027ve added a new test that exercises all of these cases, and also\nchecks the case where a user tries to use an executable that already\ncontains an index in order to generate an index.  As part of the new\ntest I\u0027ve factored out some code from ensure_gdb_index (lib/gdb.exp)\ninto a new proc (get_index_type), which I\u0027ve then used in the new\ntest.  I\u0027ve confirmed that all the tests that use ensure_gdb_index\nstill pass.\n\nDuring review it was pointed out that the testsuite proc\nhave_index (lib/gdb.exp) is similar to the new get_index_type proc, so\nI\u0027ve rewritten have_index to also use get_index_type, I\u0027ve confirmed\nthat all the tests that use have_index still pass.\n\nNothing that worked correctly before this patch should give an error\nafter this patch; I\u0027ve only changed the output when the user was going\nto get an error anyway.\n\nReviewed-By: Tom de Vries \u003ctdevries@suse.de\u003e\nReviewed-By: Tom Tromey \u003ctom@tromey.com\u003e\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b4a0117330e79f9ee3982561270c6f82fc3199a1",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/index-write.c",
      "new_id": "842708a266eec537e09f1c409e6bd4cfb9ce91d1",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/index-write.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "3a264f239ed7b1ef63cf23adcfb2169a695a80ba",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/gdb-index-err.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "31f133efbcdf6fd691db74eedc5260e8b3acc2b1",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/gdb-index-err.exp"
    },
    {
      "type": "modify",
      "old_id": "7e478ab9b6074cdcd798d3a0d3fef124cecf3ee2",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/lib/gdb.exp",
      "new_id": "eb8f6998b1ea7e5fc73540adf4f36d7dfbb024db",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/lib/gdb.exp"
    }
  ]
}
