gdb: remove gen_ret_current_ui_field_ptr
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 21 Nov 2019 14:32:15 +0000 (09:32 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 21 Nov 2019 14:32:15 +0000 (09:32 -0500)
I think it would be clearer to not use gen_ret_current_ui_field_ptr to
generate the implementation of current_ui_gdb_stdout_ptr et al.  It
doesn't save much code, but adds a layer of complexity for the reader.
Plus, it doesn't work well with IDEs, for example if you ask to find all
usages the m_gdb_stdout field.

gdb/ChangeLog:

* top.c (current_ui_gdb_stdout_ptr): Spell out by hand.
(current_ui_gdb_stdin_ptr): Likewise.
(current_ui_gdb_stderr_ptr): Likewise.
(current_ui_gdb_stdlog_ptr): Likewise.
(current_ui_current_uiout_ptr): Likewise.
(gen_ret_current_ui_field_ptr): Remove.

Change-Id: I86f821c9d119453701caedf0e47124ccddfbab2d

gdb/ChangeLog
gdb/top.c

index 3652685986fb75ba36e3ea4d070c6e71d8382254..57e8f6b43fd5498d843b681696762f7af6ef4a3a 100644 (file)
@@ -1,3 +1,12 @@
+2019-11-21  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * top.c (current_ui_gdb_stdout_ptr): Spell out by hand.
+       (current_ui_gdb_stdin_ptr): Likewise.
+       (current_ui_gdb_stderr_ptr): Likewise.
+       (current_ui_gdb_stdlog_ptr): Likewise.
+       (current_ui_current_uiout_ptr): Likewise.
+       (gen_ret_current_ui_field_ptr): Remove.
+
 2019-11-21  Tom de Vries  <tdevries@suse.de>
 
        PR gdb/24956
index 08c742548bcd6cf65bb05921523c74c81f39ddcc..2953eac81967dd54f8451ea88f976f24fffaaa82 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -92,21 +92,35 @@ extern void initialize_all_files (void);
 #define DEFAULT_PROMPT "(gdb) "
 #endif
 
-/* Generate a function that exports a pointer to a field of the
-   current UI.  */
+struct ui_file **
+current_ui_gdb_stdout_ptr ()
+{
+  return &current_ui->m_gdb_stdout;
+}
+
+struct ui_file **
+current_ui_gdb_stdin_ptr ()
+{
+  return &current_ui->m_gdb_stdin;
+}
 
-#define gen_ret_current_ui_field_ptr(type, name)       \
-type *                                                 \
-current_ui_## name ## _ptr (void)                      \
-{                                                      \
-  return &current_ui->m_ ## name;              \
+struct ui_file **
+current_ui_gdb_stderr_ptr ()
+{
+  return &current_ui->m_gdb_stderr;
 }
 
-gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdout)
-gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdin)
-gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stderr)
-gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdlog)
-gen_ret_current_ui_field_ptr (struct ui_out *, current_uiout)
+struct ui_file **
+current_ui_gdb_stdlog_ptr ()
+{
+  return &current_ui->m_gdb_stdlog;
+}
+
+struct ui_out **
+current_ui_current_uiout_ptr ()
+{
+  return &current_ui->m_current_uiout;
+}
 
 int inhibit_gdbinit = 0;