This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Heap-allocate core_target instances


*** TEST RESULTS FOR COMMIT 1524450719d3867e10fc6a8dbc051b8dc7924898 ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: 1524450719d3867e10fc6a8dbc051b8dc7924898

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]