binutils-gdb/gdb/testsuite/gdb.python
Andrew Burgess ba6a0ef349 gdb: use make_scoped_restore to restore gdbpy_current_objfile
The current mechanism by which the Python gdb.current_objfile is
maintained does not allow for nested auto-load events.  It is assumed
that once an auto-load script has finished loading then the current
objfile should be set back to NULL.  In a nested situation, we should
be restoring the previous value.

We already have an RAII class to handle save/restore type behaviour,
so lets just switch to use that.

The test is a little contrived, but is simple enough, and triggers the
bug.  The real use case might involve the auto-load script calling
functions (either in the just-loaded object file, or in the main
executable), which in turn trigger further auto-loads to occur.

gdb/ChangeLog:

	* python/python.c (gdbpy_source_objfile_script): Use
	make_scoped_restore to restore gdbpy_current_objfile.
	(gdbpy_execute_objfile_script): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.python/py-auto-load-chaining-f1.c: New file.
	* gdb.python/py-auto-load-chaining-f1.o-gdb.py: New file.
	* gdb.python/py-auto-load-chaining-f2.c: New file.
	* gdb.python/py-auto-load-chaining-f2.o-gdb.py: New file.
	* gdb.python/py-auto-load-chaining.c: New file.
	* gdb.python/py-auto-load-chaining.exp: New file.
