mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
Remove cleanups from btrace code
This removes some cleanups from the btrace code by minorly C++-ifying struct btrace_data. gdb/ChangeLog 2018-06-08 Tom Tromey <tom@tromey.com> * common/btrace-common.h (struct btrace_data): Add constructor, destructor, move assignment operator. <empty, clear, fini>: New methods. <format>: Initialize. (btrace_data_init, btrace_data_fini, btrace_data_clear) (btrace_data_empty): Don't declare. * common/btrace-common.c (btrace_data_init): Remove. (btrace_data::fini): Rename from btrace_data_fini. (btrace_data::empty): Rename from btrace_data_empty. (btrace_data::clear): Rename from btrace_data_clear. Return bool. * btrace.h (make_cleanup_btrace_data): Don't declare. * btrace.c (btrace_add_pc, btrace_stitch_trace, btrace_clear) (parse_xml_btrace): Update. (do_btrace_data_cleanup, make_cleanup_btrace_data): Remove. (maint_btrace_clear_packet_history_cmd): Update. gdb/gdbserver/ChangeLog 2018-06-08 Tom Tromey <tom@tromey.com> * linux-low.c (linux_low_read_btrace): Update.
This commit is contained in:
@@ -164,7 +164,32 @@ struct btrace_data_pt
|
||||
/* The branch trace data. */
|
||||
struct btrace_data
|
||||
{
|
||||
enum btrace_format format;
|
||||
btrace_data () = default;
|
||||
|
||||
~btrace_data ()
|
||||
{
|
||||
fini ();
|
||||
}
|
||||
|
||||
btrace_data &operator= (btrace_data &&other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
fini ();
|
||||
format = other.format;
|
||||
variant = other.variant;
|
||||
other.format = BTRACE_FORMAT_NONE;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* Return true if this is empty; false otherwise. */
|
||||
bool empty () const;
|
||||
|
||||
/* Clear this object. */
|
||||
void clear ();
|
||||
|
||||
enum btrace_format format = BTRACE_FORMAT_NONE;
|
||||
|
||||
union
|
||||
{
|
||||
@@ -174,6 +199,12 @@ struct btrace_data
|
||||
/* Format == BTRACE_FORMAT_PT. */
|
||||
struct btrace_data_pt pt;
|
||||
} variant;
|
||||
|
||||
private:
|
||||
|
||||
DISABLE_COPY_AND_ASSIGN (btrace_data);
|
||||
|
||||
void fini ();
|
||||
};
|
||||
|
||||
/* Target specific branch trace information. */
|
||||
@@ -217,18 +248,6 @@ extern const char *btrace_format_string (enum btrace_format format);
|
||||
/* Return an abbreviation string representation of FORMAT. */
|
||||
extern const char *btrace_format_short_string (enum btrace_format format);
|
||||
|
||||
/* Initialize DATA. */
|
||||
extern void btrace_data_init (struct btrace_data *data);
|
||||
|
||||
/* Cleanup DATA. */
|
||||
extern void btrace_data_fini (struct btrace_data *data);
|
||||
|
||||
/* Clear DATA. */
|
||||
extern void btrace_data_clear (struct btrace_data *data);
|
||||
|
||||
/* Return non-zero if DATA is empty; zero otherwise. */
|
||||
extern int btrace_data_empty (struct btrace_data *data);
|
||||
|
||||
/* Append the branch trace data from SRC to the end of DST.
|
||||
Both SRC and DST must use the same format.
|
||||
Returns zero on success; a negative number otherwise. */
|
||||
|
||||
Reference in New Issue
Block a user