aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-interp.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-06-08 14:06:45 -0600
committerTom Tromey <tromey@adacore.com>2023-07-07 13:55:56 -0600
commit73aa9ef81be869176814cac635723e920f7ca612 (patch)
treeae7d66f71ef3829c691e0e737dfd81069a0f8fa3 /gdb/mi/mi-interp.c
parent13f5f57e0d2fb3e06e15c57d67a40499a5910ba6 (diff)
downloadgdb-73aa9ef81be869176814cac635723e920f7ca612.zip
gdb-73aa9ef81be869176814cac635723e920f7ca612.tar.gz
gdb-73aa9ef81be869176814cac635723e920f7ca612.tar.bz2
Remove unchecked casts to mi_interp
Simon noticed a crash that could be caused via new Python gdb.execute_mi function. Looking into this, I found a few unchecked casts to mi_interp, like: - struct mi_interp *mi = (struct mi_interp *) command_interp (); This patch replaces all such casts with safer variants. For -gdb-exit and mi_load_progress, I chose to have the functions simply not generate any output. It didn't seem useful to do so. Some casts I eliminated by adding a parameter to a function. Then, in mi_execute_command, I changed the code to use gdb::checked_static_cast. This is appropriate because this particular overload can only be called by the MI interpreter. There does not seem to be a very good way to test -gdb-exit. Regression tested on x86-64 Fedora 36.
Diffstat (limited to 'gdb/mi/mi-interp.c')
-rw-r--r--gdb/mi/mi-interp.c9
1 files changed, 0 insertions, 9 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index a8de62b..0e51c88 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -72,15 +72,6 @@ display_mi_prompt (struct mi_interp *mi)
ui->prompt_state = PROMPTED;
}
-/* Returns the INTERP's data cast as mi_interp if INTERP is an MI, and
- returns NULL otherwise. */
-
-static struct mi_interp *
-as_mi_interp (struct interp *interp)
-{
- return dynamic_cast<mi_interp *> (interp);
-}
-
void
mi_interp::on_command_error ()
{