configure --enable-debug - no debug messages

Report bugs, bug fixes and workarounds here.
Topic author
refsteff
Posts: 17
Joined: 30.07.2011
With us: 13 years 3 months

configure --enable-debug - no debug messages

Post #1by refsteff » 26.09.2011, 08:40

Hello,

I was testing celestia Qt4 GUI with different config files and for debugging I did a configure --with-qt --enable-debug. I realized that if the config file didn't exists / wasn't readable, I only got the "Error reading configuration file" message box and after clicking ok, celestia exited with an segmentation fault.
No output of further messages because the DEBUG symbol was only defined in config.h
The following patch solves this:

Code: Select all

diff -urN celestia.org/src/celutil/debug.h celestia/src/celutil/debug.h
--- celestia.org/src/celutil/debug.h   2011-08-19 16:05:07.000000000 +0200
+++ celestia/src/celutil/debug.h   2011-09-25 21:23:34.683220842 +0200
@@ -10,6 +10,10 @@
 #ifndef _DEBUG_H_
 #define _DEBUG_H_
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
 // Define the DPRINTF macro; g++ supports macros with variable
 // length arguments, so we'll use those when we can.
 #ifndef DPRINTF

HAVE_CONFIG_H is only defined if you use configure to create the makefiles,
so you can do the same with debug.cpp

Code: Select all

diff -urN celestia.org/src/celutil/debug.cpp celestia/src/celutil/debug.cpp
--- celestia.org/src/celutil/debug.cpp   2011-08-19 16:05:07.000000000 +0200
+++ celestia/src/celutil/debug.cpp   2011-09-25 21:23:10.993219030 +0200
@@ -13,11 +13,9 @@
 #include <stdio.h>
 #include <cstdarg>
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* TARGET_OS_MAC */
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 static int debugVerbosity = 0;
 

The side effect of this patch is you don't have to create an empty config.h file if you use qmake on Linux.

Until now I can't fix the segmentation fault . Needs further testing.

See you

refsteff
Specs: OpenSUSE 11.2 (modified), nVidia Geforce 9400 GT, Intel E7500, celestia svn 5166 Qt4

Topic author
refsteff
Posts: 17
Joined: 30.07.2011
With us: 13 years 3 months

Re: configure --enable-debug - no debug messages

Post #2by refsteff » 28.09.2011, 02:55

refsteff
The side effect of this patch is you don't have to create an empty config.h file if you use qmake on Linux.
This was wrong. You need to patch 10 more files. :oops:

Code: Select all

diff -urN celestia.org/src/buildstardb.cpp celestia/src/buildstardb.cpp
--- celestia.org/src/buildstardb.cpp   2011-08-19 16:05:07.000000000 +0200
+++ celestia/src/buildstardb.cpp   2011-09-28 04:05:52.802391108 +0200
@@ -27,9 +27,9 @@
 static string ComponentDatabaseFile("h_dm_com.dat");
 static string OrbitalDatabase("hip_dm_o.dat");
 #else
-#ifndef MACOSX_PB
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /*MACOSX_PB*/
+#endif /*HAVE_CONFIG_H*/
 static string MainDatabaseFile(HIP_DATA_DIR "/hip_main.dat");
 static string TychoDatabaseFile(HIP_DATA_DIR "/tyc_main.dat");
 static string ComponentDatabaseFile(HIP_DATA_DIR "/h_dm_com.dat");
diff -urN celestia.org/src/celengine/asterism.cpp celestia/src/celengine/asterism.cpp
--- celestia.org/src/celengine/asterism.cpp   2011-09-28 04:02:30.000000000 +0200
+++ celestia/src/celengine/asterism.cpp   2011-09-28 04:13:46.582267618 +0200
@@ -9,11 +9,9 @@
 
 #include <algorithm>
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* TARGET_OS_MAC */
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include <celutil/util.h>
 #include <celutil/debug.h>
diff -urN celestia.org/src/celengine/celestia.h celestia/src/celengine/celestia.h
--- celestia.org/src/celengine/celestia.h   2011-08-19 16:04:58.000000000 +0200
+++ celestia/src/celengine/celestia.h   2011-09-28 04:21:09.475392300 +0200
@@ -29,11 +29,9 @@
 #define NONSTANDARD_STRING_COMPARE
 #endif // __GNUC__
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* TARGET_OS_MAC */
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 
 
