From: Stefan Kangas <stefankangas@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Dima Kogan <dima@secretsauce.net>, 58826@debbugs.gnu.org
Subject: bug#58826: 29.0.50; gud-gdb can't find core file if executable is in a different directory
Date: Sat, 12 Nov 2022 20:32:34 -0800 [thread overview]
Message-ID: <CADwFkmkydYBWPHyvEspaDaZPZdNQc9Y6NhwnpzM_3W7sw6vYQw@mail.gmail.com> (raw)
In-Reply-To: <83pmecjtxh.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 28 Oct 2022 10:20:26 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
>> > AFAIU, if you run the debugger like this:
>> >
>> > gdb --fullname python3 core.sfmviz.py.1807941
>> >
>> > then GUD will not change the default-directory to /usr/bin, which I
>> > believe is what you want. GDB will then locate the Python executable
>> > either in the current default-directory or by searching PATH.
>>
>> OK. It's documented, but it's still not good. What if the executable
>> wasn't in the $PATH?
>
> Is that what happens in your case?
>
> In general, you need in that case to change to the directory of the
> executable, and invoke gud-gdb from there.
>
> IME, the current behavior covers most of the use cases: either you are
> debugging a program you are developing from its source tree, or you
> are debugging an installed program that's on PATH.
>
>> It's also really unintuitive to have an implicit change of directory
>> here, and it would match most people's expectations if it was changed, I
>> think. Do you know why we're doing that?
>
> If you think about that, it's actually quite natural: it makes the
> files you are likely to access from the debug session appear in the
> current directory.
I think Eli is right here.
> In any case, this is a long-standing behavior.
Indeed. So any change would also need to be careful not to break
backwards-compatibility in relevant cases.
At the same time, users might not expect the change of directory to
depend on whether or not she says "python3" or "/usr/bin/python3". So
to avoid just wontfixing this outright, here are some alternative ideas:
- Perhaps we could skip changing the directory if the prefix (in the
above case "/usr/bin") is already in PATH?
- But that won't take care of the case where it is *not* in PATH. So
perhaps we should have even more heuristics to also see if it is some
interpreter (under the assumption that interpreters generally don't
live together with the source code that is being debugged)?
IOW, if --fullname is some well-known value like "python3", we don't
change directory by default. We would need to consider if such a
change would break anything for relevant use-cases, of course.
That's the best I could think of, at least. If that is overcomplicating
things, I guess we will have to close this bug as wontfix, as
unsatisfying as that seems.
next prev parent reply other threads:[~2022-11-13 4:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 23:52 bug#58826: 29.0.50; gud-gdb can't find core file if executable is in a different directory Dima Kogan
2022-10-28 6:23 ` Eli Zaretskii
2022-10-28 6:29 ` Dima Kogan
2022-10-28 7:20 ` Eli Zaretskii
2022-11-13 4:32 ` Stefan Kangas [this message]
2022-11-15 4:17 ` Richard Stallman
2022-11-15 13:46 ` Eli Zaretskii
2022-11-18 5:05 ` Richard Stallman
2022-11-18 8:23 ` Eli Zaretskii
2022-11-20 1:15 ` Richard Stallman
2022-11-20 7:45 ` Eli Zaretskii
2022-11-23 23:16 ` Richard Stallman
2022-11-23 23:17 ` Dima Kogan
2022-11-26 0:50 ` Richard Stallman
2022-11-24 6:55 ` Eli Zaretskii
2022-12-29 3:14 ` Richard Stallman
2022-12-29 6:19 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADwFkmkydYBWPHyvEspaDaZPZdNQc9Y6NhwnpzM_3W7sw6vYQw@mail.gmail.com \
--to=stefankangas@gmail.com \
--cc=58826@debbugs.gnu.org \
--cc=dima@secretsauce.net \
--cc=eliz@gnu.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).