gdb/python: move gdb.Membuf support into a new file

In a future commit I'm going to be creating gdb.Membuf objects from a
new file within gdb/python/py*.c.  Currently all gdb.Membuf objects
are created directly within infpy_read_memory (as a result of calling
gdb.Inferior.read_memory()).

Initially I split out the Membuf creation code into a new function,
and left the new function in gdb/python/py-inferior.c, however, it
felt a little random that the Membuf creation code should live with
the inferior handling code.

So, then I moved all of the Membuf related code out into a new file,
gdb/python/py-membuf.c, the interface is gdbpy_buffer_to_membuf, which
wraps an array of bytes into a gdb.Membuf object.

Most of the code is moved directly from py-inferior.c with only minor
tweaks to layout and replacing NULL with nullptr, hence, I've left the
copyright date on py-membuf.c as 2009-2021 to match py-inferior.c.

Currently, the only user of this code is still py-inferior.c, but in
later commits this will change.

There should be no user visible changes after this commit.
This commit is contained in:
Andrew Burgess
2021-09-16 18:30:35 +01:00
parent 8b87fbe6bb
commit 625f7b1cdc
5 changed files with 236 additions and 179 deletions

View File

@ -1876,6 +1876,7 @@ do_start_initialization ()
|| gdbpy_initialize_registers () < 0
|| gdbpy_initialize_xmethods () < 0
|| gdbpy_initialize_unwind () < 0
|| gdbpy_initialize_membuf () < 0
|| gdbpy_initialize_tui () < 0)
return false;