Make to_traceframe_info return a unique_ptr

Since this target method returns an allocated object, return a
unique_ptr.  It allows getting rid a some cleanups here and there.

I had to shuffle the includes around.  First, target.h now needs to
include tracepoint.h, to get the definition of traceframe_info_up.
However, the definition of enum trace_find_type was later in target, so
I had to move it to tracepoint.h, so that the declaration of tfind_1
could know about it.  I then had to remove the include of target.h from
tracepoint.h, which caused a circular dependency (it was probably
included to get enum trace_find_type in the first place anyway).

Regression tested on the buildbot.

gdb/ChangeLog:

	* target.h: Include tracepoint.h.
	(enum trace_find_type): Move to tracepoint.h.
	(struct target_ops) <to_traceframe_info>: Return a unique ptr.
	* tracepoint.h: Don't include target.h
	(enum trace_find_type): Move from target.h.
	(parse_traceframe_info): Return a unique ptr.
	* tracepoint.c (current_traceframe_info): Change type to unique
	ptr.
	(free_traceframe_info): Remove.
	(clear_traceframe_info): Don't manually free
	current_traceframe_info.
	(free_result): Remove.
	(parse_traceframe_info): Return a unique ptr.
	(get_traceframe_info): Adjust to unique ptr.
	* ctf.c (ctf_traceframe_info): Return a unique ptr.
	* remote.c (remote_traceframe_info): Return a unique ptr.
	* tracefile-tfile.c (tfile_traceframe_info): Return a unique
	ptr.
	* target-debug.h (target_debug_print_traceframe_info_up): New
	macro.
	* target-delegates.c: Regenerate.
This commit is contained in:
Simon Marchi 2017-10-14 08:47:44 -04:00 committed by Simon Marchi
parent 4cdd21a8d3
commit 2098b39391
9 changed files with 63 additions and 63 deletions

View file

@ -13061,7 +13061,7 @@ remote_set_circular_trace_buffer (struct target_ops *self, int val)
error (_("Bogus reply from target: %s"), reply);
}
static struct traceframe_info *
static traceframe_info_up
remote_traceframe_info (struct target_ops *self)
{
char *text;
@ -13070,10 +13070,9 @@ remote_traceframe_info (struct target_ops *self)
TARGET_OBJECT_TRACEFRAME_INFO, NULL);
if (text != NULL)
{
struct traceframe_info *info;
struct cleanup *back_to = make_cleanup (xfree, text);
traceframe_info_up info = parse_traceframe_info (text);
info = parse_traceframe_info (text);
do_cleanups (back_to);
return info;
}