From: Guinevere Larsen <guinevere@redhat.com>
To: Hannes Domani <ssbssa@yahoo.de>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2] gdb: add tutorial command
Date: Mon, 26 Jan 2026 15:08:19 -0300 [thread overview]
Message-ID: <93f59280-81da-4ace-9aef-40d439adbec8@redhat.com> (raw)
In-Reply-To: <219427526.4910854.1769254870963@mail.yahoo.com>
On 1/24/26 8:41 AM, Hannes Domani wrote:
> Am Donnerstag, 22. Januar 2026 um 21:30:04 MEZ hat Guinevere Larsen <guinevere@redhat.com> Folgendes geschrieben:
>
>> Before this commit, there is little way for a new user to learn how to
>> use GDB on their own. The documentation contains an example session,
>> but that isn't contained in GDB itself, and the "help" and "apropos"
>> commands exist, but they aren't the best to really teach what GDB can
>> do, only to describe commands on their own.
>>
>> This commit changes this by introducing a command called "tutorial",
>> which takes a page out of common design from the last few decades and
>> provides a self-contained tutorial for users, walking them through a
>> simple bug in C code, and explaining several commands in context.
>>
>> The tutorial is mostly implemented (ab)using the before_prompt hook to
>> print the messages, so that users can have completion, history and so
>> on, and it is implemented in python to make maintaining it in the future
>> as simple as possible.
>> ---
>> +def cleanup():
>> + print(
>> + """
>> +Thank you for taking this tutorial. We hope it has been
>> +helpful for you. If you found any bugs or would like to
>> +provide feedback, feel free to send do so through IRC, in
>> +the #gdb room of libera.chat, or send an email to
>> +gdb@sourceware.org.
>> +To recap, these were the commands explained in the tutorial
>> + * shell
> The shell command was not explained.
Good point. It is also pretty advanced, I guess I can just remove from
here.
>
>
>> + * file
>> + * start
>> + * continue
>> + * list
>> + * break
>> + * print
>> + * step
>> + * next
>> + * display
>> + * watch
>> + * quit
I suppose I didn't explain quit anymore? I'll double check and possibly
remove this as well.
>> + * help
>> + """
>> + )
>> + gdb.events.before_prompt.disconnect(tutorial_hook)
>> + gdb.events.exited.disconnect(tutorial_exit_hook)
>> + # Clean up example code.
> At the end of the tutorial I get this warning:
> warning: BFD: reopening /home/src/a.out: No such file or directory
>
> I've silenced it by adding this line here:
> gdb.execute("file")
>
> But then I get these warnings instead:
> Error in re-setting breakpoint 2: No source file named example_code.c.
> Error in re-setting breakpoint 3: No symbol table is loaded. Use the "file" command.
>
> So I've also added this line before the other:
> gdb.execute("delete breakpoints")
>
> Then all warnings were gone.
These warnings happen when the target is mourning the inferior (ie,
making an internal cleanup of stuff). I don't understand all the cleanup
that GDB has to do, so I don't know if deleting all breakpoints is
enough or if we're still leaving cruft behind
In a 1:1 meeting with Andrew, he suggested instead that cleanup could be
called in the next "before_prompt" hook instead, so we're guaranteed to
have finished the internal cleanup but we do it before the user can
actually do anything.
--
Cheers,
Guinevere Larsen
It/she
>
>
>> + try:
>> + f = open(generated_code)
>> + f.close()
>> + os.remove(generated_code)
>> + except FileNotFoundError:
>> + # File doesn't exist, nothing to do.
>> + pass
>> + try:
>> + f = open(generated_binary)
>> + f.close()
>> + os.remove(generated_binary)
>> + except FileNotFoundError:
>> + # File doesn't exist, nothing to do.
>> + pass
>> +
>
> Hannes
>
next prev parent reply other threads:[~2026-01-26 18:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 20:28 Guinevere Larsen
2026-01-23 7:11 ` Eli Zaretskii
2026-01-23 14:14 ` Guinevere Larsen
2026-01-23 14:23 ` Arsen Arsenović
2026-01-23 14:28 ` Eli Zaretskii
2026-01-26 14:54 ` Andrew Burgess
2026-01-26 18:50 ` Guinevere Larsen
2026-01-24 11:41 ` Hannes Domani
2026-01-26 18:08 ` Guinevere Larsen [this message]
2026-01-26 16:13 ` Andrew Burgess
2026-01-27 19:39 ` Guinevere Larsen
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=93f59280-81da-4ace-9aef-40d439adbec8@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=ssbssa@yahoo.de \
/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