From: Eli Zaretskii <eliz@gnu.org>
To: Matti Puputti <matti.puputti@intel.com>
Cc: gdb-patches@sourceware.org, aburgess@redhat.com
Subject: Re: [PATCH v4 1/1] gdb, infcmd: Support jump command with same line in multiple symtabs
Date: Wed, 10 May 2023 15:15:14 +0300 [thread overview]
Message-ID: <83sfc48jsd.fsf@gnu.org> (raw)
In-Reply-To: <20230510111230.839619-2-matti.puputti@intel.com> (message from Matti Puputti via Gdb-patches on Wed, 10 May 2023 13:12:30 +0200)
> Cc: aburgess@redhat.com
> Date: Wed, 10 May 2023 13:12:30 +0200
> From: Matti Puputti via Gdb-patches <gdb-patches@sourceware.org>
>
> If a header file defining a static function is included in multiple source
> files, each calling the function, and GDB is asked to jump to a line inside
> that function, there would be multiple locations matching the target. The
> solution in this commit is to select the location in the current symtab.
> ---
> gdb/doc/gdb.texinfo | 5 +-
> gdb/infcmd.c | 13 ++++-
> .../gdb.base/jump_multiple_objfiles-foo.c | 24 +++++++++
> .../gdb.base/jump_multiple_objfiles.c | 30 +++++++++++
> .../gdb.base/jump_multiple_objfiles.exp | 54 +++++++++++++++++++
> .../gdb.base/jump_multiple_objfiles.h | 30 +++++++++++
> 6 files changed, 153 insertions(+), 3 deletions(-)
> create mode 100755 gdb/testsuite/gdb.base/jump_multiple_objfiles-foo.c
> create mode 100755 gdb/testsuite/gdb.base/jump_multiple_objfiles.c
> create mode 100755 gdb/testsuite/gdb.base/jump_multiple_objfiles.exp
> create mode 100755 gdb/testsuite/gdb.base/jump_multiple_objfiles.h
>
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 4ae84ec5a63..921cff16597 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -20586,8 +20586,9 @@ an address of your own choosing, with the following commands:
> Resume execution at the address of the code location that results from
> resolving @var{locspec}.
> @xref{Location Specifications}, for a description of the different
> -forms of @var{locspec}. If @var{locspec} resolves to more than one
> -address, the command aborts before jumping.
> +forms of @var{locspec}. If @var{locspec} resolves to more than one address,
> +those outside the current compilation unit are ignored. If still not a
> +unique address found, the command aborts before jumping.
Thanks. The last sentence reads awkwardly in English, so I suggest to
rephrase:
If considering just the addresses in the current compilation unit
still doesn't yield a unique address, the command aborts before
jumping.
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -1070,7 +1070,18 @@ jump_command (const char *arg, int from_tty)
> std::vector<symtab_and_line> sals
> = decode_line_with_last_displayed (arg, DECODE_LINE_FUNFIRSTLINE);
> if (sals.size () != 1)
> - error (_("Unreasonable jump request"));
> + {
> + /* If multiple sal-objects were found, try dropping those that aren't
> + from the current symtab. */
> + struct symtab_and_line cursal = get_current_source_symtab_and_line ();
> + sals.erase (std::remove_if (sals.begin (), sals.end (),
> + [&] (const symtab_and_line &sal)
> + {
> + return sal.symtab != cursal.symtab;
> + }), sals.end ());
> + if (sals.size () != 1)
> + error (_("Unreasonable jump request"));
I wonder whether, while we are at that, we could make this error
message less vague. How about
Jump request is ambiguous: does not resolve to a single address
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
next prev parent reply other threads:[~2023-05-10 12:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 11:12 [PATCH v4 0/1] gdb, infcmd: Support jump command with same line in Matti Puputti
2023-05-10 11:12 ` [PATCH v4 1/1] gdb, infcmd: Support jump command with same line in multiple symtabs Matti Puputti
2023-05-10 12:15 ` Eli Zaretskii [this message]
2023-05-10 13:24 ` Andrew Burgess
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=83sfc48jsd.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=matti.puputti@intel.com \
/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).