gdb/python: allow instantiation of gdb.Compunit from Python

This commit adds code to allow user extension to instantiate
gdb.Compunit. This is a step towards a Python support for dynamically
generated code (JIT) in GDB.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
This commit is contained in:
Jan Vrany
2024-11-21 12:31:20 +00:00
parent b0307d2ae4
commit 79c9dc182d
5 changed files with 167 additions and 3 deletions

View File

@@ -6551,7 +6551,7 @@ that objfile. @xref{Objfiles In Python}.
A @code{gdb.Compunit} object has the following attributes:
@defvar Compunit.objfile
The compunits' backing object file. @xref{Objfiles In Python}.
The compunit's backing object file. @xref{Objfiles In Python}.
This attribute is not writable.
@end defvar
@@ -6570,6 +6570,22 @@ The list of symbol tables associated with this compunit.
A @code{gdb.Compunit} object has the following methods:
@defun Compunit.__init__ (filename, objfile, start, end @r{[}, capacity @r{]})
Create a new compunit with given @var{filename} in given @var{objfile}
(@pxref{Objfiles In Python}). The newly created compunit has an empty global
block and empty static block (@pxref{Blocks In Python}).
The @var{start} and @var{end} arguments specifies the start and end address
of compunit's global and static blocks. It must not overlap with any existing
compunit belonging to the same program space
(@pxref{Progspaces In Python}).
The optional @var{capacity} argument sets the initial capacity of the
internal block vector. More blocks than @var{capacity} can still be added
to the compunit however. If not specified, defaults to 8 blocks (including
global and static blocks).
@end defun
@defun Compunit.is_valid ()
Returns @code{True} if the @code{gdb.Compunit} object is valid,
@code{False} if not. A @code{gdb.Compunit} object can become invalid if