The use of readline in GDB is broken in commit a715464cd2e25c8bf46190cc8bde9267c9ab6ac0 when using "set debug infrun on" and "set logging enabled". GDB 12.1 doesn't have this bug, but GDB 12.1 doesn't have paging for the debug messages, so I don't know if this bug is only in the versions after GDB 12.1. Steps to produce this bug: 1. build a simple program: $ cat main.c int main() { } $ gcc -g -O0 main.c 2. debug it and use the following commands: $ ./gdb/gdb ./a.out (gdb) b main Breakpoint 1 at 0x1122: file main.c, line 3. (gdb) set debug infrun on (gdb) set logging enabled Copying output to gdb.txt. Copying debug output to gdb.txt. (gdb) r 3. just type <RET> until the debug message finishes, and type <RET> once more, GDB will crash with "readline: readline_callback_read_char() called with no handler!"
I was able to reproduce. To be clear, you press <RET> to continue past the pagination prompts. This was not clear to me at first. Basically, after running, press <RET> until it crashes.
Sounds like a regression.
I don't think any output to gdb_stdlog should be paged, so that seems like one problem here.
Fixing the logging isn't super hard, but I think the real problem is that some bit of code is enabling the stdin input handler without also installing the readline callback handler.
One other weirdness for me here is that supposedly infrun disables pagination. Looking into this, I found a buglet in fetch_inferior_event: void fetch_inferior_event () { INFRUN_SCOPED_DEBUG_ENTER_EXIT; ... /* Temporarily disable pagination. Otherwise, the user would be given an option to press 'q' to quit, which would cause an early exit and could leave GDB in a half-baked state. */ scoped_restore save_pagination = make_scoped_restore (&pagination_enabled, false); That is, it disables pagination -- but after the logging is done.
Fixing fetch_inferior event is enough to fix this bug. Should probably fix the logging in general, too, though.
It occurs to me now that changing fetch_inferior_event shouldn't be needed, because gdb_stdlog should never cause paging. So, that patch isn't actually needed.
https://sourceware.org/pipermail/gdb-patches/2022-November/193923.html
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1dd889362bb7027ebea754a161bf629270cc9042 commit 1dd889362bb7027ebea754a161bf629270cc9042 Author: Tom Tromey <tromey@adacore.com> Date: Thu Nov 17 10:24:38 2022 -0700 Don't let gdb_stdlog use pager When using the "set logging" commands, cli_interp_base::set_logging will send gdb_stdlog output (among others) to the tee it makes for gdb_stdout. However, this has the side effect of also causing logging to use the pager. This is PR gdb/29787. This patch fixes the problem by keeping stderr and stdlog separate from stdout, preserving the rule that only gdb_stdout should page. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29787
Fixed.