aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S2
-rw-r--r--gdb/testsuite/gdb.python/compare-enum-type-a.c2
-rw-r--r--gdb/testsuite/gdb.python/compare-enum-type-b.c2
-rw-r--r--gdb/testsuite/gdb.python/compare-enum-type.exp2
-rw-r--r--gdb/testsuite/gdb.python/compare-enum-type.h2
-rw-r--r--gdb/testsuite/gdb.python/flexible-array-member.c2
-rw-r--r--gdb/testsuite/gdb.python/flexible-array-member.exp2
-rw-r--r--gdb/testsuite/gdb.python/gdb_leak_detector.py121
-rw-r--r--gdb/testsuite/gdb.python/lib-types.cc2
-rw-r--r--gdb/testsuite/gdb.python/lib-types.exp2
-rw-r--r--gdb/testsuite/gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/lotsa-lines.exp2
-rw-r--r--gdb/testsuite/gdb.python/pretty-print-call-by-hand.c2
-rw-r--r--gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp2
-rw-r--r--gdb/testsuite/gdb.python/pretty-print-call-by-hand.py2
-rw-r--r--gdb/testsuite/gdb.python/py-arch-reg-groups.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-arch-reg-names.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-arch.c2
-rw-r--r--gdb/testsuite/gdb.python/py-arch.exp11
-rw-r--r--gdb/testsuite/gdb.python/py-as-string.c2
-rw-r--r--gdb/testsuite/gdb.python/py-as-string.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining-f1.c2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining-f1.o-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining-f2.c2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining-f2.o-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining.c2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h2
-rw-r--r--gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py2
-rw-r--r--gdb/testsuite/gdb.python/py-bad-printers.c2
-rw-r--r--gdb/testsuite/gdb.python/py-bad-printers.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-bad-printers.py2
-rw-r--r--gdb/testsuite/gdb.python/py-block.c2
-rw-r--r--gdb/testsuite/gdb.python/py-block.exp6
-rw-r--r--gdb/testsuite/gdb.python/py-bp-locations.c2
-rw-r--r--gdb/testsuite/gdb.python/py-bp-locations.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint-create-fail.c2
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint-create-fail.py2
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-caller-is.c2
-rw-r--r--gdb/testsuite/gdb.python/py-caller-is.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-charset.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd-exception.c2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd-exception.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd-exception.py2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd-prompt.c2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd-prompt.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd-prompt.py2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd.c2
-rw-r--r--gdb/testsuite/gdb.python/py-cmd.exp87
-rw-r--r--gdb/testsuite/gdb.python/py-color-leak.exp28
-rw-r--r--gdb/testsuite/gdb.python/py-color-leak.py37
-rw-r--r--gdb/testsuite/gdb.python/py-color.exp77
-rw-r--r--gdb/testsuite/gdb.python/py-completion.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-completion.py2
-rw-r--r--gdb/testsuite/gdb.python/py-connection-removed.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-connection.c2
-rw-r--r--gdb/testsuite/gdb.python/py-connection.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-disasm-exec.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-disasm-obj.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.c2
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.exp.tcl7
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.py20
-rw-r--r--gdb/testsuite/gdb.python/py-doc-reformat.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-error.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-error.py2
-rw-r--r--gdb/testsuite/gdb.python/py-event-load.c2
-rw-r--r--gdb/testsuite/gdb.python/py-event-load.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-event-load.py2
-rw-r--r--gdb/testsuite/gdb.python/py-events-shlib.c2
-rw-r--r--gdb/testsuite/gdb.python/py-events.c2
-rw-r--r--gdb/testsuite/gdb.python/py-events.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-events.py2
-rw-r--r--gdb/testsuite/gdb.python/py-evsignal.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-evthreads.c2
-rw-r--r--gdb/testsuite/gdb.python/py-evthreads.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-exec-file.c2
-rw-r--r--gdb/testsuite/gdb.python/py-exec-file.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-exec-mi.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-explore-cc.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-explore.c2
-rw-r--r--gdb/testsuite/gdb.python/py-explore.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-explore.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-failed-init.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.c2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.py2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint.py2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint2.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint2.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint2.py2
-rw-r--r--gdb/testsuite/gdb.python/py-format-address.c2
-rw-r--r--gdb/testsuite/gdb.python/py-format-address.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.c2
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.py2
-rw-r--r--gdb/testsuite/gdb.python/py-frame-args.c2
-rw-r--r--gdb/testsuite/gdb.python/py-frame-args.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-frame-args.py2
-rw-r--r--gdb/testsuite/gdb.python/py-frame-inline.c2
-rw-r--r--gdb/testsuite/gdb.python/py-frame-inline.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-frame.exp17
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-addr.c2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-addr.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-addr.py2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-invalidarg.py2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-mi.c2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-mi.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter.c2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter.py2
-rw-r--r--gdb/testsuite/gdb.python/py-function.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-inferior-leak.c2
-rw-r--r--gdb/testsuite/gdb.python/py-inferior-leak.exp16
-rw-r--r--gdb/testsuite/gdb.python/py-inferior-leak.py113
-rw-r--r--gdb/testsuite/gdb.python/py-inferior.exp6
-rw-r--r--gdb/testsuite/gdb.python/py-infthread.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-label-symbol-value.c2
-rw-r--r--gdb/testsuite/gdb.python/py-label-symbol-value.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-lazy-string.c2
-rw-r--r--gdb/testsuite/gdb.python/py-lazy-string.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-linetable-empty.c2
-rw-r--r--gdb/testsuite/gdb.python/py-linetable-empty.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-linetable.S2
-rw-r--r--gdb/testsuite/gdb.python/py-linetable.c2
-rw-r--r--gdb/testsuite/gdb.python/py-linetable.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-lookup-type.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-cmd.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-cmd.py2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-events-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-events.c2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-events.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-notify.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-objfile-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-objfile.c2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-objfile.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-var-info-path-expression.c2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py2
-rw-r--r--gdb/testsuite/gdb.python/py-mi.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-debug.c2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-debug.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-debug.py2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-objfile-lib.c2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-objfile.c2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-objfile.exp12
-rw-r--r--gdb/testsuite/gdb.python/py-missing-objfile.py2
-rw-r--r--gdb/testsuite/gdb.python/py-nested-maps.c2
-rw-r--r--gdb/testsuite/gdb.python/py-nested-maps.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-nested-maps.py2
-rw-r--r--gdb/testsuite/gdb.python/py-objfile-script-gdb.py2
-rw-r--r--gdb/testsuite/gdb.python/py-objfile-script.c2
-rw-r--r--gdb/testsuite/gdb.python/py-objfile-script.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.c4
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.exp5
-rw-r--r--gdb/testsuite/gdb.python/py-parameter-prefix.exp382
-rw-r--r--gdb/testsuite/gdb.python/py-parameter.exp189
-rw-r--r--gdb/testsuite/gdb.python/py-pending-frame-level.c2
-rw-r--r--gdb/testsuite/gdb.python/py-pending-frame-level.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pending-frame-level.py2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-cast.c2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-cast.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-cast.py2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-integral.c2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-integral.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-integral.py2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-maint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-maint.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-maint.py2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-re-notag.c2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-re-notag.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-re-notag.py2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-registration.c2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-registration.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-registration.py2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint-stub-2.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint-stub.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint-stub.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint-stub.h2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint-stub.py2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.py2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace-events.c2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace-events.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace-events.py2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.c2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-prompt.c2
-rw-r--r--gdb/testsuite/gdb.python/py-prompt.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-rbreak-func2.c2
-rw-r--r--gdb/testsuite/gdb.python/py-rbreak.c2
-rw-r--r--gdb/testsuite/gdb.python/py-rbreak.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.c2
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.exp16
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.py88
-rw-r--r--gdb/testsuite/gdb.python/py-record-btrace-threads.c2
-rw-r--r--gdb/testsuite/gdb.python/py-record-btrace-threads.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-record-btrace.c2
-rw-r--r--gdb/testsuite/gdb.python/py-record-btrace.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-record-full.c2
-rw-r--r--gdb/testsuite/gdb.python/py-record-full.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-recurse-unwind.c2
-rw-r--r--gdb/testsuite/gdb.python/py-recurse-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-recurse-unwind.py2
-rw-r--r--gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-section-script.c2
-rw-r--r--gdb/testsuite/gdb.python/py-section-script.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-section-script.py2
-rw-r--r--gdb/testsuite/gdb.python/py-send-packet.c2
-rw-r--r--gdb/testsuite/gdb.python/py-send-packet.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-send-packet.py2
-rw-r--r--gdb/testsuite/gdb.python/py-shared-sl.c2
-rw-r--r--gdb/testsuite/gdb.python/py-shared.c2
-rw-r--r--gdb/testsuite/gdb.python/py-shared.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-source-styling-2.c26
-rw-r--r--gdb/testsuite/gdb.python/py-source-styling-2.exp55
-rw-r--r--gdb/testsuite/gdb.python/py-source-styling.c2
-rw-r--r--gdb/testsuite/gdb.python/py-source-styling.exp174
-rw-r--r--gdb/testsuite/gdb.python/py-startup-opt.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-strfns.c2
-rw-r--r--gdb/testsuite/gdb.python/py-strfns.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-styled-execute.exp109
-rw-r--r--gdb/testsuite/gdb.python/py-sym-artificial.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol-2.c2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol-3.c2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.c2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.exp24
-rw-r--r--gdb/testsuite/gdb.python/py-symtab.exp30
-rw-r--r--gdb/testsuite/gdb.python/py-sync-interp.c2
-rw-r--r--gdb/testsuite/gdb.python/py-sync-interp.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-template.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-template.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-thread-exited.c2
-rw-r--r--gdb/testsuite/gdb.python/py-thread-exited.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-thread-exited.py2
-rw-r--r--gdb/testsuite/gdb.python/py-thrhandle.c2
-rw-r--r--gdb/testsuite/gdb.python/py-thrhandle.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-type.c2
-rw-r--r--gdb/testsuite/gdb.python/py-type.exp17
-rw-r--r--gdb/testsuite/gdb.python/py-typeprint.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-typeprint.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-typeprint.py2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-inline.c2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-inline.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-inline.py2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-maint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-maint.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-maint.py2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-user-regs.c2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-user-regs.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind-user-regs.py2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.c2
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.exp9
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.py22
-rw-r--r--gdb/testsuite/gdb.python/py-value-cc.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-value-cc.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-value.c2
-rw-r--r--gdb/testsuite/gdb.python/py-value.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-varobj.c2
-rw-r--r--gdb/testsuite/gdb.python/py-varobj.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-varobj.py2
-rw-r--r--gdb/testsuite/gdb.python/py-warning.exp63
-rw-r--r--gdb/testsuite/gdb.python/py-watchpoint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-watchpoint.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-watchpoint.py2
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.cc4
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.py2
-rw-r--r--gdb/testsuite/gdb.python/python-1.c2
-rw-r--r--gdb/testsuite/gdb.python/python.c2
-rw-r--r--gdb/testsuite/gdb.python/python.exp2
-rw-r--r--gdb/testsuite/gdb.python/source12
-rw-r--r--gdb/testsuite/gdb.python/source2.py2
-rw-r--r--gdb/testsuite/gdb.python/sys-exit.exp2
-rw-r--r--gdb/testsuite/gdb.python/tui-window-disabled.c2
-rw-r--r--gdb/testsuite/gdb.python/tui-window-disabled.exp2
-rw-r--r--gdb/testsuite/gdb.python/tui-window-disabled.py2
-rw-r--r--gdb/testsuite/gdb.python/tui-window-factory.exp2
-rw-r--r--gdb/testsuite/gdb.python/tui-window-factory.py2
-rw-r--r--gdb/testsuite/gdb.python/tui-window-names.exp2
-rw-r--r--gdb/testsuite/gdb.python/tui-window.exp2
-rw-r--r--gdb/testsuite/gdb.python/tui-window.py2
294 files changed, 1790 insertions, 513 deletions
diff --git a/gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S b/gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S
index e24b85d..0280591 100644
--- a/gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S
+++ b/gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2014-2024 Free Software Foundation, Inc.
+ Copyright 2014-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/compare-enum-type-a.c b/gdb/testsuite/gdb.python/compare-enum-type-a.c
index 237552a..cf02a15 100644
--- a/gdb/testsuite/gdb.python/compare-enum-type-a.c
+++ b/gdb/testsuite/gdb.python/compare-enum-type-a.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2020-2024 Free Software Foundation, Inc.
+ Copyright 2020-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/compare-enum-type-b.c b/gdb/testsuite/gdb.python/compare-enum-type-b.c
index 07c7fb8..4576dbb 100644
--- a/gdb/testsuite/gdb.python/compare-enum-type-b.c
+++ b/gdb/testsuite/gdb.python/compare-enum-type-b.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2020-2024 Free Software Foundation, Inc.
+ Copyright 2020-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/compare-enum-type.exp b/gdb/testsuite/gdb.python/compare-enum-type.exp
index 7d6ac9d..5dd6a3d 100644
--- a/gdb/testsuite/gdb.python/compare-enum-type.exp
+++ b/gdb/testsuite/gdb.python/compare-enum-type.exp
@@ -1,4 +1,4 @@
-# Copyright 2020-2024 Free Software Foundation, Inc.
+# Copyright 2020-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/compare-enum-type.h b/gdb/testsuite/gdb.python/compare-enum-type.h
index 674ccb8..506e0c5 100644
--- a/gdb/testsuite/gdb.python/compare-enum-type.h
+++ b/gdb/testsuite/gdb.python/compare-enum-type.h
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2020-2024 Free Software Foundation, Inc.
+ Copyright 2020-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/flexible-array-member.c b/gdb/testsuite/gdb.python/flexible-array-member.c
index d53bcd0..00e1313 100644
--- a/gdb/testsuite/gdb.python/flexible-array-member.c
+++ b/gdb/testsuite/gdb.python/flexible-array-member.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2020-2024 Free Software Foundation, Inc.
+ Copyright 2020-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/flexible-array-member.exp b/gdb/testsuite/gdb.python/flexible-array-member.exp
index f684e68..3468ec8 100644
--- a/gdb/testsuite/gdb.python/flexible-array-member.exp
+++ b/gdb/testsuite/gdb.python/flexible-array-member.exp
@@ -1,4 +1,4 @@
-# Copyright 2020-2024 Free Software Foundation, Inc.
+# Copyright 2020-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/gdb_leak_detector.py b/gdb/testsuite/gdb.python/gdb_leak_detector.py
new file mode 100644
index 0000000..8f74b67
--- /dev/null
+++ b/gdb/testsuite/gdb.python/gdb_leak_detector.py
@@ -0,0 +1,121 @@
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Defines a base class, which can be sub-classed, in order to run
+# memory leak tests on some aspects of GDB's Python API. See the
+# comments on the gdb_leak_detector class for more details.
+
+import os
+import tracemalloc
+
+import gdb
+
+
+# This class must be sub-classed to create a memory leak test. The
+# sub-classes __init__ method should call the parent classes __init__
+# method, and the sub-class should override allocate() and
+# deallocate(). See the comments on the various methods below for
+# more details of required arguments and expected usage.
+class gdb_leak_detector:
+
+ # Class initialisation. FILENAME is the file in which the
+ # sub-class is defined, usually passed as just '__file__'. This
+ # is used when looking for memory allocations; only allocations in
+ # FILENAME are considered.
+ def __init__(self, filename):
+ self.filters = [tracemalloc.Filter(True, "*" + os.path.basename(filename))]
+
+ # Internal helper function to actually run the test. Calls the
+ # allocate() method to allocate an object from GDB's Python API.
+ # When CLEAR is True the object will then be deallocated by
+ # calling deallocate(), otherwise, deallocate() is not called.
+ #
+ # Finally, this function checks for any memory allocatios
+ # originating from 'self.filename' that have not been freed, and
+ # returns the total (in bytes) of the memory that has been
+ # allocated, but not freed.
+ def _do_test(self, clear):
+ # Start tracing, and take a snapshot of the current allocations.
+ tracemalloc.start()
+ snapshot1 = tracemalloc.take_snapshot()
+
+ # Generate the GDB Python API object by calling the allocate
+ # method.
+ self.allocate()
+
+ # Possibly clear the reference to the allocated object.
+ if clear:
+ self.deallocate()
+
+ # Now grab a second snapshot of memory allocations, and stop
+ # tracing memory allocations.
+ snapshot2 = tracemalloc.take_snapshot()
+ tracemalloc.stop()
+
+ # Filter the snapshots; we only care about allocations originating
+ # from this file.
+ snapshot1 = snapshot1.filter_traces(self.filters)
+ snapshot2 = snapshot2.filter_traces(self.filters)
+
+ # Compare the snapshots, this leaves only things that were
+ # allocated, but not deallocated since the first snapshot.
+ stats = snapshot2.compare_to(snapshot1, "traceback")
+
+ # Total up all the allocated things.
+ total = 0
+ for stat in stats:
+ total += stat.size_diff
+ return total
+
+ # Run the memory leak test. Prints 'PASS' if successful,
+ # otherwise, raises an exception (of type GdbError).
+ def run(self):
+ # The first time we run this some global state will be allocated which
+ # shows up as memory that is allocated, but not released. So, run the
+ # test once and discard the result.
+ self._do_test(True)
+
+ # Now run the test twice, the first time we clear our global reference
+ # to the allocated object, which should allow Python to deallocate the
+ # object. The second time we hold onto the global reference, preventing
+ # Python from performing the deallocation.
+ bytes_with_clear = self._do_test(True)
+ bytes_without_clear = self._do_test(False)
+
+ # If there are any allocations left over when we cleared the reference
+ # (and expected deallocation) then this indicates a leak.
+ if bytes_with_clear > 0:
+ raise gdb.GdbError("memory leak when object reference was released")
+
+ # If there are no allocations showing when we hold onto a reference,
+ # then this likely indicates that the testing infrastructure is broken,
+ # and we're no longer spotting the allocations at all.
+ if bytes_without_clear == 0:
+ raise gdb.GdbError("object is unexpectedly not showing as allocated")
+
+ # Print a PASS message that the TCL script can see.
+ print("PASS")
+
+ # Sub-classes must override this method. Allocate an object (or
+ # multiple objects) from GDB's Python API. Store references to
+ # these objects within SELF.
+ def allocate(self):
+ raise NotImplementedError("allocate() not implemented")
+
+ # Sub-classes must override this method. Deallocate the object(s)
+ # allocated by the allocate() method. All that is required is for
+ # the references created in allocate() to be set to None.
+ def deallocate(self):
+ raise NotImplementedError("allocate() not implemented")
diff --git a/gdb/testsuite/gdb.python/lib-types.cc b/gdb/testsuite/gdb.python/lib-types.cc
index c221693..3901a0b 100644
--- a/gdb/testsuite/gdb.python/lib-types.cc
+++ b/gdb/testsuite/gdb.python/lib-types.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/lib-types.exp b/gdb/testsuite/gdb.python/lib-types.exp
index de24517..168f497 100644
--- a/gdb/testsuite/gdb.python/lib-types.exp
+++ b/gdb/testsuite/gdb.python/lib-types.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py b/gdb/testsuite/gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py
index 5b3a1b7..18407e2 100644
--- a/gdb/testsuite/gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py
+++ b/gdb/testsuite/gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/lotsa-lines.exp b/gdb/testsuite/gdb.python/lotsa-lines.exp
index b3e980a..537e6f8 100644
--- a/gdb/testsuite/gdb.python/lotsa-lines.exp
+++ b/gdb/testsuite/gdb.python/lotsa-lines.exp
@@ -1,4 +1,4 @@
-# Copyright 2023-2024 Free Software Foundation, Inc.
+# Copyright 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c
index 94121f5..88700a1 100644
--- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c
+++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
index e633e55..dd6cb59 100644
--- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
+++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.py b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.py
index f9289ef..3620354 100644
--- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.py
+++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
index 3475bbc..855af27 100644
--- a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
+++ b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
@@ -1,4 +1,4 @@
-# Copyright 2020-2024 Free Software Foundation, Inc.
+# Copyright 2020-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-arch-reg-names.exp b/gdb/testsuite/gdb.python/py-arch-reg-names.exp
index 7c08168..7093674 100644
--- a/gdb/testsuite/gdb.python/py-arch-reg-names.exp
+++ b/gdb/testsuite/gdb.python/py-arch-reg-names.exp
@@ -1,4 +1,4 @@
-# Copyright 2020-2024 Free Software Foundation, Inc.
+# Copyright 2020-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-arch.c b/gdb/testsuite/gdb.python/py-arch.c
index ec6874b..a630de4 100644
--- a/gdb/testsuite/gdb.python/py-arch.c
+++ b/gdb/testsuite/gdb.python/py-arch.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 14802ec..79e5939 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -1,4 +1,4 @@
-# Copyright 2013-2024 Free Software Foundation, Inc.
+# Copyright 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -104,6 +104,15 @@ foreach_with_prefix test_data { {None None} \
"check 'signed' argument can handle non-bool type $bad_type"
}
+gdb_test "python print(arch.void_type())" \
+ "void" \
+ "get void type"
+
+# Test type identity
+gdb_test "python print(arch.integer_type(32) is arch.integer_type(32))" \
+ "True" \
+ "arch.integer_type(32) always return the same Python object"
+
# Test for gdb.architecture_names(). First we're going to grab the
# complete list of architecture names using the 'complete' command.
set arch_names []
diff --git a/gdb/testsuite/gdb.python/py-as-string.c b/gdb/testsuite/gdb.python/py-as-string.c
index ec05206..1997300 100644
--- a/gdb/testsuite/gdb.python/py-as-string.c
+++ b/gdb/testsuite/gdb.python/py-as-string.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2016-2024 Free Software Foundation, Inc.
+ Copyright 2016-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-as-string.exp b/gdb/testsuite/gdb.python/py-as-string.exp
index 1a38d4b..05d55df 100644
--- a/gdb/testsuite/gdb.python/py-as-string.exp
+++ b/gdb/testsuite/gdb.python/py-as-string.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2024 Free Software Foundation, Inc.
+# Copyright (C) 2016-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.c b/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.c
index 7fb1c5f..10baa8e 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.c
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.o-gdb.py b/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.o-gdb.py
index 0740de3..9641a86 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.o-gdb.py
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining-f1.o-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.c b/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.c
index f2f3506..ef6c4a4 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.c
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.o-gdb.py b/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.o-gdb.py
index 2be5cb1..f1abc2c 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.o-gdb.py
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining-f2.o-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining.c b/gdb/testsuite/gdb.python/py-auto-load-chaining.c
index 50236c2..74ec04f 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining.c
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
index b5aabd3..451dca6 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc
index 95312ca..c8eb2e6 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h
index 4252d48..9e2bf4f 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc
index 717daf2..0beb0af 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp
index 73f66f4..3bd0494 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py
index d63c087..7bbb860 100644
--- a/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py
+++ b/gdb/testsuite/gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-bad-printers.c b/gdb/testsuite/gdb.python/py-bad-printers.c
index 17fe779..d10fde6 100644
--- a/gdb/testsuite/gdb.python/py-bad-printers.c
+++ b/gdb/testsuite/gdb.python/py-bad-printers.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2008-2024 Free Software Foundation, Inc.
+ Copyright 2008-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-bad-printers.exp b/gdb/testsuite/gdb.python/py-bad-printers.exp
index cc51a6f..ab1a9ba 100644
--- a/gdb/testsuite/gdb.python/py-bad-printers.exp
+++ b/gdb/testsuite/gdb.python/py-bad-printers.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-bad-printers.py b/gdb/testsuite/gdb.python/py-bad-printers.py
index ac9c35e..c93923c 100644
--- a/gdb/testsuite/gdb.python/py-bad-printers.py
+++ b/gdb/testsuite/gdb.python/py-bad-printers.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-block.c b/gdb/testsuite/gdb.python/py-block.c
index d180d9b..3417e2d 100644
--- a/gdb/testsuite/gdb.python/py-block.c
+++ b/gdb/testsuite/gdb.python/py-block.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp
index 0e6851d..ce3f7ce 100644
--- a/gdb/testsuite/gdb.python/py-block.exp
+++ b/gdb/testsuite/gdb.python/py-block.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -61,6 +61,10 @@ gdb_py_test_silent_cmd "python sblock = block.static_block" \
"Get block, static_block" 1
gdb_test "python print (gblock.is_global)" "True" "is the global block"
gdb_test "python print (sblock.is_static)" "True" "is the static block"
+gdb_test "python print (len(gblock.subblocks) > 0)" "True" \
+ "global block contains at least one block"
+gdb_test "python print (sblock in gblock.subblocks)" "True" \
+ "global block contains at static block"
# Move up superblock(s) until we reach function block_func.
gdb_test_no_output "python block = block.superblock" "get superblock"
diff --git a/gdb/testsuite/gdb.python/py-bp-locations.c b/gdb/testsuite/gdb.python/py-bp-locations.c
index 98b9380..a261f26 100644
--- a/gdb/testsuite/gdb.python/py-bp-locations.c
+++ b/gdb/testsuite/gdb.python/py-bp-locations.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-bp-locations.exp b/gdb/testsuite/gdb.python/py-bp-locations.exp
index 4892947..61e4e38 100644
--- a/gdb/testsuite/gdb.python/py-bp-locations.exp
+++ b/gdb/testsuite/gdb.python/py-bp-locations.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.c b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.c
index bbb4ec2..a1a964c 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.c
+++ b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2016-2024 Free Software Foundation, Inc.
+ Copyright 2016-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
index 7840dba..391744e 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2024 Free Software Foundation, Inc.
+# Copyright (C) 2016-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.py b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.py
index f85de0f..470eaea 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.py
+++ b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2024 Free Software Foundation, Inc.
+# Copyright (C) 2016-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.c b/gdb/testsuite/gdb.python/py-breakpoint.c
index 9fe21ab..4e61d0e 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.c
+++ b/gdb/testsuite/gdb.python/py-breakpoint.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 6f9245c..9a901a3 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -707,7 +707,7 @@ proc_with_prefix test_bkpt_explicit_loc {} {
delete_breakpoints
gdb_test "python bp1 = gdb.Breakpoint (line=bp1)" \
- "RuntimeError.*: Line keyword should be an integer or a string.*" \
+ "RuntimeError.*: Line keyword should be an integer or a string\\.\r\n.*" \
"set explicit breakpoint by invalid line type"
delete_breakpoints
diff --git a/gdb/testsuite/gdb.python/py-caller-is.c b/gdb/testsuite/gdb.python/py-caller-is.c
index f7c36c1..b6fd8d5 100644
--- a/gdb/testsuite/gdb.python/py-caller-is.c
+++ b/gdb/testsuite/gdb.python/py-caller-is.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2012-2024 Free Software Foundation, Inc.
+ Copyright 2012-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-caller-is.exp b/gdb/testsuite/gdb.python/py-caller-is.exp
index 301dd1b..8e54c3b 100644
--- a/gdb/testsuite/gdb.python/py-caller-is.exp
+++ b/gdb/testsuite/gdb.python/py-caller-is.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-charset.exp b/gdb/testsuite/gdb.python/py-charset.exp
index c7c4d02..0e98e07 100644
--- a/gdb/testsuite/gdb.python/py-charset.exp
+++ b/gdb/testsuite/gdb.python/py-charset.exp
@@ -1,4 +1,4 @@
-# Copyright 2022-2024 Free Software Foundation, Inc.
+# Copyright 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd-exception.c b/gdb/testsuite/gdb.python/py-cmd-exception.c
index 6cb2c2c..aa5ec04 100644
--- a/gdb/testsuite/gdb.python/py-cmd-exception.c
+++ b/gdb/testsuite/gdb.python/py-cmd-exception.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd-exception.exp b/gdb/testsuite/gdb.python/py-cmd-exception.exp
index 0bfa13e..0333d13 100644
--- a/gdb/testsuite/gdb.python/py-cmd-exception.exp
+++ b/gdb/testsuite/gdb.python/py-cmd-exception.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd-exception.py b/gdb/testsuite/gdb.python/py-cmd-exception.py
index d37257d..5a72b81 100644
--- a/gdb/testsuite/gdb.python/py-cmd-exception.py
+++ b/gdb/testsuite/gdb.python/py-cmd-exception.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd-prompt.c b/gdb/testsuite/gdb.python/py-cmd-prompt.c
index 304503c..5f785f0 100644
--- a/gdb/testsuite/gdb.python/py-cmd-prompt.c
+++ b/gdb/testsuite/gdb.python/py-cmd-prompt.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd-prompt.exp b/gdb/testsuite/gdb.python/py-cmd-prompt.exp
index ccb695f..3f392d1 100644
--- a/gdb/testsuite/gdb.python/py-cmd-prompt.exp
+++ b/gdb/testsuite/gdb.python/py-cmd-prompt.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd-prompt.py b/gdb/testsuite/gdb.python/py-cmd-prompt.py
index b80a0c9..1be9f3f 100644
--- a/gdb/testsuite/gdb.python/py-cmd-prompt.py
+++ b/gdb/testsuite/gdb.python/py-cmd-prompt.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd.c b/gdb/testsuite/gdb.python/py-cmd.c
index c18c92a..6c4357c 100644
--- a/gdb/testsuite/gdb.python/py-cmd.c
+++ b/gdb/testsuite/gdb.python/py-cmd.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index b083a80..5ac5712 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -328,4 +328,89 @@ proc_with_prefix test_command_redefining_itself {} {
"call command redefining itself 2"
}
+# Try to create commands using unknown prefixes and check GDB gives an
+# error. There's also a test in here for an ambiguous prefix, which
+# gives the same error.
+proc_with_prefix test_unknown_prefix {} {
+ clean_restart
+
+ gdb_test_no_output "python gdb.Command('foo1', gdb.COMMAND_NONE, prefix=True)"
+ gdb_test_no_output "python gdb.Command('foo cmd', gdb.COMMAND_NONE)"
+
+ foreach prefix { "xxx" "foo xxx" "foo1 xxx" } {
+ gdb_test "python gdb.Command('$prefix cmd', gdb.COMMAND_NONE)" \
+ [multi_line \
+ "Python Exception <class 'RuntimeError'>: Could not find command prefix $prefix\\." \
+ "Error occurred in Python: Could not find command prefix $prefix\\."]
+ }
+
+ gdb_test_no_output "python gdb.Command('foo2', gdb.COMMAND_NONE, prefix=True)"
+
+ foreach prefix { "foo" "foo xxx" "foo1 xxx" "foo2 xxx" } {
+ gdb_test "python gdb.Command('$prefix cmd2', gdb.COMMAND_NONE)" \
+ [multi_line \
+ "Python Exception <class 'RuntimeError'>: Could not find command prefix $prefix\\." \
+ "Error occurred in Python: Could not find command prefix $prefix\\."]
+ }
+}
+
+# Check what happens if a command object is called without an 'invoke'
+# method.
+proc_with_prefix test_deleting_invoke_methods {} {
+ clean_restart
+
+ gdb_test_multiline "create 'foo' prefix command" \
+ "python" "" \
+ "class test_prefix(gdb.Command):" "" \
+ " def __init__ (self):" "" \
+ " super().__init__ (\"foo\", gdb.COMMAND_USER, prefix=True)" "" \
+ " def invoke (self, arg, from_tty):" "" \
+ " print(\"In 'foo' invoke: %s\" % arg)" "" \
+ "foo = test_prefix()" "" \
+ "end" ""
+
+ gdb_test_multiline "create 'foo bar' command" \
+ "python" "" \
+ "class test_cmd(gdb.Command):" "" \
+ " def __init__ (self):" "" \
+ " super().__init__ (\"foo bar\", gdb.COMMAND_USER)" "" \
+ " def invoke (self, arg, from_tty):" "" \
+ " print(\"In 'foo bar' invoke: %s\" % arg)" "" \
+ "foo_bar = test_cmd()" "" \
+ "end" ""
+
+ gdb_test "foo def" "In 'foo' invoke: def" \
+ "call 'foo' with an unknown sub-command"
+
+ gdb_test "foo bar def" "In 'foo bar' invoke: def" \
+ "call 'foo bar' with arguments"
+
+ gdb_test_no_output "python del(foo_bar.__class__.invoke)" \
+ "delete invoke from test_cmd class"
+
+ with_test_prefix "after deleting test_cmd.invoke" {
+ gdb_test "foo def" "In 'foo' invoke: def" \
+ "call 'foo' with an unknown sub-command"
+
+ gdb_test "foo bar def" \
+ "^Python command object missing 'invoke' method\\." \
+ "call 'foo bar' with arguments"
+ }
+
+ gdb_test_no_output "python del(foo.__class__.invoke)" \
+ "delete invoke from test_prefix class"
+
+ with_test_prefix "after deleting test_prefix.invoke" {
+ gdb_test "foo def" \
+ "^Python command object missing 'invoke' method\\." \
+ "call 'foo' with an unknown sub-command"
+
+ gdb_test "foo bar def" \
+ "^Python command object missing 'invoke' method\\." \
+ "call 'foo bar' with arguments"
+ }
+}
+
test_command_redefining_itself
+test_unknown_prefix
+test_deleting_invoke_methods
diff --git a/gdb/testsuite/gdb.python/py-color-leak.exp b/gdb/testsuite/gdb.python/py-color-leak.exp
new file mode 100644
index 0000000..6d7fa7c
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-color-leak.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It checks for memory leaks
+# associated with allocating gdb.Color objects.
+
+load_lib gdb-python.exp
+
+require allow_python_tests
+
+standard_testfile
+
+clean_restart
+
+gdb_py_run_memory_leak_test ${srcdir}/${subdir}/${testfile}.py \
+ "gdb.Color object deallocates correctly"
diff --git a/gdb/testsuite/gdb.python/py-color-leak.py b/gdb/testsuite/gdb.python/py-color-leak.py
new file mode 100644
index 0000000..28afd59
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-color-leak.py
@@ -0,0 +1,37 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import sys
+
+# Avoid generating
+# src/gdb/testsuite/gdb.python/__pycache__/gdb_leak_detector.cpython-<n>.pyc.
+sys.dont_write_bytecode = True
+
+import gdb_leak_detector
+
+
+class color_leak_detector(gdb_leak_detector.gdb_leak_detector):
+ def __init__(self):
+ super().__init__(__file__)
+ self.color = None
+
+ def allocate(self):
+ self.color = gdb.Color("red")
+
+ def deallocate(self):
+ self.color = None
+
+
+color_leak_detector().run()
diff --git a/gdb/testsuite/gdb.python/py-color.exp b/gdb/testsuite/gdb.python/py-color.exp
index eb62d7f..2601cf3 100644
--- a/gdb/testsuite/gdb.python/py-color.exp
+++ b/gdb/testsuite/gdb.python/py-color.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -13,17 +13,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This file is part of the GDB testsuite.
-# It tests gdb.parameter and gdb.Parameter.
+# This file is part of the GDB testsuite. It tests gdb.Color.
load_lib gdb-python.exp
require allow_python_tests
-# Start with a fresh gdb.
-clean_restart
+# Start with a fresh GDB, but enable color support.
+with_ansi_styling_terminal {
+ clean_restart
+}
-gdb_test_no_output "python print_color_attrs = lambda c: print (c, c.colorspace, c.is_none, c.is_indexed, c.is_direct)" \
+gdb_test_no_output "python get_color_attrs = lambda c: \"%s %s %s %s %s\" % (str(c), c.colorspace, c.is_none, c.is_indexed, c.is_direct)" \
+ "get_color_attrs helper"
+
+gdb_test_no_output "python print_color_attrs = lambda c: print (get_color_attrs (c))" \
"print_color_attrs helper"
gdb_test_no_output "python c = gdb.Color ()" \
@@ -59,6 +63,15 @@ gdb_test "python print_color_attrs (c)" "green 1 False True False" \
gdb_test "python print (c.index)" "2" \
"print index of a basic color with ansi colorspace"
+# Create a color using keyword arguments, and check it matches the
+# non-keyword color.
+gdb_test_no_output "python c2 = gdb.Color (color_space = gdb.COLORSPACE_ANSI_8COLOR, value = 2)" \
+ "create color from basic index and ansi colorspace using keywords"
+gdb_test "python print(get_color_attrs (c) == get_color_attrs (c2))" "True" \
+ "check attributes match"
+gdb_test "python print(c.index == c2.index)" "True" \
+ "check index matches"
+
gdb_test_no_output "python c = gdb.Color (2, gdb.COLORSPACE_XTERM_256COLOR)" \
"create color from basic index and xterm256 colorspace"
gdb_test "python print_color_attrs (c)" "2 3 False True False" \
@@ -97,4 +110,54 @@ gdb_test [concat "python print (c_red.escape_sequence (True) + " \
"c_none.escape_sequence (True))"] \
"\033\\\[31m\033\\\[42mred on green\033\\\[49m red on default\033\\\[39m" \
"escape sequences"
-
+gdb_test [concat "python print (c_red.escape_sequence (is_foreground = True) + " \
+ "c_green.escape_sequence (is_foreground = False) + 'red on green' + " \
+ "c_none.escape_sequence (is_foreground = False) + ' red on default' + " \
+ "c_none.escape_sequence (is_foreground = True))"] \
+ "\033\\\[31m\033\\\[42mred on green\033\\\[49m red on default\033\\\[39m" \
+ "escape sequences using keyword arguments"
+
+# Ensure that turning styling off means no escape sequences.
+gdb_test_no_output "set style enabled off"
+gdb_test_no_output "python print (c_red.escape_sequence (True), end='')"
+gdb_test_no_output "python print (c_red.escape_sequence (False), end='')"
+gdb_test_no_output "set style enabled on"
+
+gdb_test_multiline "Try to sub-class gdb.Color" \
+ "python" "" \
+ "class my_color(gdb.Color):" "" \
+ " def __init__(self):" "" \
+ " super().__init__('red')" "" \
+ "end" \
+ [multi_line \
+ "Python Exception <class 'TypeError'>: type 'gdb\\.Color' is not an acceptable base type" \
+ "Error occurred in Python: type 'gdb\\.Color' is not an acceptable base type"]
+
+gdb_test_multiline "Setup a color parameter and non gdb.Color object" \
+ "python" "" \
+ "class my_param(gdb.Parameter):" "" \
+ " def __init__(self):" "" \
+ " super().__init__('color-param', gdb.COMMAND_NONE, gdb.PARAM_COLOR)" "" \
+ " self.value = gdb.Color('red')" "" \
+ "color_param = my_param()" "" \
+ " " "" \
+ "class bad_type:" "" \
+ " @property" "" \
+ " def __class__(self):" "" \
+ " raise RuntimeError('__class__ error for bad_type')" "" \
+ "bad_obj = bad_type()" "" \
+ "end" ""
+
+gdb_test_no_output "python color_param.value = gdb.Color('blue')" \
+ "set color parameter to blue"
+
+gdb_test "python color_param.value = bad_obj" \
+ [multi_line \
+ "Python Exception <class 'RuntimeError'>: color argument must be a gdb\\.Color object\\." \
+ "Error occurred in Python: color argument must be a gdb\\.Color object\\."] \
+ "set color parameter to a non-color type"
+
+gdb_test "python c_none.escape_sequence(c_red)" \
+ [multi_line \
+ "Python Exception <class 'TypeError'>: argument 1 must be bool, not gdb.Color" \
+ "Error occurred in Python: argument 1 must be bool, not gdb.Color"]
diff --git a/gdb/testsuite/gdb.python/py-completion.exp b/gdb/testsuite/gdb.python/py-completion.exp
index 9abe407..4c08db4 100644
--- a/gdb/testsuite/gdb.python/py-completion.exp
+++ b/gdb/testsuite/gdb.python/py-completion.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2024 Free Software Foundation, Inc.
+# Copyright (C) 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-completion.py b/gdb/testsuite/gdb.python/py-completion.py
index 1a39f6c..906b31e 100644
--- a/gdb/testsuite/gdb.python/py-completion.py
+++ b/gdb/testsuite/gdb.python/py-completion.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2024 Free Software Foundation, Inc.
+# Copyright (C) 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-connection-removed.exp b/gdb/testsuite/gdb.python/py-connection-removed.exp
index 28c71da..d60ebb0 100644
--- a/gdb/testsuite/gdb.python/py-connection-removed.exp
+++ b/gdb/testsuite/gdb.python/py-connection-removed.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-connection.c b/gdb/testsuite/gdb.python/py-connection.c
index a5530dd..a6e5093 100644
--- a/gdb/testsuite/gdb.python/py-connection.c
+++ b/gdb/testsuite/gdb.python/py-connection.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-connection.exp b/gdb/testsuite/gdb.python/py-connection.exp
index ca78b37..dbfe20f 100644
--- a/gdb/testsuite/gdb.python/py-connection.exp
+++ b/gdb/testsuite/gdb.python/py-connection.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-disasm-exec.exp b/gdb/testsuite/gdb.python/py-disasm-exec.exp
index 546c4b8..a8dceec 100644
--- a/gdb/testsuite/gdb.python/py-disasm-exec.exp
+++ b/gdb/testsuite/gdb.python/py-disasm-exec.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-disasm-obj.exp b/gdb/testsuite/gdb.python/py-disasm-obj.exp
index 37ff965..55374ad 100644
--- a/gdb/testsuite/gdb.python/py-disasm-obj.exp
+++ b/gdb/testsuite/gdb.python/py-disasm-obj.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-disasm.c b/gdb/testsuite/gdb.python/py-disasm.c
index f267dbd..95c2d11 100644
--- a/gdb/testsuite/gdb.python/py-disasm.c
+++ b/gdb/testsuite/gdb.python/py-disasm.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp.tcl b/gdb/testsuite/gdb.python/py-disasm.exp.tcl
index 8ed634e..c5099ba 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp.tcl
+++ b/gdb/testsuite/gdb.python/py-disasm.exp.tcl
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -152,7 +152,10 @@ set test_plans \
"Buffer returned from read_memory is sized $decimal instead of the expected $decimal"]] \
[list "ResultOfWrongType" \
[make_exception_pattern "TypeError" \
- "Result is not a DisassemblerResult."]] \
+ "Result from Disassembler must be gdb.DisassemblerResult, not Blah."]] \
+ [list "ResultOfVeryWrongType" \
+ [make_exception_pattern "TypeError" \
+ "Result from Disassembler must be gdb.DisassemblerResult, not Blah."]] \
[list "ErrorCreatingTextPart_NoArgs" \
[make_exception_pattern "TypeError" \
[missing_arg_pattern "style" 1]]] \
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py
index f105657..9761337 100644
--- a/gdb/testsuite/gdb.python/py-disasm.py
+++ b/gdb/testsuite/gdb.python/py-disasm.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -294,6 +294,24 @@ class ResultOfWrongType(TestDisassembler):
return self.Blah(1, "ABC")
+class ResultOfVeryWrongType(TestDisassembler):
+ """Return something that is not a DisassemblerResult from disassemble
+ method. The thing returned will raise an exception if used in an
+ isinstance() call, or in PyObject_IsInstance from C++.
+ """
+
+ class Blah:
+ def __init__(self):
+ pass
+
+ @property
+ def __class__(self):
+ raise RuntimeError("error from __class__ in Blah")
+
+ def disassemble(self, info):
+ return self.Blah()
+
+
class TaggingDisassembler(TestDisassembler):
"""A simple disassembler that just tags the output."""
diff --git a/gdb/testsuite/gdb.python/py-doc-reformat.exp b/gdb/testsuite/gdb.python/py-doc-reformat.exp
index 01671ed..519a314 100644
--- a/gdb/testsuite/gdb.python/py-doc-reformat.exp
+++ b/gdb/testsuite/gdb.python/py-doc-reformat.exp
@@ -1,4 +1,4 @@
-# Copyright 2022-2024 Free Software Foundation, Inc.
+# Copyright 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-error.exp b/gdb/testsuite/gdb.python/py-error.exp
index 6eb9cc3..1e920c2 100644
--- a/gdb/testsuite/gdb.python/py-error.exp
+++ b/gdb/testsuite/gdb.python/py-error.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-error.py b/gdb/testsuite/gdb.python/py-error.py
index f63e3e7..b128707 100644
--- a/gdb/testsuite/gdb.python/py-error.py
+++ b/gdb/testsuite/gdb.python/py-error.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-event-load.c b/gdb/testsuite/gdb.python/py-event-load.c
index 1616ff7..10b65fb 100644
--- a/gdb/testsuite/gdb.python/py-event-load.c
+++ b/gdb/testsuite/gdb.python/py-event-load.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-event-load.exp b/gdb/testsuite/gdb.python/py-event-load.exp
index c3e10f6..a09a946 100644
--- a/gdb/testsuite/gdb.python/py-event-load.exp
+++ b/gdb/testsuite/gdb.python/py-event-load.exp
@@ -1,4 +1,4 @@
-# Copyright 2022-2024 Free Software Foundation, Inc.
+# Copyright 2022-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-event-load.py b/gdb/testsuite/gdb.python/py-event-load.py
index cffd5c0..ac7c533 100644
--- a/gdb/testsuite/gdb.python/py-event-load.py
+++ b/gdb/testsuite/gdb.python/py-event-load.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-events-shlib.c b/gdb/testsuite/gdb.python/py-events-shlib.c
index 335bcdc..d77517a 100644
--- a/gdb/testsuite/gdb.python/py-events-shlib.c
+++ b/gdb/testsuite/gdb.python/py-events-shlib.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2011-2024 Free Software Foundation, Inc.
+ Copyright 2011-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c
index 747d7a8..9ecdeb7 100644
--- a/gdb/testsuite/gdb.python/py-events.c
+++ b/gdb/testsuite/gdb.python/py-events.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index 85b55ae..b440ac4 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py
index ebc59df..0573b16 100644
--- a/gdb/testsuite/gdb.python/py-events.py
+++ b/gdb/testsuite/gdb.python/py-events.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-evsignal.exp b/gdb/testsuite/gdb.python/py-evsignal.exp
index 83b351f..22b13af 100644
--- a/gdb/testsuite/gdb.python/py-evsignal.exp
+++ b/gdb/testsuite/gdb.python/py-evsignal.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-evthreads.c b/gdb/testsuite/gdb.python/py-evthreads.c
index 5605d03..321a9b7 100644
--- a/gdb/testsuite/gdb.python/py-evthreads.c
+++ b/gdb/testsuite/gdb.python/py-evthreads.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-evthreads.exp b/gdb/testsuite/gdb.python/py-evthreads.exp
index c2310a1..0e9cd97 100644
--- a/gdb/testsuite/gdb.python/py-evthreads.exp
+++ b/gdb/testsuite/gdb.python/py-evthreads.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-exec-file.c b/gdb/testsuite/gdb.python/py-exec-file.c
index ca3e5ab..df3db4d 100644
--- a/gdb/testsuite/gdb.python/py-exec-file.c
+++ b/gdb/testsuite/gdb.python/py-exec-file.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-exec-file.exp b/gdb/testsuite/gdb.python/py-exec-file.exp
index f735757..b3418a5 100644
--- a/gdb/testsuite/gdb.python/py-exec-file.exp
+++ b/gdb/testsuite/gdb.python/py-exec-file.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-exec-mi.exp b/gdb/testsuite/gdb.python/py-exec-mi.exp
index 6b81644..96ee481 100644
--- a/gdb/testsuite/gdb.python/py-exec-mi.exp
+++ b/gdb/testsuite/gdb.python/py-exec-mi.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-explore-cc.exp b/gdb/testsuite/gdb.python/py-explore-cc.exp
index 94fae13..0be7019 100644
--- a/gdb/testsuite/gdb.python/py-explore-cc.exp
+++ b/gdb/testsuite/gdb.python/py-explore-cc.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-explore.c b/gdb/testsuite/gdb.python/py-explore.c
index 8f48ecb..5546eaf 100644
--- a/gdb/testsuite/gdb.python/py-explore.c
+++ b/gdb/testsuite/gdb.python/py-explore.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2012-2024 Free Software Foundation, Inc.
+ Copyright 2012-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-explore.cc b/gdb/testsuite/gdb.python/py-explore.cc
index ea50ade..658979e 100644
--- a/gdb/testsuite/gdb.python/py-explore.cc
+++ b/gdb/testsuite/gdb.python/py-explore.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2012-2024 Free Software Foundation, Inc.
+ Copyright 2012-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-explore.exp b/gdb/testsuite/gdb.python/py-explore.exp
index 93be521..a68c110 100644
--- a/gdb/testsuite/gdb.python/py-explore.exp
+++ b/gdb/testsuite/gdb.python/py-explore.exp
@@ -1,4 +1,4 @@
-# Copyright 2012-2024 Free Software Foundation, Inc.
+# Copyright 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-failed-init.exp b/gdb/testsuite/gdb.python/py-failed-init.exp
index 1e0c10d..ee3dc7a 100644
--- a/gdb/testsuite/gdb.python/py-failed-init.exp
+++ b/gdb/testsuite/gdb.python/py-failed-init.exp
@@ -1,4 +1,4 @@
-# Copyright 2024 Free Software Foundation, Inc.
+# Copyright 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.c b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.c
index 8f0e6bb..6bc7cb6 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.c
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp
index 4aed5c5..42aa572 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.py b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.py
index c6d6df6..8d8ca53 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.py
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-deletion.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.c b/gdb/testsuite/gdb.python/py-finish-breakpoint.c
index 45dcc98..237a152 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.c
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2011-2024 Free Software Foundation, Inc.
+ Copyright 2011-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index 0316bc7..c7d31f0 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.py b/gdb/testsuite/gdb.python/py-finish-breakpoint.py
index dba0431..413489f 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.py
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.cc b/gdb/testsuite/gdb.python/py-finish-breakpoint2.cc
index 3c4f143..af8801f 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.cc
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2011-2024 Free Software Foundation, Inc.
+ Copyright 2011-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
index b837bb3..922426f 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.py b/gdb/testsuite/gdb.python/py-finish-breakpoint2.py
index 47bb2dd..ae75e51 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.py
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-format-address.c b/gdb/testsuite/gdb.python/py-format-address.c
index 2a0e916..f8eced6 100644
--- a/gdb/testsuite/gdb.python/py-format-address.c
+++ b/gdb/testsuite/gdb.python/py-format-address.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp
index ab8022c..173297c 100644
--- a/gdb/testsuite/gdb.python/py-format-address.exp
+++ b/gdb/testsuite/gdb.python/py-format-address.exp
@@ -1,4 +1,4 @@
-# Copyright 2022-2024 Free Software Foundation, Inc.
+# Copyright 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-format-string.c b/gdb/testsuite/gdb.python/py-format-string.c
index c1f59eb..eed356f 100644
--- a/gdb/testsuite/gdb.python/py-format-string.c
+++ b/gdb/testsuite/gdb.python/py-format-string.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2019-2024 Free Software Foundation, Inc.
+ Copyright 2019-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 9102391..114a606 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-format-string.py b/gdb/testsuite/gdb.python/py-format-string.py
index e4f88b1..34b0124 100644
--- a/gdb/testsuite/gdb.python/py-format-string.py
+++ b/gdb/testsuite/gdb.python/py-format-string.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-frame-args.c b/gdb/testsuite/gdb.python/py-frame-args.c
index cbf89c7..4a7b089 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.c
+++ b/gdb/testsuite/gdb.python/py-frame-args.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-frame-args.exp b/gdb/testsuite/gdb.python/py-frame-args.exp
index 4fc8f0a..1dbd30e 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.exp
+++ b/gdb/testsuite/gdb.python/py-frame-args.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-frame-args.py b/gdb/testsuite/gdb.python/py-frame-args.py
index 04ab1ac..45476b1 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.py
+++ b/gdb/testsuite/gdb.python/py-frame-args.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-frame-inline.c b/gdb/testsuite/gdb.python/py-frame-inline.c
index 691ade5..c02ddf3 100644
--- a/gdb/testsuite/gdb.python/py-frame-inline.c
+++ b/gdb/testsuite/gdb.python/py-frame-inline.c
@@ -1,6 +1,6 @@
/* This test is part of GDB, the GNU debugger.
- Copyright 2011-2024 Free Software Foundation, Inc.
+ Copyright 2011-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-frame-inline.exp b/gdb/testsuite/gdb.python/py-frame-inline.exp
index ce3d309..d4a74a1 100644
--- a/gdb/testsuite/gdb.python/py-frame-inline.exp
+++ b/gdb/testsuite/gdb.python/py-frame-inline.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index 0f1528e..c1e3e33 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -188,6 +188,21 @@ gdb_test "python print(gdb.selected_frame().read_register(list()))" \
".*Invalid type for register.*" \
"test Frame.read_register with list"
+gdb_test_multiline "setup a bad object" \
+ "python" "" \
+ "class bad_type:" "" \
+ " def __init__ (self):" "" \
+ " pass" "" \
+ " @property" "" \
+ " def __class__(self):" "" \
+ " raise RuntimeError('error from __class in bad_type')" "" \
+ "bad_object = bad_type()" "" \
+ "end" ""
+
+gdb_test "python print(gdb.selected_frame().read_register(bad_object))" \
+ ".*Invalid type for register.*" \
+ "test Frame.read_register with bad_type object"
+
# Compile again without debug info.
gdb_exit
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {}] } {
diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.c b/gdb/testsuite/gdb.python/py-framefilter-addr.c
index 6872c96..e356768 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-addr.c
+++ b/gdb/testsuite/gdb.python/py-framefilter-addr.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.exp b/gdb/testsuite/gdb.python/py-framefilter-addr.exp
index dbc3250..14eebc2 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-addr.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-addr.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.py b/gdb/testsuite/gdb.python/py-framefilter-addr.py
index c22d91c..513bf6f 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-addr.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-addr.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-gdb.py b/gdb/testsuite/gdb.python/py-framefilter-gdb.py
index ada7ad7..a725dce 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-gdb.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py b/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py
index fbe0c0d..51922fc 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2024 Free Software Foundation, Inc.
+# Copyright (C) 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
index 0e78f8d..c58dd01 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2024 Free Software Foundation, Inc.
+# Copyright (C) 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
index cb25cd9..b262968 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2024 Free Software Foundation, Inc.
+# Copyright (C) 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.c b/gdb/testsuite/gdb.python/py-framefilter-mi.c
index 35f21b2..cba2b65 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-mi.c
+++ b/gdb/testsuite/gdb.python/py-framefilter-mi.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.exp b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
index c6644e5..de04236 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-mi.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter.c b/gdb/testsuite/gdb.python/py-framefilter.c
index 135ead9..1b3d862 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.c
+++ b/gdb/testsuite/gdb.python/py-framefilter.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp
index 3a325bd..7cc8b01 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py
index fb679f1..5c3790d 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.py
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp
index 6de3b34..e618a13 100644
--- a/gdb/testsuite/gdb.python/py-function.exp
+++ b/gdb/testsuite/gdb.python/py-function.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-inferior-leak.c b/gdb/testsuite/gdb.python/py-inferior-leak.c
index 7b7b92a..a8d19f2 100644
--- a/gdb/testsuite/gdb.python/py-inferior-leak.c
+++ b/gdb/testsuite/gdb.python/py-inferior-leak.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-inferior-leak.exp b/gdb/testsuite/gdb.python/py-inferior-leak.exp
index a068ebb..15216ee 100644
--- a/gdb/testsuite/gdb.python/py-inferior-leak.exp
+++ b/gdb/testsuite/gdb.python/py-inferior-leak.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,15 +24,5 @@ standard_testfile
clean_restart
-# Skip this test if the tracemalloc module is not available.
-if { ![gdb_py_module_available "tracemalloc"] } {
- unsupported "tracemalloc module not available"
- return
-}
-
-set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
-
-# Source the Python script, this runs the test (which is written
-# completely in Python), and either prints PASS, or throws an
-# exception.
-gdb_test "source ${pyfile}" "PASS" "source python script"
+gdb_py_run_memory_leak_test ${srcdir}/${subdir}/${testfile}.py \
+ "gdb.Inferior object deallocates correctly"
diff --git a/gdb/testsuite/gdb.python/py-inferior-leak.py b/gdb/testsuite/gdb.python/py-inferior-leak.py
index ae3629a..bf61668 100644
--- a/gdb/testsuite/gdb.python/py-inferior-leak.py
+++ b/gdb/testsuite/gdb.python/py-inferior-leak.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -13,100 +13,39 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import re
-import tracemalloc
-
-import gdb
-
-# A global variable in which we store a reference to the gdb.Inferior
-# object sent to us in the new_inferior event.
-inf = None
-
-
-# Register the new_inferior event handler.
-def new_inferior_handler(event):
- global inf
- inf = event.inferior
-
-
-gdb.events.new_inferior.connect(new_inferior_handler)
+import sys
-# A global filters list, we only care about memory allocations
-# originating from this script.
-filters = [tracemalloc.Filter(True, "*py-inferior-leak.py")]
+# Avoid generating
+# src/gdb/testsuite/gdb.python/__pycache__/gdb_leak_detector.cpython-<n>.pyc.
+sys.dont_write_bytecode = True
+import re
-# Add a new inferior, and return the number of the new inferior.
-def add_inferior():
- output = gdb.execute("add-inferior", False, True)
- m = re.search(r"Added inferior (\d+)", output)
- if m:
- num = int(m.group(1))
- else:
- raise RuntimeError("no match")
- return num
-
-
-# Run the test. When CLEAR is True we clear the global INF variable
-# before comparing the before and after memory allocation traces.
-# When CLEAR is False we leave INF set to reference the gdb.Inferior
-# object, thus preventing the gdb.Inferior from being deallocated.
-def test(clear):
- global filters, inf
-
- # Start tracing, and take a snapshot of the current allocations.
- tracemalloc.start()
- snapshot1 = tracemalloc.take_snapshot()
-
- # Create an inferior, this triggers the new_inferior event, which
- # in turn holds a reference to the new gdb.Inferior object in the
- # global INF variable.
- num = add_inferior()
- gdb.execute("remove-inferiors %s" % num)
-
- # Possibly clear the global INF variable.
- if clear:
- inf = None
-
- # Now grab a second snapshot of memory allocations, and stop
- # tracing memory allocations.
- snapshot2 = tracemalloc.take_snapshot()
- tracemalloc.stop()
+import gdb_leak_detector
- # Filter the snapshots; we only care about allocations originating
- # from this file.
- snapshot1 = snapshot1.filter_traces(filters)
- snapshot2 = snapshot2.filter_traces(filters)
- # Compare the snapshots, this leaves only things that were
- # allocated, but not deallocated since the first snapshot.
- stats = snapshot2.compare_to(snapshot1, "traceback")
+class inferior_leak_detector(gdb_leak_detector.gdb_leak_detector):
+ def __init__(self):
+ super().__init__(__file__)
+ self.inferior = None
+ self.__handler = lambda event: setattr(self, "inferior", event.inferior)
+ gdb.events.new_inferior.connect(self.__handler)
- # Total up all the deallocated things.
- total = 0
- for stat in stats:
- total += stat.size_diff
- return total
+ def __del__(self):
+ gdb.events.new_inferior.disconnect(self.__handler)
+ def allocate(self):
+ output = gdb.execute("add-inferior", False, True)
+ m = re.search(r"Added inferior (\d+)", output)
+ if m:
+ num = int(m.group(1))
+ else:
+ raise RuntimeError("no match")
-# The first time we run this some global state will be allocated which
-# shows up as memory that is allocated, but not released. So, run the
-# test once and discard the result.
-test(True)
+ gdb.execute("remove-inferiors %s" % num)
-# Now run the test twice, the first time we clear our global reference
-# to the gdb.Inferior object, which should allow Python to deallocate
-# the object. The second time we hold onto the global reference,
-# preventing Python from performing the deallocation.
-bytes_with_clear = test(True)
-bytes_without_clear = test(False)
+ def deallocate(self):
+ self.inferior = None
-# The bug that used to exist in GDB was that even when we released the
-# global reference the gdb.Inferior object would not be deallocated.
-if bytes_with_clear > 0:
- raise gdb.GdbError("memory leak when gdb.Inferior should be released")
-if bytes_without_clear == 0:
- raise gdb.GdbError("gdb.Inferior object is no longer allocated")
-# Print a PASS message that the test script can see.
-print("PASS")
+inferior_leak_detector().run()
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index 58475bd..62af1a4 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -32,8 +32,8 @@ save_vars { env(ASAN_OPTIONS) env(TSAN_OPTIONS) } {
# triggers address sanitizer. Suppress the error, leaving us with just
# this warning:
# WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
- set_sanitizer ASAN_OPTIONS allocator_may_return_null 1
- set_sanitizer TSAN_OPTIONS allocator_may_return_null 1
+ append_environment ASAN_OPTIONS allocator_may_return_null 1
+ append_environment TSAN_OPTIONS allocator_may_return_null 1
clean_restart ${testfile}
}
diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp
index 9b05165..40c90b4 100644
--- a/gdb/testsuite/gdb.python/py-infthread.exp
+++ b/gdb/testsuite/gdb.python/py-infthread.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.c b/gdb/testsuite/gdb.python/py-label-symbol-value.c
index 8f6258e..0e92d58 100644
--- a/gdb/testsuite/gdb.python/py-label-symbol-value.c
+++ b/gdb/testsuite/gdb.python/py-label-symbol-value.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.exp b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
index a8360e6..ca534d4 100644
--- a/gdb/testsuite/gdb.python/py-label-symbol-value.exp
+++ b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
@@ -1,4 +1,4 @@
-# Copyright 2022-2024 Free Software Foundation, Inc.
+# Copyright 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.c b/gdb/testsuite/gdb.python/py-lazy-string.c
index 805ba92..7eaf7fd 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.c
+++ b/gdb/testsuite/gdb.python/py-lazy-string.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2015-2024 Free Software Foundation, Inc.
+ Copyright 2015-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index d212e61..7e7272e 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-linetable-empty.c b/gdb/testsuite/gdb.python/py-linetable-empty.c
index 85e5588..0e6da2d 100644
--- a/gdb/testsuite/gdb.python/py-linetable-empty.c
+++ b/gdb/testsuite/gdb.python/py-linetable-empty.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-linetable-empty.exp b/gdb/testsuite/gdb.python/py-linetable-empty.exp
index 2b7f8be..1e737e1 100644
--- a/gdb/testsuite/gdb.python/py-linetable-empty.exp
+++ b/gdb/testsuite/gdb.python/py-linetable-empty.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-linetable.S b/gdb/testsuite/gdb.python/py-linetable.S
index 5400bc0..f17faa7 100644
--- a/gdb/testsuite/gdb.python/py-linetable.S
+++ b/gdb/testsuite/gdb.python/py-linetable.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2013-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdb/testsuite/gdb.python/py-linetable.c b/gdb/testsuite/gdb.python/py-linetable.c
index 68f3226..d44ffb5 100644
--- a/gdb/testsuite/gdb.python/py-linetable.c
+++ b/gdb/testsuite/gdb.python/py-linetable.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index 5caa7c4..d27d16e 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -1,4 +1,4 @@
-# Copyright 2013-2024 Free Software Foundation, Inc.
+# Copyright 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-lookup-type.exp b/gdb/testsuite/gdb.python/py-lookup-type.exp
index 0b2f334..8673d56 100644
--- a/gdb/testsuite/gdb.python/py-lookup-type.exp
+++ b/gdb/testsuite/gdb.python/py-lookup-type.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.exp
index db017c6..7c630f6 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2024 Free Software Foundation, Inc.
+# Copyright (C) 2019-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.py b/gdb/testsuite/gdb.python/py-mi-cmd.py
index ad75c3b..7bfe188 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.py
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2024 Free Software Foundation, Inc.
+# Copyright (C) 2019-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-mi-events-gdb.py b/gdb/testsuite/gdb.python/py-mi-events-gdb.py
index 94ecddb..ea5f470 100644
--- a/gdb/testsuite/gdb.python/py-mi-events-gdb.py
+++ b/gdb/testsuite/gdb.python/py-mi-events-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2024 Free Software Foundation, Inc.
+# Copyright (C) 2016-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-events.c b/gdb/testsuite/gdb.python/py-mi-events.c
index d3b727e..d5df385 100644
--- a/gdb/testsuite/gdb.python/py-mi-events.c
+++ b/gdb/testsuite/gdb.python/py-mi-events.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2016-2024 Free Software Foundation, Inc.
+ Copyright 2016-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-events.exp b/gdb/testsuite/gdb.python/py-mi-events.exp
index d5de247..ecdb74a 100644
--- a/gdb/testsuite/gdb.python/py-mi-events.exp
+++ b/gdb/testsuite/gdb.python/py-mi-events.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-notify.exp b/gdb/testsuite/gdb.python/py-mi-notify.exp
index 7776976..e7b1521 100644
--- a/gdb/testsuite/gdb.python/py-mi-notify.exp
+++ b/gdb/testsuite/gdb.python/py-mi-notify.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-mi-objfile-gdb.py b/gdb/testsuite/gdb.python/py-mi-objfile-gdb.py
index f5a032e..0ae75b0 100644
--- a/gdb/testsuite/gdb.python/py-mi-objfile-gdb.py
+++ b/gdb/testsuite/gdb.python/py-mi-objfile-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-objfile.c b/gdb/testsuite/gdb.python/py-mi-objfile.c
index 59fd2bf..829419c 100644
--- a/gdb/testsuite/gdb.python/py-mi-objfile.c
+++ b/gdb/testsuite/gdb.python/py-mi-objfile.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2015-2024 Free Software Foundation, Inc.
+ Copyright 2015-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-objfile.exp b/gdb/testsuite/gdb.python/py-mi-objfile.exp
index 28b4589..58ecbc5 100644
--- a/gdb/testsuite/gdb.python/py-mi-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-mi-objfile.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.c b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.c
index 5e46442..6bd4b65 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.c
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright (C) 2018-2024 Free Software Foundation, Inc.
+ Copyright (C) 2018-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
index f7e072e..07cd40f 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2024 Free Software Foundation, Inc.
+# Copyright (C) 2018-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
index 889188f..e7638db 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2024 Free Software Foundation, Inc.
+# Copyright (C) 2018-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
index dad909a..7f1dffc 100644
--- a/gdb/testsuite/gdb.python/py-mi.exp
+++ b/gdb/testsuite/gdb.python/py-mi.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.c b/gdb/testsuite/gdb.python/py-missing-debug.c
index ca3e5ab..df3db4d 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.c
+++ b/gdb/testsuite/gdb.python/py-missing-debug.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.exp b/gdb/testsuite/gdb.python/py-missing-debug.exp
index dfc0a46..f028711 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.exp
+++ b/gdb/testsuite/gdb.python/py-missing-debug.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.py b/gdb/testsuite/gdb.python/py-missing-debug.py
index c1bafdd..c018d4d 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.py
+++ b/gdb/testsuite/gdb.python/py-missing-debug.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-missing-objfile-lib.c b/gdb/testsuite/gdb.python/py-missing-objfile-lib.c
index 8d740b4..179c329 100644
--- a/gdb/testsuite/gdb.python/py-missing-objfile-lib.c
+++ b/gdb/testsuite/gdb.python/py-missing-objfile-lib.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.c b/gdb/testsuite/gdb.python/py-missing-objfile.c
index 953e1c0..c5e8a63 100644
--- a/gdb/testsuite/gdb.python/py-missing-objfile.c
+++ b/gdb/testsuite/gdb.python/py-missing-objfile.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.exp b/gdb/testsuite/gdb.python/py-missing-objfile.exp
index 8afd547..29bc555 100644
--- a/gdb/testsuite/gdb.python/py-missing-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-missing-objfile.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -79,6 +79,16 @@ proc setup_debugdir { dirname files } {
# executable (when EXEC_LOADED is true) and/or the library (when LIB_LOADED
# is true).
proc check_loaded_debug { exec_loaded lib_loaded } {
+ set re_warn \
+ [string_to_regexp \
+ "Warning: the current language does not match this frame."]
+ set cmd "set lang c"
+ gdb_test_multiple $cmd "" {
+ -re -wrap "${cmd}(\r\n$re_warn)?" {
+ pass $gdb_test_name
+ }
+ }
+
if { $exec_loaded } {
gdb_test "whatis global_exec_var" "^type = volatile struct exec_type"
diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.py b/gdb/testsuite/gdb.python/py-missing-objfile.py
index 5bb8179..5efc36a 100644
--- a/gdb/testsuite/gdb.python/py-missing-objfile.py
+++ b/gdb/testsuite/gdb.python/py-missing-objfile.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.c b/gdb/testsuite/gdb.python/py-nested-maps.c
index 6cd78f7..a9480a3 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.c
+++ b/gdb/testsuite/gdb.python/py-nested-maps.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2019-2024 Free Software Foundation, Inc.
+ Copyright 2019-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.exp b/gdb/testsuite/gdb.python/py-nested-maps.exp
index 752b3a3..884b259 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.exp
+++ b/gdb/testsuite/gdb.python/py-nested-maps.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2024 Free Software Foundation, Inc.
+# Copyright (C) 2019-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.py b/gdb/testsuite/gdb.python/py-nested-maps.py
index ac04bbf..8d65fd8 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.py
+++ b/gdb/testsuite/gdb.python/py-nested-maps.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2024 Free Software Foundation, Inc.
+# Copyright (C) 2019-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-objfile-script-gdb.py b/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
index 17a4217..8666074 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
+++ b/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-objfile-script.c b/gdb/testsuite/gdb.python/py-objfile-script.c
index ad9e421..1ce505d 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script.c
+++ b/gdb/testsuite/gdb.python/py-objfile-script.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2011-2024 Free Software Foundation, Inc.
+ Copyright 2011-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-objfile-script.exp b/gdb/testsuite/gdb.python/py-objfile-script.exp
index c8cd6ee..1a3d394 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script.exp
+++ b/gdb/testsuite/gdb.python/py-objfile-script.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index 1c38ff9..d721e0c 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2011-2024 Free Software Foundation, Inc.
+ Copyright 2011-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@ int global_var = 42;
static int __attribute__ ((used)) static_var = 50;
int
-main ()
+main (void)
{
int some_var = 0;
return 0;
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 2f5b775..8d11028 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -144,7 +144,8 @@ gdb_test "python print (sep_objfile.owner.filename)" "${testfile}2" \
gdb_test "python print (sep_objfile.owner.username)" "${testfile}2" \
"Test user-name of owner of separate debug file"
-gdb_test "p main" "= {int \\(\\)} $hex <main>" \
+set re_prototype [string_to_regexp "int (void)"]
+gdb_test "p main" "= {$re_prototype} $hex <main>" \
"print main with debug info"
# Separate debug files are not findable.
diff --git a/gdb/testsuite/gdb.python/py-parameter-prefix.exp b/gdb/testsuite/gdb.python/py-parameter-prefix.exp
new file mode 100644
index 0000000..eb09fe7
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-parameter-prefix.exp
@@ -0,0 +1,382 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It tests
+# gdb.ParameterPrefix. See each of the test procs for a full
+# description of what is being tested.
+
+load_lib gdb-python.exp
+
+require allow_python_tests
+
+clean_restart
+
+# Helper proc to generate the output of 'show PREFIX' commands for the
+# case where the prefix command doesn't handle unknown sub-commands.
+# In this case GDB will list the value of every sub-command under
+# PREFIX.
+proc make_show_prefix_re { prefix } {
+ return "$prefix param-1:\\s+The current value of '$prefix param-1' is \"off\"\\."
+}
+
+# Helper proc to generate the help text that describes all of the sub
+# commands under PREFIX. The MODE is either 'set' or 'show'. This
+# output will appear for 'help MODE PREFIX' and also for 'set PREFIX'.
+proc make_sub_cmd_help_re { mode prefix } {
+ if { $mode == "set" } {
+ set word "Set"
+ } else {
+ set word "Show"
+ }
+
+ return \
+ [multi_line \
+ "List of \"$mode $prefix\" subcommands:" \
+ "" \
+ "$mode $prefix param-1 -- $word the current value of '$prefix param-1'\\." \
+ "" \
+ "Type \"help $mode $prefix\" followed by subcommand name for full documentation\\." \
+ "Type \"apropos word\" to search for commands related to \"word\"\\." \
+ "Type \"apropos -v word\" for full documentation of commands related to \"word\"\\." \
+ "Command name abbreviations are allowed if unambiguous\\."]
+}
+
+# Helper proc to generate the output of 'help MODE PREFIX', where MODE
+# will be either 'set' or 'show'. The HELP_TEXT is the expected help
+# text for this prefix command, this should not be a regexp, as this
+# proc converts the text to a regexp.
+#
+# Return a single regexp which should match the output.
+proc make_help_re { mode prefix help_text } {
+ set help_re [string_to_regexp $help_text]
+
+ return \
+ [multi_line \
+ "$help_re" \
+ "" \
+ [make_sub_cmd_help_re $mode $prefix]]
+}
+
+# Create gdb.ParameterPrefix without using a sub-class, both with, and
+# without a doc string. For the doc string case, test single line,
+# and multi-line doc strings.
+proc_with_prefix test_basic_usage {} {
+ gdb_test_multiline "some basic ParameterPrefix usage" \
+ "python" "" \
+ "gdb.ParameterPrefix('prefix-1', gdb.COMMAND_NONE)" "" \
+ "gdb.Parameter('prefix-1 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.Parameter('prefix-1 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.ParameterPrefix('prefix-2', gdb.COMMAND_NONE," "" \
+ " \"\"\"This is prefix-2 help string.\"\"\")" "" \
+ "gdb.Parameter('prefix-2 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.ParameterPrefix('prefix-3', gdb.COMMAND_NONE," "" \
+ " \"\"\"This is prefix-3 help string." "" \
+ " " "" \
+ " This help text spans multiple lines.\"\"\")" "" \
+ "gdb.Parameter('prefix-3 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "end"
+
+ foreach mode { "set" "show" } {
+ gdb_test "help $mode prefix-1" \
+ [make_help_re $mode "prefix-1" \
+ "This command is not documented."]
+
+ gdb_test "help $mode prefix-2" \
+ [make_help_re $mode "prefix-2" \
+ "This is prefix-2 help string."]
+
+ gdb_test "help $mode prefix-3" \
+ [make_help_re $mode "prefix-3" \
+ [multi_line \
+ "This is prefix-3 help string." \
+ "" \
+ "This help text spans multiple lines."]]
+
+ foreach prefix { prefix-1 prefix-2 prefix-3 } {
+ gdb_test "$mode $prefix xxx" \
+ "^Undefined $mode $prefix command: \"xxx\"\\. Try \"help $mode $prefix\"\\."
+ }
+ }
+
+ foreach prefix { prefix-1 prefix-2 prefix-3 } {
+ gdb_test "set $prefix" \
+ [make_sub_cmd_help_re "set" $prefix]
+
+ gdb_test "show $prefix" \
+ [make_show_prefix_re $prefix]
+ }
+}
+
+# Create a sub-class of gdb.ParameterPrefix, but don't do anything
+# particularly interesting. Again test the with and without
+# documentation string cases.
+proc_with_prefix test_simple_sub_class {} {
+ gdb_test_multiline "some basic ParameterPrefix usage" \
+ "python" "" \
+ "class BasicParamPrefix(gdb.ParameterPrefix):" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ "BasicParamPrefix('prefix-4')" "" \
+ "gdb.Parameter('prefix-4 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "class BasicParamPrefixWithSingleLineDoc(gdb.ParameterPrefix):" "" \
+ " \"\"\"This is a single line doc string.\"\"\"" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ "BasicParamPrefixWithSingleLineDoc('prefix-5')" "" \
+ "gdb.Parameter('prefix-5 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "class BasicParamPrefixWithMultiLineDoc(gdb.ParameterPrefix):" "" \
+ " \"\"\"This is a multi line doc string." "" \
+ " " "" \
+ " The rest of the doc string is here.\"\"\"" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ "BasicParamPrefixWithMultiLineDoc('prefix-6')" "" \
+ "gdb.Parameter('prefix-6 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "class BasicParamPrefixWithDocParameter(gdb.ParameterPrefix):" "" \
+ " \"\"\"This is an unsused doc string.\"\"\"" "" \
+ " def __init__(self, name, doc):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE, doc)" "" \
+ "BasicParamPrefixWithDocParameter('prefix-7'," "" \
+ " \"\"\"The doc string text is here.\"\"\")" "" \
+ "gdb.Parameter('prefix-7 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "end"
+
+ foreach mode { "set" "show" } {
+ gdb_test "help $mode prefix-4" \
+ [make_help_re $mode "prefix-4" \
+ "This command is not documented."]
+
+ gdb_test "help $mode prefix-5" \
+ [make_help_re $mode "prefix-5" \
+ "This is a single line doc string."]
+
+ gdb_test "help $mode prefix-6" \
+ [make_help_re $mode "prefix-6" \
+ [multi_line \
+ "This is a multi line doc string." \
+ "" \
+ "The rest of the doc string is here."]]
+
+ gdb_test "help $mode prefix-7" \
+ [make_help_re $mode "prefix-7" \
+ "The doc string text is here."]
+
+ foreach prefix { prefix-4 prefix-5 prefix-6 prefix-7 } {
+ gdb_test "$mode $prefix xxx" \
+ "^Undefined $mode $prefix command: \"xxx\"\\. Try \"help $mode $prefix\"\\."
+ }
+ }
+
+ foreach prefix { prefix-4 prefix-5 prefix-6 prefix-7 } {
+ gdb_test "set $prefix" \
+ [make_sub_cmd_help_re "set" $prefix]
+
+ gdb_test "show $prefix" \
+ [make_show_prefix_re $prefix]
+ }
+}
+
+# Create a sub-class of gdb.ParameterPrefix, and make use of
+# 'invoke_set' and 'invoke_show'. Test that the invoke method is
+# executed when expected, and that, by default, these invoke methods
+# repeat when the user issues an empty command.
+proc_with_prefix test_prefix_with_invoke {} {
+ gdb_test_multiline "ParameterPrefix with invoke_set" \
+ "python" "" \
+ "class PrefixWithInvokeSet(gdb.ParameterPrefix):" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ " def invoke_set(self, args, from_tty):" "" \
+ " print(f\"invoke_set (a): \\\"{args}\\\" {from_tty}\")" "" \
+ "PrefixWithInvokeSet('prefix-8')" "" \
+ "gdb.Parameter('prefix-8 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "class PrefixWithInvokeShow(gdb.ParameterPrefix):" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ " def invoke_show(self, args, from_tty):" "" \
+ " print(f\"invoke_show (b): \\\"{args}\\\" {from_tty}\")" "" \
+ "PrefixWithInvokeShow('prefix-9')" "" \
+ "gdb.Parameter('prefix-9 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "class PrefixWithBothInvoke(gdb.ParameterPrefix):" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ " def invoke_set(self, args, from_tty):" "" \
+ " print(f\"invoke_set (c): \\\"{args}\\\" {from_tty}\")" "" \
+ " def invoke_show(self, args, from_tty):" "" \
+ " print(f\"invoke_show (d): \\\"{args}\\\" {from_tty}\")" "" \
+ "PrefixWithBothInvoke('prefix-10')" "" \
+ "gdb.Parameter('prefix-10 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "end"
+
+ gdb_test "set prefix-8 xxx yyy" \
+ "^invoke_set \\(a\\): \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^\r\ninvoke_set \\(a\\): \"xxx yyy\" True" \
+ "repeat set prefix-8 xxx yyy"
+
+ gdb_test "show prefix-8 xxx yyy" \
+ "^Undefined show prefix-8 command: \"xxx yyy\"\\. Try \"help show prefix-8\"\\."
+
+ gdb_test "set prefix-9 xxx yyy" \
+ "^Undefined set prefix-9 command: \"xxx yyy\"\\. Try \"help set prefix-9\"\\."
+
+ gdb_test "show prefix-9 xxx yyy" \
+ "^invoke_show \\(b\\): \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^\r\ninvoke_show \\(b\\): \"xxx yyy\" True" \
+ "repeat show prefix-9 xxx yyy"
+
+ gdb_test "set prefix-10 xxx yyy" \
+ "^invoke_set \\(c\\): \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^\r\ninvoke_set \\(c\\): \"xxx yyy\" True" \
+ "repeat set prefix-10 xxx yyy"
+
+ gdb_test "show prefix-10 xxx yyy" \
+ "^invoke_show \\(d\\): \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^\r\ninvoke_show \\(d\\): \"xxx yyy\" True" \
+ "repeat show prefix-10 xxx yyy"
+
+ gdb_test "set prefix-8" \
+ "^invoke_set \\(a\\): \"\" True"
+
+ gdb_test "show prefix-8" \
+ [make_show_prefix_re "prefix-8"]
+
+ gdb_test "set prefix-9" \
+ [make_sub_cmd_help_re "set" "prefix-9"]
+
+ gdb_test "show prefix-9" \
+ "^invoke_show \\(b\\): \"\" True"
+
+ gdb_test "set prefix-10" \
+ "^invoke_set \\(c\\): \"\" True"
+
+ gdb_test "show prefix-10" \
+ "^invoke_show \\(d\\): \"\" True"
+}
+
+# Create ParameterPrefix sub-classes that make use of the
+# dont_repeat() method. Check that the relevant set/show invoke
+# callback doesn't repeat when an empty command is used.
+proc_with_prefix test_dont_repeat {} {
+ gdb_test_multiline "ParameterPrefix with invoke_set and dont_repeat" \
+ "python" "" \
+ "class PrefixWithInvokeAndDoNotRepeatSet(gdb.ParameterPrefix):" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ " def invoke_set(self, args, from_tty):" "" \
+ " self.dont_repeat()" "" \
+ " print(f\"invoke_set: \\\"{args}\\\" {from_tty}\")" "" \
+ " def invoke_show(self, args, from_tty):" "" \
+ " print(f\"invoke_show: \\\"{args}\\\" {from_tty}\")" "" \
+ "PrefixWithInvokeAndDoNotRepeatSet('prefix-11')" "" \
+ "gdb.Parameter('prefix-11 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "class PrefixWithInvokeAndDoNotRepeatShow(gdb.ParameterPrefix):" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE)" "" \
+ " def invoke_set(self, args, from_tty):" "" \
+ " print(f\"invoke_set: \\\"{args}\\\" {from_tty}\")" "" \
+ " def invoke_show(self, args, from_tty):" "" \
+ " self.dont_repeat()" "" \
+ " print(f\"invoke_show: \\\"{args}\\\" {from_tty}\")" "" \
+ "PrefixWithInvokeAndDoNotRepeatShow('prefix-12')" "" \
+ "gdb.Parameter('prefix-12 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "end"
+
+ gdb_test "set prefix-11 xxx yyy" \
+ "^invoke_set: \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^" \
+ "repeat set prefix-11 xxx yyy"
+
+ gdb_test "show prefix-11 xxx yyy" \
+ "^invoke_show: \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "invoke_show: \"xxx yyy\" True" \
+ "repeat show prefix-11 xxx yyy"
+
+ gdb_test "set prefix-12 xxx yyy" \
+ "^invoke_set: \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^\r\ninvoke_set: \"xxx yyy\" True" \
+ "repeat set prefix-12 xxx yyy"
+
+ gdb_test "show prefix-12 xxx yyy" \
+ "^invoke_show: \"xxx yyy\" True"
+
+ send_gdb "\n"
+ gdb_test "" "^" \
+ "repeat show prefix-12 xxx yyy"
+}
+
+# Create a parameter prefixm, and immediately add another prefix under
+# the first. The important thing here is that the second prefix is
+# created into an otherwise empty prefix as this triggered a bug at
+# one point.
+proc_with_prefix test_nested {} {
+ gdb_test_multiline "Create nested parameter prefixes" \
+ "python" "" \
+ "gdb.ParameterPrefix('prefix-13', gdb.COMMAND_NONE)" "" \
+ "gdb.ParameterPrefix('prefix-13 prefix-14', gdb.COMMAND_NONE)" "" \
+ "gdb.Parameter('prefix-13 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.Parameter('prefix-13 param-2', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.Parameter('prefix-13 prefix-14 param-3', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.Parameter('prefix-13 prefix-14 param-4', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "end" ""
+
+ gdb_test "show prefix-13 prefix-14" \
+ [multi_line \
+ "^prefix-13 prefix-14 param-3: The current value of 'prefix-13 prefix-14 param-3' is \"off\"\\." \
+ "prefix-13 prefix-14 param-4: The current value of 'prefix-13 prefix-14 param-4' is \"off\"\\."]
+
+ gdb_test "show prefix-13" \
+ [multi_line \
+ "^prefix-13 param-1: The current value of 'prefix-13 param-1' is \"off\"\\." \
+ "prefix-13 param-2: The current value of 'prefix-13 param-2' is \"off\"\\." \
+ "prefix-13 prefix-14 param-3: The current value of 'prefix-13 prefix-14 param-3' is \"off\"\\." \
+ "prefix-13 prefix-14 param-4: The current value of 'prefix-13 prefix-14 param-4' is \"off\"\\."]
+
+ gdb_test "set prefix-13 prefix-14" \
+ [multi_line \
+ "" \
+ "set prefix-13 prefix-14 param-3 -- Set the current value of 'prefix-13 prefix-14 param-3'\\." \
+ "set prefix-13 prefix-14 param-4 -- Set the current value of 'prefix-13 prefix-14 param-4'\\." \
+ "" \
+ ".*"]
+
+ gdb_test "set prefix-13" \
+ [multi_line \
+ "" \
+ "set prefix-13 param-1 -- Set the current value of 'prefix-13 param-1'\\." \
+ "set prefix-13 param-2 -- Set the current value of 'prefix-13 param-2'\\." \
+ "set prefix-13 prefix-14 -- This command is not documented\\." \
+ "" \
+ ".*"]
+}
+
+test_basic_usage
+test_simple_sub_class
+test_prefix_with_invoke
+test_dont_repeat
+test_nested
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index 74e4178..214c570 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -346,6 +346,91 @@ proc_with_prefix test_really_undocumented_parameter { } {
"test general help"
}
+# Test a parameter in which the __doc__ string is empty or None.
+proc_with_prefix test_empty_doc_parameter {} {
+ gdb_test_multiline "empty __doc__ parameter" \
+ "python" "" \
+ "class EmptyDocParam(gdb.Parameter):" "" \
+ " __doc__ = \"\"" "" \
+ " def __init__(self, name):" "" \
+ " super ().__init__(name, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ " self.value = True" "" \
+ "test_empty_doc_param = EmptyDocParam('print test-empty-doc-param')" ""\
+ "end"
+
+ # Setting the __doc__ string to empty means GDB will completely
+ # elide it from the output.
+ gdb_test "help set print test-empty-doc-param" \
+ "^Set the current value of 'print test-empty-doc-param'\\."
+
+ gdb_test_multiline "None __doc__ parameter" \
+ "python" "" \
+ "class NoneDocParam(gdb.Parameter):" "" \
+ " __doc__ = None" "" \
+ " def __init__(self, name):" "" \
+ " super ().__init__(name, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ " self.value = True" "" \
+ "test_none_doc_param = NoneDocParam('print test-none-doc-param')" ""\
+ "end"
+
+ # Setting the __doc__ string to None, or anything else that isn't
+ # a string, causes GDB to use a default string instead.
+ gdb_test "help set print test-none-doc-param" \
+ [multi_line \
+ "^Set the current value of 'print test-none-doc-param'\\." \
+ "This command is not documented\\."]
+}
+
+# Test a parameter in which the set_doc/show_doc strings are either
+# empty, or None.
+proc_with_prefix test_empty_set_show_doc_parameter {} {
+ gdb_test_multiline "empty set/show doc parameter" \
+ "python" "" \
+ "class EmptySetShowParam(gdb.Parameter):" "" \
+ " set_doc = \"\"" "" \
+ " show_doc = \"\"" "" \
+ " def __init__(self, name):" "" \
+ " super ().__init__(name, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ " self.value = True" "" \
+ "test_empty_set_show_param = EmptySetShowParam('print test-empty-set-show-param')" ""\
+ "end"
+
+ # Setting the set_doc/show_doc string to empty means GDB will use
+ # a suitable default string.
+ gdb_test "help set print test-empty-set-show-param" \
+ [multi_line \
+ "^Set the current value of 'print test-empty-set-show-param'\\." \
+ "This command is not documented\\."]
+
+ gdb_test "help show print test-empty-set-show-param" \
+ [multi_line \
+ "^Show the current value of 'print test-empty-set-show-param'\\." \
+ "This command is not documented\\."]
+
+ gdb_test_multiline "None set/show doc parameter" \
+ "python" "" \
+ "class NoneSetShowParam(gdb.Parameter):" "" \
+ " set_doc = None" "" \
+ " show_doc = None" "" \
+ " def __init__(self, name):" "" \
+ " super ().__init__(name, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ " self.value = True" "" \
+ "test_none_set_show_param = NoneSetShowParam('print test-none-set-show-param')" ""\
+ "end"
+
+ # Setting the set_doc/show_doc string to None (or any non-string
+ # value) means GDB will use a suitable default string.
+ gdb_test "help set print test-none-set-show-param" \
+ [multi_line \
+ "^Set the current value of 'print test-none-set-show-param'\\." \
+ "This command is not documented\\."]
+
+ gdb_test "help show print test-none-set-show-param" \
+ [multi_line \
+ "^Show the current value of 'print test-none-set-show-param'\\." \
+ "This command is not documented\\."]
+}
+
# Test deprecated API. Do not use in your own implementations.
proc_with_prefix test_deprecated_api_parameter { } {
clean_restart
@@ -669,6 +754,104 @@ proc_with_prefix test_ambiguous_parameter {} {
"Parameter .* is ambiguous.*Error occurred in Python.*"
gdb_test "python print(gdb.parameter('test-ambiguous-value-1a'))" \
"Could not find parameter.*Error occurred in Python.*"
+
+ # Create command prefixs 'set foo1' and 'show foo1'.
+ gdb_test_no_output "python gdb.Command('set foo1', gdb.COMMAND_NONE, prefix=True)"
+ gdb_test_no_output "python gdb.Command('show foo1', gdb.COMMAND_NONE, prefix=True)"
+
+ # Create a parameter under 'foo1', but use a truncated prefix. At
+ # this point though, the prefix is not ambiguous.
+ gdb_test_no_output "python gdb.Parameter('foo bar', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)"
+ gdb_test "python print(gdb.parameter('foo1 bar'))" "False"
+
+ # Create another prefix command, similar in name to the first.
+ gdb_test_no_output "python gdb.Command('set foo2', gdb.COMMAND_NONE, prefix=True)"
+ gdb_test_no_output "python gdb.Command('show foo2', gdb.COMMAND_NONE, prefix=True)"
+
+ # An attempt to create a parameter using an ambiguous prefix will give an error.
+ gdb_test "python gdb.Parameter('foo baz', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" \
+ [multi_line \
+ "Python Exception <class 'RuntimeError'>: Could not find command prefix foo\\." \
+ "Error occurred in Python: Could not find command prefix foo\\."]
+}
+
+# Check that creating a gdb.Parameter with an unknown command prefix results in an error.
+proc_with_prefix test_unknown_prefix {} {
+ gdb_test_multiline "create parameter" \
+ "python" "" \
+ "class UnknownPrefixParam(gdb.Parameter):" "" \
+ " def __init__ (self, name):" "" \
+ " super().__init__ (name, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ " self.value = True" "" \
+ "end"
+
+ foreach prefix { "unknown-prefix" "style unknown-prefix" "style disassembler unknown-prefix"} {
+ gdb_test "python UnknownPrefixParam('$prefix new-param')" \
+ [multi_line \
+ "Python Exception <class 'RuntimeError'>: Could not find command prefix $prefix\\." \
+ "Error occurred in Python: Could not find command prefix $prefix\\."]
+ }
+}
+
+# Test the default behaviour of a set/show parameter prefix command.
+proc_with_prefix test_set_show_parameters {} {
+ # This first set/show prefix command doesn't have an invoke
+ # method. As such, GDB installs the default invoke behaviour; set
+ # prints the full list of sub-commands, and show prints all the
+ # sub-command values.
+ gdb_test_multiline "Setup set/show parameter prefix with no invoke" \
+ "python" "" \
+ "class TestParamPrefix(gdb.Command):" "" \
+ " \"\"\"TestParamPrefix documentation string.\"\"\"" "" \
+ " def __init__(self, name):" "" \
+ " super().__init__(name, gdb.COMMAND_NONE, prefix = True)" "" \
+ "TestParamPrefix('set test-prefix')" "" \
+ "TestParamPrefix('show test-prefix')" "" \
+ "gdb.Parameter('test-prefix param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.Parameter('test-prefix param-2', gdb.COMMAND_NONE, gdb.PARAM_INTEGER)" "" \
+ "gdb.Parameter('test-prefix param-3', gdb.COMMAND_NONE, gdb.PARAM_STRING)" "" \
+ "end"
+
+ gdb_test "set test-prefix" \
+ [multi_line \
+ "List of \"set test-prefix\" subcommands:" \
+ "" \
+ "set test-prefix param-1 -- Set the current value of 'test-prefix param-1'." \
+ "set test-prefix param-2 -- Set the current value of 'test-prefix param-2'." \
+ "set test-prefix param-3 -- Set the current value of 'test-prefix param-3'." \
+ "" \
+ "Type \"help set test-prefix\" followed by subcommand name for full documentation\\." \
+ "Type \"apropos word\" to search for commands related to \"word\"\\." \
+ "Type \"apropos -v word\" for full documentation of commands related to \"word\"\\." \
+ "Command name abbreviations are allowed if unambiguous\\."]
+
+ gdb_test "show test-prefix" \
+ [multi_line \
+ "test-prefix param-1: The current value of 'test-prefix param-1' is \"off\"\\." \
+ "test-prefix param-2: The current value of 'test-prefix param-2' is \"0\"\\." \
+ "test-prefix param-3: The current value of 'test-prefix param-3' is \"\"\\."]
+
+ # This next set/show prefix has an invoke method, which will be
+ # called instead of the default behaviour tested above.
+ gdb_test_multiline "Setup set/show parameter prefix with invoke" \
+ "python" "" \
+ "class TestParamPrefix(gdb.Command):" "" \
+ " \"\"\"TestParamPrefix documentation string.\"\"\"" "" \
+ " def __init__(self, name, mode):" "" \
+ " self._mode = mode" "" \
+ " super().__init__(self._mode + ' ' + name, gdb.COMMAND_NONE, prefix = True)" "" \
+ " def invoke(self, args, from_tty):" "" \
+ " print('invoke -- ' + self._mode)" "" \
+ "TestParamPrefix('test-prefix-2', 'set')" "" \
+ "TestParamPrefix('test-prefix-2', 'show')" "" \
+ "gdb.Parameter('test-prefix-2 param-1', gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN)" "" \
+ "gdb.Parameter('test-prefix-2 param-2', gdb.COMMAND_NONE, gdb.PARAM_INTEGER)" "" \
+ "gdb.Parameter('test-prefix-2 param-3', gdb.COMMAND_NONE, gdb.PARAM_STRING)" "" \
+ "end"
+
+ gdb_test "set test-prefix-2" "^invoke -- set"
+
+ gdb_test "show test-prefix-2" "^invoke -- show"
}
test_directories
@@ -679,11 +862,15 @@ test_color_parameter
test_file_parameter
test_undocumented_parameter
test_really_undocumented_parameter
+test_empty_doc_parameter
+test_empty_set_show_doc_parameter
test_deprecated_api_parameter
test_gdb_parameter
test_integer_parameter
test_throwing_parameter
test_language
test_ambiguous_parameter
+test_unknown_prefix
+test_set_show_parameters
rename py_param_test_maybe_no_output ""
diff --git a/gdb/testsuite/gdb.python/py-pending-frame-level.c b/gdb/testsuite/gdb.python/py-pending-frame-level.c
index dba64b8..56734ad 100644
--- a/gdb/testsuite/gdb.python/py-pending-frame-level.c
+++ b/gdb/testsuite/gdb.python/py-pending-frame-level.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pending-frame-level.exp b/gdb/testsuite/gdb.python/py-pending-frame-level.exp
index dcefdce..4eb82c5 100644
--- a/gdb/testsuite/gdb.python/py-pending-frame-level.exp
+++ b/gdb/testsuite/gdb.python/py-pending-frame-level.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pending-frame-level.py b/gdb/testsuite/gdb.python/py-pending-frame-level.py
index 7742fda..8a9783b 100644
--- a/gdb/testsuite/gdb.python/py-pending-frame-level.py
+++ b/gdb/testsuite/gdb.python/py-pending-frame-level.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-cast.c b/gdb/testsuite/gdb.python/py-pp-cast.c
index be665bb..dcd4619 100644
--- a/gdb/testsuite/gdb.python/py-pp-cast.c
+++ b/gdb/testsuite/gdb.python/py-pp-cast.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-cast.exp b/gdb/testsuite/gdb.python/py-pp-cast.exp
index 61c2fba..7e20756 100644
--- a/gdb/testsuite/gdb.python/py-pp-cast.exp
+++ b/gdb/testsuite/gdb.python/py-pp-cast.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-cast.py b/gdb/testsuite/gdb.python/py-pp-cast.py
index c071920..515aa77 100644
--- a/gdb/testsuite/gdb.python/py-pp-cast.py
+++ b/gdb/testsuite/gdb.python/py-pp-cast.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-integral.c b/gdb/testsuite/gdb.python/py-pp-integral.c
index 1e13fc1..2c3afa1 100644
--- a/gdb/testsuite/gdb.python/py-pp-integral.c
+++ b/gdb/testsuite/gdb.python/py-pp-integral.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-integral.exp b/gdb/testsuite/gdb.python/py-pp-integral.exp
index 0635e05..8111d75 100644
--- a/gdb/testsuite/gdb.python/py-pp-integral.exp
+++ b/gdb/testsuite/gdb.python/py-pp-integral.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-integral.py b/gdb/testsuite/gdb.python/py-pp-integral.py
index 089ca5b..a87736c 100644
--- a/gdb/testsuite/gdb.python/py-pp-integral.py
+++ b/gdb/testsuite/gdb.python/py-pp-integral.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.c b/gdb/testsuite/gdb.python/py-pp-maint.c
index 3ef4f10..f40bbe5 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.c
+++ b/gdb/testsuite/gdb.python/py-pp-maint.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp
index 1ee206c..74d8e76 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.exp
+++ b/gdb/testsuite/gdb.python/py-pp-maint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.py b/gdb/testsuite/gdb.python/py-pp-maint.py
index 91c193f..8b96cc0 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.py
+++ b/gdb/testsuite/gdb.python/py-pp-maint.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.c b/gdb/testsuite/gdb.python/py-pp-re-notag.c
index 1e13fc1..2c3afa1 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.c
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.exp b/gdb/testsuite/gdb.python/py-pp-re-notag.exp
index 0635e05..8111d75 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.exp
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.py b/gdb/testsuite/gdb.python/py-pp-re-notag.py
index 00bc5c7..32ea2c9 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.py
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.c b/gdb/testsuite/gdb.python/py-pp-registration.c
index b597f14..5a95917 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.c
+++ b/gdb/testsuite/gdb.python/py-pp-registration.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp
index 4bfdf5e..c5e7f9a 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.exp
+++ b/gdb/testsuite/gdb.python/py-pp-registration.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.py b/gdb/testsuite/gdb.python/py-pp-registration.py
index 1b7eff8..e9f3dfb 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.py
+++ b/gdb/testsuite/gdb.python/py-pp-registration.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint-stub-2.cc b/gdb/testsuite/gdb.python/py-prettyprint-stub-2.cc
index 1988cc0..592200b 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint-stub-2.cc
+++ b/gdb/testsuite/gdb.python/py-prettyprint-stub-2.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint-stub.cc b/gdb/testsuite/gdb.python/py-prettyprint-stub.cc
index fc453d9..156532f 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint-stub.cc
+++ b/gdb/testsuite/gdb.python/py-prettyprint-stub.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint-stub.exp b/gdb/testsuite/gdb.python/py-prettyprint-stub.exp
index 2dab863..1c1d010 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint-stub.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint-stub.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint-stub.h b/gdb/testsuite/gdb.python/py-prettyprint-stub.h
index fa18165..cb17cb5 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint-stub.h
+++ b/gdb/testsuite/gdb.python/py-prettyprint-stub.h
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint-stub.py b/gdb/testsuite/gdb.python/py-prettyprint-stub.py
index 2378f55..b66086c 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint-stub.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint-stub.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index 312420b..56c19ad 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2008-2024 Free Software Foundation, Inc.
+ Copyright 2008-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index ec2bdc9..0b5ca9a 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py
index e4ac3e1..21c2569 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-progspace-events.c b/gdb/testsuite/gdb.python/py-progspace-events.c
index f8b2909..5c4dd4d 100644
--- a/gdb/testsuite/gdb.python/py-progspace-events.c
+++ b/gdb/testsuite/gdb.python/py-progspace-events.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-progspace-events.exp b/gdb/testsuite/gdb.python/py-progspace-events.exp
index 9dfc757..5ee9977 100644
--- a/gdb/testsuite/gdb.python/py-progspace-events.exp
+++ b/gdb/testsuite/gdb.python/py-progspace-events.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-progspace-events.py b/gdb/testsuite/gdb.python/py-progspace-events.py
index 23c6fc5..3a53fb16 100644
--- a/gdb/testsuite/gdb.python/py-progspace-events.py
+++ b/gdb/testsuite/gdb.python/py-progspace-events.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-progspace.c b/gdb/testsuite/gdb.python/py-progspace.c
index 80fcda0..170249b 100644
--- a/gdb/testsuite/gdb.python/py-progspace.c
+++ b/gdb/testsuite/gdb.python/py-progspace.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index fe46537..1d271d4 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prompt.c b/gdb/testsuite/gdb.python/py-prompt.c
index c7657d7..6718bb1 100644
--- a/gdb/testsuite/gdb.python/py-prompt.c
+++ b/gdb/testsuite/gdb.python/py-prompt.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2007-2024 Free Software Foundation, Inc.
+ Copyright 2007-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp
index 614fe9d..01176a3 100644
--- a/gdb/testsuite/gdb.python/py-prompt.exp
+++ b/gdb/testsuite/gdb.python/py-prompt.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2024 Free Software Foundation, Inc.
+# Copyright (C) 2011-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-rbreak-func2.c b/gdb/testsuite/gdb.python/py-rbreak-func2.c
index fdcece6..085d869 100644
--- a/gdb/testsuite/gdb.python/py-rbreak-func2.c
+++ b/gdb/testsuite/gdb.python/py-rbreak-func2.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2017-2024 Free Software Foundation, Inc.
+ Copyright 2017-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-rbreak.c b/gdb/testsuite/gdb.python/py-rbreak.c
index 1cc4561..4da4de4 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.c
+++ b/gdb/testsuite/gdb.python/py-rbreak.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-rbreak.exp b/gdb/testsuite/gdb.python/py-rbreak.exp
index dca8731..fe1e0fc 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.exp
+++ b/gdb/testsuite/gdb.python/py-rbreak.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2024 Free Software Foundation, Inc.
+# Copyright (C) 2017-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.c b/gdb/testsuite/gdb.python/py-read-memory-leak.c
index 75035cd..0319268 100644
--- a/gdb/testsuite/gdb.python/py-read-memory-leak.c
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2014-2024 Free Software Foundation, Inc.
+ Copyright 2014-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.exp b/gdb/testsuite/gdb.python/py-read-memory-leak.exp
index 52b072f..9ae5eb8 100644
--- a/gdb/testsuite/gdb.python/py-read-memory-leak.exp
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,15 +30,5 @@ if ![runto_main] {
return -1
}
-# Skip this test if the tracemalloc module is not available.
-if { ![gdb_py_module_available "tracemalloc"] } {
- unsupported "tracemalloc module not available"
- return
-}
-
-set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
-
-# Source the Python script, this runs the test (which is written
-# completely in Python), and either prints PASS, or throws an
-# exception.
-gdb_test "source ${pyfile}" "PASS" "source python script"
+gdb_py_run_memory_leak_test ${srcdir}/${subdir}/${testfile}.py \
+ "buffers returned by read_memory() deallocates correctly"
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.py b/gdb/testsuite/gdb.python/py-read-memory-leak.py
index 430c5c2..89647cf 100644
--- a/gdb/testsuite/gdb.python/py-read-memory-leak.py
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -13,81 +13,27 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
-import tracemalloc
+import sys
-import gdb
+# Avoid generating
+# src/gdb/testsuite/gdb.python/__pycache__/gdb_leak_detector.cpython-<n>.pyc.
+sys.dont_write_bytecode = True
-# A global variable in which we store a reference to the memory buffer
-# returned from gdb.Inferior.read_memory().
-mem_buf = None
+import gdb_leak_detector
-# A global filters list, we only care about memory allocations
-# originating from this script.
-filters = [tracemalloc.Filter(True, "*" + os.path.basename(__file__))]
+class read_leak_detector(gdb_leak_detector.gdb_leak_detector):
+ def __init__(self):
+ super().__init__(__file__)
+ self.mem_buf = None
+ self.addr = gdb.parse_and_eval("px")
+ self.inf = gdb.inferiors()[0]
+ def allocate(self):
+ self.mem_buf = self.inf.read_memory(self.addr, 4096)
-# Run the test. When CLEAR is True we clear the global INF variable
-# before comparing the before and after memory allocation traces.
-# When CLEAR is False we leave INF set to reference the gdb.Inferior
-# object, thus preventing the gdb.Inferior from being deallocated.
-def test(clear):
- global filters, mem_buf
+ def deallocate(self):
+ self.mem_buf = None
- addr = gdb.parse_and_eval("px")
- inf = gdb.inferiors()[0]
- # Start tracing, and take a snapshot of the current allocations.
- tracemalloc.start()
- snapshot1 = tracemalloc.take_snapshot()
-
- # Read from the inferior, this allocate a memory buffer object.
- mem_buf = inf.read_memory(addr, 4096)
-
- # Possibly clear the global INF variable.
- if clear:
- mem_buf = None
-
- # Now grab a second snapshot of memory allocations, and stop
- # tracing memory allocations.
- snapshot2 = tracemalloc.take_snapshot()
- tracemalloc.stop()
-
- # Filter the snapshots; we only care about allocations originating
- # from this file.
- snapshot1 = snapshot1.filter_traces(filters)
- snapshot2 = snapshot2.filter_traces(filters)
-
- # Compare the snapshots, this leaves only things that were
- # allocated, but not deallocated since the first snapshot.
- stats = snapshot2.compare_to(snapshot1, "traceback")
-
- # Total up all the allocated things.
- total = 0
- for stat in stats:
- total += stat.size_diff
- return total
-
-
-# The first time we run this some global state will be allocated which
-# shows up as memory that is allocated, but not released. So, run the
-# test once and discard the result.
-test(True)
-
-# Now run the test twice, the first time we clear our global reference
-# to the memory buffer object, which should allow Python to deallocate
-# the object. The second time we hold onto the global reference,
-# preventing Python from performing the deallocation.
-bytes_with_clear = test(True)
-bytes_without_clear = test(False)
-
-# The bug that used to exist in GDB was that even when we released the
-# global reference the gdb.Inferior object would not be deallocated.
-if bytes_with_clear > 0:
- raise gdb.GdbError("memory leak when memory buffer should be released")
-if bytes_without_clear == 0:
- raise gdb.GdbError("memory buffer object is no longer allocated")
-
-# Print a PASS message that the test script can see.
-print("PASS")
+read_leak_detector().run()
diff --git a/gdb/testsuite/gdb.python/py-record-btrace-threads.c b/gdb/testsuite/gdb.python/py-record-btrace-threads.c
index 2c2ef32..5058ce1 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace-threads.c
+++ b/gdb/testsuite/gdb.python/py-record-btrace-threads.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2017-2024 Free Software Foundation, Inc.
+ Copyright 2017-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
index d723879..4a3b59fb 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace-threads.exp
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.
#
-# Copyright 2017-2024 Free Software Foundation, Inc.
+# Copyright 2017-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.c b/gdb/testsuite/gdb.python/py-record-btrace.c
index abc0dcf..10c0d41 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.c
+++ b/gdb/testsuite/gdb.python/py-record-btrace.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2016-2024 Free Software Foundation, Inc.
+ Copyright 2016-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index b035e14..aff7c6c 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.
#
-# Copyright 2016-2024 Free Software Foundation, Inc.
+# Copyright 2016-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-record-full.c b/gdb/testsuite/gdb.python/py-record-full.c
index abc0dcf..10c0d41 100644
--- a/gdb/testsuite/gdb.python/py-record-full.c
+++ b/gdb/testsuite/gdb.python/py-record-full.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2016-2024 Free Software Foundation, Inc.
+ Copyright 2016-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp
index da38d1c..97d21ce 100644
--- a/gdb/testsuite/gdb.python/py-record-full.exp
+++ b/gdb/testsuite/gdb.python/py-record-full.exp
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.
#
-# Copyright 2016-2024 Free Software Foundation, Inc.
+# Copyright 2016-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-recurse-unwind.c b/gdb/testsuite/gdb.python/py-recurse-unwind.c
index 1ecdaa2..573ee3c 100644
--- a/gdb/testsuite/gdb.python/py-recurse-unwind.c
+++ b/gdb/testsuite/gdb.python/py-recurse-unwind.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2016-2024 Free Software Foundation, Inc.
+ Copyright 2016-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-recurse-unwind.exp b/gdb/testsuite/gdb.python/py-recurse-unwind.exp
index 1c22dc2..a1d1462 100644
--- a/gdb/testsuite/gdb.python/py-recurse-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-recurse-unwind.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2024 Free Software Foundation, Inc.
+# Copyright (C) 2016-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-recurse-unwind.py b/gdb/testsuite/gdb.python/py-recurse-unwind.py
index 0b0004b..244c693 100644
--- a/gdb/testsuite/gdb.python/py-recurse-unwind.py
+++ b/gdb/testsuite/gdb.python/py-recurse-unwind.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2024 Free Software Foundation, Inc.
+# Copyright (C) 2016-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
index 3403797..e3f71d0 100644
--- a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2012-2024 Free Software Foundation, Inc.
+ Copyright 2012-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
index 7e6f0d0..2e92756 100644
--- a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-section-script.c b/gdb/testsuite/gdb.python/py-section-script.c
index 2d465c2..2d08cbc 100644
--- a/gdb/testsuite/gdb.python/py-section-script.c
+++ b/gdb/testsuite/gdb.python/py-section-script.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index 206b8c6..cc4425c 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-section-script.py b/gdb/testsuite/gdb.python/py-section-script.py
index 73230c9..d85221e 100644
--- a/gdb/testsuite/gdb.python/py-section-script.py
+++ b/gdb/testsuite/gdb.python/py-section-script.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-send-packet.c b/gdb/testsuite/gdb.python/py-send-packet.c
index 1c97790..abdb71b 100644
--- a/gdb/testsuite/gdb.python/py-send-packet.c
+++ b/gdb/testsuite/gdb.python/py-send-packet.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-send-packet.exp b/gdb/testsuite/gdb.python/py-send-packet.exp
index bbee5ac..6c2984f 100644
--- a/gdb/testsuite/gdb.python/py-send-packet.exp
+++ b/gdb/testsuite/gdb.python/py-send-packet.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-send-packet.py b/gdb/testsuite/gdb.python/py-send-packet.py
index 402b039..0a0b359 100644
--- a/gdb/testsuite/gdb.python/py-send-packet.py
+++ b/gdb/testsuite/gdb.python/py-send-packet.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-shared-sl.c b/gdb/testsuite/gdb.python/py-shared-sl.c
index be736c2..49032ad 100644
--- a/gdb/testsuite/gdb.python/py-shared-sl.c
+++ b/gdb/testsuite/gdb.python/py-shared-sl.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-shared.c b/gdb/testsuite/gdb.python/py-shared.c
index 4b23980..dc28f32 100644
--- a/gdb/testsuite/gdb.python/py-shared.c
+++ b/gdb/testsuite/gdb.python/py-shared.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-shared.exp b/gdb/testsuite/gdb.python/py-shared.exp
index 9be5aa4..d80e139 100644
--- a/gdb/testsuite/gdb.python/py-shared.exp
+++ b/gdb/testsuite/gdb.python/py-shared.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-source-styling-2.c b/gdb/testsuite/gdb.python/py-source-styling-2.c
new file mode 100644
index 0000000..aaa3d69
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-source-styling-2.c
@@ -0,0 +1,26 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main ()
+{ /* List this line. */
+ try
+ {}
+ catch (...)
+ {}
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.python/py-source-styling-2.exp b/gdb/testsuite/gdb.python/py-source-styling-2.exp
new file mode 100644
index 0000000..ebf7f32
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-source-styling-2.exp
@@ -0,0 +1,55 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Compile a c++ file using a .c extension, and check that pygments uses c++
+# highlighting instead of c highlighting.
+
+require allow_python_tests
+
+load_lib gdb-python.exp
+
+standard_testfile py-source-styling-2.c
+
+set line_number [gdb_get_line_number "List this line."]
+
+set opts {}
+lappend opts debug
+lappend opts c++
+
+if { [build_executable "failed to build" $testfile $srcfile $opts] == -1 } {
+ return
+}
+
+with_ansi_styling_terminal {
+ clean_restart
+}
+
+gdb_test_no_output "maint set gnu-source-highlight enabled off"
+
+gdb_load $binfile
+
+require {gdb_py_module_available pygments}
+
+gdb_test_no_output "set style enabled on"
+
+gdb_test_multiple "list $line_number" "Styling of c++ keyword try" {
+ -re -wrap " try\r\n.*" {
+ # Unstyled.
+ fail $gdb_test_name
+ }
+ -re -wrap "" {
+ pass $gdb_test_name
+ }
+}
diff --git a/gdb/testsuite/gdb.python/py-source-styling.c b/gdb/testsuite/gdb.python/py-source-styling.c
index eda87a7..308da9c 100644
--- a/gdb/testsuite/gdb.python/py-source-styling.c
+++ b/gdb/testsuite/gdb.python/py-source-styling.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-source-styling.exp b/gdb/testsuite/gdb.python/py-source-styling.exp
index 7b5c1b0..308053c 100644
--- a/gdb/testsuite/gdb.python/py-source-styling.exp
+++ b/gdb/testsuite/gdb.python/py-source-styling.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -13,27 +13,66 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This file is part of the GDB testsuite. It checks for memory leaks
-# associated with allocating and deallocation gdb.Inferior objects.
+# Test related to source code highlighting and Python. Includes a
+# test for using the Pygments module as a fall back to GNU source
+# highlight.
+#
+# This script also includes tests for handling a non-uft-8 character
+# with both Pygments highlighting, and with gdb.execute (when using
+# the list command).
+
+require allow_python_tests
load_lib gdb-python.exp
standard_testfile
-with_ansi_styling_terminal {
- # We need an ANSI-capable terminal to get the output, additionally
- # we need to set LC_ALL so GDB knows the terminal is UTF-8
- # capable, otherwise we'll get a UnicodeEncodeError trying to
- # encode the output.
- if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
- return -1
+if { [build_executable "failed to build" ${testfile} ${srcfile}] == -1 } {
+ return
+}
+
+set line_number [gdb_get_line_number "List this line."]
+
+# Helper proc. Run CMD, which should produce a source listing, and
+# check if the source code is styled or not. EXPECT_STYLED indicates
+# if we expect the source listing to be styled or not.
+proc check_source_listing_styling { cmd expect_styled { testname "" } } {
+ if { $testname eq "" } {
+ set testname $cmd
+ }
+
+ set seen_style_escape false
+ gdb_test_multiple $cmd $testname {
+ -re -wrap "Python Exception.*" {
+ fail $gdb_test_name
+ return
+ }
+ -re "\033" {
+ set seen_style_escape true
+ exp_continue
+ }
+ -re "$::gdb_prompt $" {
+ gdb_assert { $seen_style_escape == $expect_styled } \
+ $gdb_test_name
+ }
}
+}
- if { ![allow_python_tests] } { continue }
+# Check that the Python pygments module can be used for source
+# highlighting when GNU source highlight is not available (or is
+# disabled, as is done in this test).
+proc test_pygments_styling {} {
+ clean_restart $::binfile
+
+ # Remote host boards disable styling via GDB's command line. Turn
+ # it back on now.
+ if {[is_remote host]} {
+ gdb_test "set style enabled on"
+ }
if { ![gdb_py_module_available "pygments"] } {
unsupported "pygments module not available"
- return -1
+ return
}
if ![runto_main] {
@@ -44,19 +83,102 @@ with_ansi_styling_terminal {
gdb_test "maint flush source-cache" "Source cache flushed\\."
- set seen_style_escape false
- set line_number [gdb_get_line_number "List this line."]
- gdb_test_multiple "list ${line_number}" "" {
- -re "Python Exception.*" {
- fail $gdb_test_name
- }
- -re "\033" {
- set seen_style_escape true
- exp_continue
- }
- -re "$gdb_prompt $" {
- gdb_assert { $seen_style_escape }
- pass $gdb_test_name
- }
+ check_source_listing_styling "list $::line_number" true
+}
+
+# Use gdb.execute to list source code containing non-utf-8 character.
+# Check that initially GDB fails to convert the source code to a
+# string, then set the correct host encoding, and try again. This
+# time the conversion should succeed.
+proc test_gdb_execute_non_utf8_source {} {
+ clean_restart $::binfile
+
+ # The default host charset is utf-8, the source code contains a
+ # non-utf-8 character, so this will fail.
+ gdb_test \
+ "python source = gdb.execute('list $::line_number', True, True)" \
+ [multi_line \
+ "Python Exception <class 'UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xc0 in position 250: ordinal not in range\\(128\\)" \
+ "Error occurred in Python: 'ascii' codec can't decode byte 0xc0 in position 250: ordinal not in range\\(128\\)"] \
+ "gdb.execute fails to convert result to string"
+
+ # Set the correct host charset, and try the conversion again.
+ gdb_test_no_output "set host-charset ISO-8859-1"
+ gdb_test_no_output \
+ "python source = gdb.execute('list $::line_number', True, True)" \
+ "gdb.execute does convert result to string"
+
+ # Check that we captured something that looks like the expected source.
+ gdb_test "python print(source)" ".*List this line.*"
+}
+
+# Use gdb.execute() to list source code. Alternate between asking for
+# styled, and unstyled source code. In some cases we ask for the
+# output to be returned via a string, and in other cases we ask for
+# the output to be sent straight to stdout.
+proc_with_prefix test_source_cache_style_tracking {} {
+ clean_restart $::binfile
+
+ # Remote host boards disable styling via GDB's command line. Turn
+ # it back on now.
+ if {[is_remote host]} {
+ gdb_test "set style enabled on"
+ }
+
+ gdb_test_no_output "set host-charset ISO-8859-1"
+
+ # Commands which return styled, and non-styled source code mixed
+ # together. This ensures that the source cache will need to keep
+ # discarding the entry with the wrong styling mode. All of these
+ # gdb.execute calls send their output via a string.
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', to_string=True), end='')" \
+ false
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', to_string=True, styling=True), end='')" \
+ true
+ foreach from_tty { True False } {
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', $from_tty, True), end='')" \
+ false
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', $from_tty, True, True), end='')" \
+ true
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', $from_tty, True, False), end='')" \
+ false
}
+
+ # The same again, but this time the output is sent directly to
+ # stdout.
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number')" \
+ true
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', to_string=False, styling=False)" \
+ false
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', to_string=False, styling=True)" \
+ true
+ foreach from_tty { True False } {
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', $from_tty, False, False)" \
+ false
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', $from_tty, False, True)" \
+ true
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', $from_tty, False)" \
+ true
+ }
+}
+
+# We need an ANSI-capable terminal to get the output, additionally we
+# need to set LC_ALL so GDB knows the terminal is UTF-8 capable,
+# otherwise we'll get a UnicodeEncodeError trying to encode the
+# output.
+with_ansi_styling_terminal {
+ test_pygments_styling
+ test_gdb_execute_non_utf8_source
+ test_source_cache_style_tracking
}
diff --git a/gdb/testsuite/gdb.python/py-startup-opt.exp b/gdb/testsuite/gdb.python/py-startup-opt.exp
index 038814a..7410706 100644
--- a/gdb/testsuite/gdb.python/py-startup-opt.exp
+++ b/gdb/testsuite/gdb.python/py-startup-opt.exp
@@ -1,4 +1,4 @@
-# Copyright 2021-2024 Free Software Foundation, Inc.
+# Copyright 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-strfns.c b/gdb/testsuite/gdb.python/py-strfns.c
index 21988fe..c3b846d 100644
--- a/gdb/testsuite/gdb.python/py-strfns.c
+++ b/gdb/testsuite/gdb.python/py-strfns.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2012-2024 Free Software Foundation, Inc.
+ Copyright 2012-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-strfns.exp b/gdb/testsuite/gdb.python/py-strfns.exp
index e8180ac..2b5dff19 100644
--- a/gdb/testsuite/gdb.python/py-strfns.exp
+++ b/gdb/testsuite/gdb.python/py-strfns.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-styled-execute.exp b/gdb/testsuite/gdb.python/py-styled-execute.exp
new file mode 100644
index 0000000..0b27c63
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-styled-execute.exp
@@ -0,0 +1,109 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check the the output of gdb.execute can be styled or not depending
+# on the value of the third argument passed to gdb.execute.
+
+require allow_python_tests
+
+load_lib gdb-python.exp
+
+# Use gdb.execute() to run CMD passing different argument values. The
+# output should match either STYLED_RE or UNSTYLED_RE depending on
+# whether the 'styling' argument is True or False.
+proc do_gdb_execute { cmd styled_re unstyled_re } {
+ gdb_test "python gdb.execute('$cmd')" $styled_re
+
+ foreach from_tty { True False } {
+ gdb_test \
+ "python gdb.execute('$cmd', $from_tty)" \
+ $styled_re
+ gdb_test \
+ "python gdb.execute('$cmd', $from_tty, False)" \
+ $styled_re
+ gdb_test \
+ "python gdb.execute('$cmd', $from_tty, False, True)" \
+ $styled_re
+ gdb_test \
+ "python gdb.execute('$cmd', $from_tty, False, False)" \
+ $unstyled_re
+ gdb_test \
+ "python print(gdb.execute('$cmd', $from_tty, True), end='')" \
+ $unstyled_re
+ gdb_test \
+ "python print(gdb.execute('$cmd', $from_tty, True, False), end='')" \
+ $unstyled_re
+ gdb_test \
+ "python print(gdb.execute('$cmd', $from_tty, True, True), end='')" \
+ $styled_re
+ }
+}
+
+# Test that the output from gdb.execute is styled or not based on the
+# arguments passed in.
+proc test_gdb_execute_styling {} {
+ clean_restart
+
+ # Two possible outputs, BASIC_RE, the unstyled output text, or
+ # STYLED_RE, the same things, but with styling applied.
+ set text "\"version\" style"
+ set styled_text \
+ [style "\"" version][style "version" version][style "\" style" version]
+ set basic_re "The $text foreground color is: \[^\r\n\]+"
+ set styled_re "The $styled_text foreground color is: \[^\r\n\]+"
+
+ # The command we'll run. It's output matches the above regexp.
+ set show_style_version_cmd "show style version foreground"
+
+ # Another command we'll run. The output of this command is never
+ # styled, but we run this to check that the output doesn't change
+ # even when gdb.execute() asks for styled, or unstyled output.
+ set show_style_enabled_cmd "show style enabled"
+
+ with_test_prefix "with style enabled on" {
+ do_gdb_execute $show_style_version_cmd $styled_re $basic_re
+
+ # This time, print the value of 'show style enabled'. This
+ # output is unstyled, so there's only one regexp. The
+ # interesting thing here is that we don't expect the output to
+ # change, even when gdb.execute() is printing unstyled output.
+ # The "styling=False" argument to gdb.execute() is separate to
+ # the 'set style enabled on|off' setting.
+ set re "CLI output styling is enabled\\."
+ do_gdb_execute $show_style_enabled_cmd $re $re
+ }
+
+ gdb_test_no_output "set style enabled off"
+
+ with_test_prefix "with style enabled off" {
+ # With 'set style enabled off' in use, even a request to
+ # gdb.execute() to produce styled output should produce
+ # unstyled output. The assumption is that 'set style enabled
+ # off' is done by the user, while the gdb.execute() is likely
+ # from some Python extension. The users request for no
+ # styling overrules the extensions request for styled output.
+ do_gdb_execute $show_style_version_cmd $basic_re $basic_re
+
+ # Now check that even when we request styled output, the 'show
+ # style enabled' value is always reported as disabled.
+ set re "CLI output styling is disabled\\."
+ do_gdb_execute $show_style_enabled_cmd $re $re
+ }
+}
+
+# Run the tests.
+with_ansi_styling_terminal {
+ test_gdb_execute_styling
+}
diff --git a/gdb/testsuite/gdb.python/py-sym-artificial.exp b/gdb/testsuite/gdb.python/py-sym-artificial.exp
index 3ae516c..e26e9d2 100644
--- a/gdb/testsuite/gdb.python/py-sym-artificial.exp
+++ b/gdb/testsuite/gdb.python/py-sym-artificial.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-symbol-2.c b/gdb/testsuite/gdb.python/py-symbol-2.c
index c895159..806bcca 100644
--- a/gdb/testsuite/gdb.python/py-symbol-2.c
+++ b/gdb/testsuite/gdb.python/py-symbol-2.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2019-2024 Free Software Foundation, Inc.
+ Copyright 2019-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-symbol-3.c b/gdb/testsuite/gdb.python/py-symbol-3.c
index 6a95193..181c3fc 100644
--- a/gdb/testsuite/gdb.python/py-symbol-3.c
+++ b/gdb/testsuite/gdb.python/py-symbol-3.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index b6b2cd6..41cc60d 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index e6411b4..dfc435e 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -100,7 +100,6 @@ gdb_test_multiple $cmd "print value of rr" {
fail $gdb_test_name
}
}
-
gdb_test "python print (gdb.lookup_static_symbol ('rr').needs_frame)" \
"False" \
@@ -142,16 +141,19 @@ gdb_test "python print (func.name)" "func" "test func.name"
gdb_test "python print (func.print_name)" "func" "test func.print_name"
gdb_test "python print (func.linkage_name)" "func" "test func.linkage_name"
gdb_test "python print (func.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "test func.addr_class"
+gdb_test "python print (func.domain == gdb.SYMBOL_FUNCTION_DOMAIN)" "True" "test func.domain"
# Stop in a second file and ensure we find its local static symbol.
gdb_breakpoint "function_in_other_file"
gdb_continue_to_breakpoint "function_in_other_file"
gdb_test "python print (gdb.lookup_static_symbol ('rr').value ())" "99" \
"print value of rr from other file"
-gdb_test "python print (gdb.lookup_static_symbols ('rr')\[0\].value ())" "99" \
- "print value of gdb.lookup_static_symbols ('rr')\[0\], from the other file"
-gdb_test "python print (gdb.lookup_static_symbols ('rr')\[1\].value ())" "42" \
- "print value of gdb.lookup_static_symbols ('rr')\[1\], from the other file"
+# GDB doesn't really guarantee the order of these, so sort the values.
+gdb_test_no_output "python rrs = gdb.lookup_static_symbols ('rr')" \
+ "fetch all rr symbols, from the other file"
+gdb_test "python print (sorted(\[int(x.value()) for x in rrs\]))" \
+ "\\\[42, 99\\\]" \
+ "print values of all 'rr' symbols, from the other file"
# Now continue back to the first source file.
set linenum [gdb_get_line_number "Break at end."]
@@ -163,10 +165,12 @@ gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
# static symbol from the second source file.
gdb_test "python print (gdb.lookup_static_symbol ('rr').value ())" "42" \
"print value of rr from main file"
-gdb_test "python print (gdb.lookup_static_symbols ('rr')\[0\].value ())" "99" \
- "print value of gdb.lookup_static_symbols ('rr')\[0\], from the main file"
-gdb_test "python print (gdb.lookup_static_symbols ('rr')\[1\].value ())" "42" \
- "print value of gdb.lookup_static_symbols ('rr')\[1\], from the main file"
+# This should be consistent with the first file.
+gdb_test_no_output "python rrs = gdb.lookup_static_symbols ('rr')" \
+ "fetch all rr symbols, from the main file"
+gdb_test "python print (sorted(\[int(x.value()) for x in rrs\]))" \
+ "\\\[42, 99\\\]" \
+ "print values of all 'rr' symbols, from the main file"
# Test is_variable attribute.
gdb_py_test_silent_cmd "python a = gdb.lookup_symbol(\'a\')" "Get variable a" 0
diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp
index 4765ef5..a4891f3 100644
--- a/gdb/testsuite/gdb.python/py-symtab.exp
+++ b/gdb/testsuite/gdb.python/py-symtab.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -90,6 +90,34 @@ gdb_test_multiple "python print (\"simple_struct\" in static_symbols)" \
}
}
+# Test symtab identity
+gdb_test "python print (symtab is symtab)"\
+ "True" \
+ "test symtab identity 1"
+gdb_test "python print (symtab is gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab identity 2"
+gdb_test "python print (sal.symtab is gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab identity 3"
+gdb_test "python print (symtab is not \"xxx\")"\
+ "True" \
+ "test symtab non-identity with non-symtab"
+
+# Test symtab equality
+gdb_test "python print (symtab == symtab)"\
+ "True" \
+ "test symtab equality 1"
+gdb_test "python print (symtab == gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab equality 2"
+gdb_test "python print (sal.symtab == gdb.selected_frame().find_sal().symtab)"\
+ "True" \
+ "test symtab equality 3"
+gdb_test "python print (symtab != \"xxx\")"\
+ "True" \
+ "test symtab non-equality with non-symtab"
+
# Test is_valid when the objfile is unloaded. This must be the last
# test as it unloads the object file in GDB.
gdb_unload
diff --git a/gdb/testsuite/gdb.python/py-sync-interp.c b/gdb/testsuite/gdb.python/py-sync-interp.c
index 9dabd28..f5fef95 100644
--- a/gdb/testsuite/gdb.python/py-sync-interp.c
+++ b/gdb/testsuite/gdb.python/py-sync-interp.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2013-2024 Free Software Foundation, Inc.
+ Copyright 2013-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-sync-interp.exp b/gdb/testsuite/gdb.python/py-sync-interp.exp
index 9db7853..ea91cb2 100644
--- a/gdb/testsuite/gdb.python/py-sync-interp.exp
+++ b/gdb/testsuite/gdb.python/py-sync-interp.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
+# Copyright (C) 2013-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-template.cc b/gdb/testsuite/gdb.python/py-template.cc
index 73b4982..4c306ac 100644
--- a/gdb/testsuite/gdb.python/py-template.cc
+++ b/gdb/testsuite/gdb.python/py-template.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2008-2024 Free Software Foundation, Inc.
+ Copyright 2008-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp
index bba80e3..a0f9d80 100644
--- a/gdb/testsuite/gdb.python/py-template.exp
+++ b/gdb/testsuite/gdb.python/py-template.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.c b/gdb/testsuite/gdb.python/py-thread-exited.c
index 3af93f9..dd859ce 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.c
+++ b/gdb/testsuite/gdb.python/py-thread-exited.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.exp b/gdb/testsuite/gdb.python/py-thread-exited.exp
index dda8470..dcacb11 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.exp
+++ b/gdb/testsuite/gdb.python/py-thread-exited.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.py b/gdb/testsuite/gdb.python/py-thread-exited.py
index f813271..ef5a244 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.py
+++ b/gdb/testsuite/gdb.python/py-thread-exited.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2024 Free Software Foundation, Inc.
+# Copyright 2022-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.c b/gdb/testsuite/gdb.python/py-thrhandle.c
index f6dd6d2..69c0aaf 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.c
+++ b/gdb/testsuite/gdb.python/py-thrhandle.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2017-2024 Free Software Foundation, Inc.
+ Copyright 2017-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index 702a3a5..343bf4b 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2024 Free Software Foundation, Inc.
+# Copyright (C) 2017-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-type.c b/gdb/testsuite/gdb.python/py-type.c
index 7a0df8a..cc5fcb2 100644
--- a/gdb/testsuite/gdb.python/py-type.c
+++ b/gdb/testsuite/gdb.python/py-type.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2009-2024 Free Software Foundation, Inc.
+ Copyright 2009-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 7e469c9..0bc4556 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+# Copyright (C) 2009-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -324,6 +324,19 @@ proc test_type_equality {} {
}
}
+# Test type identity
+proc test_type_identity {} {
+ gdb_test_no_output "python v1 = gdb.parse_and_eval('global_unsigned_int')"
+ gdb_test_no_output "python v2 = gdb.parse_and_eval('global_unsigned_int')"
+
+ gdb_test "python print(v1.type is v2.type)" "True"
+
+ gdb_test_no_output "python t1 = gdb.lookup_type ('char')"
+ gdb_test_no_output "python t2 = gdb.lookup_type ('char')"
+
+ gdb_test "python print(t1 is t2)" "True"
+}
+
# Test the gdb.Type.is_scalar property.
proc test_is_scalar { lang } {
if {$lang == "c++"} {
@@ -376,6 +389,7 @@ if { [build_inferior "${binfile}" "c"] == 0 } {
test_is_scalar "c"
test_is_signed "c"
test_type_equality
+ test_type_identity
}
}
@@ -392,6 +406,7 @@ if { [build_inferior "${binfile}-cxx" "c++"] == 0 } {
test_is_scalar "c++"
test_is_signed "c++"
test_type_equality
+ test_type_identity
}
}
diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc
index af06b54..b77bd8a 100644
--- a/gdb/testsuite/gdb.python/py-typeprint.cc
+++ b/gdb/testsuite/gdb.python/py-typeprint.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2008-2024 Free Software Foundation, Inc.
+ Copyright 2008-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp
index 5fafe26..74d755f 100644
--- a/gdb/testsuite/gdb.python/py-typeprint.exp
+++ b/gdb/testsuite/gdb.python/py-typeprint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py
index 0fd2f0e..dc13210 100644
--- a/gdb/testsuite/gdb.python/py-typeprint.py
+++ b/gdb/testsuite/gdb.python/py-typeprint.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-inline.c b/gdb/testsuite/gdb.python/py-unwind-inline.c
index 6511a6b..1143e52 100644
--- a/gdb/testsuite/gdb.python/py-unwind-inline.c
+++ b/gdb/testsuite/gdb.python/py-unwind-inline.c
@@ -1,4 +1,4 @@
-/* Copyright 2019-2024 Free Software Foundation, Inc.
+/* Copyright 2019-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-inline.exp b/gdb/testsuite/gdb.python/py-unwind-inline.exp
index 1ba1c14..74d4ead 100644
--- a/gdb/testsuite/gdb.python/py-unwind-inline.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-inline.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 Free Software Foundation, Inc.
+# Copyright (C) 2020-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-inline.py b/gdb/testsuite/gdb.python/py-unwind-inline.py
index b0a8083..ca6b16e 100644
--- a/gdb/testsuite/gdb.python/py-unwind-inline.py
+++ b/gdb/testsuite/gdb.python/py-unwind-inline.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 Free Software Foundation, Inc.
+# Copyright (C) 2020-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.c b/gdb/testsuite/gdb.python/py-unwind-maint.c
index 80dc9d9..1b99849 100644
--- a/gdb/testsuite/gdb.python/py-unwind-maint.c
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2015-2024 Free Software Foundation, Inc.
+ Copyright 2015-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.exp b/gdb/testsuite/gdb.python/py-unwind-maint.exp
index 9e525f6..d9450ef 100644
--- a/gdb/testsuite/gdb.python/py-unwind-maint.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.py b/gdb/testsuite/gdb.python/py-unwind-maint.py
index 1d049a9..4a109d5 100644
--- a/gdb/testsuite/gdb.python/py-unwind-maint.py
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-user-regs.c b/gdb/testsuite/gdb.python/py-unwind-user-regs.c
index be7b2fd..edd9284 100644
--- a/gdb/testsuite/gdb.python/py-unwind-user-regs.c
+++ b/gdb/testsuite/gdb.python/py-unwind-user-regs.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-user-regs.exp b/gdb/testsuite/gdb.python/py-unwind-user-regs.exp
index b27e038..1a464f0 100644
--- a/gdb/testsuite/gdb.python/py-unwind-user-regs.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-user-regs.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind-user-regs.py b/gdb/testsuite/gdb.python/py-unwind-user-regs.py
index 7e331a8..c6a56b8 100644
--- a/gdb/testsuite/gdb.python/py-unwind-user-regs.py
+++ b/gdb/testsuite/gdb.python/py-unwind-user-regs.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind.c b/gdb/testsuite/gdb.python/py-unwind.c
index 81132f4..f785c5e 100644
--- a/gdb/testsuite/gdb.python/py-unwind.c
+++ b/gdb/testsuite/gdb.python/py-unwind.c
@@ -1,6 +1,6 @@
/* This test program is part of GDB, the GNU debugger.
- Copyright 2015-2024 Free Software Foundation, Inc.
+ Copyright 2015-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index d5efc02..b416c2f 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -245,6 +245,13 @@ with_test_prefix "frame-id 'pc' is invalid" {
"Python Exception <class 'ValueError'>: invalid literal for int\\(\\) with base 10: 'xyz'\r\n.*"
}
+with_test_prefix "bad object unwinder" {
+ gdb_test_no_output "python obj = bad_object_unwinder(\"bad-object\")"
+ gdb_test_no_output "python gdb.unwinder.register_unwinder(None, obj, replace=True)"
+ gdb_test "backtrace" \
+ "Python Exception <class 'gdb.error'>: an Unwinder should return gdb.UnwindInfo, not Blah\\.\r\n.*"
+}
+
# Gather information about every frame.
gdb_test_no_output "python capture_all_frame_information()"
gdb_test_no_output "python gdb.newest_frame().select()"
diff --git a/gdb/testsuite/gdb.python/py-unwind.py b/gdb/testsuite/gdb.python/py-unwind.py
index 62bfb09..0faccf2 100644
--- a/gdb/testsuite/gdb.python/py-unwind.py
+++ b/gdb/testsuite/gdb.python/py-unwind.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
+# Copyright (C) 2015-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -267,4 +267,24 @@ class validating_unwinder(Unwinder):
return None
+class bad_object_unwinder(Unwinder):
+ def __init__(self, name):
+ super().__init__(name)
+
+ def __call__(self, pending_frame):
+
+ if pending_frame.level() != 1:
+ return None
+
+ class Blah:
+ def __init__(self):
+ pass
+
+ @property
+ def __class__(self):
+ raise RuntimeError("error in Blah.__class__")
+
+ return Blah()
+
+
print("Python script imported")
diff --git a/gdb/testsuite/gdb.python/py-value-cc.cc b/gdb/testsuite/gdb.python/py-value-cc.cc
index 08b9915..1a70943 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.cc
+++ b/gdb/testsuite/gdb.python/py-value-cc.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2012-2024 Free Software Foundation, Inc.
+ Copyright 2012-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp
index b096c75..3d371bc 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-value-cc.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2024 Free Software Foundation, Inc.
+# Copyright (C) 2012-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-value.c b/gdb/testsuite/gdb.python/py-value.c
index c9da6c2..a822346 100644
--- a/gdb/testsuite/gdb.python/py-value.c
+++ b/gdb/testsuite/gdb.python/py-value.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2008-2024 Free Software Foundation, Inc.
+ Copyright 2008-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 8ab867a..93985a9 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-varobj.c b/gdb/testsuite/gdb.python/py-varobj.c
index da72f9a..6117b35 100644
--- a/gdb/testsuite/gdb.python/py-varobj.c
+++ b/gdb/testsuite/gdb.python/py-varobj.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2023-2024 Free Software Foundation, Inc.
+ Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-varobj.exp b/gdb/testsuite/gdb.python/py-varobj.exp
index 4e0e64e..7fb45f9 100644
--- a/gdb/testsuite/gdb.python/py-varobj.exp
+++ b/gdb/testsuite/gdb.python/py-varobj.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-varobj.py b/gdb/testsuite/gdb.python/py-varobj.py
index 9401514..3699bdf 100644
--- a/gdb/testsuite/gdb.python/py-varobj.py
+++ b/gdb/testsuite/gdb.python/py-varobj.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
diff --git a/gdb/testsuite/gdb.python/py-warning.exp b/gdb/testsuite/gdb.python/py-warning.exp
new file mode 100644
index 0000000..6b26a4e
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-warning.exp
@@ -0,0 +1,63 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test the gdb.warning() function.
+
+load_lib gdb-python.exp
+
+require allow_python_tests
+
+clean_restart
+
+# Basic usage.
+gdb_test "python gdb.warning(\"some text\")" \
+ "warning: some text"
+
+# Basic usage with named argument.
+gdb_test "python gdb.warning(text=\"a warning message\")" \
+ "warning: a warning message"
+
+# Make sure GDB prints format specifiers correctly.
+gdb_test "python gdb.warning(\"%s %d %p\")" \
+ "warning: %s %d %p"
+
+# Empty string gives an error.
+gdb_test "python gdb.warning(\"\")" \
+ [multi_line \
+ "Python Exception <class 'ValueError'>: Empty text string passed to gdb\\.warning" \
+ "Error occurred in Python: Empty text string passed to gdb\\.warning"]
+
+# Missing argument gives an error.
+set re1 \
+ [multi_line \
+ [string_to_regexp \
+ [concat \
+ "Python Exception <class 'TypeError'>:" \
+ "function missing required argument 'text' (pos 1)"]] \
+ [string_to_regexp \
+ [concat \
+ "Error occurred in Python:" \
+ "function missing required argument 'text' (pos 1)"]]]
+set re2 \
+ [multi_line \
+ [string_to_regexp \
+ [concat \
+ "Python Exception <class 'TypeError'>:" \
+ "Required argument 'text' (pos 1) not found"]] \
+ [string_to_regexp \
+ [concat \
+ "Error occurred in Python:" \
+ "Required argument 'text' (pos 1) not found"]]]
+gdb_test "python gdb.warning()" $re1|$re2
diff --git a/gdb/testsuite/gdb.python/py-watchpoint.c b/gdb/testsuite/gdb.python/py-watchpoint.c
index 05748b0..9b05601 100644
--- a/gdb/testsuite/gdb.python/py-watchpoint.c
+++ b/gdb/testsuite/gdb.python/py-watchpoint.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2022-2024 Free Software Foundation, Inc.
+ Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-watchpoint.exp b/gdb/testsuite/gdb.python/py-watchpoint.exp
index 9361956..ea21020 100644
--- a/gdb/testsuite/gdb.python/py-watchpoint.exp
+++ b/gdb/testsuite/gdb.python/py-watchpoint.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-watchpoint.py b/gdb/testsuite/gdb.python/py-watchpoint.py
index dbb2bfe..d25826f 100644
--- a/gdb/testsuite/gdb.python/py-watchpoint.py
+++ b/gdb/testsuite/gdb.python/py-watchpoint.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-xmethods.cc b/gdb/testsuite/gdb.python/py-xmethods.cc
index 52fa2ff..336762e 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.cc
+++ b/gdb/testsuite/gdb.python/py-xmethods.cc
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2014-2024 Free Software Foundation, Inc.
+ Copyright 2014-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -137,7 +137,7 @@ G<T>::mul (const T1 t1)
return t1 * t;
}
-} // namespace dop
+} /* namespace dop */
using namespace dop;
diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp
index 55ec66c..3dafe0e 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.exp
+++ b/gdb/testsuite/gdb.python/py-xmethods.exp
@@ -1,4 +1,4 @@
-# Copyright 2014-2024 Free Software Foundation, Inc.
+# Copyright 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py
index a2b8d57..33bc41a 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.py
+++ b/gdb/testsuite/gdb.python/py-xmethods.py
@@ -1,4 +1,4 @@
-# Copyright 2014-2024 Free Software Foundation, Inc.
+# Copyright 2014-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/python-1.c b/gdb/testsuite/gdb.python/python-1.c
index be736c2..49032ad 100644
--- a/gdb/testsuite/gdb.python/python-1.c
+++ b/gdb/testsuite/gdb.python/python-1.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/python.c b/gdb/testsuite/gdb.python/python.c
index fda271e..501b25f 100644
--- a/gdb/testsuite/gdb.python/python.c
+++ b/gdb/testsuite/gdb.python/python.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2010-2024 Free Software Foundation, Inc.
+ Copyright 2010-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 19c8958..6b2f671 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2024 Free Software Foundation, Inc.
+# Copyright (C) 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/source1 b/gdb/testsuite/gdb.python/source1
index 6d457b5..b704d92 100644
--- a/gdb/testsuite/gdb.python/source1
+++ b/gdb/testsuite/gdb.python/source1
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.
-# Copyright 2008-2024 Free Software Foundation, Inc.
+# Copyright 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/source2.py b/gdb/testsuite/gdb.python/source2.py
index 79dc1c2..7ca0bb2 100644
--- a/gdb/testsuite/gdb.python/source2.py
+++ b/gdb/testsuite/gdb.python/source2.py
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.
-# Copyright 2008-2024 Free Software Foundation, Inc.
+# Copyright 2008-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/sys-exit.exp b/gdb/testsuite/gdb.python/sys-exit.exp
index 3396b8d..878cf93 100644
--- a/gdb/testsuite/gdb.python/sys-exit.exp
+++ b/gdb/testsuite/gdb.python/sys-exit.exp
@@ -1,4 +1,4 @@
-# Copyright 2024 Free Software Foundation, Inc.
+# Copyright 2024-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window-disabled.c b/gdb/testsuite/gdb.python/tui-window-disabled.c
index 538c9e8..ed650ca 100644
--- a/gdb/testsuite/gdb.python/tui-window-disabled.c
+++ b/gdb/testsuite/gdb.python/tui-window-disabled.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2021-2024 Free Software Foundation, Inc.
+ Copyright 2021-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window-disabled.exp b/gdb/testsuite/gdb.python/tui-window-disabled.exp
index 750520c..afc9570 100644
--- a/gdb/testsuite/gdb.python/tui-window-disabled.exp
+++ b/gdb/testsuite/gdb.python/tui-window-disabled.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window-disabled.py b/gdb/testsuite/gdb.python/tui-window-disabled.py
index aef6f2a..8d140c4 100644
--- a/gdb/testsuite/gdb.python/tui-window-disabled.py
+++ b/gdb/testsuite/gdb.python/tui-window-disabled.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window-factory.exp b/gdb/testsuite/gdb.python/tui-window-factory.exp
index 5d8189d..4780fe4 100644
--- a/gdb/testsuite/gdb.python/tui-window-factory.exp
+++ b/gdb/testsuite/gdb.python/tui-window-factory.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window-factory.py b/gdb/testsuite/gdb.python/tui-window-factory.py
index edd39a4..7593214 100644
--- a/gdb/testsuite/gdb.python/tui-window-factory.py
+++ b/gdb/testsuite/gdb.python/tui-window-factory.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+# Copyright (C) 2023-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window-names.exp b/gdb/testsuite/gdb.python/tui-window-names.exp
index 8236fc9..2a8db69 100644
--- a/gdb/testsuite/gdb.python/tui-window-names.exp
+++ b/gdb/testsuite/gdb.python/tui-window-names.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+# Copyright (C) 2022-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp
index c521dcc..744a09a 100644
--- a/gdb/testsuite/gdb.python/tui-window.exp
+++ b/gdb/testsuite/gdb.python/tui-window.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 Free Software Foundation, Inc.
+# Copyright (C) 2020-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/gdb/testsuite/gdb.python/tui-window.py b/gdb/testsuite/gdb.python/tui-window.py
index 0661acc..d03a8ce 100644
--- a/gdb/testsuite/gdb.python/tui-window.py
+++ b/gdb/testsuite/gdb.python/tui-window.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 Free Software Foundation, Inc.
+# Copyright (C) 2020-2025 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by