* gdb_assert.h (gdb_assert_not_reached): New macro.
authorDoug Evans <dje@google.com>
Wed, 18 Aug 2010 19:13:33 +0000 (19:13 +0000)
committerDoug Evans <dje@google.com>
Wed, 18 Aug 2010 19:13:33 +0000 (19:13 +0000)
(gdb_assert_fail): Fix typo in comment.
* avr-tdep.c (avr_return_value): Use gdb_assert_not_reached instead of
gdb_assert (0).
* darwin-nat.c (darwin_check_new_threads): Ditto.
* dwarf2read.c (dwarf2_get_section_info): Ditto.
(munmap_section_buffer): Ditto.
* m32c-tdep.c (make_types): Ditto.
(m32c_decode_srcdest4, m32c_decode_sd23, m32c_frame_base): Ditto.
* macroexp.c (get_character_constant): Ditto.
(get_string_literal): Ditto.
* mep-tdep.c (mep_pseudo_cr_size): Ditto.
(mep_pseudo_cr_index, mep_register_type): Ditto.
(mep_pseudo_register_read, mep_pseudo_register_write): Ditto.
(mep_get_insn, mep_analyze_prologue): Ditto.
* objfiles.c (qsort_cmp): Ditto.
* prologue-value.c (pv_is_identical): Ditto.
* record.c (record_get_loc): Ditto.
* value.c (value_static_field): Ditto.
* xtensa-tdep.c (call0_track_op): Ditto.

13 files changed:
gdb/ChangeLog
gdb/avr-tdep.c
gdb/darwin-nat.c
gdb/dwarf2read.c
gdb/gdb_assert.h
gdb/m32c-tdep.c
gdb/macroexp.c
gdb/mep-tdep.c
gdb/objfiles.c
gdb/prologue-value.c
gdb/record.c
gdb/value.c
gdb/xtensa-tdep.c

index 5ae1bc6f6c3027ee5da016efa2c79dc4498707e4..bcbff59abd92009b7b8371141457ba9cec2a11db 100644 (file)
@@ -1,3 +1,26 @@
+2010-08-18  Doug Evans  <dje@google.com>
+
+       * gdb_assert.h (gdb_assert_not_reached): New macro.
+       (gdb_assert_fail): Fix typo in comment.
+       * avr-tdep.c (avr_return_value): Use gdb_assert_not_reached instead of
+       gdb_assert (0).
+       * darwin-nat.c (darwin_check_new_threads): Ditto.
+       * dwarf2read.c (dwarf2_get_section_info): Ditto.
+       (munmap_section_buffer): Ditto.
+       * m32c-tdep.c (make_types): Ditto.
+       (m32c_decode_srcdest4, m32c_decode_sd23, m32c_frame_base): Ditto.
+       * macroexp.c (get_character_constant): Ditto.
+       (get_string_literal): Ditto.
+       * mep-tdep.c (mep_pseudo_cr_size): Ditto.
+       (mep_pseudo_cr_index, mep_register_type): Ditto.
+       (mep_pseudo_register_read, mep_pseudo_register_write): Ditto.
+       (mep_get_insn, mep_analyze_prologue): Ditto.
+       * objfiles.c (qsort_cmp): Ditto.
+       * prologue-value.c (pv_is_identical): Ditto.
+       * record.c (record_get_loc): Ditto.
+       * value.c (value_static_field): Ditto.
+       * xtensa-tdep.c (call0_track_op): Ditto.
+
 2010-08-18  Tom Tromey  <tromey@redhat.com>
 
        PR symtab/11919:
index ef7d2a71068f6a2dbf32f8057b59c63791714b37..1b9e41139ab91448cdeb3fa2ef9f2ffd5575dc5b 100644 (file)
@@ -922,7 +922,7 @@ avr_return_value (struct gdbarch *gdbarch, struct type *func_type,
   else if (TYPE_LENGTH (valtype) <= 8)
     lsb_reg = 18;
   else
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected type length");
 
   if (writebuf != NULL)
     {
index 40b9f3fdf000c9ccc7ea62cc7b18539f61cba7f3..4cd0e0b7c90a4dbb765fd6bcdbe1df3299d7cbf4 100644 (file)
@@ -363,7 +363,7 @@ darwin_check_new_threads (struct inferior *inf)
          old_ix++;
          continue;
        }
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected thread case");
     }
 
   if (darwin_inf->threads)
