Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@yahoo.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	 Guinevere Larsen <guinevere@redhat.com>
Subject: Re: [PATCH v2] gdb: add tutorial command
Date: Sat, 24 Jan 2026 11:41:10 +0000 (UTC)	[thread overview]
Message-ID: <219427526.4910854.1769254870963@mail.yahoo.com> (raw)
In-Reply-To: <20260122202834.393095-1-guinevere@redhat.com>

 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.


> +  * file
> +  * start
> +  * continue
> +  * list
> +  * break
> +  * print
> +  * step
> +  * next
> +  * display
> +  * watch
> +  * quit
> +  * 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.


> +    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

  parent reply	other threads:[~2026-01-24 11:41 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 [this message]
2026-01-26 18:08   ` Guinevere Larsen
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=219427526.4910854.1769254870963@mail.yahoo.com \
    --to=ssbssa@yahoo.de \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.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