gdb.execute and redirect
Stefan Puiu
stefan.puiu@gmail.com
Wed Feb 18 11:05:57 GMT 2026
On Fri, Feb 13, 2026 at 11:29 PM Paul Koning via Gdb <gdb@sourceware.org> wrote:
>
> I noticed the other day that logging redirect is not honored by gdb.execute, at least not in GDB 8.2 which is what came with my OS kit.
>
> I can work around this by doing something like this:
>
> s = gdb.execute(cmd, False, True)
> print (s)
>
> but it's surprising that this would be needed. Is it intentional? Is it fixed in a more recent release?
I have gdb 14.2 built with yocto on x86-64, running on a custom board,
and even the above workaround isn't working:
# gdb --version
GNU gdb (GDB) 14.2
(gdb) python
res = gdb.execute("pipe info files | grep '.text.*libsmth'", False, True)
print("Done execute")
print("Now res is %s" %res)
0x00007f6b6793f760 - 0x00007f6b6b148ed1 is .text in
/path/to/libsmth.so.1
Done execute
Now res is
On the other hand, the workaround seems to work on gdb 15 from Ubuntu
24.04, in an x86-64 VMWare VM:
stefan@stefpuiu-linvm:~/git/bb/me/code-tests/interviuri$ gdb ./int_to_string1
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[...]
(gdb) python
>res = gdb.execute("info shared", False, True)
>print("Done execute")
print("Now res is %s" %res)
>end
Done execute
Now res is No shared libraries loaded at this time.
On the latter, I get the same result if using:
gdb.execute("info shared", to_string=True)
Regards,
Stefan.
>
> paul
>
More information about the Gdb
mailing list