This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Assert gdbarch != NULL
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 03 May 2002 16:59:35 -0400
- Subject: [patch] Assert gdbarch != NULL
Hello,
The attached patch just checks that the ``gdbarch'' isn't NULL before
using it. As they say, this should just never happen (but it did).
committed,
Andrew
2002-05-03 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh: Assert that gdbarch is non-NULL.
* gdbarch.c: Regenerate.
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.132
diff -u -r1.132 gdbarch.sh
--- gdbarch.sh 2 May 2002 01:38:27 -0000 1.132
+++ gdbarch.sh 3 May 2002 20:49:09 -0000
@@ -1628,6 +1628,7 @@
printf "int\n"
printf "gdbarch_${function}_p (struct gdbarch *gdbarch)\n"
printf "{\n"
+ printf " gdb_assert (gdbarch != NULL);\n"
if [ -n "${valid_p}" ]
then
printf " return ${valid_p};\n"
@@ -1647,6 +1648,7 @@
printf "gdbarch_${function} (struct gdbarch *gdbarch, ${formal})\n"
fi
printf "{\n"
+ printf " gdb_assert (gdbarch != NULL);\n"
printf " if (gdbarch->${function} == 0)\n"
printf " internal_error (__FILE__, __LINE__,\n"
printf " \"gdbarch: gdbarch_${function} invalid\");\n"
@@ -1688,6 +1690,7 @@
printf "${returntype}\n"
printf "gdbarch_${function} (struct gdbarch *gdbarch)\n"
printf "{\n"
+ printf " gdb_assert (gdbarch != NULL);\n"
if [ "x${invalid_p}" = "x0" ]
then
printf " /* Skip verify of ${function}, invalid_p == 0 */\n"
@@ -1719,6 +1722,7 @@
printf "${returntype}\n"
printf "gdbarch_${function} (struct gdbarch *gdbarch)\n"
printf "{\n"
+ printf " gdb_assert (gdbarch != NULL);\n"
printf " if (gdbarch_debug >= 2)\n"
printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_${function} called\\\\n\");\n"
printf " return gdbarch->${function};\n"