From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 0/2] Auto roll back on error while changing a setting
Date: Fri, 11 Nov 2016 18:19:00 -0000 [thread overview]
Message-ID: <1478888325-32039-1-git-send-email-andrew.burgess@embecosm.com> (raw)
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
next reply other threads:[~2016-11-11 18:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 18:19 Andrew Burgess [this message]
2016-11-11 18:19 ` [PATCH 2/2] gdb: Simplify variable set hooks Andrew Burgess
2016-11-12 0:29 ` Luis Machado
2016-11-14 8:35 ` Metzger, Markus T
2016-11-24 23:57 ` Pedro Alves
2016-11-11 18:19 ` [PATCH 1/2] gdb: Restore a settings previous value on error during change Andrew Burgess
2016-11-12 0:20 ` Luis Machado
2016-11-15 23:02 ` Andrew Burgess
2016-11-16 14:18 ` Luis Machado
2016-11-16 18:02 ` Andrew Burgess
2016-11-16 18:15 ` Luis Machado
2016-11-24 23:52 ` Pedro Alves
2016-12-29 14:42 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478888325-32039-1-git-send-email-andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox