From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.129]) by sourceware.org (Postfix) with ESMTPS id B4D78386103B for ; Sat, 18 Jul 2020 17:29:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B4D78386103B 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 cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 38161406FA for ; Sat, 18 Jul 2020 12:29:20 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id wqeGjf4G4zOauwqeGjYyzN; Sat, 18 Jul 2020 12:29:20 -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=/ALPBHI7RkRvWIK0Wjw5VqOohRnXCphuxae5tQg3bR4=; b=AXIjDFsUBSk0kpZI9biiibkwyy LRhU1nX0HvCRBFaKk6954jHyc18x3rLlxuSut90mJJ/VdDzuDcSudFXz4AVhskDgz5bibi0hZcWam fsioMxo6MbUhk0Ajk+Htblil5; Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:56458 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 1jwqeG-000fmD-8W; Sat, 18 Jul 2020 11:29:20 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 8/9] Use htab_up in type copying Date: Sat, 18 Jul 2020 11:29:14 -0600 Message-Id: <20200718172915.6811-9-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200718172915.6811-1-tom@tromey.com> References: <20200718172915.6811-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: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jwqeG-000fmD-8W X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya.Home) [174.16.104.48]:56458 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3035.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL, TXREP 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: Sat, 18 Jul 2020 17:29:27 -0000 This changes create_copied_types_hash to return an htab_up, then modifies the callers to avoid explicit use of htab_delete. gdb/ChangeLog 2020-07-18 Tom Tromey * value.c (preserve_values): Update. * python/py-type.c (save_objfile_types): Update. * guile/scm-type.c (save_objfile_types): Update. * gdbtypes.h (create_copied_types_hash): Return htab_up. * gdbtypes.c (create_copied_types_hash): Return htab_up. * compile/compile-object-run.c (compile_object_run): Update. --- gdb/ChangeLog | 9 +++++++++ gdb/compile/compile-object-run.c | 6 ++---- gdb/gdbtypes.c | 10 +++++----- gdb/gdbtypes.h | 2 +- gdb/guile/scm-type.c | 7 ++----- gdb/python/py-type.c | 10 ++++------ gdb/value.c | 11 ++++------- 7 files changed, 27 insertions(+), 28 deletions(-) diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index a2f39900053..533478a0fb4 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -140,14 +140,12 @@ compile_object_run (struct compile_module *module) try { struct type *func_type = SYMBOL_TYPE (func_sym); - htab_t copied_types; int current_arg = 0; struct value **vargs; /* OBJFILE may disappear while FUNC_TYPE still will be in use. */ - copied_types = create_copied_types_hash (objfile); - func_type = copy_type_recursive (objfile, func_type, copied_types); - htab_delete (copied_types); + htab_up copied_types = create_copied_types_hash (objfile); + func_type = copy_type_recursive (objfile, func_type, copied_types.get ()); gdb_assert (func_type->code () == TYPE_CODE_FUNC); func_val = value_from_pointer (lookup_pointer_type (func_type), diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index e87648813ec..9c395846895 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5201,13 +5201,13 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) types without duplicates. We use OBJFILE's obstack, because OBJFILE is about to be deleted. */ -htab_t +htab_up create_copied_types_hash (struct objfile *objfile) { - return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq, - NULL, &objfile->objfile_obstack, - hashtab_obstack_allocate, - dummy_obstack_deallocate); + return htab_up (htab_create_alloc_ex (1, type_pair_hash, type_pair_eq, + NULL, &objfile->objfile_obstack, + hashtab_obstack_allocate, + dummy_obstack_deallocate)); } /* Recursively copy (deep copy) a dynamic attribute list of a type. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index eaa4cff608d..3a8b5e7ad80 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2379,7 +2379,7 @@ extern int class_or_union_p (const struct type *); extern void maintenance_print_type (const char *, int); -extern htab_t create_copied_types_hash (struct objfile *objfile); +extern htab_up create_copied_types_hash (struct objfile *objfile); extern struct type *copy_type_recursive (struct objfile *objfile, struct type *type, diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 19b7996c946..8fc9629eb0d 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -387,20 +387,17 @@ static void save_objfile_types (struct objfile *objfile, void *datum) { htab_t htab = (htab_t) datum; - htab_t copied_types; if (!gdb_scheme_initialized) return; - copied_types = create_copied_types_hash (objfile); + htab_up copied_types = create_copied_types_hash (objfile); if (htab != NULL) { - htab_traverse_noresize (htab, tyscm_copy_type_recursive, copied_types); + htab_traverse_noresize (htab, tyscm_copy_type_recursive, copied_types.get ()); htab_delete (htab); } - - htab_delete (copied_types); } /* Administrivia for field smobs. */ diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index d0dfb52811b..f37a7652f6d 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1068,7 +1068,6 @@ static void save_objfile_types (struct objfile *objfile, void *datum) { type_object *obj = (type_object *) datum; - htab_t copied_types; if (!gdb_python_initialized) return; @@ -1077,23 +1076,22 @@ save_objfile_types (struct objfile *objfile, void *datum) operating on. */ gdbpy_enter enter_py (objfile->arch (), current_language); - copied_types = create_copied_types_hash (objfile); + htab_up copied_types = create_copied_types_hash (objfile); while (obj) { type_object *next = obj->next; - htab_empty (copied_types); + htab_empty (copied_types.get ()); - obj->type = copy_type_recursive (objfile, obj->type, copied_types); + obj->type = copy_type_recursive (objfile, obj->type, + copied_types.get ()); obj->next = NULL; obj->prev = NULL; obj = next; } - - htab_delete (copied_types); } static void diff --git a/gdb/value.c b/gdb/value.c index 3a5b02bcb46..a018443a2c5 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2516,22 +2516,19 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, void preserve_values (struct objfile *objfile) { - htab_t copied_types; struct internalvar *var; /* Create the hash table. We allocate on the objfile's obstack, since it is soon to be deleted. */ - copied_types = create_copied_types_hash (objfile); + htab_up copied_types = create_copied_types_hash (objfile); for (const value_ref_ptr &item : value_history) - preserve_one_value (item.get (), objfile, copied_types); + preserve_one_value (item.get (), objfile, copied_types.get ()); for (var = internalvars; var; var = var->next) - preserve_one_internalvar (var, objfile, copied_types); + preserve_one_internalvar (var, objfile, copied_types.get ()); - preserve_ext_lang_values (objfile, copied_types); - - htab_delete (copied_types); + preserve_ext_lang_values (objfile, copied_types.get ()); } static void -- 2.17.2