aboutsummaryrefslogtreecommitdiff
path: root/gdb/extension.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-10-19 23:50:50 +0200
committerTom de Vries <tdevries@suse.de>2021-10-19 23:50:50 +0200
commitc82f680a94399a0f1c9fdc53ed79a8cf333213a6 (patch)
tree2f8984a012c205b65b357f93be8f5b02a9977dd5 /gdb/extension.c
parent5a8edb756a56cdfb563006cbc39561994acf6d2d (diff)
downloadbinutils-c82f680a94399a0f1c9fdc53ed79a8cf333213a6.zip
binutils-c82f680a94399a0f1c9fdc53ed79a8cf333213a6.tar.gz
binutils-c82f680a94399a0f1c9fdc53ed79a8cf333213a6.tar.bz2
[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest
The test-case gdb.gdb/python-interrupts.exp: - runs to captured_command_loop - sets a breakpoint at set_active_ext_lang - calls a python command - verifies the command triggers the breakpoint - sends a signal and verifies the result The test-case is fragile, because (f.i. with -flto) it cannot be guaranteed that captured_command_loop and set_active_ext_lang are available for setting breakpoints. Reimplement the test-case as unittest, using: - execute_command_to_string to capture the output - try/catch to catch the "Error while executing Python code" exception - a new hook selftests::hook_set_active_ext_lang to raise the signal Tested on x86_64-linux.
Diffstat (limited to 'gdb/extension.c')
-rw-r--r--gdb/extension.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/extension.c b/gdb/extension.c
index 27dce9b..89ab29f 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -682,6 +682,12 @@ install_gdb_sigint_handler (struct signal_handler *previous)
previous->handler_saved = 0;
}
+#if GDB_SELF_TEST
+namespace selftests {
+void (*hook_set_active_ext_lang) () = nullptr;
+}
+#endif
+
/* Set the currently active extension language to NOW_ACTIVE.
The result is a pointer to a malloc'd block of memory to pass to
restore_active_ext_lang.
@@ -708,6 +714,11 @@ install_gdb_sigint_handler (struct signal_handler *previous)
struct active_ext_lang_state *
set_active_ext_lang (const struct extension_language_defn *now_active)
{
+#if GDB_SELF_TEST
+ if (selftests::hook_set_active_ext_lang)
+ selftests::hook_set_active_ext_lang ();
+#endif
+
struct active_ext_lang_state *previous
= XCNEW (struct active_ext_lang_state);