Bug 17911 - gdb reports "/some/path/: Success" when trying to open a directory
Summary: gdb reports "/some/path/: Success" when trying to open a directory
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: 7.8
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-31 14:38 UTC by Nicolai Hähnle
Modified: 2016-04-19 16:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Proposed patch (594 bytes, patch)
2015-01-31 14:38 UTC, Nicolai Hähnle
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolai Hähnle 2015-01-31 14:38:01 UTC
Created attachment 8093 [details]
Proposed patch

(This is on 7.8, but a quick glance at the source suggests it is also present in more recent versions).

Consider the following transcript of a GDB session:

$ gdb
...
(gdb) file /home/
/home/: Success.
...

Clearly, it would be nice if the GDB output were more helpful. (The transcript may seem trivial; however, this problem leads to significantly more confusion in the context of KDevelop's gdb plugin.)

I am attaching a patch proposal which changes the behavior to:

(gdb) file /home/haehnle
/home/haehnle: Is a directory.
(gdb) file /home/haehnle/asdfs
/home/haehnle/asdfs: No such file or directory.
(gdb) file /dev/null          
/dev/null: Exec format error.

(The last case is a bit of an odd one out. Unfortunately, there is no ENOTAREGULARFILE as far as I can tell, and ENOEXEC was the best I could come up with.)
Comment 1 Doug Evans 2015-09-19 23:10:55 UTC
I tripped over this this morning, and came up with a similar patch,
posted here:
https://sourceware.org/ml/gdb-patches/2015-09/msg00491.html
Comment 2 Doug Evans 2016-04-19 16:59:16 UTC
Patch committed here:
https://sourceware.org/ml/gdb-patches/2016-04/msg00461.html