This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFC: Fix unpaginated backtrace and various other corrupted output
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Elena Zannoni <ezannoni at redhat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Mon, 7 Jul 2003 10:36:40 -0400
- Subject: Re: RFC: Fix unpaginated backtrace and various other corrupted output
- References: <20030628175855.GA23768@nevyn.them.org> <16132.37989.22280.142932@localhost.redhat.com>
On Thu, Jul 03, 2003 at 04:39:01PM -0400, Elena Zannoni wrote:
> Daniel Jacobowitz writes:
> > I've noticed recently that backtraces aren't paginating. The immediate
> > problem is this code in fputs_maybe_filtered:
> >
> > /* Don't do any filtering if it is disabled. */
> > if ((stream != gdb_stdout) || !pagination_enabled
> > || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX))
> >
> > It turns out that cli_text's saved stream is NOT equal to gdb_stdout. Why
> > not? Well, captured_main first initializes gdb_stdout:
> > gdb_stdout = stdio_fileopen (stdout);
> >
> > Then _initialize_cli_interp creates the CLI output object:
> > #1 0x0807ef6d in _initialize_cli_interp () at /opt/src/gdb/src/gdb/cli/cli-interp.c:136
> > 136 cli_uiout = cli_out_new (gdb_stdout);
> >
> > and then:
> > #0 gdb_setup_readline () at /opt/src/gdb/src/gdb/event-top.c:1123
> > #1 0x0807ee6b in cli_interpreter_resume (data=0x0) at /opt/src/gdb/src/gdb/cli/cli-interp.c:57
> > #2 0x080bbb78 in interp_set (interp=0x8271df8) at /opt/src/gdb/src/gdb/interps.c:203
> >
> > 1122 gdb_stdout = stdio_fileopen (stdout);
> >
> > Oops! We've changed gdb_stdout. Now all CLI output using ui_out is
> > considered unfiltered. This leads to broken pagination, bad interleaving,
> > et cetera.
> >
> > Possible solutions: change the test, change stdio_fileopen to return the
> > same stream, update the CLI's stream value. I chose door #3. The
> > resulting patch isn't pretty, but door #1 was even worse and door #2 has
> > some surprising warts unless I introduce reference counting.
> >
> > Does anyone have comments on this patch?
> >
>
> Does this fix the problem in this thread (on which I dropped the ball)?
> http://sources.redhat.com/ml/gdb-patches/2003-04/msg00284.html
Oops, didn't remember that thread. Yes, it fixes that problem also.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer