mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 12:03:41 +08:00
5c5e642dc0
While making recent changes to 'save gdb-index' command I triggered some errors -- of the kind a user might be expected to trigger if they do something wrong -- and I didn't find GDB's output as helpful as it might be. For example: $ gdb -q /tmp/hello.x ... (gdb) save gdb-index /non_existing_dir Error while writing index for `/tmp/hello': mkstemp: No such file or directory. That the error message mentions '/tmp/hello', which does exist, but doesn't mention '/non_existing_dir', which doesn't is, I think, confusing. Also, I find the 'mkstemp' in the error message confusing for a user facing error. A user might not know what mkstemp means, and even if they do, that it appears in the error message is an internal GDB detail. The user doesn't care what function failed, but wants to know what was wrong with their input, and what they should do to fix things. Similarly, for a directory that does exist, but can't be written to: (gdb) save gdb-index /no_access_dir Error while writing index for `/tmp/hello': mkstemp: Permission denied. In this case, the 'Permission denied' might make the user thing there is a permissions issue with '/tmp/hello', which is not the case. After this patch, the new errors are: (gdb) save gdb-index /non_existing_dir Error while writing index for `/tmp/hello': `/non_existing_dir': No such file or directory. and: (gdb) save gdb-index /no_access_dir Error while writing index for `/tmp/hello': `/no_access_dir': Permission denied. we also have: (gdb) save gdb-index /tmp/not_a_directory Error while writing index for `/tmp/hello': `/tmp/not_a_directory': Is not a directory. I think these do a better job of guiding the user towards fixing the problem. I've added a new test that exercises all of these cases, and also checks the case where a user tries to use an executable that already contains an index in order to generate an index. As part of the new test I've factored out some code from ensure_gdb_index (lib/gdb.exp) into a new proc (get_index_type), which I've then used in the new test. I've confirmed that all the tests that use ensure_gdb_index still pass. During review it was pointed out that the testsuite proc have_index (lib/gdb.exp) is similar to the new get_index_type proc, so I've rewritten have_index to also use get_index_type, I've confirmed that all the tests that use have_index still pass. Nothing that worked correctly before this patch should give an error after this patch; I've only changed the output when the user was going to get an error anyway. Reviewed-By: Tom de Vries <tdevries@suse.de> Reviewed-By: Tom Tromey <tom@tromey.com> Approved-By: Tom Tromey <tom@tromey.com> |
||
---|---|---|
.. | ||
abbrev-cache.c | ||
abbrev-cache.h | ||
abbrev.c | ||
abbrev.h | ||
ada-imported.c | ||
aranges.c | ||
aranges.h | ||
attribute.c | ||
attribute.h | ||
call-site.h | ||
comp-unit-head.c | ||
comp-unit-head.h | ||
cooked-index.c | ||
cooked-index.h | ||
cu.c | ||
cu.h | ||
die.c | ||
die.h | ||
dwz.c | ||
dwz.h | ||
expr.c | ||
expr.h | ||
file-and-dir.h | ||
frame-tailcall.c | ||
frame-tailcall.h | ||
frame.c | ||
frame.h | ||
index-cache.c | ||
index-cache.h | ||
index-common.c | ||
index-common.h | ||
index-write.c | ||
index-write.h | ||
leb.c | ||
leb.h | ||
line-header.c | ||
line-header.h | ||
loc.c | ||
loc.h | ||
macro.c | ||
macro.h | ||
mapped-index.h | ||
public.h | ||
read-debug-names.c | ||
read-debug-names.h | ||
read-gdb-index.c | ||
read-gdb-index.h | ||
read.c | ||
read.h | ||
sect-names.h | ||
section.c | ||
section.h | ||
stringify.c | ||
stringify.h | ||
tag.h | ||
types.h |