From patchwork Fri Sep 15 18:36:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 76161 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B2BD03858C33 for ; Fri, 15 Sep 2023 18:36:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2BD03858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694802990; bh=+glESpznIMCc7o704EobzYrO6pnGGG2Op2QNydhiD/s=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xDeI/opf+ncbY3k+ABxuSiRFgUDXrsVY0eIdJDJx4aRg4unATUy4VVfA135o/Cd1I 2/Xv9IWc7cPVpg11UURROmHwa59ij2aQHN0pFGy39afpV6HFDu774aJB9BmlScFvmP +BEWuYqvfUeRZ70RvVC7OrgJCFpoyPCuJ9j7J9KI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 83AD33858C3A for ; Fri, 15 Sep 2023 18:36:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83AD33858C3A Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-34fcbb4a097so1569645ab.1 for ; Fri, 15 Sep 2023 11:36:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694802966; x=1695407766; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+glESpznIMCc7o704EobzYrO6pnGGG2Op2QNydhiD/s=; b=lwv83IQJBRJ1zUZ0YdsT09NISK3kHe76NF7cEQrfhGb+/u1pPz2gHoAZisD3EooIyb OfwakFxUz0FS1XeBtA1FXixjJdANOeQroDAMn52rxqQFfikVZUeCBpBK1tZ3R5HwD1ra hcnyAYEaDpdWQKISaku7KdBJ2dy6BKxZHuUWE4vudmXP1/BMd5cDWiZccYjaYGY4tCPt wxz5w2Wha1nx0+MRr3FvZd++kbgc7Ex6g7FyeA84dEe9XAcmXBoHcsWnN1RAsS5+a4c8 O8eDtCeLpBNTphat7gwNCbpMUisbh/VJP1wK8msgDIHTChE/PZiGLnVa7rkRkdcQfDCf arjg== X-Gm-Message-State: AOJu0YwW1ZidiSLzGVmYUCvnAn0l8OCsyx0vFJOZVG4bEGeot+Ix2xUL oZDG3P7kUhnREck+SDfboLF6b89wzIV/GihWq08pRQ== X-Google-Smtp-Source: AGHT+IGKfJITDGG4yd/omtAxYcM39zW+FEoJT2hXJSXJCYLnoNtOA8b8D32jDGpQLAZLuIf8jga2sw== X-Received: by 2002:a05:6e02:de2:b0:34f:41ba:7c98 with SMTP id m2-20020a056e020de200b0034f41ba7c98mr2885231ilj.12.1694802965837; Fri, 15 Sep 2023 11:36:05 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id w25-20020a02cf99000000b0042b0a6d899fsm1235997jar.60.2023.09.15.11.36.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 11:36:05 -0700 (PDT) Date: Fri, 15 Sep 2023 12:36:04 -0600 Subject: [PATCH 4/4] Use gdb::checked_static_cast for catchpoints MIME-Version: 1.0 Message-Id: <20230915-watchpoint-casts-v1-4-a4ff35c9644e@adacore.com> References: <20230915-watchpoint-casts-v1-0-a4ff35c9644e@adacore.com> In-Reply-To: <20230915-watchpoint-casts-v1-0-a4ff35c9644e@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This replaces some casts to various kinds of catchpoint with checked_static_cast. --- gdb/ada-lang.c | 3 ++- gdb/break-catch-sig.c | 8 +++++--- gdb/break-catch-syscall.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2496c099f19..b1de58cce6f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12203,7 +12203,8 @@ ada_catchpoint::allocate_location () bool ada_catchpoint::should_stop_exception (const struct bp_location *bl) const { - struct ada_catchpoint *c = (struct ada_catchpoint *) bl->owner; + struct ada_catchpoint *c + = gdb::checked_static_cast (bl->owner); const struct ada_catchpoint_location *ada_loc = (const struct ada_catchpoint_location *) bl; bool stop; diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index 10c8b81f8e8..cc4f525e3a3 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -103,7 +103,8 @@ signal_to_name_or_int (enum gdb_signal sig) int signal_catchpoint::insert_location (struct bp_location *bl) { - struct signal_catchpoint *c = (struct signal_catchpoint *) bl->owner; + struct signal_catchpoint *c + = gdb::checked_static_cast (bl->owner); if (!c->signals_to_be_caught.empty ()) { @@ -130,7 +131,8 @@ int signal_catchpoint::remove_location (struct bp_location *bl, enum remove_bp_reason reason) { - struct signal_catchpoint *c = (struct signal_catchpoint *) bl->owner; + struct signal_catchpoint *c + = gdb::checked_static_cast (bl->owner); if (!c->signals_to_be_caught.empty ()) { @@ -166,7 +168,7 @@ signal_catchpoint::breakpoint_hit (const struct bp_location *bl, const target_waitstatus &ws) { const struct signal_catchpoint *c - = (const struct signal_catchpoint *) bl->owner; + = gdb::checked_static_cast (bl->owner); gdb_signal signal_number; if (ws.kind () != TARGET_WAITKIND_STOPPED) diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 9abf8183984..313ac44562c 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -480,10 +480,10 @@ catch_syscall_enabled (void) static bool catching_syscall_number_1 (struct breakpoint *b, int syscall_number) { - if (is_syscall_catchpoint_enabled (b)) { - struct syscall_catchpoint *c = (struct syscall_catchpoint *) b; + struct syscall_catchpoint *c + = gdb::checked_static_cast (b); if (!c->syscalls_to_be_caught.empty ()) {