From patchwork Sat Apr 8 20:11:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 19914 Received: (qmail 18983 invoked by alias); 8 Apr 2017 20:12:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 18897 invoked by uid 89); 8 Apr 2017 20:12:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ADVERT2, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS, T_FILL_THIS_FORM_LOAN autolearn=ham version=3.3.2 spammy=warned, registering, us!, H*Ad:U*tom X-HELO: gproxy7-pub.mail.unifiedlayer.com Received: from gproxy7-pub.mail.unifiedlayer.com (HELO gproxy7-pub.mail.unifiedlayer.com) (70.40.196.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Sat, 08 Apr 2017 20:12:16 +0000 Received: (qmail 8919 invoked by uid 0); 8 Apr 2017 20:12:15 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy7.mail.unifiedlayer.com with SMTP; 8 Apr 2017 20:12:15 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id 5wCC1v0082f2jeq01wCFWm; Sat, 08 Apr 2017 14:12:15 -0600 X-Authority-Analysis: v=2.2 cv=cpDrqxwi c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=zstS-IiYAAAA:8 a=0FD05c-RAAAA:8 a=aFSCze2PnopovZZaVPwA:9 a=Sx2OJiAnxhH0ISm4:21 a=lft3Xy4t5jwK9i0n:21 a=4G6NA9xxw8l3yy4pmD5M:22 a=l1rpMCqCXRGZwUSuRcM3:22 Received: from 75-166-65-226.hlrn.qwest.net ([75.166.65.226]:43578 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cwwiR-0003Fw-N5; Sat, 08 Apr 2017 14:12:12 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 01/14] Introduce event_location_up Date: Sat, 8 Apr 2017 14:11:55 -0600 Message-Id: <20170408201208.2672-2-tom@tromey.com> In-Reply-To: <20170408201208.2672-1-tom@tromey.com> References: <20170408201208.2672-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1cwwiR-0003Fw-N5 X-Source-Sender: 75-166-65-226.hlrn.qwest.net (bapiya.Home) [75.166.65.226]:43578 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This removes make_cleanup_delete_event_location and instead changes the various location functions to return an event_location_up, a new unique_ptr typedef. This is largely straightforward, but be sure to examine the init_breakpoint_sal change. I believe the code I deleted there is dead, because "location != NULL" can never be true in that branch; but you should double-check. gdb/ChangeLog 2017-04-07 Tom Tromey * tracepoint.c (scope_info): Update. * spu-tdep.c (spu_catch_start): Update. * python/python.c (gdbpy_decode_line): Update. * python/py-finishbreakpoint.c (bpfinishpy_init): Update. * python/py-breakpoint.c (bppy_init): Update. * probe.c (parse_probes): Update. * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update. * location.h (event_location_deleter): New struct. (event_location_up): New typedef. (new_linespec_location, new_address_location, new_probe_location) (new_explicit_location, copy_event_location) (string_to_event_location, string_to_event_location_basic) (string_to_explicit_location): Update return type. (make_cleanup_delete_event_location): Remove. * location.c (new_linespec_location, new_address_location) (new_probe_location, new_explicit_location, copy_event_location): Return event_location_up. (delete_event_location_cleanup) (make_cleanup_delete_event_location): Remove. (string_to_explicit_location, string_to_event_location_basic) (string_to_event_location): Return event_location_up. * linespec.c (canonicalize_linespec, event_location_to_sals) (decode_line_with_current_source) (decode_line_with_last_displayed, decode_objc): Update. * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update. * completer.c (location_completer): Update. * cli/cli-cmds.c (edit_command, list_command): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint) (create_thread_event_breakpoint): Update. (init_breakpoint_sal): Update. Remove some dead code. (create_breakpoint_sal): Change type of "location". Update. (create_breakpoints_sal, create_breakpoint, break_command_1) (dprintf_command, break_range_command, until_break_command) (init_ada_exception_breakpoint) (strace_marker_create_sals_from_location) (update_static_tracepoint, trace_command, ftrace_command) (strace_command, create_tracepoint_from_upload): Update. * break-catch-throw.c (re_set_exception_catchpoint): Update. * ax-gdb.c (agent_command_1): Update. --- gdb/ChangeLog | 45 ++++++++++++ gdb/ax-gdb.c | 8 +- gdb/break-catch-throw.c | 14 ++-- gdb/breakpoint.c | 153 ++++++++++++++------------------------- gdb/cli/cli-cmds.c | 43 ++++------- gdb/completer.c | 14 ++-- gdb/guile/scm-breakpoint.c | 9 +-- gdb/linespec.c | 27 +++---- gdb/location.c | 53 ++++---------- gdb/location.h | 62 ++++++++-------- gdb/mi/mi-cmd-break.c | 11 +-- gdb/probe.c | 2 +- gdb/python/py-breakpoint.c | 10 +-- gdb/python/py-finishbreakpoint.c | 10 +-- gdb/python/python.c | 9 +-- gdb/spu-tdep.c | 8 +- gdb/tracepoint.c | 11 +-- 17 files changed, 203 insertions(+), 286 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 01c4c70..0779339 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,48 @@ +2017-04-07 Tom Tromey + + * tracepoint.c (scope_info): Update. + * spu-tdep.c (spu_catch_start): Update. + * python/python.c (gdbpy_decode_line): Update. + * python/py-finishbreakpoint.c (bpfinishpy_init): Update. + * python/py-breakpoint.c (bppy_init): Update. + * probe.c (parse_probes): Update. + * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update. + * location.h (event_location_deleter): New struct. + (event_location_up): New typedef. + (new_linespec_location, new_address_location, new_probe_location) + (new_explicit_location, copy_event_location) + (string_to_event_location, string_to_event_location_basic) + (string_to_explicit_location): Update return type. + (make_cleanup_delete_event_location): Remove. + * location.c (new_linespec_location, new_address_location) + (new_probe_location, new_explicit_location, copy_event_location): + Return event_location_up. + (delete_event_location_cleanup) + (make_cleanup_delete_event_location): Remove. + (string_to_explicit_location, string_to_event_location_basic) + (string_to_event_location): Return event_location_up. + * linespec.c (canonicalize_linespec, event_location_to_sals) + (decode_line_with_current_source) + (decode_line_with_last_displayed, decode_objc): Update. + * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update. + * completer.c (location_completer): Update. + * cli/cli-cmds.c (edit_command, list_command): Update. + * breakpoint.c (create_overlay_event_breakpoint) + (create_longjmp_master_breakpoint) + (create_std_terminate_master_breakpoint) + (create_exception_master_breakpoint) + (create_thread_event_breakpoint): Update. + (init_breakpoint_sal): Update. Remove some dead code. + (create_breakpoint_sal): Change type of "location". Update. + (create_breakpoints_sal, create_breakpoint, break_command_1) + (dprintf_command, break_range_command, until_break_command) + (init_ada_exception_breakpoint) + (strace_marker_create_sals_from_location) + (update_static_tracepoint, trace_command, ftrace_command) + (strace_command, create_tracepoint_from_upload): Update. + * break-catch-throw.c (re_set_exception_catchpoint): Update. + * ax-gdb.c (agent_command_1): Update. + 2017-04-07 Simon Marchi * unittests/ptid-selftests.c: Fix erroneous assert messages. diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 05b1dd7..7206022 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2604,16 +2604,14 @@ agent_command_1 (char *exp, int eval) int ix; struct linespec_sals *iter; struct cleanup *old_chain; - struct event_location *location; exp = skip_spaces (exp); init_linespec_result (&canonical); - location = new_linespec_location (&exp); - old_chain = make_cleanup_delete_event_location (location); - decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL, + event_location_up location = new_linespec_location (&exp); + decode_line_full (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, (struct symtab *) NULL, 0, &canonical, NULL, NULL); - make_cleanup_destroy_linespec_result (&canonical); + old_chain = make_cleanup_destroy_linespec_result (&canonical); exp = skip_spaces (exp); if (exp[0] == ',') { diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 2e18d2a..2714bbf 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -205,17 +205,14 @@ re_set_exception_catchpoint (struct breakpoint *self) struct symtabs_and_lines sals_end = {0}; struct cleanup *cleanup; enum exception_event_kind kind = classify_exception_breakpoint (self); - struct event_location *location; struct program_space *filter_pspace = current_program_space; /* We first try to use the probe interface. */ TRY { - location + event_location_up location = new_probe_location (exception_functions[kind].probe); - cleanup = make_cleanup_delete_event_location (location); - sals = parse_probes (location, filter_pspace, NULL); - do_cleanups (cleanup); + sals = parse_probes (location.get (), filter_pspace, NULL); } CATCH (e, RETURN_MASK_ERROR) { @@ -228,10 +225,9 @@ re_set_exception_catchpoint (struct breakpoint *self) initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (exception_functions[kind].function); - location = new_explicit_location (&explicit_loc); - cleanup = make_cleanup_delete_event_location (location); - self->ops->decode_location (self, location, filter_pspace, &sals); - do_cleanups (cleanup); + event_location_up location = new_explicit_location (&explicit_loc); + self->ops->decode_location (self, location.get (), filter_pspace, + &sals); } CATCH (ex, RETURN_MASK_ERROR) { diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3925ec6..f3834d5 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3472,7 +3472,7 @@ create_overlay_event_breakpoint (void) &internal_breakpoint_ops); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->location = new_explicit_location (&explicit_loc).release (); if (overlay_debugging == ovly_auto) { @@ -3553,7 +3553,7 @@ create_longjmp_master_breakpoint (void) bp_longjmp_master, &internal_breakpoint_ops); b->location - = new_probe_location ("-probe-stap libc:longjmp"); + = new_probe_location ("-probe-stap libc:longjmp").release (); b->enable_state = bp_disabled; } @@ -3593,7 +3593,7 @@ create_longjmp_master_breakpoint (void) &internal_breakpoint_ops); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->location = new_explicit_location (&explicit_loc).release (); b->enable_state = bp_disabled; } } @@ -3651,7 +3651,7 @@ create_std_terminate_master_breakpoint (void) &internal_breakpoint_ops); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->location = new_explicit_location (&explicit_loc).release (); b->enable_state = bp_disabled; } } @@ -3721,7 +3721,7 @@ create_exception_master_breakpoint (void) bp_exception_master, &internal_breakpoint_ops); b->location - = new_probe_location ("-probe-stap libgcc:unwind"); + = new_probe_location ("-probe-stap libgcc:unwind").release (); b->enable_state = bp_disabled; } @@ -3756,7 +3756,7 @@ create_exception_master_breakpoint (void) &internal_breakpoint_ops); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->location = new_explicit_location (&explicit_loc).release (); b->enable_state = bp_disabled; } } @@ -7796,7 +7796,7 @@ create_thread_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address) b->enable_state = bp_enabled; /* location has to be used or breakpoint_re_set will delete me. */ - b->location = new_address_location (b->loc->address, NULL, 0); + b->location = new_address_location (b->loc->address, NULL, 0).release (); update_global_location_list_nothrow (UGLL_MAY_INSERT); @@ -9219,7 +9219,7 @@ update_dprintf_commands (char *args, int from_tty, static void init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, struct symtabs_and_lines sals, - struct event_location *location, + event_location_up &&location, char *filter, char *cond_string, char *extra_string, enum bptype type, enum bpdisp disposition, @@ -9348,27 +9348,16 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, b->display_canonical = display_canonical; if (location != NULL) - b->location = location; + b->location = location.release (); else - { - const char *addr_string = NULL; - int addr_string_len = 0; - - if (location != NULL) - addr_string = event_location_to_string (location); - if (addr_string != NULL) - addr_string_len = strlen (addr_string); - - b->location = new_address_location (b->loc->address, - addr_string, addr_string_len); - } + b->location = new_address_location (b->loc->address, NULL, 0).release (); b->filter = filter; } static void create_breakpoint_sal (struct gdbarch *gdbarch, struct symtabs_and_lines sals, - struct event_location *location, + event_location_up &&location, char *filter, char *cond_string, char *extra_string, enum bptype type, enum bpdisp disposition, @@ -9393,7 +9382,7 @@ create_breakpoint_sal (struct gdbarch *gdbarch, old_chain = make_cleanup (xfree, b); init_breakpoint_sal (b, gdbarch, - sals, location, + sals, std::move (location), filter, cond_string, extra_string, type, disposition, thread, task, ignore_count, @@ -9439,22 +9428,20 @@ create_breakpoints_sal (struct gdbarch *gdbarch, { /* Note that 'location' can be NULL in the case of a plain 'break', without arguments. */ - struct event_location *location + event_location_up location = (canonical->location != NULL ? copy_event_location (canonical->location) : NULL); char *filter_string = lsal->canonical ? xstrdup (lsal->canonical) : NULL; - struct cleanup *inner = make_cleanup_delete_event_location (location); make_cleanup (xfree, filter_string); create_breakpoint_sal (gdbarch, lsal->sals, - location, + std::move (location), filter_string, cond_string, extra_string, type, disposition, thread, task, ignore_count, ops, from_tty, enabled, internal, flags, canonical->special_display); - discard_cleanups (inner); } } @@ -9892,7 +9879,7 @@ create_breakpoint (struct gdbarch *gdbarch, b = new breakpoint (); init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops); - b->location = copy_event_location (location); + b->location = copy_event_location (location).release (); if (parse_extra) b->cond_string = NULL; @@ -9960,21 +9947,18 @@ break_command_1 (char *arg, int flag, int from_tty) ? bp_hardware_breakpoint : bp_breakpoint); struct breakpoint_ops *ops; - struct event_location *location; - struct cleanup *cleanup; - location = string_to_event_location (&arg, current_language); - cleanup = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&arg, current_language); /* Matching breakpoints on probes. */ if (location != NULL - && event_location_type (location) == PROBE_LOCATION) + && event_location_type (location.get ()) == PROBE_LOCATION) ops = &bkpt_probe_breakpoint_ops; else ops = &bkpt_breakpoint_ops; create_breakpoint (get_current_arch (), - location, + location.get (), NULL, 0, arg, 1 /* parse arg */, tempflag, type_wanted, 0 /* Ignore count */, @@ -9984,7 +9968,6 @@ break_command_1 (char *arg, int flag, int from_tty) 1 /* enabled */, 0 /* internal */, 0); - do_cleanups (cleanup); } /* Helper function for break_command_1 and disassemble_command. */ @@ -10151,11 +10134,7 @@ stopat_command (char *arg, int from_tty) static void dprintf_command (char *arg, int from_tty) { - struct event_location *location; - struct cleanup *cleanup; - - location = string_to_event_location (&arg, current_language); - cleanup = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&arg, current_language); /* If non-NULL, ARG should have been advanced past the location; the next character must be ','. */ @@ -10171,7 +10150,7 @@ dprintf_command (char *arg, int from_tty) } create_breakpoint (get_current_arch (), - location, + location.get (), NULL, 0, arg, 1 /* parse arg */, 0, bp_dprintf, 0 /* Ignore count */, @@ -10181,7 +10160,6 @@ dprintf_command (char *arg, int from_tty) 1 /* enabled */, 0 /* internal */, 0); - do_cleanups (cleanup); } static void @@ -10379,7 +10357,6 @@ break_range_command (char *arg, int from_tty) struct symtab_and_line sal_start, sal_end; struct cleanup *cleanup_bkpt; struct linespec_sals *lsal_start, *lsal_end; - struct event_location *start_location, *end_location; /* We don't support software ranged breakpoints. */ if (target_ranged_break_num_registers () < 0) @@ -10399,10 +10376,10 @@ break_range_command (char *arg, int from_tty) init_linespec_result (&canonical_start); arg_start = arg; - start_location = string_to_event_location (&arg, current_language); - cleanup_bkpt = make_cleanup_delete_event_location (start_location); - parse_breakpoint_sals (start_location, &canonical_start); - make_cleanup_destroy_linespec_result (&canonical_start); + event_location_up start_location = string_to_event_location (&arg, + current_language); + parse_breakpoint_sals (start_location.get (), &canonical_start); + cleanup_bkpt = make_cleanup_destroy_linespec_result (&canonical_start); if (arg[0] != ',') error (_("Too few arguments.")); @@ -10432,9 +10409,9 @@ break_range_command (char *arg, int from_tty) symtab and line as the default symtab and line for the end of the range. This makes it possible to have ranges like "foo.c:27, +14", where +14 means 14 lines from the start location. */ - end_location = string_to_event_location (&arg, current_language); - make_cleanup_delete_event_location (end_location); - decode_line_full (end_location, DECODE_LINE_FUNFIRSTLINE, NULL, + event_location_up end_location = string_to_event_location (&arg, + current_language); + decode_line_full (end_location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, sal_start.symtab, sal_start.line, &canonical_end, NULL, NULL); @@ -10475,8 +10452,8 @@ break_range_command (char *arg, int from_tty) set_breakpoint_count (breakpoint_count + 1); b->number = breakpoint_count; b->disposition = disp_donttouch; - b->location = copy_event_location (start_location); - b->location_range_end = copy_event_location (end_location); + b->location = start_location.release (); + b->location_range_end = end_location.release (); b->loc->length = length; do_cleanups (cleanup_bkpt); @@ -11676,10 +11653,9 @@ until_break_command (char *arg, int from_tty, int anywhere) struct frame_id caller_frame_id; struct breakpoint *location_breakpoint; struct breakpoint *caller_breakpoint = NULL; - struct cleanup *old_chain, *cleanup; + struct cleanup *old_chain; int thread; struct thread_info *tp; - struct event_location *location; struct until_break_fsm *sm; clear_proceed_status (0); @@ -11687,15 +11663,14 @@ until_break_command (char *arg, int from_tty, int anywhere) /* Set a breakpoint where the user wants it and at return from this function. */ - location = string_to_event_location (&arg, current_language); - cleanup = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&arg, current_language); if (last_displayed_sal_is_valid ()) - sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL, + sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, get_last_displayed_symtab (), get_last_displayed_line ()); else - sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, + sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, (struct symtab *) NULL, 0); if (sals.nelts != 1) @@ -11767,8 +11742,6 @@ until_break_command (char *arg, int from_tty, int anywhere) discard_cleanups (old_chain); proceed (-1, GDB_SIGNAL_DEFAULT); - - do_cleanups (cleanup); } /* This function attempts to parse an optional "if " clause @@ -11926,8 +11899,9 @@ init_ada_exception_breakpoint (struct breakpoint *b, b->enable_state = enabled ? bp_enabled : bp_disabled; b->disposition = tempflag ? disp_del : disp_donttouch; - b->location = string_to_event_location (&addr_string, - language_def (language_ada)); + b->location + = string_to_event_location (&addr_string, + language_def (language_ada)).release (); b->language = language_ada; } @@ -13690,7 +13664,7 @@ strace_marker_create_sals_from_location (const struct event_location *location, str = savestring (arg_start, arg - arg_start); cleanup = make_cleanup (xfree, str); - canonical->location = new_linespec_location (&str); + canonical->location = new_linespec_location (&str).release (); do_cleanups (cleanup); lsal.canonical = xstrdup (event_location_to_string (canonical->location)); @@ -13725,18 +13699,16 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, { struct symtabs_and_lines expanded; struct tracepoint *tp; - struct cleanup *old_chain; - struct event_location *location; + event_location_up location; expanded.nelts = 1; expanded.sals = &lsal->sals.sals[i]; location = copy_event_location (canonical->location); - old_chain = make_cleanup_delete_event_location (location); tp = new tracepoint (); init_breakpoint_sal (&tp->base, gdbarch, expanded, - location, NULL, + std::move (location), NULL, cond_string, extra_string, type_wanted, disposition, thread, task, ignore_count, ops, @@ -13751,8 +13723,6 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, tp->static_trace_marker_id_idx = i; install_breakpoint (internal, &tp->base, 0); - - discard_cleanups (old_chain); } } @@ -14155,7 +14125,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) = ASTRDUP (symtab_to_filename_for_display (sal2.symtab)); explicit_loc.line_offset.offset = b->loc->line_number; explicit_loc.line_offset.sign = LINE_OFFSET_NONE; - b->location = new_explicit_location (&explicit_loc); + b->location = new_explicit_location (&explicit_loc).release (); /* Might be nice to check if function changed, and warn if so. */ @@ -15225,19 +15195,17 @@ static void trace_command (char *arg, int from_tty) { struct breakpoint_ops *ops; - struct event_location *location; - struct cleanup *back_to; - location = string_to_event_location (&arg, current_language); - back_to = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&arg, + current_language); if (location != NULL - && event_location_type (location) == PROBE_LOCATION) + && event_location_type (location.get ()) == PROBE_LOCATION) ops = &tracepoint_probe_breakpoint_ops; else ops = &tracepoint_breakpoint_ops; create_breakpoint (get_current_arch (), - location, + location.get (), NULL, 0, arg, 1 /* parse arg */, 0 /* tempflag */, bp_tracepoint /* type_wanted */, @@ -15247,19 +15215,15 @@ trace_command (char *arg, int from_tty) from_tty, 1 /* enabled */, 0 /* internal */, 0); - do_cleanups (back_to); } static void ftrace_command (char *arg, int from_tty) { - struct event_location *location; - struct cleanup *back_to; - - location = string_to_event_location (&arg, current_language); - back_to = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&arg, + current_language); create_breakpoint (get_current_arch (), - location, + location.get (), NULL, 0, arg, 1 /* parse arg */, 0 /* tempflag */, bp_fast_tracepoint /* type_wanted */, @@ -15269,7 +15233,6 @@ ftrace_command (char *arg, int from_tty) from_tty, 1 /* enabled */, 0 /* internal */, 0); - do_cleanups (back_to); } /* strace command implementation. Creates a static tracepoint. */ @@ -15278,7 +15241,7 @@ static void strace_command (char *arg, int from_tty) { struct breakpoint_ops *ops; - struct event_location *location; + event_location_up location; struct cleanup *back_to; /* Decide if we are dealing with a static tracepoint marker (`-m'), @@ -15294,9 +15257,9 @@ strace_command (char *arg, int from_tty) location = string_to_event_location (&arg, current_language); } - back_to = make_cleanup_delete_event_location (location); + create_breakpoint (get_current_arch (), - location, + location.get (), NULL, 0, arg, 1 /* parse arg */, 0 /* tempflag */, bp_static_tracepoint /* type_wanted */, @@ -15306,7 +15269,6 @@ strace_command (char *arg, int from_tty) from_tty, 1 /* enabled */, 0 /* internal */, 0); - do_cleanups (back_to); } /* Set up a fake reader function that gets command lines from a linked @@ -15338,8 +15300,6 @@ create_tracepoint_from_upload (struct uploaded_tp *utp) { char *addr_str, small_buf[100]; struct tracepoint *tp; - struct event_location *location; - struct cleanup *cleanup; if (utp->at_string) addr_str = utp->at_string; @@ -15362,10 +15322,10 @@ create_tracepoint_from_upload (struct uploaded_tp *utp) "has no source form, ignoring it"), utp->number); - location = string_to_event_location (&addr_str, current_language); - cleanup = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&addr_str, + current_language); if (!create_breakpoint (get_current_arch (), - location, + location.get (), utp->cond_string, -1, addr_str, 0 /* parse cond/thread */, 0 /* tempflag */, @@ -15377,12 +15337,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp) utp->enabled /* enabled */, 0 /* internal */, CREATE_BREAKPOINT_FLAGS_INSERTED)) - { - do_cleanups (cleanup); - return NULL; - } - - do_cleanups (cleanup); + return NULL; /* Get the tracepoint we just created. */ tp = get_tracepoint (tracepoint_count); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 4956ba7..2a5b128 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -828,28 +828,25 @@ edit_command (char *arg, int from_tty) } else { - struct cleanup *cleanup; - struct event_location *location; char *arg1; /* Now should only be one argument -- decode it in SAL. */ arg1 = arg; - location = string_to_event_location (&arg1, current_language); - cleanup = make_cleanup_delete_event_location (location); - sals = decode_line_1 (location, DECODE_LINE_LIST_MODE, NULL, NULL, 0); + event_location_up location = string_to_event_location (&arg1, + current_language); + sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, + NULL, NULL, 0); filter_sals (&sals); if (! sals.nelts) { /* C++ */ - do_cleanups (cleanup); return; } if (sals.nelts > 1) { ambiguous_line_spec (&sals); xfree (sals.sals); - do_cleanups (cleanup); return; } @@ -891,7 +888,6 @@ edit_command (char *arg, int from_tty) if (sal.symtab == 0) error (_("No line number known for %s."), arg); - do_cleanups (cleanup); } if ((editor = (char *) getenv ("EDITOR")) == NULL) @@ -920,9 +916,6 @@ list_command (char *arg, int from_tty) int dummy_beg = 0; int linenum_beg = 0; char *p; - struct cleanup *cleanup; - - cleanup = make_cleanup (null_cleanup, NULL); /* Pull in the current default source line if necessary. */ if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0')) @@ -985,24 +978,21 @@ list_command (char *arg, int from_tty) dummy_beg = 1; else { - struct event_location *location; - - location = string_to_event_location (&arg1, current_language); - make_cleanup_delete_event_location (location); - sals = decode_line_1 (location, DECODE_LINE_LIST_MODE, NULL, NULL, 0); + event_location_up location = string_to_event_location (&arg1, + current_language); + sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, + NULL, NULL, 0); filter_sals (&sals); if (!sals.nelts) { /* C++ */ - do_cleanups (cleanup); return; } if (sals.nelts > 1) { ambiguous_line_spec (&sals); xfree (sals.sals); - do_cleanups (cleanup); return; } @@ -1027,28 +1017,22 @@ list_command (char *arg, int from_tty) dummy_end = 1; else { - struct event_location *location; - - location = string_to_event_location (&arg1, current_language); - make_cleanup_delete_event_location (location); + event_location_up location + = string_to_event_location (&arg1, current_language); if (dummy_beg) - sals_end = decode_line_1 (location, + sals_end = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); else - sals_end = decode_line_1 (location, DECODE_LINE_LIST_MODE, + sals_end = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, NULL, sal.symtab, sal.line); filter_sals (&sals_end); if (sals_end.nelts == 0) - { - do_cleanups (cleanup); - return; - } + return; if (sals_end.nelts > 1) { ambiguous_line_spec (&sals_end); xfree (sals_end.sals); - do_cleanups (cleanup); return; } sal_end = sals_end.sals[0]; @@ -1129,7 +1113,6 @@ list_command (char *arg, int from_tty) ? sal.line + get_lines_to_list () : sal_end.line + 1), 0); - do_cleanups (cleanup); } /* Subroutine of disassemble_command to simplify it. diff --git a/gdb/completer.c b/gdb/completer.c index 7e46416..6acf115 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -507,17 +507,13 @@ location_completer (struct cmd_list_element *ignore, { VEC (char_ptr) *matches = NULL; const char *copy = text; - struct event_location *location; - location = string_to_explicit_location (©, current_language, 1); + event_location_up location = string_to_explicit_location (©, + current_language, + 1); if (location != NULL) - { - struct cleanup *cleanup; - - cleanup = make_cleanup_delete_event_location (location); - matches = explicit_location_completer (ignore, location, text, word); - do_cleanups (cleanup); - } + matches = explicit_location_completer (ignore, location.get (), + text, word); else { /* This is an address or linespec location. diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index 9189446..3a1e4d3 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -413,8 +413,6 @@ gdbscm_register_breakpoint_x (SCM self) = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct gdb_exception except = exception_none; char *location, *copy; - struct event_location *eloc; - struct cleanup *cleanup; /* We only support registering breakpoints created with make-breakpoint. */ if (!bp_smob->is_scheme_bkpt) @@ -426,8 +424,8 @@ gdbscm_register_breakpoint_x (SCM self) pending_breakpoint_scm = self; location = bp_smob->spec.location; copy = skip_spaces (location); - eloc = string_to_event_location_basic (©, current_language); - cleanup = make_cleanup_delete_event_location (eloc); + event_location_up eloc = string_to_event_location_basic (©, + current_language); TRY { @@ -438,7 +436,7 @@ gdbscm_register_breakpoint_x (SCM self) case bp_breakpoint: { create_breakpoint (get_current_arch (), - eloc, NULL, -1, NULL, + eloc.get (), NULL, -1, NULL, 0, 0, bp_breakpoint, 0, @@ -474,7 +472,6 @@ gdbscm_register_breakpoint_x (SCM self) /* Ensure this gets reset, even if there's an error. */ pending_breakpoint_scm = SCM_BOOL_F; GDBSCM_HANDLE_GDB_EXCEPTION (except); - do_cleanups (cleanup); return SCM_UNSPECIFIED; } diff --git a/gdb/linespec.c b/gdb/linespec.c index dcbe253..41b82d7 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1751,7 +1751,7 @@ canonicalize_linespec (struct linespec_state *state, const linespec_p ls) /* Save everything as an explicit location. */ canon = state->canonical->location - = new_explicit_location (&ls->explicit_loc); + = new_explicit_location (&ls->explicit_loc).release (); explicit_loc = get_explicit_location (canon); if (explicit_loc->label_name != NULL) @@ -2491,7 +2491,7 @@ event_location_to_sals (linespec_parser *parser, addr = linespec_expression_to_pc (&const_expr); if (PARSER_STATE (parser)->canonical != NULL) PARSER_STATE (parser)->canonical->location - = copy_event_location (location); + = copy_event_location (location).release (); do_cleanups (cleanup); } @@ -2630,8 +2630,6 @@ decode_line_with_current_source (char *string, int flags) { struct symtabs_and_lines sals; struct symtab_and_line cursal; - struct event_location *location; - struct cleanup *cleanup; if (string == 0) error (_("Empty line specification.")); @@ -2640,15 +2638,14 @@ decode_line_with_current_source (char *string, int flags) and get a default source symtab+line or it will recursively call us! */ cursal = get_current_source_symtab_and_line (); - location = string_to_event_location (&string, current_language); - cleanup = make_cleanup_delete_event_location (location); - sals = decode_line_1 (location, flags, NULL, + event_location_up location = string_to_event_location (&string, + current_language); + sals = decode_line_1 (location.get (), flags, NULL, cursal.symtab, cursal.line); if (*string) error (_("Junk at end of line specification: %s"), string); - do_cleanups (cleanup); return sals; } @@ -2658,25 +2655,23 @@ struct symtabs_and_lines decode_line_with_last_displayed (char *string, int flags) { struct symtabs_and_lines sals; - struct event_location *location; - struct cleanup *cleanup; if (string == 0) error (_("Empty line specification.")); - location = string_to_event_location (&string, current_language); - cleanup = make_cleanup_delete_event_location (location); + event_location_up location = string_to_event_location (&string, + current_language); if (last_displayed_sal_is_valid ()) - sals = decode_line_1 (location, flags, NULL, + sals = decode_line_1 (location.get (), flags, NULL, get_last_displayed_symtab (), get_last_displayed_line ()); else - sals = decode_line_1 (location, flags, NULL, (struct symtab *) NULL, 0); + sals = decode_line_1 (location.get (), flags, NULL, + (struct symtab *) NULL, 0); if (*string) error (_("Junk at end of line specification: %s"), string); - do_cleanups (cleanup); return sals; } @@ -2785,7 +2780,7 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg) str = xstrdup (saved_arg); make_cleanup (xfree, str); - self->canonical->location = new_linespec_location (&str); + self->canonical->location = new_linespec_location (&str).release (); } } diff --git a/gdb/location.c b/gdb/location.c index fbd09e2..877c1ed 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -81,7 +81,7 @@ initialize_explicit_location (struct explicit_location *explicit_loc) /* See description in location.h. */ -struct event_location * +event_location_up new_linespec_location (char **linespec) { struct event_location *location; @@ -98,7 +98,7 @@ new_linespec_location (char **linespec) if ((p - orig) > 0) EL_LINESPEC (location) = savestring (orig, p - orig); } - return location; + return event_location_up (location); } /* See description in location.h. */ @@ -112,7 +112,7 @@ get_linespec_location (const struct event_location *location) /* See description in location.h. */ -struct event_location * +event_location_up new_address_location (CORE_ADDR addr, const char *addr_string, int addr_string_len) { @@ -123,7 +123,7 @@ new_address_location (CORE_ADDR addr, const char *addr_string, EL_ADDRESS (location) = addr; if (addr_string != NULL) EL_STRING (location) = xstrndup (addr_string, addr_string_len); - return location; + return event_location_up (location); } /* See description in location.h. */ @@ -146,7 +146,7 @@ get_address_string_location (const struct event_location *location) /* See description in location.h. */ -struct event_location * +event_location_up new_probe_location (const char *probe) { struct event_location *location; @@ -155,7 +155,7 @@ new_probe_location (const char *probe) EL_TYPE (location) = PROBE_LOCATION; if (probe != NULL) EL_PROBE (location) = xstrdup (probe); - return location; + return event_location_up (location); } /* See description in location.h. */ @@ -169,7 +169,7 @@ get_probe_location (const struct event_location *location) /* See description in location.h. */ -struct event_location * +event_location_up new_explicit_location (const struct explicit_location *explicit_loc) { struct event_location tmp; @@ -293,7 +293,7 @@ explicit_location_to_linespec (const struct explicit_location *explicit_loc) /* See description in location.h. */ -struct event_location * +event_location_up copy_event_location (const struct event_location *src) { struct event_location *dst; @@ -339,25 +339,7 @@ copy_event_location (const struct event_location *src) gdb_assert_not_reached ("unknown event location type"); } - return dst; -} - -/* A cleanup function for struct event_location. */ - -static void -delete_event_location_cleanup (void *data) -{ - struct event_location *location = (struct event_location *) data; - - delete_event_location (location); -} - -/* See description in location.h. */ - -struct cleanup * -make_cleanup_delete_event_location (struct event_location *location) -{ - return make_cleanup (delete_event_location_cleanup, location); + return event_location_up (dst); } /* See description in location.h. */ @@ -505,13 +487,12 @@ explicit_location_lex_one (const char **inp, /* See description in location.h. */ -struct event_location * +event_location_up string_to_explicit_location (const char **argp, const struct language_defn *language, int dont_throw) { - struct cleanup *cleanup; - struct event_location *location; + event_location_up location; /* It is assumed that input beginning with '-' and a non-digit character is an explicit location. "-p" is reserved, though, @@ -524,7 +505,6 @@ string_to_explicit_location (const char **argp, return NULL; location = new_explicit_location (NULL); - cleanup = make_cleanup_delete_event_location (location); /* Process option/argument pairs. dprintf_command requires that processing stop on ','. */ @@ -591,7 +571,6 @@ string_to_explicit_location (const char **argp, *argp = start; discard_cleanups (oarg_cleanup); do_cleanups (opt_cleanup); - discard_cleanups (cleanup); return location; } @@ -621,17 +600,16 @@ string_to_explicit_location (const char **argp, "line offset.")); } - discard_cleanups (cleanup); return location; } /* See description in location.h. */ -struct event_location * +event_location_up string_to_event_location_basic (char **stringp, const struct language_defn *language) { - struct event_location *location; + event_location_up location; const char *cs; /* Try the input as a probe spec. */ @@ -666,16 +644,15 @@ string_to_event_location_basic (char **stringp, /* See description in location.h. */ -struct event_location * +event_location_up string_to_event_location (char **stringp, const struct language_defn *language) { - struct event_location *location; const char *arg, *orig; /* Try an explicit location. */ orig = arg = *stringp; - location = string_to_explicit_location (&arg, language, 0); + event_location_up location = string_to_explicit_location (&arg, language, 0); if (location != NULL) { /* It was a valid explicit location. Advance STRINGP to diff --git a/gdb/location.h b/gdb/location.h index e8a3d20..5a5adb5 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -114,11 +114,27 @@ extern char * extern const char * event_location_to_string (struct event_location *location); -/* Create a new linespec location. The return result is malloc'd - and should be freed with delete_event_location. */ +/* Free an event location and any associated data. */ + +extern void delete_event_location (struct event_location *location); + +/* A deleter for a struct event_location. */ + +struct event_location_deleter +{ + void operator() (event_location *location) const + { + delete_event_location (location); + } +}; + +/* A unique pointer for event_location. */ +typedef std::unique_ptr + event_location_up; + +/* Create a new linespec location. */ -extern struct event_location * - new_linespec_location (char **linespec); +extern event_location_up new_linespec_location (char **linespec); /* Return the linespec location (a string) of the given event_location (which must be of type LINESPEC_LOCATION). */ @@ -131,9 +147,9 @@ extern const char * ADDR_STRING, a string of ADDR_STRING_LEN characters, is the expression that was parsed to determine the address ADDR. */ -extern struct event_location * - new_address_location (CORE_ADDR addr, const char *addr_string, - int addr_string_len); +extern event_location_up new_address_location (CORE_ADDR addr, + const char *addr_string, + int addr_string_len); /* Return the address location (a CORE_ADDR) of the given event_location (which must be of type ADDRESS_LOCATION). */ @@ -147,11 +163,9 @@ extern CORE_ADDR extern const char * get_address_string_location (const struct event_location *location); -/* Create a new probe location. The return result is malloc'd - and should be freed with delete_event_location. */ +/* Create a new probe location. */ -extern struct event_location * - new_probe_location (const char *probe); +extern event_location_up new_probe_location (const char *probe); /* Return the probe location (a string) of the given event_location (which must be of type PROBE_LOCATION). */ @@ -165,12 +179,9 @@ extern void initialize_explicit_location (struct explicit_location *explicit_loc); /* Create a new explicit location. If not NULL, EXPLICIT is checked for - validity. If invalid, an exception is thrown. + validity. If invalid, an exception is thrown. */ - The return result is malloc'd and should be freed with - delete_event_location. */ - -extern struct event_location * +extern event_location_up new_explicit_location (const struct explicit_location *explicit_loc); /* Return the explicit location of the given event_location @@ -184,18 +195,9 @@ extern struct explicit_location * extern const struct explicit_location * get_explicit_location_const (const struct event_location *location); -/* Free an event location and any associated data. */ - -extern void delete_event_location (struct event_location *location); - -/* Make a cleanup to free LOCATION. */ - -extern struct cleanup * - make_cleanup_delete_event_location (struct event_location *location); - /* Return a copy of the given SRC location. */ -extern struct event_location * +extern event_location_up copy_event_location (const struct event_location *src); /* Attempt to convert the input string in *ARGP into an event_location. @@ -207,21 +209,19 @@ extern struct event_location * but invalid, input, e.g., if it is called with missing argument parameters or invalid options. - The return result must be freed with delete_event_location. - This function is intended to be used by CLI commands and will parse explicit locations in a CLI-centric way. Other interfaces should use string_to_event_location_basic if they want to maintain support for legacy specifications of probe, address, and linespec locations. */ -extern struct event_location * +extern event_location_up string_to_event_location (char **argp, const struct language_defn *langauge); /* Like string_to_event_location, but does not attempt to parse explicit locations. */ -extern struct event_location * +extern event_location_up string_to_event_location_basic (char **argp, const struct language_defn *language); @@ -235,7 +235,7 @@ extern struct event_location * parameters or invalid options. If DONT_THROW is non-zero, this function will not throw any exceptions. */ -extern struct event_location * +extern event_location_up string_to_explicit_location (const char **argp, const struct language_defn *langauge, int dont_throw); diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 8cc6034..0780f7b 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -180,7 +180,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) int tracepoint = 0; struct cleanup *back_to = make_cleanup (null_cleanup, NULL); enum bptype type_wanted; - struct event_location *location; + event_location_up location; struct breakpoint_ops *ops; int is_explicit = 0; struct explicit_location explicit_loc; @@ -343,15 +343,10 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) { location = string_to_event_location_basic (&address, current_language); if (*address) - { - delete_event_location (location); - error (_("Garbage '%s' at end of location"), address); - } + error (_("Garbage '%s' at end of location"), address); } - make_cleanup_delete_event_location (location); - - create_breakpoint (get_current_arch (), location, condition, thread, + create_breakpoint (get_current_arch (), location.get (), condition, thread, extra_string, 0 /* condition and thread are valid. */, temp_p, type_wanted, diff --git a/gdb/probe.c b/gdb/probe.c index c147810..4f4a5a3 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -205,7 +205,7 @@ parse_probes (const struct event_location *location, make_cleanup (xfree, canon); canonical->special_display = 1; canonical->pre_expanded = 1; - canonical->location = new_probe_location (canon); + canonical->location = new_probe_location (canon).release (); } do_cleanups (cleanup); diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 6bf517c..d63f458 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -680,22 +680,16 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) { case bp_breakpoint: { - struct event_location *location; - struct cleanup *cleanup; - - location + event_location_up location = string_to_event_location_basic (©, current_language); - cleanup = make_cleanup_delete_event_location (location); create_breakpoint (python_gdbarch, - location, NULL, -1, NULL, + location.get (), NULL, -1, NULL, 0, temporary_bp, bp_breakpoint, 0, AUTO_BOOLEAN_TRUE, &bkpt_breakpoint_ops, 0, 1, internal_bp, 0); - - do_cleanups (cleanup); break; } case bp_watchpoint: diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 797ca84..204d818 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -293,14 +293,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) TRY { - struct event_location *location; - struct cleanup *back_to; - /* Set a breakpoint on the return address. */ - location = new_address_location (get_frame_pc (prev_frame), NULL, 0); - back_to = make_cleanup_delete_event_location (location); + event_location_up location + = new_address_location (get_frame_pc (prev_frame), NULL, 0); create_breakpoint (python_gdbarch, - location, NULL, thread, NULL, + location.get (), NULL, thread, NULL, 0, 1 /*temp_flag*/, bp_breakpoint, @@ -308,7 +305,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) AUTO_BOOLEAN_TRUE, &bkpt_breakpoint_ops, 0, 1, internal_bp, 0); - do_cleanups (back_to); } CATCH (except, RETURN_MASK_ALL) { diff --git a/gdb/python/python.c b/gdb/python/python.c index e0e24ac..ec202de 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -672,7 +672,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) struct cleanup *cleanups; gdbpy_ref<> result; gdbpy_ref<> unparsed; - struct event_location *location = NULL; + event_location_up location; if (! PyArg_ParseTuple (args, "|s", &arg)) return NULL; @@ -682,15 +682,12 @@ gdbpy_decode_line (PyObject *self, PyObject *args) sals.sals = NULL; if (arg != NULL) - { - location = string_to_event_location_basic (&arg, python_language); - make_cleanup_delete_event_location (location); - } + location = string_to_event_location_basic (&arg, python_language); TRY { if (location != NULL) - sals = decode_line_1 (location, 0, NULL, NULL, 0); + sals = decode_line_1 (location.get (), 0, NULL, NULL, 0); else { set_default_source_symtab_and_line (); diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index 00e59c2..91b1a0e 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -1934,8 +1934,6 @@ spu_catch_start (struct objfile *objfile) struct bound_minimal_symbol minsym; struct compunit_symtab *cust; CORE_ADDR pc; - struct event_location *location; - struct cleanup *back_to; /* Do this only if requested by "set spu stop-on-load on". */ if (!spu_stop_on_load_p) @@ -1979,9 +1977,8 @@ spu_catch_start (struct objfile *objfile) /* Use a numerical address for the set_breakpoint command to avoid having the breakpoint re-set incorrectly. */ - location = new_address_location (pc, NULL, 0); - back_to = make_cleanup_delete_event_location (location); - create_breakpoint (get_objfile_arch (objfile), location, + event_location_up location = new_address_location (pc, NULL, 0); + create_breakpoint (get_objfile_arch (objfile), location.get (), NULL /* cond_string */, -1 /* thread */, NULL /* extra_string */, 0 /* parse_condition_and_thread */, 1 /* tempflag */, @@ -1990,7 +1987,6 @@ spu_catch_start (struct objfile *objfile) AUTO_BOOLEAN_FALSE /* pending_break_support */, &bkpt_breakpoint_ops /* ops */, 0 /* from_tty */, 1 /* enabled */, 0 /* internal */, 0); - do_cleanups (back_to); } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index c28aa38..dac1657 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2591,20 +2591,18 @@ scope_info (char *args, int from_tty) int j, count = 0; struct gdbarch *gdbarch; int regno; - struct event_location *location; - struct cleanup *back_to; if (args == 0 || *args == 0) error (_("requires an argument (function, " "line or *addr) to define a scope")); - location = string_to_event_location (&args, current_language); - back_to = make_cleanup_delete_event_location (location); - sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL, NULL, 0); + event_location_up location = string_to_event_location (&args, + current_language); + sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, + NULL, NULL, 0); if (sals.nelts == 0) { /* Presumably decode_line_1 has already warned. */ - do_cleanups (back_to); return; } @@ -2743,7 +2741,6 @@ scope_info (char *args, int from_tty) if (count <= 0) printf_filtered ("Scope for %s contains no locals or arguments.\n", save_args); - do_cleanups (back_to); } /* Helper for trace_dump_command. Dump the action list starting at