From: Paul Ramsey Date: Fri, 8 Sep 2017 19:20:46 +0000 (+0000) Subject: #3837, --enable-debug to set PARANOIA level X-Git-Tag: 2.4.0rc1~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1cdbca255e55d4d090b940370db6da210272ce9a;p=postgis #3837, --enable-debug to set PARANOIA level This required some re-working of the protobuf sections, for reasons that aren't clear. However, hopefully that re-working will also fix things for others. Basically, the pkg-config portions seemed to only work by accident for the folks who wrote them initially, so they are improved, and the use of --without is more strongly enforced in the conditional blocks git-svn-id: http://svn.osgeo.org/postgis/trunk@15662 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/configure.ac b/configure.ac index 8448ef622..eb819ba24 100644 --- a/configure.ac +++ b/configure.ac @@ -857,7 +857,7 @@ AC_ARG_WITH([json], [AS_HELP_STRING([--without-json], [build without json-c support])], [CHECK_JSON="$withval"], []) -if test "$CHECK_JSON" != "no"; then dnl { +if test "$CHECK_JSON" != "no"; then AC_ARG_WITH([jsondir], [AS_HELP_STRING([--with-jsondir=PATH], [specify the json-c installation directory])], @@ -903,7 +903,7 @@ AC_SUBST([JSON_CPPFLAGS]) AC_SUBST([JSON_LDFLAGS]) AC_SUBST([HAVE_JSON]) -fi dnl } +fi dnl =========================================================================== @@ -927,62 +927,76 @@ AC_ARG_WITH([protobuf], [AS_HELP_STRING([--without-protobuf], [build without protobuf-c support])], [CHECK_PROTOBUF="$withval"], []) -if test "$CHECK_PROTOBUF" != "no"; then dnl { - -AC_ARG_WITH([protobufdir], - [AS_HELP_STRING([--with-protobufdir=PATH], [specify the protobuf-c installation directory])], - [PROTOBUFDIR="$withval"], [PROTOBUFDIR=]) - -if test ! "x$PROTOBUFDIR" = "x"; then - dnl Make sure that the directory exists - if test "x$PROTOBUFDIR" = "xyes"; then - AC_MSG_ERROR([you must specify a parameter to --with-protobufdir, e.g. --with-protobufdir=/path/to]) - else - AC_MSG_RESULT([Using user-specified protobuf-c directory: $PROTOBUFDIR]) - - dnl Add the include directory to PROTOBUF_CPPFLAGS - PROTOBUF_CPPFLAGS="-I$PROTOBUFDIR/include" - PROTOBUF_LDFLAGS="-L$PROTOBUFDIR/lib" - fi -fi - -dnl Check that we can find the protobuf/protobuf.h header file -CPPFLAGS_SAVE="$CPPFLAGS" -CPPFLAGS="$PROTOBUF_CPPFLAGS" -AC_CHECK_HEADER([protobuf-c/protobuf-c.h], [HAVE_PROTOBUF=yes], []) -CPPFLAGS="$CPPFLAGS_SAVE" - -dnl Ensure we can link against libprotobuf-c -LIBS_SAVE="$LIBS" -LIBS="$PROTOBUF_LDFLAGS" -AC_CHECK_LIB([protobuf-c], [protobuf_c_message_check], [HAVE_PROTOBUF=yes; PROTOBUF_LDFLAGS="${PROTOBUF_LDFLAGS} -lprotobuf-c"], [HAVE_PROTOBUF=no]) -LIBS="$LIBS_SAVE" +dnl User didn't turn off protobuf support so... +if test "$CHECK_PROTOBUF" != "no"; then + + AC_ARG_WITH([protobufdir], + [AS_HELP_STRING([--with-protobufdir=PATH], [specify the protobuf-c installation directory])], + [PROTOBUFDIR="$withval"], [PROTOBUFDIR=]) + + dnl User specified the directory to find protobuf in, check that and + dnl fail if it doesn't work + if test ! "x$PROTOBUFDIR" = "x"; then + dnl Make sure that the directory exists + if test "x$PROTOBUFDIR" = "xyes"; then + AC_MSG_ERROR([you must specify a parameter to --with-protobufdir, e.g. --with-protobufdir=/path/to]) + else + AC_MSG_RESULT([Using user-specified protobuf-c directory: $PROTOBUFDIR]) + + dnl Add the include directory to PROTOBUF_CPPFLAGS + PROTOBUF_CPPFLAGS="-I$PROTOBUFDIR/include" + PROTOBUF_LDFLAGS="-L$PROTOBUFDIR/lib" + fi + + dnl Check that we can find the protobuf/protobuf.h header file + CPPFLAGS_SAVE="$CPPFLAGS" + CPPFLAGS="$PROTOBUF_CPPFLAGS" + AC_CHECK_HEADER([protobuf-c/protobuf-c.h], [], + AC_MSG_ERROR([unable to find $PROTOBUFDIR/include/protobuf-c/protobuf-c.h]) + ) + CPPFLAGS="$CPPFLAGS_SAVE" + + dnl Ensure we can link against libprotobuf-c + LIBS_SAVE="$LIBS" + LIBS="$PROTOBUF_LDFLAGS" + AC_CHECK_LIB([protobuf-c], [protobuf_c_message_check], [], + AC_MSG_ERROR([unable to link protobuf-c from $PROTOBUFDIR/lib]) + ) + HAVE_PROTOBUF=yes + PROTOBUF_LDFLAGS="-L$PROTOBUFDIR/lib -lprotobuf-c" + LIBS="$LIBS_SAVE" + + dnl No user-specified protobuf dir, try to find one using pkg-config + else + if test "$PKG_CONFIG" = "no"; then + AC_MSG_WARN([Cannot find pkg-config, disabling protobuf support.]) + HAVE_PROTOBUF=no + else + dnl Ensure libprotobuf-c is of minimum required version + PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c >= 1.1.0], [ + HAVE_PROTOBUF=yes; + PROTOBUF_CPPFLAGS=$PROTOBUFC_CFLAGS; + PROTOBUF_LDFLAGS=$PROTOBUFC_LIBS + ], + [HAVE_PROTOBUF=no]) + fi + fi -if test "$PKG_CONFIG" = "no"; then - AC_MSG_WARN([Cannot find pkg-config, disabling protobuf support.]) - HAVE_PROTOBUF=no -else - dnl Ensure libprotobuf-c is of minimum required version - PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c >= 1.1.0], [HAVE_PROTOBUF=yes], [HAVE_PROTOBUF=no]) -fi + if test "$HAVE_PROTOBUF" = "yes"; then + AC_PATH_PROG(PROTOCC, protoc-c) + if test "x$PROTOCC" = "x"; then + AC_MSG_WARN([Protobuf compiler missing, disabling protobuf support.]) + HAVE_PROTOBUF=no + else + AC_DEFINE([HAVE_LIBPROTOBUF], [1], [Define to 1 if libprotobuf-c is present]) + fi + fi -if test "$HAVE_PROTOBUF" = "yes"; then - AC_PATH_PROG(PROTOCC, protoc-c) - if test "x$PROTOCC" = "x"; then - AC_MSG_WARN([Protobuf compiler missing, disabling protobuf support.]) - HAVE_PROTOBUF=no - else - AC_DEFINE([HAVE_LIBPROTOBUF], 1, [Define to 1 if libprotobuf-c is present]) - fi + AC_SUBST([PROTOBUF_CPPFLAGS]) + AC_SUBST([PROTOBUF_LDFLAGS]) + AC_SUBST([HAVE_PROTOBUF]) fi -AC_SUBST([PROTOBUF_CPPFLAGS]) -AC_SUBST([PROTOBUF_LDFLAGS]) -AC_SUBST([HAVE_PROTOBUF]) - -fi dnl } - - dnl =========================================================================== dnl Detect GTK+2.0 for GUI @@ -1019,24 +1033,20 @@ AC_SUBST([IGE_MAC_LIBS]) dnl =========================================================================== -dnl Allow the user to enable debugging with --enable-debug -dnl -dnl Currently we default to debug level 4. See DEBUG for more information. +dnl Allow the developer to turn on expensive checks and debugging flags +dnl with --enable-debug dnl -AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable verbose debugging messages]), - [POSTGIS_DEBUG_LEVEL=4], [POSTGIS_DEBUG_LEVEL=0]) - -AC_DEFINE_UNQUOTED([POSTGIS_DEBUG_LEVEL], [$POSTGIS_DEBUG_LEVEL], [PostGIS library debug level (0=disabled)]) - -dnl =========================================================================== -dnl Allow the user to enable GEOS profiling with --enable-profile -dnl +AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code and flags]), + [ENABLE_DEBUG=1], [ENABLE_DEBUG=0]) -AC_ARG_ENABLE([profile], AC_HELP_STRING([--enable-profile], [Enable GEOS profiling messages]), - [POSTGIS_PROFILE=1], [POSTGIS_PROFILE=0]) +if test $ENABLE_DEBUG -eq 1; then + AC_DEFINE_UNQUOTED([PARANOIA_LEVEL], [10], [Enable use of memory checks]) + CFLAGS="$CFLAGS -g" +else + AC_DEFINE_UNQUOTED([PARANOIA_LEVEL], [0], [Disable use of memory checks]) +fi -AC_DEFINE_UNQUOTED([POSTGIS_PROFILE], [$POSTGIS_PROFILE], [Enable GEOS profiling (0=disabled)]) dnl =========================================================================== dnl Define version macros diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index fb2e26ccd..6748915f4 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -1516,11 +1516,6 @@ void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2) LWPOLY *poly; int i; -#if PARANOIA_LEVEL > 0 - assert(o1 < 4); - assert(o2 < 4); -#endif - if ( (!in) || lwgeom_is_empty(in) ) return; /* TODO: check for lwgeom NOT having the specified dimension ? */ diff --git a/liblwgeom/lwgeom_api.c b/liblwgeom/lwgeom_api.c index a3fe27774..83aab7ef6 100644 --- a/liblwgeom/lwgeom_api.c +++ b/liblwgeom/lwgeom_api.c @@ -32,11 +32,6 @@ #include #include "../postgis_svn_revision.h" -/* - * Lower this to reduce integrity checks - */ -#define PARANOIA_LEVEL 1 - const char * lwgeom_version() { diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c index 4a4cdd014..dde69595a 100644 --- a/liblwgeom/lwgeom_geos.c +++ b/liblwgeom/lwgeom_geos.c @@ -1247,7 +1247,7 @@ LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in) * We should now have a collection */ #if PARANOIA_LEVEL > 0 - if ( GEOSGeometryTypeId(geos_result) != COLLECTIONTYPE ) + if ( GEOSGeomTypeId(geos_result) != COLLECTIONTYPE ) { GEOSGeom_destroy(geos_result); lwerror("Unexpected return from GEOSpolygonize"); diff --git a/liblwgeom/lwgeom_geos_split.c b/liblwgeom/lwgeom_geos_split.c index 246610bb6..3447aed0e 100644 --- a/liblwgeom/lwgeom_geos_split.c +++ b/liblwgeom/lwgeom_geos_split.c @@ -419,7 +419,7 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in) } #if PARANOIA_LEVEL > 0 - if ( GEOSGeometryTypeId(polygons) != COLLECTIONTYPE ) + if ( GEOSGeomTypeId(polygons) != COLLECTIONTYPE ) { GEOSGeom_destroy(g1); GEOSGeom_destroy(g2); diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c index d2b0403f3..102b2c1bd 100644 --- a/liblwgeom/ptarray.c +++ b/liblwgeom/ptarray.c @@ -391,11 +391,6 @@ ptarray_swap_ordinates(POINTARRAY *pa, LWORD o1, LWORD o2) double d, *dp1, *dp2; POINT4D p; -#if PARANOIA_LEVEL > 0 - assert(o1 < 4); - assert(o2 < 4); -#endif - dp1 = ((double*)&p)+(unsigned)o1; dp2 = ((double*)&p)+(unsigned)o2; for (i=0 ; i < pa->npoints ; i++) diff --git a/libpgcommon/lwgeom_pg.c b/libpgcommon/lwgeom_pg.c index 5f800c6a7..f5d84a605 100644 --- a/libpgcommon/lwgeom_pg.c +++ b/libpgcommon/lwgeom_pg.c @@ -29,8 +29,6 @@ #include #include -#define PARANOIA_LEVEL 1 - #define PGC_ERRMSG_MAXLEN 256 /** diff --git a/postgis_config.h.in b/postgis_config.h.in index d4ffab56e..47b057852 100644 --- a/postgis_config.h.in +++ b/postgis_config.h.in @@ -3,6 +3,13 @@ #include "postgis_svn_revision.h" +/* Manually manipulate the POSTGIS_DEBUG_LEVEL, it is not affected by the + configure process */ +#define POSTGIS_DEBUG_LEVEL 0 + +/* Define to 1 to enable memory checks in pointarray management. */ +#undef PARANOIA_LEVEL + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS @@ -121,9 +128,6 @@ /* PostGIS build date */ #undef POSTGIS_BUILD_DATE -/* PostGIS library debug level (0=disabled) */ -#undef POSTGIS_DEBUG_LEVEL - /* SFCGAL library version at buil time */ #undef POSTGIS_SFCGAL_VERSION @@ -151,9 +155,6 @@ /* PostgreSQL server version */ #undef POSTGIS_PGSQL_VERSION -/* Enable GEOS profiling (0=disabled) */ -#undef POSTGIS_PROFILE - /* PROJ library version */ #undef POSTGIS_PROJ_VERSION