Re: [PATCH v3 1/2] Emit inferior, thread and frame selection events to all UIs
Hi! On Thu, 08 Dec 2016 10:25:53 -0500, Simon Marchi wrote: > On 2016-12-08 07:01, Thomas Schwinge wrote: > > On GNU/Hurd, there is no "#define PATH_MAX", so this fails to build. > > --- gdb/inferior.c > > +++ gdb/inferior.c > > [...] > Yeah it looks much better. Also, if you want to factor out complexity > from this big one liner by using temporary variables, I think it would > improve it further. Pushed to master: commit 53488a6e194af11c2528e5e284facb8a6171b695 Author: Thomas Schwinge Date: Thu Dec 8 18:42:03 2016 +0100 Avoid PATH_MAX usage On GNU/Hurd, there is no "#define PATH_MAX", so this failed to build. gdb/ * inferior.c (print_selected_inferior): Avoid PATH_MAX usage. --- gdb/ChangeLog | 4 gdb/inferior.c | 15 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git gdb/ChangeLog gdb/ChangeLog index 2bd99f1..302eb6e 100644 --- gdb/ChangeLog +++ gdb/ChangeLog @@ -1,3 +1,7 @@ +2016-12-09 Thomas Schwinge + + * inferior.c (print_selected_inferior): Avoid PATH_MAX usage. + 2016-12-08 Simon Marchi Thomas Schwinge diff --git gdb/inferior.c gdb/inferior.c index 9fcdbd3..af6f3af 100644 --- gdb/inferior.c +++ gdb/inferior.c @@ -556,17 +556,12 @@ inferior_pid_to_str (int pid) void print_selected_inferior (struct ui_out *uiout) { - char buf[PATH_MAX + 256]; struct inferior *inf = current_inferior (); - - xsnprintf (buf, sizeof (buf), -_("[Switching to inferior %d [%s] (%s)]\n"), -inf->num, -inferior_pid_to_str (inf->pid), -(inf->pspace->pspace_exec_filename != NULL - ? inf->pspace->pspace_exec_filename - : _(""))); - ui_out_text (uiout, buf); + const char *filename = inf->pspace->pspace_exec_filename; + if (filename == NULL) +filename = _(""); + ui_out_message (uiout, _("[Switching to inferior %d [%s] (%s)]\n"), + inf->num, inferior_pid_to_str (inf->pid), filename); } /* Prints the list of inferiors and their details on UIOUT. This is a Grüße Thomas
Re: [PATCH v3 1/2] Emit inferior, thread and frame selection events to all UIs
On 2016-12-08 07:01, Thomas Schwinge wrote: On GNU/Hurd, there is no "#define PATH_MAX", so this fails to build. (I'm aware that there is other PATH_MAX usage in GDB sources, which we ought to fix at some point, for example in gdbserver -- which is not yet enabled for GNU/Hurd.) Unless I miss something, this issue could be addressed by simply using ui_out_message instead of ui_out_text with a temporary "buf" -- OK to push the following? --- gdb/inferior.c +++ gdb/inferior.c @@ -556,17 +556,15 @@ inferior_pid_to_str (int pid) void print_selected_inferior (struct ui_out *uiout) { - char buf[PATH_MAX + 256]; struct inferior *inf = current_inferior (); - xsnprintf (buf, sizeof (buf), -_("[Switching to inferior %d [%s] (%s)]\n"), -inf->num, -inferior_pid_to_str (inf->pid), -(inf->pspace->pspace_exec_filename != NULL - ? inf->pspace->pspace_exec_filename - : _(""))); - ui_out_text (uiout, buf); + ui_out_message (uiout, + _("[Switching to inferior %d [%s] (%s)]\n"), + inf->num, + inferior_pid_to_str (inf->pid), + (inf->pspace->pspace_exec_filename != NULL + ? inf->pspace->pspace_exec_filename + : _(""))); } /* Prints the list of inferiors and their details on UIOUT. This is a Yeah it looks much better. Also, if you want to factor out complexity from this big one liner by using temporary variables, I think it would improve it further. Thanks, Simon
Re: [PATCH v3 1/2] Emit inferior, thread and frame selection events to all UIs
Hi! On Sat, 24 Sep 2016 16:13:30 -0400, Simon Marchi wrote: > --- a/gdb/inferior.c > +++ b/gdb/inferior.c > +void > +print_selected_inferior (struct ui_out *uiout) > +{ > + char buf[PATH_MAX + 256]; > + struct inferior *inf = current_inferior (); > + > + xsnprintf (buf, sizeof (buf), > + _("[Switching to inferior %d [%s] (%s)]\n"), > + inf->num, > + inferior_pid_to_str (inf->pid), > + (inf->pspace->pspace_exec_filename != NULL > + ? inf->pspace->pspace_exec_filename > + : _(""))); > + ui_out_text (uiout, buf); > +} > + On GNU/Hurd, there is no "#define PATH_MAX", so this fails to build. (I'm aware that there is other PATH_MAX usage in GDB sources, which we ought to fix at some point, for example in gdbserver -- which is not yet enabled for GNU/Hurd.) Unless I miss something, this issue could be addressed by simply using ui_out_message instead of ui_out_text with a temporary "buf" -- OK to push the following? --- gdb/inferior.c +++ gdb/inferior.c @@ -556,17 +556,15 @@ inferior_pid_to_str (int pid) void print_selected_inferior (struct ui_out *uiout) { - char buf[PATH_MAX + 256]; struct inferior *inf = current_inferior (); - xsnprintf (buf, sizeof (buf), -_("[Switching to inferior %d [%s] (%s)]\n"), -inf->num, -inferior_pid_to_str (inf->pid), -(inf->pspace->pspace_exec_filename != NULL - ? inf->pspace->pspace_exec_filename - : _(""))); - ui_out_text (uiout, buf); + ui_out_message (uiout, + _("[Switching to inferior %d [%s] (%s)]\n"), + inf->num, + inferior_pid_to_str (inf->pid), + (inf->pspace->pspace_exec_filename != NULL + ? inf->pspace->pspace_exec_filename + : _(""))); } /* Prints the list of inferiors and their details on UIOUT. This is a Grüße Thomas