public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/4] Use gdb::checked_static_cast for catchpoints
Date: Fri, 15 Sep 2023 12:36:04 -0600	[thread overview]
Message-ID: <20230915-watchpoint-casts-v1-4-a4ff35c9644e@adacore.com> (raw)
In-Reply-To: <20230915-watchpoint-casts-v1-0-a4ff35c9644e@adacore.com>

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<ada_catchpoint *> (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<signal_catchpoint *> (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<signal_catchpoint *> (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<const signal_catchpoint *> (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<syscall_catchpoint *> (b);
 
       if (!c->syscalls_to_be_caught.empty ())
 	{

-- 
2.40.1


  parent reply	other threads:[~2023-09-15 18:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 18:36 [PATCH 0/4] Use checked_static_cast for breakpoint casts Tom Tromey
2023-09-15 18:36 ` [PATCH 1/4] Use gdb::checked_static_cast for watchpoints Tom Tromey
2023-09-18  0:40   ` Simon Marchi
2023-09-18 14:20     ` Tom Tromey
2023-09-15 18:36 ` [PATCH 2/4] Use gdb::checked_static_cast for tracepoints Tom Tromey
2023-09-15 18:36 ` [PATCH 3/4] Use gdb::checked_static_cast for code_breakpoint Tom Tromey
2023-09-15 18:36 ` Tom Tromey [this message]
2023-09-18  0:45 ` [PATCH 0/4] Use checked_static_cast for breakpoint casts Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230915-watchpoint-casts-v1-4-a4ff35c9644e@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).