From: Guinevere Larsen <blarsen@redhat.com>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simark@simark.ca>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: [PATCH v3] gdb: Change "list ." command's error when no debuginfo is available
Date: Thu, 2 May 2024 17:19:46 -0300 [thread overview]
Message-ID: <6704f914-c558-403b-a208-792dcc723026@redhat.com> (raw)
In-Reply-To: <87ikzwodgw.fsf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4612 bytes --]
On 5/2/24 04:54, Andrew Burgess wrote:
>> @@ -1274,25 +1276,42 @@ list_command (const char *arg, int from_tty)
>> /* "list ." lists the default location again. */
>> else if (arg[0] == '.')
>> {
>> + std::optional<const symtab_and_line> cursal;
> I don't see why this needs to be a std::optional. Along both branches
> of the following if/else we assign cursal a value.
You're right. I think this is a leftover from a previous strategy (or
just a copy from Simon's email, I honestly can't remember). I've removed
this locally
In double checking this change, I noticed that I forgot to change the
test strings to the form suggested by Eli. Also fixed locally. For
convenience, this is the change:
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index ee3318d7910..d5c8ad33457 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1276,16 +1276,16 @@ list_command (const char *arg, int from_tty)
/* "list ." lists the default location again. */
else if (arg[0] == '.')
{
- std::optional<const symtab_and_line> cursal;
+ symtab_and_line cursal;
if (target_has_stack ())
{
/* Find the current line by getting the PC of the currently
selected frame, and finding the line associated to it. */
frame_info_ptr frame = get_selected_frame (nullptr);
CORE_ADDR curr_pc = get_frame_pc (frame);
- cursal.emplace (find_pc_line (curr_pc, 0));
+ cursal = find_pc_line (curr_pc, 0);
- if (cursal->symtab == nullptr)
+ if (cursal.symtab == nullptr)
error
(_("Insufficient debug info for showing source lines at "
"current PC (%s)."), paddress (get_frame_arch (frame),
@@ -1305,12 +1305,12 @@ list_command (const char *arg, int from_tty)
error (_("Insufficient debug info for showing source "
"lines at default location"));
}
- cursal.emplace (get_current_source_symtab_and_line ());
+ cursal = get_current_source_symtab_and_line ();
- gdb_assert (cursal->symtab != nullptr);
+ gdb_assert (cursal.symtab != nullptr);
}
- list_around_line (arg, *cursal);
+ list_around_line (arg, cursal);
/* Set the repeat args so just pressing "enter" after using
"list ."
will print the following lines instead of the same lines
again. */
diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.exp
b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
index 7c4144da8ab..20050a90245 100644
--- a/gdb/testsuite/gdb.base/list-dot-nodebug.exp
+++ b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
@@ -54,7 +54,7 @@ foreach_with_prefix debug {"none" "some"} {
}
gdb_test "list ." \
- "No debug information available to print source lines.*" \
+ "Insufficient debug info for showing source lines.*" \
"print before start"
if { ![runto bar] } {
@@ -62,6 +62,6 @@ foreach_with_prefix debug {"none" "some"} {
}
gdb_test "list ." \
- "No debug information available to print source lines at current
PC.*" \
+ "Insufficient debug info for showing source lines at current PC.*" \
"print after start"
}
diff --git a/gdb/testsuite/gdb.base/list-nodebug.exp
b/gdb/testsuite/gdb.base/list-nodebug.exp
index 942a282083a..e07fa9e2417 100644
--- a/gdb/testsuite/gdb.base/list-nodebug.exp
+++ b/gdb/testsuite/gdb.base/list-nodebug.exp
@@ -33,8 +33,8 @@ if {![runto_main]} {
# Check that GDB doesn't crash when we use list . on an inferior with
# no debug information
-gdb_test "list ." "No debug.*" "first 'list .'"
+gdb_test "list ." "Insufficient debug.*" "first 'list .'"
# This should be called twice because the first list invocation since
# printing a frame may take a different codepath, which wouldn't
# trigger the crash.
-gdb_test "list ." "No debug.*" "second 'list .'"
+gdb_test "list ." "Insufficient debug.*" "second 'list .'"
--
Cheers,
Guinevere Larsen
She/Her/Hers
>
> Thanks,
> Andrew
next prev parent reply other threads:[~2024-05-02 20:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 18:35 Guinevere Larsen
2024-05-02 7:54 ` Andrew Burgess
2024-05-02 20:19 ` Guinevere Larsen [this message]
2024-05-08 14:25 ` Andrew Burgess
2024-05-08 17:13 ` Guinevere Larsen
2024-05-10 6:26 ` Tom de Vries
2024-05-10 19:53 ` Pedro Alves
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=6704f914-c558-403b-a208-792dcc723026@redhat.com \
--to=blarsen@redhat.com \
--cc=aburgess@redhat.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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).