index 09e78042d31b81f35be62584c1c53f13e1975a27..6ea1704c3c03aa1a54096c836474ab450ec5d196 100644 (file)
@@ -1585,7 +1585,7 @@ dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
   else if (section_is_p (section_name, FRAME_SECTION))
     info = &data->frame;
   else
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected section");
 
   if (info->asection != NULL && info->size != 0 && info->buffer == NULL)
     /* We haven't read this section in yet.  Do it now.  */
@@ -14263,7 +14263,7 @@ munmap_section_buffer (struct dwarf2_section_info *info)
       gdb_assert (munmap ((void *) map_begin, map_length) == 0);
 #else
       /* Without HAVE_MMAP, we should never be here to begin with.  */
-      gdb_assert (0);
+      gdb_assert_not_reached ("no mmap support");
 #endif
     }
 }
index 2d04fb0b22b4c69904550745821e9949a68a5c70..853797629cd3c3d37c318cd90df452a99f801f2e 100644 (file)
@@ -42,7 +42,7 @@
 #endif
 #endif
 
-/* This prints an "Assertion failed" message, aksing the user if they
+/* This prints an "Assertion failed" message, asking the user if they
    want to continue, dump core, or just exit.  */
 #if defined (ASSERT_FUNCTION)
 #define gdb_assert_fail(assertion, file, line, function)                      \
                  assertion)
 #endif
 
+/* The canonical form of gdb_assert (0).
+   MESSAGE is a string to include in the error message.  */
+
+#if defined (ASSERT_FUNCTION)
+#define gdb_assert_not_reached(message) \
+  internal_error (__FILE__, __LINE__, "%s: %s", ASSERT_FUNCTION, _(message))
+#else
+#define gdb_assert_not_reached(message) \
+  internal_error (__FILE__, __LINE__, _(message))
+#endif
+
 #endif /* gdb_assert.h */
index 6f640d53842382d784b80c6b8f7778fd1793f22c..992cb007fd6fde8c4e45dbeb2070865ed8a7911f 100644 (file)
@@ -187,7 +187,7 @@ make_types (struct gdbarch *arch)
       break;
 
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected mach");
     }
 
   /* The builtin_type_mumble variables are sometimes uninitialized when
@@ -1242,7 +1242,7 @@ m32c_decode_srcdest4 (struct m32c_pv_state *st,
     case 0xf: sd.addr = pv_constant (m32c_udisp16 (st)); break;
 
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected srcdest4");
     }
 
   return sd;
@@ -1301,7 +1301,7 @@ m32c_decode_sd23 (struct m32c_pv_state *st, int code, int size, int ind)
     case 0x0f: sd.addr = pv_constant (m32c_udisp16 (st)); break;
     case 0x0e: sd.addr = pv_constant (m32c_udisp24 (st)); break;
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected sd23");
     }
 
   if (ind)
@@ -1886,7 +1886,7 @@ m32c_frame_base (struct frame_info *this_frame,
       return 0;
 
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected prologue kind");
     }
 }
 
index 73e68d76df5f69158446b8d549e832840f1c1000..86689c3362168035ea93ee7a12a3fbbffe064ffd 100644 (file)
@@ -334,7 +334,7 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
       else if (*p == 'L' || *p == 'u' || *p == 'U')
         p += 2;
       else
-        gdb_assert (0);
+        gdb_assert_not_reached ("unexpected character constant");
 
       body_start = p;
       for (;;)
@@ -389,7 +389,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
       else if (*p == 'L' || *p == 'u' || *p == 'U')
         p += 2;
       else
-        gdb_assert (0);
+        gdb_assert_not_reached ("unexpected string literal");
 
       for (;;)
         {
index bd200c1443726f66f1313e9f3aa88fddd5919ecf..5cf76a220822af76af66a8f1ab55246d90f064f0 100644 (file)
@@ -804,7 +804,7 @@ mep_pseudo_cr_size (int pseudo)
            || IS_FP_CR64_REGNUM (pseudo))
     return 64;
   else
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected coprocessor pseudo register");
 }
 
 
@@ -833,7 +833,7 @@ mep_pseudo_cr_index (int pseudo)
   else if (IS_FP_CR64_REGNUM (pseudo))
       return pseudo - MEP_FIRST_FP_CR64_REGNUM;
   else
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected coprocessor pseudo register");
 }
 
 
@@ -1109,7 +1109,7 @@ mep_register_type (struct gdbarch *gdbarch, int reg_nr)
             return builtin_type (gdbarch)->builtin_uint64;
         }
       else
-        gdb_assert (0);
+        gdb_assert_not_reached ("unexpected cr size");
     }
 
   /* All other registers are 32 bits long.  */
