Re: gdb.execute and redirect

Tom Tromey <[email protected]> Fri, 20 Feb 2026 11:56:11 -0700
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
>>>>> "Paul" == Paul Koning via Gdb <[email protected]> writes:

Paul> I noticed the other day that logging redirect is not honored by
Paul> gdb.execute, at least not in GDB 8.2 which is what came with my OS
Paul> kit.

You mean if you have 'set logging' enabled, then output that is captured
by gdb.execute(..., to_string=True) is not logged?

Or something else?

Paul> but it's surprising that this would be needed.  Is it intentional?
Paul> Is it fixed in a more recent release?

This area has not been extremely well defined.  Recently I rewrote a
bunch of the logging and output redirection logic.

This particular issue did come up and at least for the time being we
decided not to log the output.  This wasn't a final decision (IMO
anyway), just more of a recognition that the issue was more of a side
excursion for the series at hand.

One difficulty with respecting the logging settings is that one can end
up in the weird situation where "set logging redirect" is enabled, and
in that case gdb.execute(..., to_string=True) will always return the
empty string.

The latest series was here:

https://sourceware.org/pipermail/gdb-patches/2026-February/224751.html

The sub-thread specifically about logging is here:

https://inbox.sourceware.org/gdb-patches/[email protected]/


Anyway, the good news is that if we do decide to change, at least it
shouldn't be too hard to do now.

Maybe one idea would be to log the output but temporarily disable
"redirect" when string capturing is requested.

A related idea is to provide some more general control, see

https://sourceware.org/bugzilla/show_bug.cgi?id=33880

Tom