]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Heap-allocate core_target instances
authorPedro Alves <palves@redhat.com>
Fri, 11 May 2018 18:10:14 +0000 (19:10 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 11 May 2018 18:12:21 +0000 (19:12 +0100)
commit1524450719d3867e10fc6a8dbc051b8dc7924898
tree65e147c2934fb6b2eae72aaf309a71f032c3ea76
parent451953fa440aa0ade02b652159155fae689483a3
Heap-allocate core_target instances

This gets rid of the core_ops global, and replaces it with
heap-allocated core_target instances.  In practice, there will only be
one such instance, though that will change further ahead as more
pieces of multi-target support are merged.

Notice that this replaces one heap-allocated object for another, the
number of allocations is the same.  Specifically, currently we
heap-allocate the 'core_data' object, which holds the core's section
table.  With this patch, that object is made a field of the
core_target class, and no longer allocated separately.

Note that this bit:

  -  /* Looks semi-reasonable.  Toss the old core file and work on the
  -     new.  */
  -
  -  unpush_target (&core_ops);

does not need a replacement, because by the time we get here, the
target_preopen call at the top of core_target_open has already
unpushed any previous target.

gdb/ChangeLog:
2018-05-11  Pedro Alves  <palves@redhat.com>

* corelow.c (core_target) <core_target>: No longer inline.
Initialize m_core_gdbarch, m_core_vec and build the section table
here.
<~core_target>: New.
<core_gdbarch, get_core_register_section>: New methods.
<m_core_section_table, m_core_vec, m_core_gdbarch>: New fields,
factored out from ...
<core_data, core_vec, core_gdbarch>: ... these deleted globals.
(core_ops): Delete.
(sniff_core_bfd): Add gdbarch parameter.
(core_close): Delete, merged into ...
(core_target::close): ... here.  Delete self.
(core_close_cleanup): Delete.
(core_target_open): Allocate a core_target on the heap.  Use a
unique_ptr instead of a cleanup.  Bits moved into the core_target
ctor.  Adjust to use core_target methods instead of globals.
(get_core_register_section): Rename to ...
(core_target::get_core_register_section): ... this and adjust.
(struct get_core_registers_cb_data): New.
(get_core_registers_cb): Use it.  Use bool.
(core_target::fetch_registers, core_target::files_info)
(core_target::xfer_partial, core_target::read_description)
(core_target::pid_to, core_target::thread_name): Adjust to
reference class fields instead of globals.
* target.h (struct target_ops_deleter, target_ops_up): New.
gdb/ChangeLog
gdb/corelow.c
gdb/target.h