From 8cc96ee4169f631917d048cbaeec14ddf8ccb90d Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Thu, 9 Feb 2023 20:35:32 -0500 Subject: gdb/source: Fix open_source_file error handling open_source_file relies on errno to communicate the reason for a missing source file. open_source_file may also call debuginfod_find_source. It is possible for debuginfod_find_source to set errno to a value unrelated to the reason for a failed download. This can result in bogus error messages being reported as the reason for a missing source file. The following error message should instead be "No such file or directory": Temporary breakpoint 1, 0x00005555556f4de0 in main () (gdb) list Downloading source file /usr/src/debug/glibc-2.36-8.fc37.x86_64/elf/ 1 /usr/src/debug/glibc-2.36-8.fc37.x86_64/elf/: Directory not empty. Fix this by having open_source_file return a negative errno if it fails to open a source file. Use this value to generate the error message instead of errno. Approved-By: Tom Tromey Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29999 --- gdb/source.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gdb/source.h') diff --git a/gdb/source.h b/gdb/source.h index 61d1bcd..dd6f58c 100644 --- a/gdb/source.h +++ b/gdb/source.h @@ -67,7 +67,8 @@ extern void init_source_path (void); The caller is responsible for freeing FULLNAME. On Failure - An invalid file descriptor is returned (the return value is negative). + An invalid file descriptor is returned. The value of this file + descriptor is a negative errno indicating the reason for the failure. FULLNAME is set to NULL. */ extern scoped_fd find_and_open_source (const char *filename, const char *dirname, @@ -81,7 +82,7 @@ extern gdb::unique_xmalloc_ptr find_source_or_rewrite (const char *filename, const char *dirname); /* Open a source file given a symtab S. Returns a file descriptor or - negative number for error. */ + negative errno indicating the reason for the failure. */ extern scoped_fd open_source_file (struct symtab *s); extern gdb::unique_xmalloc_ptr rewrite_source_path (const char *path); -- cgit v1.1