From: Eli Zaretskii <eliz@gnu.org>
To: Simon Marchi <simark@simark.ca>
Cc: guinevere@redhat.com, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: add tutorial command
Date: Wed, 03 Dec 2025 14:43:38 +0200 [thread overview]
Message-ID: <867bv33fd1.fsf@gnu.org> (raw)
In-Reply-To: <aa5d0e66-0f76-46f8-9b33-0c1c567d15ac@simark.ca> (message from Simon Marchi on Tue, 2 Dec 2025 14:33:08 -0500)
> Date: Tue, 2 Dec 2025 14:33:08 -0500
> Cc: gdb-patches@sourceware.org
> From: Simon Marchi <simark@simark.ca>
>
> > First, writing this command in Python means that GDB without Python
> > will not have a tutorial, which is IMO a pity. Is it so complicated
> > to have this implemented in C++ instead? The text and the basic
> > script of the tutorial session could be on a text file that code
> > accesses when the tutorial is running, so that only the necessary
> > stuff needs to be in code.
>
> If possible, it would indeed be nice, but I'll take a tutorial written
> in Python over nothing.
If the C++ implementation is not feasible or not practical, I agree.
My point is that we should consider that possibility before deciding
on a Python implementation.
> > Next, I'm not sure we need to compile a program for this purpose. We
> > could use the GDB executable itself instead: that would allow us to
> > show the basic commands without the need for the user to have a
> > compiler and a working development environment to go with it.
>
> I don't see how that's feasible or practical. The GDB binary users are
> most likely to have are optimized (bad debugging experience, especially
> if you're learning) and won't have debug info anyway. And like
> Guinevere said, GDB is way too complicated to throw at newbies anyway.
> I like Guinevere's idea of giving the user a small program they can toy
> with.
This is a _GDB_ tutorial. It doesn't need to include a complete
debugging problem described in its entirety, right up to finding the
bug and fixing it. It needs to show the use of important GDB
commands, under the assumption that the person using the tutorial
knows how to debug programs, but is not familiar with GDB commands to
do that. (Yes, teaching debugging techniques in addition is helpful,
but IMO the minimal requirements from a useful tutorial are to teach
the commands.)
For the purpose of teaching the useful commands, it doesn't matter
much that GDB is optimized, the only possible problem could be that
it's stripped. If it is not stripped, I don't see why we couldn't
show use of important commands on GDB itself, explaining their purpose
in plain text. There's no need to solve an actual bug, just let users
tinker with commands when they have a live program at their disposal.
Whatever the complexity of GDB, users definitely can step it, step
into functions, examine its data, set breakpoints and watchpoints and
see them break, etc. We could also show how to change values of
variables and call functions from the program. Moreover, if we limit
ourselves to teaching commands, we can show advanced commands and
techniques, like working with threads and scheduling them, following
'fork', handling signals, etc. -- these are hard to impossible to do
with toy programs, but they are needed in most real-life debugging
sessions.
> > Also, a tutorial doesn't have to teach people how to debug, it could
> > only teach them the important GDB commands to use for debugging.
> > Doing both makes the tutorial more complex because it teaches two
> > non-trivial subjects instead of just one.
> >
> > What do others think?
>
> I don't understand your last point. Do you mean that the tutorial
> should just be some text that says "you can use command X to do this,
> command Y to do that, etc"? Seems way less interesting and interactive
> than what is proposed here.
Yes, I mean just describe the important commands and let the user try
them and see the results.
Indeed, teaching both debugging techniques and GDB commands is better,
but that job is much more complex if taken seriously. And I question
the actual value of showing how to debug a toy program anyway, because
it is nothing like debugging real-life programs. The latter
frequently requires advanced techniques, some of them special to the
program in question (e.g., see etc/DEBUG in the Emacs source tree).
So I suggest to start from a modest task of showing and teaching the
important commands, leaving the rest to the users, who will need to
learn much more, if they never debugged a real-life program. We may
decide in the future to have a separate tutorial about debugging
techniques.
Please note that the above is just MO; I will not object and won't
argue if you-all think differently. I just wanted to present an
alternative POV, so that people could think about this and make up
their minds. After all, it is unlikely that I will use this tutorial
myself...
next prev parent reply other threads:[~2025-12-03 12:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 17:08 Guinevere Larsen
2025-12-02 14:20 ` Eli Zaretskii
2025-12-02 17:02 ` Guinevere Larsen
2025-12-02 19:33 ` Simon Marchi
2025-12-03 12:43 ` Eli Zaretskii [this message]
2025-12-03 13:07 ` Guinevere Larsen
2025-12-03 17:27 ` Simon Marchi
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=867bv33fd1.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
--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