This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFA: Building GDB under GLIBC 2.8 [resend w/the patch]
Hi Jim,
[ attaching this time ]
FYI that part for "ui-file.c" crashes GDB on the testsuite as when the GDB is
existing it has already closed its output. Testsuite results are not changed
(as GDB output is already ignored that time) but many core files start to be
generated.
Attaching a possible replacement for that ui-file.c part: When GDB cannot
write to its output IMO some message about it is no longer of much use.
Regards,
Jan
Program terminated with signal 11, Segmentation fault.
[New process 9576]
#0 0x00000000006024ff in exceptions_state_mc (action=CATCH_THROWING) at exceptions.c:125
125 switch (current_catcher->state)
(gdb) p current_catcher
$1 = (struct catcher *) 0x0
(gdb) bt
#0 0x00000000006024ff in exceptions_state_mc (action=CATCH_THROWING) at exceptions.c:125
#1 0x0000000000602808 in throw_exception (exception=
{reason = RETURN_ERROR, error = GENERIC_ERROR, message = 0x3776910 "stdio_file_fputs: Input/output error"}) at exceptions.c:235
#2 0x0000000000602c29 in throw_it (reason=RETURN_ERROR, error=GENERIC_ERROR, fmt=0xc8224b "stdio_file_fputs: %s", ap=0x7fff750c9f80)
at exceptions.c:396
#3 0x0000000000602c51 in throw_verror (error=GENERIC_ERROR, fmt=0xc8224b "stdio_file_fputs: %s", ap=0x7fff750c9f80) at exceptions.c:402
#4 0x000000000047a466 in error (string=0xc8224b "stdio_file_fputs: %s") at utils.c:796
#5 0x000000000047f7a7 in stdio_file_fputs (linebuffer=0x376e900 '\225' <repeats 37 times>, "ï\225\225ï", file=0x2f31e20) at ui-file.c:496
#6 0x000000000047efbd in fputs_unfiltered (buf=0x376e900 '\225' <repeats 37 times>, "ï\225\225ï", file=0x2f31e20) at ui-file.c:211
#7 0x000000000047c36c in fputs_maybe_filtered (linebuffer=0x376e900 '\225' <repeats 37 times>, "ï\225\225ï", stream=0x2f31e20, filter=1)
at utils.c:2028
#8 0x000000000047c5be in fputs_filtered (linebuffer=0x376e900 '\225' <repeats 37 times>, "ï\225\225ï", stream=0x2f31e20) at utils.c:2119
#9 0x0000000000602960 in print_exception (file=0x2f31e20, e=
{reason = RETURN_ERROR, error = GENERIC_ERROR, message = 0x376e900 '\225' <repeats 37 times>, "ï\225\225ï"}) at exceptions.c:306
#10 0x0000000000602bc5 in print_any_exception (file=0x2f31e20, prefix=0xc7df05 "", e=
{reason = RETURN_ERROR, error = GENERIC_ERROR, message = 0x376e900 '\225' <repeats 37 times>, "ï\225\225ï"}) at exceptions.c:373
#11 0x0000000000602fbd in catch_errors (func=0x46fc27 <captured_main>, func_args=0x7fff750ca200, errstring=0xc7df05 "", mask=6)
at exceptions.c:518
#12 0x0000000000470cdd in gdb_main (args=0x7fff750ca200) at .././gdb/main.c:840
#13 0x000000000046fbe0 in main (argc=3, argv=0x7fff750ca2f8) at gdb.c:33
On Sat, 13 Dec 2008 03:04:47 +0100, Jim Blandy wrote:
> From: Jim Blandy <jimb@red-bean.com>
...
> * ui-file.c (stdio_file_write): Check return value from fwrite.
> (stdio_file_fputs): Check return value from fputs.
...
> diff --git a/gdb/ui-file.c b/gdb/ui-file.c
> index 9a1d892..2ed304f 100644
> --- a/gdb/ui-file.c
> +++ b/gdb/ui-file.c
> @@ -481,7 +481,8 @@ stdio_file_write (struct ui_file *file, const char *buf, long length_buf)
> if (stdio->magic != &stdio_file_magic)
> internal_error (__FILE__, __LINE__,
> _("stdio_file_write: bad magic number"));
> - fwrite (buf, length_buf, 1, stdio->file);
> + if (fwrite (buf, length_buf, 1, stdio->file) != 1)
> + error ("stdio_file_write: %s", safe_strerror (errno));
> }
>
> static void
> @@ -491,7 +492,8 @@ stdio_file_fputs (const char *linebuffer, struct ui_file *file)
> if (stdio->magic != &stdio_file_magic)
> internal_error (__FILE__, __LINE__,
> _("stdio_file_fputs: bad magic number"));
> - fputs (linebuffer, stdio->file);
> + if (fputs (linebuffer, stdio->file) == EOF)
> + error ("stdio_file_fputs: %s", safe_strerror (errno));
> }
>
> static int
--- gdb/ui-file.c 1 Jan 2008 22:53:13 -0000 1.15
+++ gdb/ui-file.c 14 Dec 2008 18:16:56 -0000
@@ -481,7 +481,9 @@ stdio_file_write (struct ui_file *file,
if (stdio->magic != &stdio_file_magic)
internal_error (__FILE__, __LINE__,
_("stdio_file_write: bad magic number"));
- fwrite (buf, length_buf, 1, stdio->file);
+ /* Calling error crashes when we are called from the exception framework. */
+ if (fwrite (buf, length_buf, 1, stdio->file))
+ ;
}
static void
@@ -491,7 +493,9 @@ stdio_file_fputs (const char *linebuffer
if (stdio->magic != &stdio_file_magic)
internal_error (__FILE__, __LINE__,
_("stdio_file_fputs: bad magic number"));
- fputs (linebuffer, stdio->file);
+ /* Calling error crashes when we are called from the exception framework. */
+ if (fputs (linebuffer, stdio->file))
+ ;
}
static int