[review] gdb: remove gen_ret_current_ui_field_ptr
Commit Message
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/696
......................................................................
gdb: remove gen_ret_current_ui_field_ptr
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
---
M gdb/top.c
1 file changed, 27 insertions(+), 13 deletions(-)
Comments
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/696
......................................................................
Patch Set 2: Code-Review+2
Thank you. I agree with your critique of the current code.
This looks good.
@@ -92,21 +92,35 @@
#define DEFAULT_PROMPT "(gdb) "
#endif
-/* Generate a function that exports a pointer to a field of the
- current UI. */
-
-#define gen_ret_current_ui_field_ptr(type, name) \
-type * \
-current_ui_## name ## _ptr (void) \
-{ \
- return ¤t_ui->m_ ## name; \
+struct ui_file **
+current_ui_gdb_stdout_ptr (void)
+{
+ return ¤t_ui->m_gdb_stdout;
}
-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_stdin_ptr (void)
+{
+ return ¤t_ui->m_gdb_stdin;
+}
+
+struct ui_file **
+current_ui_gdb_stderr_ptr (void)
+{
+ return ¤t_ui->m_gdb_stderr;
+}
+
+struct ui_file **
+current_ui_gdb_stdlog_ptr (void)
+{
+ return ¤t_ui->m_gdb_stdlog;
+}
+
+struct ui_out **
+current_ui_current_uiout_ptr (void)
+{
+ return ¤t_ui->m_current_uiout;
+}
int inhibit_gdbinit = 0;