From 2098b39391a5ade9ed308d76f2dfc7ceedd2d9a3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 14 Oct 2017 08:47:44 -0400 Subject: 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) : 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. --- gdb/target-delegates.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gdb/target-delegates.c') diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index c981796..00efbb1 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -3357,29 +3357,29 @@ debug_static_tracepoint_markers_by_strid (struct target_ops *self, const char *a return result; } -static struct traceframe_info * +static traceframe_info_up delegate_traceframe_info (struct target_ops *self) { self = self->beneath; return self->to_traceframe_info (self); } -static struct traceframe_info * +static traceframe_info_up tdefault_traceframe_info (struct target_ops *self) { tcomplain (); } -static struct traceframe_info * +static traceframe_info_up debug_traceframe_info (struct target_ops *self) { - struct traceframe_info * result; + traceframe_info_up result; fprintf_unfiltered (gdb_stdlog, "-> %s->to_traceframe_info (...)\n", debug_target.to_shortname); result = debug_target.to_traceframe_info (&debug_target); fprintf_unfiltered (gdb_stdlog, "<- %s->to_traceframe_info (", debug_target.to_shortname); target_debug_print_struct_target_ops_p (&debug_target); fputs_unfiltered (") = ", gdb_stdlog); - target_debug_print_struct_traceframe_info_p (result); + target_debug_print_traceframe_info_up (result); fputs_unfiltered ("\n", gdb_stdlog); return result; } -- cgit v1.1