[5/5] gdb: make deprecated_show_value_hack static

Message ID 6fddb814d85dcacfcd3de87404b722d52edcc89e.1680608960.git.aburgess@redhat.com
State New
Headers
Series Fixes for per-inferior settings and $_gdb_setting_str() |

Commit Message

Andrew Burgess April 4, 2023, 12:45 p.m. UTC
  The deprecated_show_value_hack function is now only used inside
cli-setshow.c, so lets make the function static to discourage its use
anywhere else.

There should be no user visible changes after this commit
---
 gdb/cli/cli-setshow.c | 2 +-
 gdb/command.h         | 7 +------
 2 files changed, 2 insertions(+), 7 deletions(-)
  

Comments

Tom Tromey April 17, 2023, 4:41 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> The deprecated_show_value_hack function is now only used inside
Andrew> cli-setshow.c, so lets make the function static to discourage its use
Andrew> anywhere else.

Andrew> There should be no user visible changes after this commit

FWIW I wouldn't mind if we removed nearly all "show" functions and just
made some variant of deprecated_show_value_hack the standard way to
print things.  Instead of munging the help text (which is
i18n-unfriendly) it could just print the option name:

(gdb) show mumble var
Current setting of "mumble variable": 23

For "auto" variables, I guess we'd eventually need to implement that
"second getter" idea and then we could remove even more of these
functions, maybe all of them.

Tom
  
Andrew Burgess April 28, 2023, 2:57 p.m. UTC | #2
Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Andrew> The deprecated_show_value_hack function is now only used inside
> Andrew> cli-setshow.c, so lets make the function static to discourage its use
> Andrew> anywhere else.
>
> Andrew> There should be no user visible changes after this commit
>
> FWIW I wouldn't mind if we removed nearly all "show" functions and just
> made some variant of deprecated_show_value_hack the standard way to
> print things.  Instead of munging the help text (which is
> i18n-unfriendly) it could just print the option name:
>
> (gdb) show mumble var
> Current setting of "mumble variable": 23

I have a branch which I occasionally work on which is filling in all the
missing show functions -- which is the opposite to what you are
suggesting.

Didn't plan to post it anytime soon though, as I only work on it when
I'm /really/ bored.

Thanks,
Andrew
  
Tom Tromey July 10, 2023, 5:25 p.m. UTC | #3
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

>> FWIW I wouldn't mind if we removed nearly all "show" functions and just
>> made some variant of deprecated_show_value_hack the standard way to
>> print things.  Instead of munging the help text (which is
>> i18n-unfriendly) it could just print the option name:
>> 
>> (gdb) show mumble var
>> Current setting of "mumble variable": 23

Andrew> I have a branch which I occasionally work on which is filling in all the
Andrew> missing show functions -- which is the opposite to what you are
Andrew> suggesting.

Forgot to reply to this when you first sent it.

For me the attraction of removing these is that it simplifies things --
less code, less to get wrong.  Maybe it would require us to also
regularize & automate the "auto means xyz in this context" concept, but
that would also be beneficial (I think there's a bug in the Python
component about this).  I also don't really mind having a "computer-ish"
output format here, as opposed to natural language text.

However if you want to do it the other way, that's also fine.

Tom
  

Patch

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index dad3e606620..07233e36a38 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -117,7 +117,7 @@  parse_cli_boolean_value (const char *arg)
 }
 
 
-void
+static void
 deprecated_show_value_hack (struct ui_file *ignore_file,
 			    int ignore_from_tty,
 			    struct cmd_list_element *c,
diff --git a/gdb/command.h b/gdb/command.h
index e9c9f160e1f..a4641bb1fd5 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -656,16 +656,11 @@  extern void complete_on_enum (completion_tracker &tracker,
 extern void help_list (struct cmd_list_element *, const char *,
 		       enum command_class, struct ui_file *);
 
-/* Method for show a set/show variable's VALUE on FILE.  If this
-   method isn't supplied deprecated_show_value_hack() is called (which
-   is not good).  */
+/* Method for show a set/show variable's VALUE on FILE.  */
 typedef void (show_value_ftype) (struct ui_file *file,
 				 int from_tty,
 				 struct cmd_list_element *cmd,
 				 const char *value);
-/* NOTE: i18n: This function is not i18n friendly.  Callers should
-   instead print the value out directly.  */
-extern show_value_ftype deprecated_show_value_hack;
 
 /* Various sets of extra literals accepted.  */
 extern const literal_def integer_unlimited_literals[];