diff options
author | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2019-04-28 14:38:18 +0200 |
---|---|---|
committer | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2019-10-31 23:31:43 +0100 |
commit | 9ad9b77d64920d3113a9e7ab9f022eb5a45cd49e (patch) | |
tree | 46aea16ddae3415219b847d785c4f3e1f63b3993 /gdb/ChangeLog | |
parent | Also check for strerror_r in gdbserver (diff) | |
download | binutils-gdb-9ad9b77d64920d3113a9e7ab9f022eb5a45cd49e.tar.gz binutils-gdb-9ad9b77d64920d3113a9e7ab9f022eb5a45cd49e.tar.bz2 binutils-gdb-9ad9b77d64920d3113a9e7ab9f022eb5a45cd49e.zip |
Implement convenience functions to examine GDB settings.
The new convenience functions $_gdb_setting and $_gdb_setting_str
provide access to the GDB settings in user-defined commands.
Similarly, $_gdb_maint_setting and $_gdb_maint_setting_str
provide access to the GDB maintenance settings.
The patch was developed following a comment of Eli about the
'set may-call-functions'. Eli said that user-defined functions
should have a way to change their behavior according to this setting.
Rather than have a specialized $_may_call_functions, this patch
implements a general way to access any GDB setting.
Compared to doing such access via Python 'gdb.parameter' and/or
'gdb.execute("set somesetting tosomevalue"):
* The 'with' command is much better than the above python usage:
if the user types C-c or an error happens between the set pagination off
and the python "set pagination on", the above python
does not restore the original setting.
* Effectively, with the "gdb.parameter" python one liner, it is possible to do
simple 'if' conditions, such as set and restore pagination.
But mixing the "python if" within canned
sequence of commands is cumbersome for non trivial combinations.
E.g. if several commands have to be done for a certain condition
accessed from python, I guess something like will be needed:
python if __some_setting: gdb.execute("some command")
python if __some_setting: gdb.execute("some other command")
python if __some_setting: gdb.execute("some different command")
(without speaking about nested "if-s").
With the convenience function:
if $_gdb_setting("some_setting")
some command
some other command
some different command
end
Integer settings (for example print elements) will also be more difficult
to use.
For example, a user defined function that scans and prints a linked list
might want to use the value of "set print elements" to stop printing
the linked list.
Doing that by mixing python expression/if is likely doable, but seems
not easy with the above one liners.
So, in summary, the $_gdb_setting and $_gdb_setting_str avoids to have the
heterogeneous mix of python and GDB commands in one single script
(and of course, it works even if python is not configured, but that
must be an unusual setup I guess).
gdb/ChangeLog
2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-cmds.c (setting_cmd, value_from_setting)
(gdb_setting_internal_fn, gdb_maint_setting_internal_fn)
(str_value_from_setting, gdb_setting_str_internal_fn)
(gdb_maint_setting_str_internal_fn): New functions.
(_initialize_cli_cmds): Define the new convenience functions.
* gdb/cli/cli-setshow.h (get_setshow_command_value_string): Constify.
* gdb/cli/cli-setshow.c (get_setshow_command_value_string): Constify.
Diffstat (limited to 'gdb/ChangeLog')
-rw-r--r-- | gdb/ChangeLog | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3c26e6d6f37..7c68083b012 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> + + * cli/cli-cmds.c (setting_cmd, value_from_setting) + (gdb_setting_internal_fn, gdb_maint_setting_internal_fn) + (str_value_from_setting, gdb_setting_str_internal_fn) + (gdb_maint_setting_str_internal_fn): New functions. + (_initialize_cli_cmds): Define the new convenience functions. + * gdb/cli/cli-setshow.h (get_setshow_command_value_string): Constify. + * gdb/cli/cli-setshow.c (get_setshow_command_value_string): Constify. + 2019-10-31 Christian Biesinger <cbiesinger@google.com> * agent.c (set_can_use_agent): When the setting is turned on, |