]> granicus.if.org Git - nethack/commitdiff
add debugger window support via _RPT*; add regex
authorDerek S. Ray <derekray@gmail.com>
Wed, 15 Apr 2015 22:19:16 +0000 (18:19 -0400)
committerDerek S. Ray <derekray@gmail.com>
Wed, 15 Apr 2015 22:19:16 +0000 (18:19 -0400)
currently it's locked behind _MSC_VER, but anything that runs on Win32
should be able to use those functions as long as it has something that
can pass as a debug window.

also, add a non-wildcard-accepting version of showdebug for the dumpit()
functions in dungeon.c and questpgr.c; this makes DEBUGFILES=* workable
without being excruciatingly painful

include/extern.h
include/hack.h
src/dungeon.c
src/files.c
src/questpgr.c
sys/share/pcmain.c
win/win32/vs2013/NetHack.vcxproj
win/win32/vs2013/NetHackW.vcxproj

index 997885882447e1a3cb6c121e4e3120ef45442b84..bec672979520b7e4edd66c0c935ffe6a59a7729f 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 extern.h        $NHDT-Date: 1428806395 2015/04/12 02:39:55 $  $NHDT-Branch: master $:$NHDT-Revision: 1.455 $ */
+/* NetHack 3.5 extern.h        $NHDT-Date: 1429135323 2015/04/15 22:02:03 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.464 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -749,7 +749,7 @@ E int FDECL(nhclose, (int));
 E void NDECL(really_close);
 #endif
 #ifdef DEBUG
-E boolean FDECL(showdebug, (const char *));
+E boolean FDECL(debugcore, (const char *, boolean));
 #endif
 E void FDECL(read_tribute, (const char *,const char *,int));
 
index 0b5feb50130b8596d2bb0f6f0f8e2a0f210011ce..7b530e0a73facc0e370c3be57f0e8f4bd13f8049 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 hack.h  $NHDT-Date: 1426465431 2015/03/16 00:23:51 $  $NHDT-Branch: debug $:$NHDT-Revision: 1.52 $ */
+/* NetHack 3.5 hack.h  $NHDT-Date: 1429136301 2015/04/15 22:18:21 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.59 $ */
 /*     SCCS Id: @(#)hack.h     3.5     2008/03/19      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /* [DEBUG shouldn't be defined unless you know what you're doing...] */
 #ifdef DEBUG
-# define ifdebug(stmt) do { if (showdebug(__FILE__)) stmt; } while (0)
+# define showdebug(file)        debugcore(file, TRUE)
+# define explicitdebug(file)    debugcore(file, FALSE)
+# define ifdebug(stmt)    do { if (showdebug(__FILE__)) stmt; } while (0)
+# ifdef _MSC_VER 
+   /* if we have microsoft's C runtime we can use these instead */
+#  include <crtdbg.h>
+#  define crtdebug(stmt) do { if (showdebug(__FILE__)) stmt; \
+                                _RPT0(_CRT_WARN,"\n"); } while (0)
+#  define debugpline0(str)                crtdebug(_RPT0(_CRT_WARN,str))
+#  define debugpline1(fmt,arg)            crtdebug(_RPT1(_CRT_WARN,fmt,arg))
+#  define debugpline2(fmt,a1,a2)          crtdebug(_RPT2(_CRT_WARN,fmt,a1,a2))
+#  define debugpline3(fmt,a1,a2,a3)       crtdebug(_RPT3(_CRT_WARN,fmt,a1,a2,a3))
+#  define debugpline4(fmt,a1,a2,a3,a4)    crtdebug(_RPT4(_CRT_WARN,fmt,a1,a2,a3,a4))
+# else
 /* these don't require compiler support for C99 variadic macros */
