This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 0/2] Auto roll back on error while changing a setting
- From: Andrew Burgess <andrew dot burgess at embecosm dot com>
- To: gdb-patches at sourceware dot org
- Cc: Andrew Burgess <andrew dot burgess at embecosm dot com>
- Date: Fri, 11 Nov 2016 18:18:43 +0000
- Subject: [PATCH 0/2] Auto roll back on error while changing a setting
- Authentication-results: sourceware.org; auth=none
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