From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv2 2/5] gdb: use archive name in warning when appropriate
Date: Thu, 28 Sep 2023 15:00:41 +0100 [thread overview]
Message-ID: <0611bf29b93059df312acf56601cd45398e7dd0e.1695909469.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1695909469.git.aburgess@redhat.com>
While working on some other patch I noticed that in reread_symbols
there is a diagnostic message that can be printed, and in some cases
we might use the wrong filename in the message.
The code in question is checking to see if an objfile has changed on
disk, we do this by stat-ing the on disk file and checking the mtime.
If this file has been removed from disk then we print a message that
the file has been removed, however, if the objfile is within an
archive then we stat the archive itself, but then warn that the
component within the archive has disappeared. I think it makes more
sense to say that the archive has disappeared.
The last related commit is this one:
commit 02aeec7bde8ec8a04d14a5637e75f1c6ab899e23
Date: Tue Apr 27 21:01:30 2010 +0000
Check library name rather than member name when rereading symbols.
Though this just makes the code to stat the archive unconditional, the
code in question existed before this commit.
However, the above commit doesn't include any tests, and seems to
indicate that the problem being addressed was seen on Darwin. I'm not
sure how to setup a test where GDB is using an objfile from within an
archive, and so there's no tests for this commit...
... but if someone can let me know how I can setup a suitable test,
please let me know and I'll try to get something working.
---
gdb/symfile.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 19cf9c911f9..145621f3c67 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2459,7 +2459,6 @@ reread_symbols (int from_tty)
{
long new_modtime;
struct stat new_statbuf;
- int res;
std::vector<struct objfile *> new_objfiles;
for (objfile *objfile : current_program_space->objfiles ())
@@ -2475,16 +2474,18 @@ reread_symbols (int from_tty)
`ar', often called a `static library' on most systems, though
a `shared library' on AIX is also an archive), then you should
stat on the archive name, not member name. */
+ const char *filename;
if (objfile->obfd->my_archive)
- res = stat (bfd_get_filename (objfile->obfd->my_archive), &new_statbuf);
+ filename = bfd_get_filename (objfile->obfd->my_archive);
else
- res = stat (objfile_name (objfile), &new_statbuf);
+ filename = objfile_name (objfile);
+
+ int res = stat (filename, &new_statbuf);
if (res != 0)
{
/* FIXME, should use print_sys_errmsg but it's not filtered. */
gdb_printf (_("`%ps' has disappeared; keeping its symbols.\n"),
- styled_string (file_name_style.style (),
- objfile_name (objfile)));
+ styled_string (file_name_style.style (), filename));
continue;
}
new_modtime = new_statbuf.st_mtime;
--
2.25.4
next prev parent reply other threads:[~2023-09-28 14:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 14:22 [PATCH 0/5] Fix using an exec file with target: prefix Andrew Burgess
2023-09-27 14:22 ` [PATCH 1/5] gdb: some additional filename styling Andrew Burgess
2023-09-27 14:22 ` [PATCH 2/5] gdb: use archive name in warning when appropriate Andrew Burgess
2023-09-27 14:22 ` [PATCH 3/5] gdb: remove use of a static buffer for building error strings Andrew Burgess
2023-09-27 14:22 ` [PATCH 4/5] gdb: remove print_sys_errmsg Andrew Burgess
2023-09-28 12:06 ` Andrew Burgess
2023-09-27 14:22 ` [PATCH 5/5] gdb: fix reread_symbols when an objfile has target: prefix Andrew Burgess
2023-09-28 14:00 ` [PATCHv2 0/5] Fix using an exec file with " Andrew Burgess
2023-09-28 14:00 ` [PATCHv2 1/5] gdb: some additional filename styling Andrew Burgess
2023-09-28 14:00 ` Andrew Burgess [this message]
2023-09-28 14:00 ` [PATCHv2 3/5] gdb: remove use of a static buffer for building error strings Andrew Burgess
2023-09-28 14:00 ` [PATCHv2 4/5] gdb: remove print_sys_errmsg Andrew Burgess
2023-09-28 14:00 ` [PATCHv2 5/5] gdb: fix reread_symbols when an objfile has target: prefix Andrew Burgess
2023-09-28 18:17 ` Tom Tromey
2023-09-29 10:20 ` Andrew Burgess
2023-10-02 14:19 ` Tom Tromey
2023-10-02 16:05 ` Andrew Burgess
2023-10-02 17:00 ` Tom Tromey
2023-10-02 19:13 ` [PATCHv2 0/5] Fix using an exec file with " Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0611bf29b93059df312acf56601cd45398e7dd0e.1695909469.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).