@@ -1180,7 +1180,7 @@ mep_pseudo_register_read (struct gdbarch *gdbarch,
            || IS_FP_CR64_REGNUM (cookednum))
     mep_pseudo_cr64_read (gdbarch, regcache, cookednum, buf);
   else
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected pseudo register");
 }
 
 
@@ -1263,7 +1263,7 @@ mep_pseudo_register_write (struct gdbarch *gdbarch,
   else if (IS_CCR_REGNUM (cookednum))
     regcache_raw_write (regcache, mep_pseudo_to_raw[cookednum], buf);
   else
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected pseudo register");
 }
 
 
@@ -1488,7 +1488,7 @@ mep_get_insn (struct gdbarch *gdbarch, CORE_ADDR pc, long *insn)
 
       /* We'd better be in either core, 32-bit VLIW, or 64-bit VLIW mode.  */
       else
-        gdb_assert (0);
+        gdb_assert_not_reached ("unexpected vliw mode");
     }
   
   /* Otherwise, the top two bits of the major opcode are (again) what
@@ -1792,8 +1792,7 @@ mep_analyze_prologue (struct gdbarch *gdbarch,
           int disp = SWBH_32_OFFSET (insn);
           int size = (IS_SB (insn) ? 1
                       : IS_SH (insn) ? 2
-                      : IS_SW (insn) ? 4
-                      : (gdb_assert (0), 1));
+                      : (gdb_assert (IS_SW (insn)), 4));
           pv_t addr = pv_add_constant (reg[rm], disp);
 
           if (pv_area_store_would_trash (stack, addr))
index b522189b92783bf5c92489697ccef6ce655ba664..a5e07e10d61058adcf236371552760bc568211f2 100644 (file)
@@ -1068,7 +1068,7 @@ qsort_cmp (const void *a, const void *b)
              return 1;
 
          /* We should have found one of the sections before getting here.  */
-         gdb_assert (0);
+         gdb_assert_not_reached ("section not found");
        }
       else
        {
@@ -1083,12 +1083,12 @@ qsort_cmp (const void *a, const void *b)
              return 1;
 
          /* We should have found one of the objfiles before getting here.  */
-         gdb_assert (0);
+         gdb_assert_not_reached ("objfile not found");
        }
     }
 
   /* Unreachable.  */
-  gdb_assert (0);
+  gdb_assert_not_reached ("unexpected code path");
   return 0;
 }
 
index 4ff5a0c7f676d5e827478b54944af914becd4658..f1dd2bb0ad13bc795bfb06910c3bd9dcbbf148d6 100644 (file)
@@ -203,7 +203,7 @@ pv_is_identical (pv_t a, pv_t b)
     case pvk_register:
       return (a.reg == b.reg && a.k == b.k);
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected prologue value kind");
     }
 }
 
index 0b4924bbd94288999d5caa73a74a1ef7b8fda6a1..89a2d6bd9c9b90c92d7619458862970e78fd6eae 100644 (file)
@@ -454,7 +454,7 @@ record_get_loc (struct record_entry *rec)
       return rec->u.reg.u.buf;
   case record_end:
   default:
-    gdb_assert (0);
+    gdb_assert_not_reached ("unexpected record_entry type");
     return NULL;
   }
 }
index d1c37e37c2d830a551a0176cd5fd151303564203..e5754d062bc7f03ebb825e81a1ad861836a68093 100644 (file)
@@ -1917,7 +1917,7 @@ value_static_field (struct type *type, int fieldno)
       break;
     }
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected field location kind");
     }
 
   return retval;
index 370b3edbfe3eb088084c256d25895f2f09b35758..dca12befb66985fc739237a7de86639132496b88 100644 (file)
@@ -2057,7 +2057,7 @@ call0_track_op (struct gdbarch *gdbarch,
        }
       break;
     default:
-       gdb_assert (0);
+       gdb_assert_not_reached ("unexpected instruction kind");
     }
 }
 
This page took 0.051632 seconds and 4 git commands to generate.