From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by sourceware.org (Postfix) with ESMTPS id 233B13858C2C for ; Mon, 30 Jan 2023 15:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 233B13858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso3410453wms.5 for ; Mon, 30 Jan 2023 07:12:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:to:from:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Trg7UPuuAlAWWrReFZiLQSJPR5wHI/n9UDF3/IrFTDA=; b=QgJSXefpGKZsf02DzB07jK0dHvkBOdZsIJ+kdv9HMreXY7yCrE0s/wDCZlNKhJCfty XgnT2gCuc0j5y9j7osxIGdmkbs/oKldWSUsvKYpGLgpR5OdUDWL/mDRlToMCXz7kiJSm ZgvIYISAa7KrzVNXYQelLed4xJdx4Z96TAWIxajTVR0Pq0sDgRPNxARlo5JqUioSpyCU GOUqY0wA3H/wMWfNROxpv5Zv4AhSqkKHLiRcy15e0BPW6J4vGJLaPwXSHHUOFyseQ9sj SGyYvgiUr3ZcOCWh7j+IVA9EfYTk4FyEBMlajhxmNXsX7NrzV5H0mIq0AZy42bpFSZVD NNmw== X-Gm-Message-State: AFqh2kqaiHmsg9/NCKLy4AK7N/oSGB8uXvR015y9VPfF0nSWM3WliIe5 Gx9h/HRN8zaVEbzcY80p2v27MsiWIZHY+g== X-Google-Smtp-Source: AMrXdXujPv/Qwj1K7XA2BaOJIHH19U4ndoNDn+kAn6qCrwgDhCaOFcbNMnBZhZafgZo5ui2VUAYLkA== X-Received: by 2002:a1c:7216:0:b0:3cf:614e:b587 with SMTP id n22-20020a1c7216000000b003cf614eb587mr52906140wmc.26.1675091548679; Mon, 30 Jan 2023 07:12:28 -0800 (PST) Received: from ?IPv6:2001:8a0:f92b:9e00::1fe? ([2001:8a0:f92b:9e00::1fe]) by smtp.gmail.com with ESMTPSA id h15-20020a05600c2caf00b003d974076f13sm14693432wmc.3.2023.01.30.07.12.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jan 2023 07:12:28 -0800 (PST) Subject: Re: [PATCH 5/5] Add "save history" command From: Pedro Alves To: Tom Tromey , gdb-patches@sourceware.org References: <20230129162105.526266-1-tom@tromey.com> <20230129162105.526266-6-tom@tromey.com> Message-ID: Date: Mon, 30 Jan 2023 15:12:27 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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 2023-01-30 2:50 p.m., Pedro Alves wrote: > On 2023-01-29 4:21 p.m., Tom Tromey wrote: >> >> +@kindex save history >> +@item save history @var{filename} >> +Occasionally you may want to save your history to a file. This >> +command will do just that, saving the commands in your current session >> +to the named file. Note that you should normally edit the saved >> +history before using @code{source} to reload it, as the @code{save >> +history} command itself will be at the end of the file. > > We could also suggest using "server save history" here. Something like, > "Alternatively, you can use the server prefix to blah, blah. @xref." > > Prefixing a comment with "server" makes it so that it won't be added to > the history: > > https://sourceware.org/gdb/current/onlinedocs/gdb.html/Server-Prefix.html > An alternative idea would be to make use of the fact that history entries are already numbered, and to let the user say which history entry range to save. E.g., we have: (gdb) help show commands Show the history of commands you typed. You can supply a command number to start with, or a `+' to start after the previous command number shown. and, e.g., I see currently: (gdb) show commands 1016 q 1017 q 1018 p 1 1019 p 2 1020 p 3 1021 show commands 1022 p 4 1023 p 5 1024 apropos history 1025 show commands so we could support something like: (gdb) save history $filename 1020 1025 # save from 1020 to 1025 (gdb) save history $filename 1020 # save from 1020 to $end (gdb) save history $filename -5 # save from 1020 ($last - 5) to end (gdb) save history $filename -5 -1 # save from 1020 ($last - 5) to 1024 ($last - 1) or whatever other syntax makes sense and achieves a similar effect. Being able to save just the last N entries seems like a useful feature.