From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway34.websitewelcome.com (gateway34.websitewelcome.com [192.185.149.62]) by sourceware.org (Postfix) with ESMTPS id 335593858D34 for ; Sat, 18 Jul 2020 17:29:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 335593858D34 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 gateway34.websitewelcome.com (Postfix) with ESMTP id 897D3CF0E0 for ; Sat, 18 Jul 2020 12:29:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id wqeEjPY8lQyTQwqeEjDSlu; Sat, 18 Jul 2020 12:29:18 -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=EZH54usoWiJ9iu2qUFdVpujhP+/Sl3o08HxAsYkvs+k=; b=MEAqWGl39kuHUYxg8wQt21RnAi LSpuSMU2SBV4nnwEv3kAInteyiAuFd1OnCPI3wcDCXUWfBfJfCMamPFoKGIFVGInLgZcWTvbalqMW 0dX6ecKjJnNH3+AdwF8Z5Vhw/; 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 1jwqeE-000fmD-B4; Sat, 18 Jul 2020 11:29:18 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/9] Use htab_up in auto-load.c Date: Sat, 18 Jul 2020 11:29:07 -0600 Message-Id: <20200718172915.6811-2-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: 1jwqeE-000fmD-B4 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: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3036.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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:21 -0000 This changes auto-load.c to use htab_up, rather than manually calling htab_delete. gdb/ChangeLog 2020-07-18 Tom Tromey * auto-load.c (struct auto_load_pspace_info) <~auto_load_pspace_info>: Default. : Change type to htab_up. (~auto_load_pspace_info) Remove. (init_loaded_scripts_info, maybe_add_script_file) (maybe_add_script_text, auto_load_info_scripts): Update. --- gdb/ChangeLog | 10 ++++++++++ gdb/auto-load.c | 40 +++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/gdb/auto-load.c b/gdb/auto-load.c index c967261925a..e21788f481f 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -530,12 +530,12 @@ For more information about this security protection see the\n\ struct auto_load_pspace_info { auto_load_pspace_info () = default; - ~auto_load_pspace_info (); + ~auto_load_pspace_info () = default; /* For each program space we keep track of loaded scripts, both when specified as file names and as scripts to be executed directly. */ - struct htab *loaded_script_files = nullptr; - struct htab *loaded_script_texts = nullptr; + htab_up loaded_script_files; + htab_up loaded_script_texts; /* Non-zero if we've issued the warning about an auto-load script not being supported. We only want to issue this warning once. */ @@ -567,14 +567,6 @@ struct loaded_script static const struct program_space_key auto_load_pspace_data; -auto_load_pspace_info::~auto_load_pspace_info () -{ - if (loaded_script_files) - htab_delete (loaded_script_files); - if (loaded_script_texts) - htab_delete (loaded_script_texts); -} - /* Get the current autoload data. If none is found yet, add it now. This function always returns a valid object. */ @@ -621,14 +613,16 @@ init_loaded_scripts_info (struct auto_load_pspace_info *pspace_info) Space for each entry is obtained with one malloc so we can free them easily. */ - pspace_info->loaded_script_files = htab_create (31, - hash_loaded_script_entry, - eq_loaded_script_entry, - xfree); - pspace_info->loaded_script_texts = htab_create (31, - hash_loaded_script_entry, - eq_loaded_script_entry, - xfree); + pspace_info->loaded_script_files.reset + (htab_create (31, + hash_loaded_script_entry, + eq_loaded_script_entry, + xfree)); + pspace_info->loaded_script_texts.reset + (htab_create (31, + hash_loaded_script_entry, + eq_loaded_script_entry, + xfree)); pspace_info->unsupported_script_warning_printed = false; pspace_info->script_not_found_warning_printed = false; @@ -660,7 +654,7 @@ maybe_add_script_file (struct auto_load_pspace_info *pspace_info, int loaded, const char *name, const char *full_path, const struct extension_language_defn *language) { - struct htab *htab = pspace_info->loaded_script_files; + struct htab *htab = pspace_info->loaded_script_files.get (); struct loaded_script **slot, entry; int in_hash_table; @@ -708,7 +702,7 @@ maybe_add_script_text (struct auto_load_pspace_info *pspace_info, int loaded, const char *name, const struct extension_language_defn *language) { - struct htab *htab = pspace_info->loaded_script_texts; + struct htab *htab = pspace_info->loaded_script_texts.get (); struct loaded_script **slot, entry; int in_hash_table; @@ -1299,7 +1293,7 @@ auto_load_info_scripts (const char *pattern, int from_tty, collect_matching_scripts_data data (&script_files, language); /* Pass a pointer to scripts as VEC_safe_push can realloc space. */ - htab_traverse_noresize (pspace_info->loaded_script_files, + htab_traverse_noresize (pspace_info->loaded_script_files.get (), collect_matching_scripts, &data); std::sort (script_files.begin (), script_files.end (), @@ -1311,7 +1305,7 @@ auto_load_info_scripts (const char *pattern, int from_tty, collect_matching_scripts_data data (&script_texts, language); /* Pass a pointer to scripts as VEC_safe_push can realloc space. */ - htab_traverse_noresize (pspace_info->loaded_script_texts, + htab_traverse_noresize (pspace_info->loaded_script_texts.get (), collect_matching_scripts, &data); std::sort (script_texts.begin (), script_texts.end (), -- 2.17.2