This is the mail archive of the
insight@sourceware.org
mailing list for the Insight project.
Re: [patch] suppress annoying warnings about cygwin1.dbg
Brian Dessent wrote:
> > How about a patch that modifies gdbtk-hooks.c:gdbtk_warning() such that
> > instead of just blindly punting everything to gdbtk_tcl_warning(), it
> > first tries to check if stdout has been redirected to a null handle, and
> > just skip the warning if so? That would let the exiting stuff in
> > win32-nat.c take care of suppressing these without any regexps.
>
> See attached.
Arg, that won't work. Simply checking ui_file_data (gdb_stdout) != NULL
is no good because even when gdb_stdout is not redirected its data
member can be NULL. The only reliable way I could figure out to
determine if the stdout was redirected was to add an interface to
ui-file.c that checks if both the fputs and write functions were the
null functions. See attached.
Brian
gdb/
2007-04-18 Brian Dessent <brian@dessent.net>
* ui-file.c (ui_file_isnull): New function.
* ui-file.h (ui_file_isnull): Add declaration.
gdb/gdbtk/
2007-04-18 Brian Dessent <brian@dessent.net>
* generic/gdbtk-hooks.c (gdbtk_warning): Do not process the warning
if gdb_stdout has been redirected to a null handle.
Index: ui-file.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-file.c,v
retrieving revision 1.13
diff -u -p -r1.13 ui-file.c
--- ui-file.c 9 Jan 2007 17:58:59 -0000 1.13
+++ ui-file.c 18 Apr 2007 16:34:59 -0000
@@ -166,6 +166,15 @@ ui_file_data (struct ui_file *file)
return file->to_data;
}
+int
+ui_file_isnull (struct ui_file *file)
+{
+ /* Return true if this handle has no output methods. Used for checking
+ if a handle has been temporarily redirected to suppress warnings. */
+ return (file->to_fputs == null_file_fputs &&
+ file->to_write == null_file_write);
+}
+
void
gdb_flush (struct ui_file *file)
{
Index: ui-file.h
===================================================================
RCS file: /cvs/src/src/gdb/ui-file.h,v
retrieving revision 1.6
diff -u -p -r1.6 ui-file.h
--- ui-file.h 9 Jan 2007 17:58:59 -0000 1.6
+++ ui-file.h 18 Apr 2007 16:34:59 -0000
@@ -59,6 +59,7 @@ extern void set_ui_file_data (struct ui_
extern void *ui_file_data (struct ui_file *file);
+extern int ui_file_isnull (struct ui_file *file);
extern void gdb_flush (struct ui_file *);
Index: gdbtk/generic/gdbtk-hooks.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v
retrieving revision 1.41
diff -u -p -r1.41 gdbtk-hooks.c
--- gdbtk/generic/gdbtk-hooks.c 23 Dec 2005 18:23:16 -0000 1.41
+++ gdbtk/generic/gdbtk-hooks.c 18 Apr 2007 16:34:59 -0000
@@ -347,9 +347,15 @@ static void
gdbtk_warning (const char *warning, va_list args)
{
char *buf;
- xvasprintf (&buf, warning, args);
- gdbtk_two_elem_cmd ("gdbtk_tcl_warning", buf);
- free(buf);
+
+ /* If gdb_stdout is currently attached to a null handle, do not display
+ the warning. */
+ if (!ui_file_isnull (gdb_stdout))
+ {
+ xvasprintf (&buf, warning, args);
+ gdbtk_two_elem_cmd ("gdbtk_tcl_warning", buf);
+ free (buf);
+ }
}