-# define debugpline0(str)              ifdebug(pline(str))
-# define debugpline1(fmt,arg)          ifdebug(pline(fmt,arg))
-# define debugpline2(fmt,a1,a2)                ifdebug(pline(fmt,a1,a2))
-# define debugpline3(fmt,a1,a2,a3)     ifdebug(pline(fmt,a1,a2,a3))
-# define debugpline4(fmt,a1,a2,a3,a4)  ifdebug(pline(fmt,a1,a2,a3,a4))
+#  define debugpline0(str)                ifdebug(pline(str))
+#  define debugpline1(fmt,arg)            ifdebug(pline(fmt,arg))
+#  define debugpline2(fmt,a1,a2)          ifdebug(pline(fmt,a1,a2))
+#  define debugpline3(fmt,a1,a2,a3)       ifdebug(pline(fmt,a1,a2,a3))
+#  define debugpline4(fmt,a1,a2,a3,a4)    ifdebug(pline(fmt,a1,a2,a3,a4))
+# endif
 #else
-# define debugpline0(str)              /*empty*/
-# define debugpline1(fmt,arg)          /*empty*/
-# define debugpline2(fmt,a1,a2)                /*empty*/
-# define debugpline3(fmt,a1,a2,a3)     /*empty*/
-# define debugpline4(fmt,a1,a2,a3,a4)  /*empty*/
-#endif /*DEBUG*/
+#  define debugpline0(str)              /*empty*/
+#  define debugpline1(fmt,arg)          /*empty*/
+#  define debugpline2(fmt,a1,a2)        /*empty*/
+#  define debugpline3(fmt,a1,a2,a3)     /*empty*/
+#  define debugpline4(fmt,a1,a2,a3,a4)  /*empty*/
+#endif    /*DEBUG*/
 
 #define TELL           1
 #define NOTELL         0
index 58f83eed740b857f9bdb3806912f4c97780b61a4..5fd42f3ded5205653542d239793717464caab8c7 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 dungeon.c       $NHDT-Date: 1426465434 2015/03/16 00:23:54 $  $NHDT-Branch: debug $:$NHDT-Revision: 1.39 $ */
+/* NetHack 3.5 dungeon.c       $NHDT-Date: 1429135381 2015/04/15 22:03:01 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.49 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -80,7 +80,7 @@ dumpit()
        s_level *x;
        branch *br;
 
-       if (!showdebug(__FILE__)) return;
+       if (!explicitdebug(__FILE__)) return;
 
        for(i = 0; i < n_dgns; i++)  {
            fprintf(stderr, "\n#%d \"%s\" (%s):\n", i,
index 95273727526174d84f7ed81be6828ef8913f77b6..5ac1e67a06c8b5244bd622dadc0d02031cc20f3e 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 files.c $NHDT-Date: 1427337311 2015/03/26 02:35:11 $  $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.141 $ */
+/* NetHack 3.5 files.c $NHDT-Date: 1429136302 2015/04/15 22:18:22 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.166 $ */
 
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -3267,11 +3267,16 @@ assure_syscf_file() {
 
 #ifdef DEBUG
 /* used by debugpline() to decide whether to issue a message
-   from a partiular source file; caller passes __FILE__ and we check
-   whether it is in the source file list supplied by SYSCF's DEBUGFILES */ 
+ * from a partiular source file; caller passes __FILE__ and we check
+ * whether it is in the source file list supplied by SYSCF's DEBUGFILES
+ *
+ * pass FALSE to override wildcard matching; useful for files 
+ * like dungeon.c and questpgr.c, which generate a ridiculous amount of
+ * output if DEBUG is defined and effectively block the use of a wildcard */
 boolean
-showdebug(filename)
+debugcore(filename, wildcards)
 const char *filename;
+boolean wildcards;
 {
     const char *debugfiles, *p;
 
@@ -3314,7 +3319,7 @@ const char *filename;
      * attempt a wildcard match against each element, but that would be
      * overkill for the intended usage.]
      */
-    if (pmatch(debugfiles, filename))
+    if (wildcards && pmatch(debugfiles, filename))
     return TRUE;
 
     /* check whether filename is an element of the list */
@@ -3327,6 +3332,7 @@ const char *filename;
     }
     return FALSE;
 }
+
 #endif /*DEBUG*/
 
 /* ----------  BEGIN TRIBUTE ----------- */