2021-03-15 09:21:37 +00:00
..
amd64-py-framefilter-invalidarg.S
compare-enum-type-a.c
compare-enum-type-b.c
compare-enum-type.exp
compare-enum-type.h
lib-types.cc
lib-types.exp gdb/testsuite: check the correct Python variable in test 2021-03-12 12:18:33 +00:00
py-arch-reg-groups.exp
py-arch-reg-names.exp
py-arch.c
py-arch.exp
py-as-string.c
py-as-string.exp
py-auto-load-chaining-f1.c gdb: use make_scoped_restore to restore gdbpy_current_objfile 2021-03-15 09:21:37 +00:00
py-auto-load-chaining-f1.o-gdb.py gdb: use make_scoped_restore to restore gdbpy_current_objfile 2021-03-15 09:21:37 +00:00
py-auto-load-chaining-f2.c gdb: use make_scoped_restore to restore gdbpy_current_objfile 2021-03-15 09:21:37 +00:00
py-auto-load-chaining-f2.o-gdb.py gdb: use make_scoped_restore to restore gdbpy_current_objfile 2021-03-15 09:21:37 +00:00
py-auto-load-chaining.c gdb: use make_scoped_restore to restore gdbpy_current_objfile 2021-03-15 09:21:37 +00:00
py-auto-load-chaining.exp gdb: use make_scoped_restore to restore gdbpy_current_objfile 2021-03-15 09:21:37 +00:00
py-bad-printers.c
py-bad-printers.exp gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp 2021-03-12 12:18:34 +00:00
py-bad-printers.py
py-block.c
py-block.exp gdb/testsuite: make test names unique in gdb.python/py-block.exp 2021-03-12 12:18:33 +00:00
py-breakpoint-create-fail.c
py-breakpoint-create-fail.exp
py-breakpoint-create-fail.py
py-breakpoint.c
py-breakpoint.exp
py-caller-is.c
py-caller-is.exp
py-cmd.c
py-cmd.exp
py-completion.exp
py-completion.py
py-error.exp
py-error.py
py-events-shlib.c
py-events.c
py-events.exp gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp 2021-03-12 12:18:34 +00:00
py-events.py
py-evsignal.exp
py-evthreads.c
py-evthreads.exp
py-explore-cc.exp gdb/testsuite: make test names unique in gdb.python/py-explore-cc.exp 2021-03-12 12:18:33 +00:00
py-explore.c
py-explore.cc
py-explore.exp gdb/testsuite: make test names unique in gdb.python/py-explore.exp 2021-03-12 12:18:33 +00:00
py-finish-breakpoint2.cc
py-finish-breakpoint2.exp gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp 2021-03-12 12:18:34 +00:00
py-finish-breakpoint2.py
py-finish-breakpoint.c
py-finish-breakpoint.exp gdb/testsuite: make test names unique in gdb.python/py-finish-breakpoint.exp 2021-03-12 12:18:33 +00:00
py-finish-breakpoint.py
py-format-string.c
py-format-string.exp
py-format-string.py
py-frame-args.c
py-frame-args.exp
py-frame-args.py
py-frame-inline.c
py-frame-inline.exp gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp 2021-03-12 12:18:34 +00:00
py-frame.c
py-frame.exp gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp 2021-03-12 12:18:34 +00:00
py-framefilter-gdb.py.in
py-framefilter-invalidarg-gdb.py.in
py-framefilter-invalidarg.exp
py-framefilter-invalidarg.py
py-framefilter-mi.c
py-framefilter-mi.exp
py-framefilter.c
py-framefilter.exp
py-framefilter.py
py-function.exp
py-inferior.c
py-inferior.exp
py-infthread.c
py-infthread.exp gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp 2021-03-12 12:18:34 +00:00
py-lazy-string.c
py-lazy-string.exp
py-linetable.c
py-linetable.exp
py-linetable.S
py-lookup-type.exp gdb/testsuite: remove a duplicate test 2021-03-12 12:18:33 +00:00
py-mi-events-gdb.py
py-mi-events.c
py-mi-events.exp
py-mi-objfile-gdb.py
py-mi-objfile.c
py-mi-objfile.exp
py-mi-var-info-path-expression.c
py-mi-var-info-path-expression.exp
py-mi-var-info-path-expression.py
py-mi.exp
py-nested-maps.c
py-nested-maps.exp
py-nested-maps.py
py-objfile-script-gdb.py
py-objfile-script.c
py-objfile-script.exp
py-objfile.c
py-objfile.exp
py-parameter.exp
py-pp-integral.c
py-pp-integral.exp
py-pp-integral.py
py-pp-maint.c
py-pp-maint.exp gdb/testsuite: make test names unique in gdb.python/py-pp-maint.exp 2021-03-12 12:18:33 +00:00
py-pp-maint.py
py-pp-re-notag.c
py-pp-re-notag.exp
py-pp-re-notag.py
py-pp-registration.c
py-pp-registration.exp
py-pp-registration.py
py-prettyprint.c
py-prettyprint.exp
py-prettyprint.py
py-progspace.c
py-progspace.exp
py-prompt.c
py-prompt.exp gdb/testsuite: make test names unique in gdb.python/py-prompt.exp 2021-03-12 12:18:33 +00:00
py-rbreak-func2.c
py-rbreak.c
py-rbreak.exp
py-record-btrace-threads.c
py-record-btrace-threads.exp
py-record-btrace.c
py-record-btrace.exp
py-record-full.c
py-record-full.exp
py-recurse-unwind.c
py-recurse-unwind.exp
py-recurse-unwind.py
py-rvalue-ref-value-cc.cc
py-rvalue-ref-value-cc.exp
py-section-script.c
py-section-script.exp
py-section-script.py
py-shared-sl.c
py-shared.c
py-shared.exp
py-strfns.c
py-strfns.exp gdb/testsuite: make test names unique in gdb.python/py-strfns.exp 2021-03-12 12:18:33 +00:00
py-symbol-2.c
py-symbol.c
py-symbol.exp
py-symtab.exp gdb/testsuite: make test names unique in gdb.python/py-symtab.exp 2021-03-12 12:18:33 +00:00
py-sync-interp.c
py-sync-interp.exp
py-template.cc
py-template.exp
py-thrhandle.c
py-thrhandle.exp
py-type.c
py-type.exp
py-typeprint.cc
py-typeprint.exp
py-typeprint.py
py-unwind-inline.c
py-unwind-inline.exp
py-unwind-inline.py
py-unwind-maint.c
py-unwind-maint.exp
py-unwind-maint.py
py-unwind.c
py-unwind.exp
py-unwind.py
py-value-cc.cc
py-value-cc.exp gdb/testsuite: remove duplicate test from gdb.python/py-value-cc.exp 2021-03-12 12:18:34 +00:00
py-value.c
py-value.exp
py-xmethods.cc
py-xmethods.exp
py-xmethods.py
python-1.c
python.c
python.exp
source1
source2.py
tui-window-disabled.c
tui-window-disabled.exp
tui-window-disabled.py
tui-window.exp
tui-window.py