From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CZBUE7Wtd2k4ZhYAWB0awg (envelope-from ) for ; Mon, 26 Jan 2026 13:08:53 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ABfXxibO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4B9BD1E0AD; Mon, 26 Jan 2026 13:08:53 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A63181E08D for ; Mon, 26 Jan 2026 13:08:52 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 0E4974BC895A for ; Mon, 26 Jan 2026 18:08:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E4974BC895A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ABfXxibO Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 722EF4BA2E34 for ; Mon, 26 Jan 2026 18:08:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 722EF4BA2E34 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 722EF4BA2E34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769450906; cv=none; b=eCI0wryWLmVYp8SGYZ8pwfn+tRfOD0sEIyg3RtV6gDxk/1OUlFV0AOrWp+J8t0nKwlbPHhmjL6+s/jxs9X0JAJ82oukYHQmTWnCOodNf1WWi5Rs3owvkmA0a8Um1heXV37UCFw4ZxnrwdXNHdOY6BKNKdQEGTmZsLS2RF22Tics= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769450906; c=relaxed/simple; bh=042VrbsEUqe+L24KFj0BZgMQaW90p5X4W/mjA/n6dT8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=mEnNw5RxiOrJ3sQNsbejsCSDejMHcolop5GdQciE00VnXcbClCEfUeL2/znFCp5GOcDVkIko8892QyggIEIxCGylTYYjmMnybL/UMl7sna8hoH/U/b2HNt+GsYnPXMMlTf463eDeUJ8VWBrZ5cAD8bgbhpAryD8Rczmf8nlmEEY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 722EF4BA2E34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769450906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=304xPH2no+KbO+sEc49WKqfLczblVnjy/CNe4zCo9CE=; b=ABfXxibOmZoglLs3rFYHSvXJYJ6SHFZ7eRpgLdbUCprz4GkzEWUaQQt9s4kot4HEZdLs/x rzRzt4gcA0J4AqstXxO8kzexuD+G/aaAmT4vgY2GN9ZETZwY+ANjujxli9bn3a45KSIuvK ybmZrTU507fkcKLJ6qvHt8rfuhQ08HI= Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-Ap-Y2VmDPwSVDNHNBPpQTg-1; Mon, 26 Jan 2026 13:08:24 -0500 X-MC-Unique: Ap-Y2VmDPwSVDNHNBPpQTg-1 X-Mimecast-MFC-AGG-ID: Ap-Y2VmDPwSVDNHNBPpQTg_1769450904 Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-2b74aff34efso2672025eec.1 for ; Mon, 26 Jan 2026 10:08:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769450904; x=1770055704; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=304xPH2no+KbO+sEc49WKqfLczblVnjy/CNe4zCo9CE=; b=CJYCbks6U2DD/m6IwFRvRjzOMlS6eraSEIMo283G43skQ76TIgaQur8j3Ig+iA/ry5 GImtB70MGQVK/lMSxDDVGe4bHgAzsDPf+8s/vRR844uUYi3UYOxNZqrkuIUIyjuNi1iW eJM8zPIijRpHxh1DP4wfWJXUgvLjqlAqiHbpXRUHzHqZQmn6MbEwZ/8HLp3bsP/0tQae gYdIxdYwmJ7rwBI3ienuDTSVGbLmMOUaYq7GcTHdIOmn8pQq6TofDdv9PT0CV8e4qj7+ lQEbkyam9m5X/0MqXaGW0ypNQNV6QxiIrHKb3HbfMTaNQuAfpAmPqxVAAookvLNza/Qs hf7w== X-Forwarded-Encrypted: i=1; AJvYcCWe8EJ/XrDka/VQ3Kit3QR3W5TvpMUW43svYaNpBGO2Via9zhhMWnjHG4hFng1u+LpDdbJmBeH7oSPXfQ==@sourceware.org X-Gm-Message-State: AOJu0YxMrdKjdAz/5bpfOBRvXjVxehiw7by2LUKTX6Agunfn4d4eYd5W tcB6lULNowSh7HwSuxzoGu++REhxj/U0SznQp1/53/dBZkQoFLw0tpWzBWFKWFs9AjJY5RZtcLt XknMbLo4xu7z+CiZONeZm00DsValsliNfnOcv7tktSZ5lH4P5Mfd6Ft6AlBC0Qn8= X-Gm-Gg: AZuq6aL5iE9kI0XVewRt1+oBaaL9HAQvPKJgIkY1kRh3OZCux4o3Mwwgk5X3/0d+kMt 84YcMOm9Uidag34F6H2FiGayZ57n12ts+IWO2jGkf+i0D5XcpUi7CHbJeIh5E5eMszHJKAV2A+/ 6JenAIkJzS7mF0/KENZngI5lNOwyvJ6A8SZry+F2zhwTcoBcYc1k5Nw8CnzrVEcD67B25Ea7WgU FIXqJJ0791Hubzx9vY7fC+xP50932oYQ8RYIpTAPWYLLNn/Rb2nPpu7wW4ZMDd99rZx0yWfHASv bRbXVx7KR0k896u/aegz5uG2oH1LIJQNNw4loonqPwG6IbH/GN23P2VHM9lDVqQyEyjKan9SMFO rVOgt+54yOZQyJg9GTjn9UQ== X-Received: by 2002:a05:7300:8188:b0:2b0:50a7:b784 with SMTP id 5a478bee46e88-2b76483ac65mr2544633eec.42.1769450903557; Mon, 26 Jan 2026 10:08:23 -0800 (PST) X-Received: by 2002:a05:7300:8188:b0:2b0:50a7:b784 with SMTP id 5a478bee46e88-2b76483ac65mr2544621eec.42.1769450903082; Mon, 26 Jan 2026 10:08:23 -0800 (PST) Received: from ?IPV6:2804:14d:8084:a5b1::1002? ([2804:14d:8084:a5b1::1002]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b73aa22707sm14148629eec.29.2026.01.26.10.08.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jan 2026 10:08:22 -0800 (PST) Message-ID: <93f59280-81da-4ace-9aef-40d439adbec8@redhat.com> Date: Mon, 26 Jan 2026 15:08:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] gdb: add tutorial command To: Hannes Domani , "gdb-patches@sourceware.org" References: <20260122202834.393095-1-guinevere@redhat.com> <219427526.4910854.1769254870963@mail.yahoo.com> From: Guinevere Larsen In-Reply-To: <219427526.4910854.1769254870963@mail.yahoo.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: s2DGPoHqfnG7GskiEmEBz9X3ri-UllYAwp5o-zjeBoI_1769450904 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 1/24/26 8:41 AM, Hannes Domani wrote: > Am Donnerstag, 22. Januar 2026 um 21:30:04 MEZ hat Guinevere Larsen 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 >