From patchwork Tue Apr 23 02:09:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32370 Received: (qmail 16759 invoked by alias); 23 Apr 2019 02:10:04 -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 16544 invoked by uid 89); 23 Apr 2019 02:10:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=Catch, 2172 X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.63.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Apr 2019 02:10:01 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 058FA400C7E28 for ; Mon, 22 Apr 2019 21:10:00 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Ikshhwn2w4FKpIksihOxdQ; Mon, 22 Apr 2019 21:10:00 -0500 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=hxIC0pwzxC2fkxD1KPq5V9e93TeP4QpkzCiM2fLKWro=; b=FTuQuTEzYEYC9JVf9hN+77e7Y6 o+qn2w6+W1ZqHpRKT4R1DGyyPCD7e31HLhnJZlZg1HpyBAIsgMUQjt1Ote1mZrCVg5BU5C1QftQTM 3zNRay22TRG553RKt62KqLvkN; Received: from 97-122-168-123.hlrn.qwest.net ([97.122.168.123]:43470 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hIksh-000jpC-Qp; Mon, 22 Apr 2019 21:09:59 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 06/14] Convert break-catch-syscall.c to type-safe registry API Date: Mon, 22 Apr 2019 20:09:47 -0600 Message-Id: <20190423020955.17356-7-tom@tromey.com> In-Reply-To: <20190423020955.17356-1-tom@tromey.com> References: <20190423020955.17356-1-tom@tromey.com> This changes break-catch-syscall.c to use the type-safe registry API. gdb/ChangeLog 2019-04-22 Tom Tromey * break-catch-syscall.c (catch_syscall_inferior_data): Move. Change type. (get_catch_syscall_inferior_data): Update. (catch_syscall_inferior_data_cleanup): Remove. (_initialize_break_catch_syscall): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/break-catch-syscall.c | 25 +++++-------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 6a911fbc2a3..cd4870f7f51 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -42,8 +42,6 @@ struct syscall_catchpoint : public breakpoint std::vector syscalls_to_be_caught; }; -static const struct inferior_data *catch_syscall_inferior_data = NULL; - struct catch_syscall_inferior_data { /* We keep a count of the number of times the user has requested a @@ -61,31 +59,21 @@ struct catch_syscall_inferior_data int total_syscalls_count; }; +static const struct inferior_key + catch_syscall_inferior_data; + static struct catch_syscall_inferior_data * get_catch_syscall_inferior_data (struct inferior *inf) { struct catch_syscall_inferior_data *inf_data; - inf_data = ((struct catch_syscall_inferior_data *) - inferior_data (inf, catch_syscall_inferior_data)); + inf_data = catch_syscall_inferior_data.get (inf); if (inf_data == NULL) - { - inf_data = new struct catch_syscall_inferior_data (); - set_inferior_data (inf, catch_syscall_inferior_data, inf_data); - } + inf_data = catch_syscall_inferior_data.emplace (inf); return inf_data; } -static void -catch_syscall_inferior_data_cleanup (struct inferior *inf, void *arg) -{ - struct catch_syscall_inferior_data *inf_data - = (struct catch_syscall_inferior_data *) arg; - delete inf_data; -} - - /* Implement the "insert" breakpoint_ops method for syscall catchpoints. */ @@ -617,9 +605,6 @@ _initialize_break_catch_syscall (void) initialize_syscall_catchpoint_ops (); gdb::observers::inferior_exit.attach (clear_syscall_counts); - catch_syscall_inferior_data - = register_inferior_data_with_cleanup (NULL, - catch_syscall_inferior_data_cleanup); add_catch_command ("syscall", _("\ Catch system calls by their names, groups and/or numbers.\n\