gdb: add gdbarch_up

Add a gdbarch_up unique pointer type, that calls gdbarch_free on
deletion.  This is used in the ROCm support patch at the end of this
series.

Change-Id: I4b808892d35d69a590ce83180f41afd91705b2c8
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Simon Marchi 2022-10-03 12:56:30 -04:00 committed by Simon Marchi
parent 9056c917b3
commit d246d904ad

View file

@ -306,6 +306,14 @@ extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info,
extern void gdbarch_free (struct gdbarch *);
struct gdbarch_deleter
{
void operator() (gdbarch *arch) const
{ gdbarch_free (arch); }
};
using gdbarch_up = std::unique_ptr<gdbarch, gdbarch_deleter>;
/* Get the obstack owned by ARCH. */
extern obstack *gdbarch_obstack (gdbarch *arch);