aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-12-04 14:23:17 +0000
committerRichard Bunt <richard.bunt@linaro.org>2023-12-04 14:23:17 +0000
commitfc7df214ef57f11a5d2c87f0dba24ad5ef5263f6 (patch)
tree42018ff7af93e3f72c44c225744ebf8be160dd22 /gdbsupport
parentd1a912db7fdf50c28224d20464bfa163d8438980 (diff)
downloadgdb-fc7df214ef57f11a5d2c87f0dba24ad5ef5263f6.zip
gdb-fc7df214ef57f11a5d2c87f0dba24ad5ef5263f6.tar.gz
gdb-fc7df214ef57f11a5d2c87f0dba24ad5ef5263f6.tar.bz2
gdb: install CLI uiout while processing early init files
The next commit wants to use a 'show' command within an early initialisation file, despite these commands not being in the list of acceptable commands for use within an early initialisation file. The problem we run into is that the early initialisation files are processed before GDB has installed the top level interpreter. The interpreter is responsible to installing the default uiout (accessed through current_uiout), and as a result code that depends on uiout (e.g. 'show' commands) will end up dereferencing a nullptr, and crashing GDB. I did consider moving the interpreter installation before the early initialisation, and this would work fine except for the new DAP interpreter, which relies on having Python available during its initialisation. Which means we can't install the interpreter until after Python has been initialised, and the early initialisation handling has to occur before Python is setup -- that's the whole point of this feature (to allow customisation of how Python is setup). So, what I propose is that early within captured_main_1, we install a temporary cli_ui_out as the current_uiout. This will remain in place until the top-level interpreter is installed, at which point the temporary will be replaced. What this means is that current_uiout will no longer be nullptr, instead, any commands within an early initialisation file that trigger output, will perform that output in a CLI style. I propose that we don't update the documentation for early initialisation files, we leave the user advice as being only 'set' and 'source' commands are acceptable. But now, if a user does try a 'show' command, then instead of crashing, GDB will do something predictable. I've not added a test in this commit. The next commit relies on this patch and will serve as a test. Tested-By: Richard Bunt <richard.bunt@linaro.org>
Diffstat (limited to 'gdbsupport')
0 files changed, 0 insertions, 0 deletions