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 026D13858D35 for ; Thu, 22 Jun 2023 10:53:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 026D13858D35 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=1687431181; 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=Qun/0GiCwKE0q2B8Azqqmy3Bj84mHymrdgA9DwLl9D8=; b=LPVkmTOKvnqEnMjwdpT+btcwhnygSO93HrKzIbYDJRm9Llnwym3THMuXBmO++2YUZQ1F62 dI2yAQTg2M2jfdF0av9mMuAnfl8QMiY/ijMTjxSa3JTRM67a0e1K95/k6cwrNKqfVKtRut K0eOnjXZV/uV64oGckoMWMO9OW0fSr4= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-OTt9zqXOPbaK1OQtGojsUA-1; Thu, 22 Jun 2023 06:52:58 -0400 X-MC-Unique: OTt9zqXOPbaK1OQtGojsUA-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2b465ab1c76so44291861fa.0 for ; Thu, 22 Jun 2023 03:52:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687431175; x=1690023175; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Qun/0GiCwKE0q2B8Azqqmy3Bj84mHymrdgA9DwLl9D8=; b=aRNmzcU4hUw9kSWUahO6QQ8P6o3luxDaZoZvKX86d8uZXy3ckxu1WNnRRW1uel1m1K g6Sb9/uRhmrloJGhKzavyPC6Jw/iRlloroqXtYa2qHVMXo113DNEvST70aLU/rMIlVyC ykKeAMMzSJ8BYS4L7CaaJsVI3pqNHLhu4L3jNj9vk0cRn2y0kv7VmhN/Qpo3zOYG1m33 gD1rp+tZMoHNePVfYe0sv0G+evv61OxbUagOF4wbj2qJxC2q7hZtfcs20lYn+Be2lqlx P3SEJAh0D9HWKDoyqbqL86oe7oGsbxJU5ipiILIwx7BJodJ5U1YtBhVDpUxVxLf/66X0 r5NQ== X-Gm-Message-State: AC+VfDx/GMsv6CY0rdlCZ193PMu8WW046h4RChljyDwAZVzh9fqT3G+D 2e7bXpCukizfvNCXsQDWr5QY/V+QUP2+MrKfkDPANRbzDmJ6rvoMokzfkOOlIWAEIj99/JilTdP DQoEjSbN8bNLeLhp0N/ogDS5qIw48fg== X-Received: by 2002:a19:4f18:0:b0:4f8:5964:ac63 with SMTP id d24-20020a194f18000000b004f85964ac63mr10836670lfb.24.1687431175312; Thu, 22 Jun 2023 03:52:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7H2ADKNB6CCGg0trLu6cY6ClO7SpxgEDapHzp3hcSFDgmxrQD6u8aG+cws079LX0v57W/QEg== X-Received: by 2002:a19:4f18:0:b0:4f8:5964:ac63 with SMTP id d24-20020a194f18000000b004f85964ac63mr10836659lfb.24.1687431174964; Thu, 22 Jun 2023 03:52:54 -0700 (PDT) Received: from [192.168.0.129] (ip-94-112-225-44.bb.vodafone.cz. [94.112.225.44]) by smtp.gmail.com with ESMTPSA id k10-20020adff5ca000000b0030ae87bd3e3sm6796781wrp.18.2023.06.22.03.52.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jun 2023 03:52:54 -0700 (PDT) Message-ID: <0e9e8f1a-3a02-113f-5144-0c8b660060d5@redhat.com> Date: Thu, 22 Jun 2023 12:52:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v3 3/4] gdb/cli: add '.' as an argument for 'list' command To: Keith Seitz , gdb-patches@sourceware.org References: <20230621104545.2530552-1-blarsen@redhat.com> <20230621104545.2530552-4-blarsen@redhat.com> <311c8e10-ae51-aab1-820d-d849b4a2f6fc@redhat.com> From: Bruno Larsen In-Reply-To: <311c8e10-ae51-aab1-820d-d849b4a2f6fc@redhat.com> 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: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 21/06/2023 19:25, Keith Seitz wrote: > 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.] My logic was that '.' is supposed to be 'current location', so if the inferior is not running, there is no current location. I'm changing it, no problem :) > > 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? Today I learned about GDB dealing with command arguments! TL;DR yes, I'll do that in v4 For future reference (probably for myself) if you advance the arg pointer when handling the command, the next command invocation is going to use the advanced argument pointer. When handling the number, list_command advances the arg, so everything after the first line is literally a no arg invocation. > > Keith > -- Cheers, Bruno