Go to file
Andrew Burgess 3965bff5b9 gdb/python: add mechanism to manage Python initialization functions
Currently, when we add a new python sub-system to GDB,
e.g. py-inferior.c, we end up having to create a new function like
gdbpy_initialize_inferior, which then has to be called from the
function do_start_initialization in python.c.

In some cases (py-micmd.c and py-tui.c), we have two functions
gdbpy_initialize_*, and gdbpy_finalize_*, with the second being called
from finalize_python which is also in python.c.

This commit proposes a mechanism to manage these initialization and
finalization calls, this means that adding a new Python subsystem will
no longer require changes to python.c or python-internal.h, instead,
the initialization and finalization functions will be registered
directly from the sub-system file, e.g. py-inferior.c, or py-micmd.c.

The initialization and finalization functions are managed through a
new class gdbpy_initialize_file in python-internal.h.  This class
contains a single global vector of all the initialization and
finalization functions.

In each Python sub-system we create a new gdbpy_initialize_file
object, the object constructor takes care of registering the two
callback functions.

Now from python.c we can call static functions on the
gdbpy_initialize_file class which take care of walking the callback
list and invoking each callback in turn.

To slightly simplify the Python sub-system files I added a new macro
GDBPY_INITIALIZE_FILE, which hides the need to create an object.  We
can now just do this:

  GDBPY_INITIALIZE_FILE (gdbpy_initialize_registers);

One possible problem with this change is that there is now no
guaranteed ordering of how the various sub-systems are initialized (or
finalized).  To try and avoid dependencies creeping in I have added a
use of the environment variable GDB_REVERSE_INIT_FUNCTIONS, this is
the same environment variable used in the generated init.c file.

Just like with init.c, when this environment variable is set we
reverse the list of Python initialization (and finalization)
functions.  As there is already a test that starts GDB with the
environment variable set then this should offer some level of
protection against dependencies creeping in - though for full
protection I guess we'd need to run all gdb.python/*.exp tests with
the variable set.

I have tested this patch with the environment variable set, and saw no
regressions, so I think we are fine right now.

One other change of note was for gdbpy_initialize_gdb_readline, this
function previously returned void.  In order to make this function
have the correct signature I've updated its return type to int, and we
now return 0 to indicate success.

All of the other initialize (and finalize) functions have been made
static within their respective sub-system files.

There should be no user visible changes after this commit.
2023-05-05 18:24:42 +01:00
bfd Debug info is lost for functions only called from functions marked with cmse_nonsecure_entr 2023-05-05 11:11:32 +01:00
binutils Remove Dimity Diky as MSP430 maintainer. 2023-05-02 13:33:53 +01:00
config Merge config/picflag.m4 from gcc 2023-01-04 13:23:54 +10:30
contrib Import mklog.py from gcc repo 2020-09-25 10:24:44 -04:00
cpu cpu/mem.opc whitespace tidy 2023-03-16 17:30:19 +10:30
elfcpp Update year range in copyright notice of binutils files 2023-01-01 21:50:11 +10:30
etc Update year range in gprofng copyright notices 2023-01-01 23:26:30 +10:30
gas RISC-V: tighten post-relocation-operator separator expectation 2023-05-04 10:24:36 +02:00
gdb gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
gdbserver gdbserver: allow agent expressions to fail with invalid memory access 2023-04-03 14:46:32 +01:00
gdbsupport gdb: Fix building with latest libc++ 2023-04-29 00:35:11 -07:00
gnulib Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gold MIPS: support mips*64 as CPU and gnuabi64 as ABI 2023-04-23 14:32:43 +08:00
gprof Updated Hungarian translation for the gprof directory 2023-04-19 10:37:33 +01:00
gprofng gprofng: 30360 Seg. Fault when application uses std::thread 2023-04-17 13:01:38 -07:00
include Re: Keeping track of rs6000-coff archive element pointers 2023-04-28 15:19:59 +09:30
intl egrep in binutils 2022-09-28 13:37:31 +09:30
ld Stop the linker from loosing the entry point for COFF/PE code when compiling with LTO enabled. 2023-05-04 14:24:16 +01:00
libbacktrace Ensure that libbacktrace/allocfail.sh is not deleted when creating release tarballs. 2023-01-12 13:39:03 +00:00
libctf libctf, link: fix CU-mapped links with CTF_LINK_EMPTY_CU_MAPPINGS 2023-04-08 16:07:17 +01:00
libdecnumber Merge config/ changes from GCC, to enable DFP on AArch64 2022-05-24 10:47:29 +01:00
libiberty Merge config/picflag.m4 from gcc 2023-01-04 13:23:54 +10:30
libsframe libsframe: minor formatting fixes in sframe_encoder_write_fre 2023-04-19 14:38:18 -07:00
opcodes x86: limit data passed to i386_dis_printf() 2023-04-28 08:24:41 +02:00
readline gdb/readline: fix extra 'quit' message problem 2022-05-07 10:49:27 +01:00
sim sim: bpf: update to new BPF relocations 2023-04-26 19:22:14 +02:00
texinfo
zlib Regenerate with automake-1.15.1 2022-07-09 20:10:47 +09:30
.cvsignore
.editorconfig Add top-level .editorconfig file 2022-01-28 08:25:42 -05:00
.gitattributes binutils-gdb/git: highlight whitespace errors in source files 2022-07-25 14:35:41 +01:00
.gitignore Add gnu global outputs to .gitignore 2020-12-02 10:00:27 -05:00
ar-lib
ChangeLog Add a SECURITY.txt file describing the GNU Binutils' project's stance on security related bugs. 2023-04-20 16:52:11 +01:00
compile
config-ml.in
config.guess Update the config.guess and config.sub files from the master repository and regenerate files. 2022-01-17 16:21:22 +00:00
config.rpath
config.sub Update the config.guess and config.sub files from the master repository and regenerate files. 2022-01-17 16:21:22 +00:00
configure configure: remove dependencies on gmp and mpfr when gdb is disabled 2023-01-06 09:32:07 +01:00
configure.ac configure: remove dependencies on gmp and mpfr when gdb is disabled 2023-01-06 09:32:07 +01:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4 libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Update path to readline config.{sub,guess} files 2021-05-24 18:11:49 +02:00
Makefile.def toplevel: Makefile.def: add install-strip dependency on libsframe 2023-01-18 23:17:49 -08:00
Makefile.in toplevel: Makefile.def: add install-strip dependency on libsframe 2023-01-18 23:17:49 -08:00
Makefile.tpl Pass PKG_CONFIG_PATH down from top-level Makefile 2022-04-08 10:56:41 -04:00
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am Merge autoconf / automake update changes from GCC. 2018-10-31 17:10:56 +00:00
README
README-maintainer-mode Note that at least dejagnu version 1.5.3 is required in order to be ale to run the testsuites. 2022-10-04 10:54:19 +01:00
SECURITY.txt Add a SECURITY.txt file describing the GNU Binutils' project's stance on security related bugs. 2023-04-20 16:52:11 +01:00
setup.com
src-release.sh Add a SECURITY.txt file describing the GNU Binutils' project's stance on security related bugs. 2023-04-20 16:52:11 +01:00
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.