From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 20EFD3858D35 for ; Wed, 21 Jun 2023 17:25:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20EFD3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687368311; 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=ZfT84ERFDGs7etX+bV/EDR+TlQZbYbziI69iqw5HlhI=; b=GqUs25/QJcu2eeJci0tb5f8aNFJZNutlw8JbavxR+upyLY8i0KPtI/eVuFc4B4K2sSUVb1 oi4QL0XEP3yrRdadukyHLhuJVic2r+Ia8cG4eQugaTRcHW7FbEAYwNFEwrrUWyAW7AxvuM B6evHozN/sdrZ0ps49XJqmF/sVshdfg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-ppjg-DsqNHeHRlLfAjGEhQ-1; Wed, 21 Jun 2023 13:25:10 -0400 X-MC-Unique: ppjg-DsqNHeHRlLfAjGEhQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92A148030AC for ; Wed, 21 Jun 2023 17:25:09 +0000 (UTC) Received: from [10.22.18.131] (unknown [10.22.18.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC518112132E; Wed, 21 Jun 2023 17:25:08 +0000 (UTC) Message-ID: <311c8e10-ae51-aab1-820d-d849b4a2f6fc@redhat.com> Date: Wed, 21 Jun 2023 10:25:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v3 3/4] gdb/cli: add '.' as an argument for 'list' command To: Bruno Larsen , gdb-patches@sourceware.org References: <20230621104545.2530552-1-blarsen@redhat.com> <20230621104545.2530552-4-blarsen@redhat.com> From: Keith Seitz In-Reply-To: <20230621104545.2530552-4-blarsen@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 6/21/23 03:45, Bruno Larsen via Gdb-patches wrote: > Currently, after the user has used the list command once, there is no > way to ask GDB to print the location where the inferior is stopped. > This commit adds a way to do that using '.' as a new argument for the > 'list' command. If the inferior isn't running, the command throws an > error. The test gdb.base/list.exp was updated to test this new argument. I'm not entirely sure how I feel about throwing an error when using "list ." with no running inferior. Can you explain why that might be preferable to, say, just mimicking "list" with no argument or some other fallback? [I'm not going to NACK this patch for this, of course. I am just normally cautious about adding errors when logical, convenient fallbacks could be used instead.] However, there is a problem that specifically needs addressing IMO. Compare (using gdb debugging gdb): (top-gdb) list 10 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. (top-gdb) 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see . */ 18 19 #include "defs.h" 20 #include "main.h" 21 #include "interps.h" 22 23 int 24 main (int argc, char **argv) (top-gdb) 25 { 26 struct captured_main_args args; 27 28 memset (&args, 0, sizeof args); 29 args.argc = argc; 30 args.argv = argv; 31 args.interpreter_p = INTERP_CONSOLE; 32 return gdb_main (&args); 33 } (top-gdb) With (after "start"): (top-gdb) list . 23 int 24 main (int argc, char **argv) 25 { 26 struct captured_main_args args; 27 28 memset (&args, 0, sizeof args); 29 args.argc = argc; 30 args.argv = argv; 31 args.interpreter_p = INTERP_CONSOLE; 32 return gdb_main (&args); (top-gdb) 23 int 24 main (int argc, char **argv) 25 { 26 struct captured_main_args args; 27 28 memset (&args, 0, sizeof args); 29 args.argc = argc; 30 args.argv = argv; 31 args.interpreter_p = INTERP_CONSOLE; 32 return gdb_main (&args); (top-gdb) 23 int 24 main (int argc, char **argv) 25 { 26 struct captured_main_args args; 27 28 memset (&args, 0, sizeof args); 29 args.argc = argc; 30 args.argv = argv; 31 args.interpreter_p = INTERP_CONSOLE; 32 return gdb_main (&args); (top-gdb) I don't think this is particularly user-friendly. Is it possible to make the two use cases behave similarly? Keith