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 4D5D23858D20 for ; Fri, 3 Feb 2023 18:49:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D5D23858D20 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=1675450173; 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=jCPGonIhh/LaPOJ59WE3Im5cP+1chVMIgAdsB7tnR3U=; b=V41ly0PvGlyHDJiB3dVpd8XxX+8JdI4BUjGxDqPZtg24Qz1Eqp7ZmZNhrw8wqp3NOSs5Nm 4V7gwhNmkEKwarMVIoRtdHX5IgaG2p4F+72U53URuCU52JXw0G9AqbaHIMlZoV/B1ATKWf BKKhuHRN+wzrKqZYgT492C+THzDx3mI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-b6YtLGB1NUWNMpojVtnK6A-1; Fri, 03 Feb 2023 13:49:30 -0500 X-MC-Unique: b6YtLGB1NUWNMpojVtnK6A-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 50D3A3C02B7D for ; Fri, 3 Feb 2023 18:49:30 +0000 (UTC) Received: from [10.2.16.136] (unknown [10.2.16.136]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E5F3112132C; Fri, 3 Feb 2023 18:49:29 +0000 (UTC) Message-ID: <304a1f8b-9aac-c695-ffc6-0287bfebd356@redhat.com> Date: Fri, 3 Feb 2023 10:49:29 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [RFC PATCH 2/2] Allow and evaluate expressions in command arguments To: Andrew Burgess , gdb-patches@sourceware.org References: <20230125193825.3665649-1-keiths@redhat.com> <20230125193825.3665649-3-keiths@redhat.com> <87edr6r7e3.fsf@redhat.com> From: Keith Seitz In-Reply-To: <87edr6r7e3.fsf@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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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 2/3/23 09:22, Andrew Burgess wrote: > Keith Seitz via Gdb-patches writes: > >> In order to mark the bounds of expressions to be evaluated, I've >> introduced the (arbitrary) marker "$()". Everything contained inside >> this marker will be passed to the expression parser, evaluated, printed >> as a string, and then substituted for the original expression. > > I really like the goal of this series, and think something like this > would be awesome to add. > > I do worry about the extra $(..) wrapper though, that feels a little > clunky, if the common case turns out to be just doing simple things like > environment variables, I wonder if we could make things like: > > (gdb) file $_env("HOME")/$_env("BLAH") > > just work? I agree. That $() marker *is* cumbersome. > We could still retain $(...) for full expression evaluation, because I > guess, in theory this would allow things like: > > (gdb) some_gdb_command $(some_inferior_function()) > > thought I suspect things like this will be far less common ... maybe? That's another good idea. We could explicitly permit: 1. $(): Evaluate ANY arbitrary expression 2. $VAR_OR_FUNC: Evaluate /only/ a convenience variable or expression. Convenience funcs are easier than vars, but I think this can be made to work. As you note, if using just a convenience variable or function is insufficient, users could fallback to the more clumsy $() notation. Thank you for the input! I will work on completing this patch for formal submission. Keith