aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorMatti Puputti <matti.puputti@intel.com>2023-05-12 15:33:20 +0200
committerAndrew Burgess <aburgess@redhat.com>2023-05-24 17:02:21 +0100
commit389971df23ca74092314dbde1303310a33766ba7 (patch)
tree84a5bfe3138619a51de2ff04661ee35f9bfc8394 /gdb/infcmd.c
parentea33730dfa4b2e639f99bb4c1f4f8f073ef5b937 (diff)
downloadgdb-389971df23ca74092314dbde1303310a33766ba7.zip
gdb-389971df23ca74092314dbde1303310a33766ba7.tar.gz
gdb-389971df23ca74092314dbde1303310a33766ba7.tar.bz2
gdb, infcmd: Support jump command with same line in multiple symtabs
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. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index b12b58d..15702f8 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1070,7 +1070,19 @@ 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 (_("Jump request is ambiguous: "
+ "does not resolve to a single address"));
+ }
symtab_and_line &sal = sals[0];