From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway32.websitewelcome.com (gateway32.websitewelcome.com [192.185.144.98]) by sourceware.org (Postfix) with ESMTPS id 1696B3857C5C for ; Sun, 9 Aug 2020 13:53:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1696B3857C5C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 265704EC6E3 for ; Sun, 9 Aug 2020 08:53:03 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 4lkzkmOjECjCV4lkzkhwvX; Sun, 09 Aug 2020 08:53:03 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=JNAuxgETfYhZrxaFswvEy1VxC1T1FW2Fx6SYG1RVmoc=; b=pyImrQ2iJRK+w7CZvyZFd3cQAY 7qHCQjpzg/THAFSca8zYo34+KQ8lAMEA1fZKOiO9+xiBlHonXmkHvPzVsNaQ2BspsN4KgZmOTQPj5 QEap/kx7ciS7ncyJ+t+4DA1/v; Received: from 75-166-101-103.hlrn.qwest.net ([75.166.101.103]:56058 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1k4lkz-0022sH-OP; Sun, 09 Aug 2020 07:53:01 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/6] Transfer module ownership to do_module_cleanup Date: Sun, 9 Aug 2020 07:52:56 -0600 Message-Id: <20200809135258.8207-5-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200809135258.8207-1-tom@tromey.com> References: <20200809135258.8207-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.101.103 X-Source-L: No X-Exim-ID: 1k4lkz-0022sH-OP X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-101-103.hlrn.qwest.net (bapiya.Home) [75.166.101.103]:56058 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Aug 2020 13:53:07 -0000 This changes the do_module_cleanup structure to simply hold on to the module itself. This lets us remove most members from do_module_cleanup. gdb/ChangeLog 2020-08-08 Tom Tromey * compile/compile-object-run.c (struct do_module_cleanup): Add parameters to constructor. Update destructor. : Remove. : New member. (do_module_cleanup): Update. (compile_object_run): Update. --- gdb/ChangeLog | 10 +++++ gdb/compile/compile-object-run.c | 67 ++++++++++++-------------------- 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index 5a680a6723f..ac0a995fee9 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -32,13 +32,16 @@ struct do_module_cleanup { - do_module_cleanup () = default; + do_module_cleanup (int *ptr, compile_module_up &&mod) + : executedp (ptr), + module (std::move (mod)) + { + } ~do_module_cleanup () { - delete munmap_list_head; - xfree (source_file); - xfree (objfile_name_string); + delete module->munmap_list_head; + xfree (module->source_file); } DISABLE_COPY_AND_ASSIGN (do_module_cleanup); @@ -47,22 +50,8 @@ struct do_module_cleanup The pointer may be NULL. */ int *executedp; - /* .c file OBJFILE was built from. It needs to be xfree-d. */ - char *source_file; - - /* Copy from struct compile_module. */ - enum compile_i_scope_types scope; - void *scope_data; - - /* Copy from struct compile_module. */ - struct type *out_value_type; - CORE_ADDR out_value_addr; - - /* Copy from struct compile_module. */ - struct munmap_list *munmap_list_head; - - /* objfile_name of our objfile. */ - char *objfile_name_string; + /* The compile module. */ + compile_module_up module; }; /* Cleanup everything after the inferior function dummy frame gets @@ -80,22 +69,26 @@ do_module_cleanup (void *arg, int registers_valid) /* This code cannot be in compile_object_run as OUT_VALUE_TYPE no longer exists there. */ - if (data->scope == COMPILE_I_PRINT_ADDRESS_SCOPE - || data->scope == COMPILE_I_PRINT_VALUE_SCOPE) + if (data->module->scope == COMPILE_I_PRINT_ADDRESS_SCOPE + || data->module->scope == COMPILE_I_PRINT_VALUE_SCOPE) { struct value *addr_value; - struct type *ptr_type = lookup_pointer_type (data->out_value_type); + struct type *ptr_type + = lookup_pointer_type (data->module->out_value_type); - addr_value = value_from_pointer (ptr_type, data->out_value_addr); + addr_value = value_from_pointer (ptr_type, + data->module->out_value_addr); /* SCOPE_DATA would be stale unless EXECUTEDP != NULL. */ - compile_print_value (value_ind (addr_value), data->scope_data); + compile_print_value (value_ind (addr_value), + data->module->scope_data); } } + const char *objfile_name_s = objfile_name (data->module->objfile); for (objfile *objfile : current_program_space->objfiles ()) if ((objfile->flags & OBJF_USERLOADED) == 0 - && (strcmp (objfile_name (objfile), data->objfile_name_string) == 0)) + && (strcmp (objfile_name (objfile), objfile_name_s) == 0)) { objfile->unlink (); @@ -106,10 +99,10 @@ do_module_cleanup (void *arg, int registers_valid) } /* Delete the .c file. */ - unlink (data->source_file); + unlink (data->module->source_file); /* Delete the .o file. */ - unlink (data->objfile_name_string); + unlink (objfile_name_s); delete data; } @@ -125,23 +118,12 @@ compile_object_run (compile_module_up &&module) { struct value *func_val; struct do_module_cleanup *data; - const char *objfile_name_s = objfile_name (module->objfile); int dtor_found, executed = 0; struct symbol *func_sym = module->func_sym; CORE_ADDR regs_addr = module->regs_addr; struct objfile *objfile = module->objfile; - data = new struct do_module_cleanup; - data->executedp = &executed; - data->source_file = xstrdup (module->source_file); - data->objfile_name_string = xstrdup (objfile_name_s); - data->scope = module->scope; - data->scope_data = module->scope_data; - data->out_value_type = module->out_value_type; - data->out_value_addr = module->out_value_addr; - data->munmap_list_head = module->munmap_list_head; - - xfree (module->source_file); + data = new struct do_module_cleanup (&executed, std::move (module)); try { @@ -169,9 +151,10 @@ compile_object_run (compile_module_up &&module) } if (func_type->num_fields () >= 2) { - gdb_assert (data->out_value_addr != 0); + gdb_assert (data->module->out_value_addr != 0); vargs[current_arg] = value_from_pointer - (func_type->field (current_arg).type (), data->out_value_addr); + (func_type->field (current_arg).type (), + data->module->out_value_addr); ++current_arg; } gdb_assert (current_arg == func_type->num_fields ()); -- 2.17.2