index a52cc4a1dddfa474f26fc1e06913f71229e0f50e..e30ca5406935ca188e2a5814329ddfeeddf42731 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 questpgr.c      $NHDT-Date: 1426465439 2015/03/16 00:23:59 $  $NHDT-Branch: debug $:$NHDT-Revision: 1.18 $ */
+/* NetHack 3.5 questpgr.c      $NHDT-Date: 1429135390 2015/04/15 22:03:10 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.26 $ */
 /*     Copyright 1991, M. Stephenson             */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -46,7 +46,7 @@ dump_qtlist() /* dump the character msg list to check appearance */
 {
        struct  qtmsg   *msg;
 
-       if (!showdebug(__FILE__)) return;
+       if (!explicitdebug(__FILE__)) return;
 
        for (msg = qt_list.chrole; msg->msgnum > 0; msg++) {
                pline("msgnum %d: delivery %c",
index 48cbae0294fa0c95870d6d1cad00ff92f7d2b64c..8e54f078ac41b67130ba01bb3f8b9075db21ecae 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 pcmain.c        $NHDT-Date: 1427337317 2015/03/26 02:35:17 $  $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.52 $ */
+/* NetHack 3.5 pcmain.c        $NHDT-Date: 1429135416 2015/04/15 22:03:36 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.60 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -118,6 +118,17 @@ char *argv[];
 #endif
     boolean resuming = FALSE;  /* assume new game */
 
+#ifdef _MSC_VER
+    /* set these appropriately for VS debugging */
+    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
+    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); /* | _CRTDBG_MODE_FILE);*/
+    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
+                        /*| _CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW);*/
+    /* use STDERR by default 
+    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
+#endif
+
 #if defined(__BORLANDC__) && !defined(_WIN32)
     startup();
 #endif
index 09ca8b8a1feb283fc6499e9edbd6d63591d5b0d0..9ed7463cd924fd59123477d0f81df3e43077d391 100644 (file)
       <PreprocessorDefinitions>NDEBUG;WIN32;WIN32CON;DLB;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <SDLCheck>true</SDLCheck>\r
       <StringPooling>true</StringPooling>\r
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <PrecompiledHeaderOutputFile>.\Debug/NetHack.pch</PrecompiledHeaderOutputFile>\r
       <AssemblerListingLocation>.\$(ConfigurationName)\$(ProjectName)\</AssemblerListingLocation>\r
       <PreprocessorDefinitions>WIN32;WIN32CON;DLB;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <SDLCheck>true</SDLCheck>\r
       <StringPooling>true</StringPooling>\r
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <PrecompiledHeaderOutputFile>.\Debug/NetHack.pch</PrecompiledHeaderOutputFile>\r
       <AssemblerListingLocation>.\$(ConfigurationName)\$(ProjectName)\</AssemblerListingLocation>\r
     <ClCompile Include="..\src\worn.c" />\r
     <ClCompile Include="..\src\write.c" />\r
     <ClCompile Include="..\src\zap.c" />\r
+    <ClCompile Include="..\sys\share\cppregex.cpp" />\r
     <ClCompile Include="..\sys\share\nhlan.c" />\r
     <ClCompile Include="..\sys\share\pcmain.c" />\r
     <ClCompile Include="..\sys\share\pcsys.c" />\r
     <ClCompile Include="..\sys\winnt\ntsound.c" />\r
     <ClCompile Include="..\sys\winnt\nttty.c" />\r
     <ClCompile Include="..\sys\winnt\winnt.c" />\r
-    <ClCompile Include="..\sys\share\cppregex.cpp" />\r
     <ClCompile Include="..\win\tty\getline.c" />\r
     <ClCompile Include="..\win\tty\topl.c" />\r
     <ClCompile Include="..\win\tty\wintty.c" />\r
index ae9c1d42f08f52c1fa5192f97f0dd9e8bbc91caa..88ed645a353e8f0a37148e700561d8d8ec145b94 100644 (file)
@@ -650,6 +650,7 @@ copy ..\sys\winnt\defaults.nh ..\binary\defaults.nh
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
     </ClCompile>\r
+    <ClCompile Include="..\sys\share\cppregex.cpp" />\r
     <ClCompile Include="..\win\tty\getline.c">\r
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r