Use gdb::checked_static_cast for catchpoints
authorTom Tromey <tromey@adacore.com>
Fri, 15 Sep 2023 18:22:47 +0000 (12:22 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 19 Sep 2023 14:14:01 +0000 (08:14 -0600)
This replaces some casts to various kinds of catchpoint with
checked_static_cast.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c
gdb/break-catch-sig.c
gdb/break-catch-syscall.c

index 2496c099f19e01d37d7f5e438a5da2cb2383004a..b9a271bc12689a29aa4ce2dffc929386ced4297d 100644 (file)
@@ -12203,7 +12203,7 @@ 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;
+  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;
index 10c8b81f8e83f2dc0b2ef33956a55447fc5cb5dd..7a07fb61100704dbf2b80d5497bf1821bce9683b 100644 (file)
@@ -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;
+  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;
+  signal_catchpoint *c
+    = gdb::checked_static_cast<signal_catchpoint *> (bl->owner);
 
   if (!c->signals_to_be_caught.empty ())
     {
@@ -165,8 +167,8 @@ signal_catchpoint::breakpoint_hit (const struct bp_location *bl,
                                   CORE_ADDR bp_addr,
                                   const target_waitstatus &ws)
 {
-  const struct signal_catchpoint *c
-    = (const struct signal_catchpoint *) bl->owner;
+  const signal_catchpoint *c
+    = gdb::checked_static_cast<const signal_catchpoint *> (bl->owner);
   gdb_signal signal_number;
 
   if (ws.kind () != TARGET_WAITKIND_STOPPED)
index 9abf8183984f2a7d6b079ddaa759974dce5d8eb2..9bdfcf73efa31956af45ea765e9c0a1989b97729 100644 (file)
@@ -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;
+      syscall_catchpoint *c
+       = gdb::checked_static_cast<syscall_catchpoint *> (b);
 
       if (!c->syscalls_to_be_caught.empty ())
        {