From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105016 invoked by alias); 11 Nov 2016 18:19:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 105005 invoked by uid 89); 11 Nov 2016 18:19:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=handful, rolled, CATCH, H*MI:andrew X-HELO: mail-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Nov 2016 18:18:58 +0000 Received: by mail-wm0-f46.google.com with SMTP id t79so106082668wmt.0 for ; Fri, 11 Nov 2016 10:18:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XCBWsBX926XY73zcrFfQxDlGxJnNGXI+F3U9ijiLfYw=; b=GAvZmjDbTRmbTmLqXkVfk45OiBJPahCID3KhO9bekkn+Zf0R9teJsWZXEa99SQMQAg mhqYMLLxY+TIF+3VjbReZJ269pa+2xbneIZXGMVw9spGbCGPm232DXKqMTL1P8FK/O7q BJdZkqF9bu1yYjFJgk3jkT8DZ2YPKJrL7g9xCkhbcBsgQijrlp2PvAHJpWOlSdjdhXc9 CX2PeoECObATexC5HwqIHYK/clj7p2s7hKlhgFOhyNtx/kuP4Xp7e/RBTUlYTX746SlZ LbZplRL+qxQ7JtTPpOoj0dvf2FnjGY25cUtesuuYBssw48FJRjQ0ljujH+Zrz0AOwxyd zShg== X-Gm-Message-State: ABUngvdKWUST+6mLMsyW8dsUP6PHREQu5IGFRQensoQj7EhMVsux6qKk86zQwnf8SkcBXg== X-Received: by 10.194.94.39 with SMTP id cz7mr10337972wjb.204.1478888336096; Fri, 11 Nov 2016 10:18:56 -0800 (PST) Received: from localhost (host86-164-199-110.range86-164.btcentralplus.com. [86.164.199.110]) by smtp.gmail.com with ESMTPSA id d8sm15699951wmi.21.2016.11.11.10.18.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Nov 2016 10:18:54 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 0/2] Auto roll back on error while changing a setting Date: Fri, 11 Nov 2016 18:19:00 -0000 Message-Id: <1478888325-32039-1-git-send-email-andrew.burgess@embecosm.com> X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00294.txt.bz2 When we create a user setting within GDB there's an oportunity to register a callback function that will be called when the value of the setting is changed. The callback function can do many things, for example triggering aditional work as a result of the change in setting, but it can also error check the new value of the setting. If the callback is being used to error check the setting then we have two basic approaches: 1. If the new value is wrong, install a suitable default and then throw an error, or 2. Maintain a local copy of the setting, then if the new value is wrong we can restore the previous value. If the new vaule is acceptable, then we update the local cached copy, after which we throw an error. There are two problems with the above, they are: 1. Raising an error in a set callback will cause GDB to skip sending out a change notification for the setting. This change notification is sent out from do_set_command, but will be skipped if an error is thrown. 2. We end up duplicating the rollback approach, or with inconsistent behaviour on errors (some rollback, some install a default). In this patch series I propose moving the rollback approach up into do_set_command, and adding a TRY / CATCH to do_set_command. Now, if any set callback throws an error then the setting will automatically be rolled back to the previous value (and no change notification will be sent out as the value did not change). This allows us to simplify a handful of existing set callbacks to remove rollback and default setting code. Tested on x86-64 Fedora Linux with no regressions. --- Andrew Burgess (2): gdb: Restore a settings previous value on error during change gdb: Simplify variable set hooks gdb/ChangeLog | 32 ++++++++++ gdb/cli/cli-setshow.c | 80 ++++++++++++++++++++++-- gdb/dcache.c | 12 +--- gdb/record.c | 41 +++--------- gdb/symtab.c | 23 ++----- gdb/testsuite/ChangeLog | 8 +++ gdb/testsuite/gdb.base/dcache-line-set-error.exp | 67 ++++++++++++++++++++ gdb/testsuite/gdb.base/max-value-size.exp | 4 +- gdb/valprint.c | 31 +++------ gdb/value.c | 6 +- 10 files changed, 209 insertions(+), 95 deletions(-) create mode 100644 gdb/testsuite/gdb.base/dcache-line-set-error.exp -- 2.5.1