diff -urN celestia.org/src/celengine/image.cpp celestia/src/celengine/image.cpp
--- celestia.org/src/celengine/image.cpp   2011-08-19 16:04:58.000000000 +0200
+++ celestia/src/celengine/image.cpp   2011-09-28 04:13:26.821267469 +0200
@@ -23,11 +23,9 @@
 #endif
 #endif
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* ! TARGET_OS_MAC */
-#endif /* ! _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include "image.h"
 
diff -urN celestia.org/src/celengine/render.cpp celestia/src/celengine/render.cpp
--- celestia.org/src/celengine/render.cpp   2011-08-19 16:04:58.000000000 +0200
+++ celestia/src/celengine/render.cpp   2011-09-28 04:15:43.901391165 +0200
@@ -36,11 +36,9 @@
 
 // #define ENABLE_SELF_SHADOW
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include "render.h"
 #include "boundaries.h"
diff -urN celestia.org/src/celengine/renderglsl.cpp celestia/src/celengine/renderglsl.cpp
--- celestia.org/src/celengine/renderglsl.cpp   2011-08-19 16:04:58.000000000 +0200
+++ celestia/src/celengine/renderglsl.cpp   2011-09-28 04:14:20.973266296 +0200
@@ -15,11 +15,9 @@
 #include <cstring>
 #include <cassert>
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include "render.h"
 #include "astro.h"
diff -urN celestia.org/src/celengine/solarsys.cpp celestia/src/celengine/solarsys.cpp
--- celestia.org/src/celengine/solarsys.cpp   2011-08-19 16:04:58.000000000 +0200
+++ celestia/src/celengine/solarsys.cpp   2011-09-28 04:11:23.342267462 +0200
@@ -14,11 +14,9 @@
 // #include <limits>
 #include <cstdio>
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* ! TARGET_OS_MAC */
-#endif /* ! _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include <celutil/debug.h>
 #include <celmath/mathlib.h>
diff -urN celestia.org/src/celengine/texture.cpp celestia/src/celengine/texture.cpp
--- celestia.org/src/celengine/texture.cpp   2011-08-19 16:04:58.000000000 +0200
+++ celestia/src/celengine/texture.cpp   2011-09-28 04:14:52.589267556 +0200
@@ -29,11 +29,9 @@
 #include <cstdio>
 #include <cassert>
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* ! TARGET_OS_MAC */
-#endif /* ! _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include <celutil/filetype.h>
 #include <celutil/debug.h>
diff -urN celestia.org/src/celtxf/texturefont.cpp celestia/src/celtxf/texturefont.cpp
--- celestia.org/src/celtxf/texturefont.cpp   2011-08-19 16:04:54.000000000 +0200
+++ celestia/src/celtxf/texturefont.cpp   2011-09-28 04:16:30.640267510 +0200
@@ -11,11 +11,9 @@
 #include <cstring>
 #include <fstream>
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* TARGET_OS_MAC */
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #include <celutil/debug.h>
 #include <celutil/bytes.h>
diff -urN celestia.org/src/celutil/bytes.h celestia/src/celutil/bytes.h
--- celestia.org/src/celutil/bytes.h   2011-08-19 16:05:07.000000000 +0200
+++ celestia/src/celutil/bytes.h   2011-09-28 04:19:42.059392613 +0200
@@ -10,11 +10,9 @@
 #ifndef _CELUTIL_BYTES_H_
 #define _CELUTIL_BYTES_H_
 
-#ifndef _WIN32
-#ifndef TARGET_OS_MAC
+#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif /* TARGET_OS_MAC */
-#endif /* _WIN32 */
+#endif /* HAVE_CONFIG_H */
 
 #ifndef COMPILE_TYPE_ASSERT
 #define COMPILE_TIME_ASSERT(pred) \

It looks weird but in my opinion it's cleaner ( maybe in the future someone wants to port celestia to another os than Mac, Windows or Linux, or the compiler symbols changes)
Specs: OpenSUSE 11.2 (modified), nVidia Geforce 9400 GT, Intel E7500, celestia svn 5166 Qt4


Return to “Bugs”