Re: [Warzone-dev] [patch] No asserts cheat

2009-01-05 Thread Giel van Schijndel
On Thu, Jan 01, 2009 at 06:22:40PM +0100, Per Inge Mathisen wrote:
> On Thu, Jan 1, 2009 at 4:26 PM, Dennis Schridde  wrote:
> > Can you not just skip asserts in the debugger?
> 
> Can you? Ever since the crash handler was added, I always end up in a
> non-skippable abort inside it when trying to skip an assert in the
> debugger.

This disables passing of the abort signal to the program:
> handle SIGABRT nopass

That allows you to just "continue" after having caught an abort signal
in the debugger (the debugger will *always* receive the signal before
the program does, except for SIGKILL...).

-- 
Giel


signature.asc
Description: Digital signature
___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] [patch] No asserts cheat

2009-01-01 Thread Per Inge Mathisen
On Thu, Jan 1, 2009 at 6:30 PM, Dennis Schridde  wrote:
> Am Donnerstag, 1. Januar 2009 18:22:40 schrieb Per Inge Mathisen:
>> On Thu, Jan 1, 2009 at 4:26 PM, Dennis Schridde  wrote:
>> > Can you not just skip asserts in the debugger?
>>
>> Can you? Ever since the crash handler was added, I always end up in a
>> non-skippable abort inside it when trying to skip an assert in the
>> debugger.
> In that case we maybe want to fix the cause for that and make it possible to
> disable to crash handler. ;)

Perhaps we should do that, as well. But I have more trust in this
approach since it is the closest approximation to how non-debug builds
operate, and my experience with continue in gdb is that it does not
always work well.

  - Per

___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] [patch] No asserts cheat

2009-01-01 Thread Dennis Schridde
Am Donnerstag, 1. Januar 2009 18:22:40 schrieb Per Inge Mathisen:
> On Thu, Jan 1, 2009 at 4:26 PM, Dennis Schridde  wrote:
> > Can you not just skip asserts in the debugger?
>
> Can you? Ever since the crash handler was added, I always end up in a
> non-skippable abort inside it when trying to skip an assert in the
> debugger.
In that case we maybe want to fix the cause for that and make it possible to 
disable to crash handler. ;)

--DevU


signature.asc
Description: This is a digitally signed message part.
___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] [patch] No asserts cheat

2009-01-01 Thread Per Inge Mathisen
On Thu, Jan 1, 2009 at 4:26 PM, Dennis Schridde  wrote:
> Can you not just skip asserts in the debugger?

Can you? Ever since the crash handler was added, I always end up in a
non-skippable abort inside it when trying to skip an assert in the
debugger.

> And there are still assert()s, which are disabled by defining NDEBUG at 
> compiletime.

All asserts should be ASSERT(), not assert(), this has been done quite
consistently.

 - Per

___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] [patch] No asserts cheat

2009-01-01 Thread Dennis Schridde
Am Donnerstag, 1. Januar 2009 15:54:26 schrieb Per Inge Mathisen:
> On Thu, Jan 1, 2009 at 3:39 PM, Per Inge Mathisen
>
>  wrote:
> > This patch adds a new cheat "noassert" which turns off asserts. ASSERT
> > calls will still generate log entries, but not take down the program.
> > This is meant for testing that code hit by an assert bug has
> > sufficient error handling that it can survive when compiled without
> > assertions. Which it always should.
> >
> > Sending it directly to list because trac stuff is down.
>
> As requested by gerard_, a command-line option to disable asserts was
> added.
Can you not just skip asserts in the debugger? And there are still assert()s, 
which are disabled by defining NDEBUG at compiletime.

Bottomline: I am a bit skeptical about the sense of such a patch, but if you 
think you need it, just commit.

--DevU


signature.asc
Description: This is a digitally signed message part.
___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] [patch] No asserts cheat

2009-01-01 Thread Per Inge Mathisen
On Thu, Jan 1, 2009 at 3:39 PM, Per Inge Mathisen
 wrote:
> This patch adds a new cheat "noassert" which turns off asserts. ASSERT
> calls will still generate log entries, but not take down the program.
> This is meant for testing that code hit by an assert bug has
> sufficient error handling that it can survive when compiled without
> assertions. Which it always should.
>
> Sending it directly to list because trac stuff is down.

As requested by gerard_, a command-line option to disable asserts was added.

  - Per
Index: src/keybind.c
===
--- src/keybind.c	(revision 6523)
+++ src/keybind.c	(working copy)
@@ -2599,3 +2599,10 @@
 		}
 	}
 }
+
+void kf_NoAssert()
+{
+	debugDisableAssert();
+	console("Asserts turned off");
+	debug(LOG_ERROR, "Asserts turned off");
+}
Index: src/keybind.h
===
--- src/keybind.h	(revision 6523)
+++ src/keybind.h	(working copy)
@@ -21,6 +21,7 @@
 #ifndef __INCLUDED_SRC_KEYBIND_H__
 #define __INCLUDED_SRC_KEYBIND_H__
 
+#include "console.h"
 #include "lib/ivis_common/piefixedpoint.h"
 
 // --- All those keyboard mappable functions */
@@ -234,6 +235,8 @@
 
 void kf_TileInfo(void);
 
+void kf_NoAssert(void);
+
 extern void	kf_ToggleWatchWindow( void );
 
 bool runningMultiplayer(void);
Index: src/cheat.c
===
--- src/cheat.c	(revision 6523)
+++ src/cheat.c	(working copy)
@@ -44,6 +44,7 @@
 //	{"PJKSVQZ,",kf_ToggleOutline},
 //	{"L\\MZZQ[JRO",kf_ScreenDump},	//screendump
 
+	{"noassert", kf_NoAssert}, // turn off asserts
 	{"count me", kf_ShowNumObjects}, // give a count of objects in the world
 	{"give all", kf_AllAvailable},	// give all
 	{"research all", kf_FinishAllResearch}, // research everything at once
Index: src/clparse.c
===
--- src/clparse.c	(revision 6523)
+++ src/clparse.c	(working copy)
@@ -43,6 +43,7 @@
 #include "wrappers.h"
 #include "cheat.h"
 #include "init.h"
+#include "keybind.h"
  // To set the shadow config:
 #include "display.h"
 #include "version.h"
@@ -86,6 +87,7 @@
 	CLI_SELFTEST,
 	CLI_CONNECTTOIP,
 	CLI_HOSTLAUNCH,
+	CLI_NOASSERT,
 } CLI_OPTIONS;
 
 static const struct poptOption* getOptionsTable(void)
@@ -104,6 +106,7 @@
 		{ "mod",'\0', POPT_ARG_STRING, NULL, CLI_MOD_GLOB,   N_("Enable a global mod"),   N_("mod") },
 		{ "mod_ca", '\0', POPT_ARG_STRING, NULL, CLI_MOD_CA, N_("Enable a campaign only mod"),N_("mod") },
 		{ "mod_mp", '\0', POPT_ARG_STRING, NULL, CLI_MOD_MP, N_("Enable a multiplay only mod"),   N_("mod") },
+		{ "noassert",	'\0', POPT_ARG_NONE,   NULL, CLI_NOASSERT,   N_("Disable asserts"),   NULL },
 		{ "savegame",   '\0', POPT_ARG_STRING, NULL, CLI_SAVEGAME,   N_("Load a saved game"), N_("savegame") },
 		{ "usage",  '\0', POPT_ARG_NONE
 		  | POPT_ARGFLAG_DOC_HIDDEN,   NULL, CLI_USAGE,  NULL,NULL, },
@@ -283,6 +286,10 @@
 // These options are parsed in ParseCommandLineEarly() already, so ignore them
 break;
 
+			case CLI_NOASSERT:
+kf_NoAssert();
+break;
+
 			case CLI_CHEAT:
 printf("  ** DEBUG MODE UNLOCKED! **\n");
 bAllowDebugMode = true;
Index: lib/framework/debug.c
===
--- lib/framework/debug.c	(revision 6523)
+++ lib/framework/debug.c	(working copy)
@@ -41,6 +41,7 @@
 
 static debug_callback * callbackRegistry = NULL;
 BOOL enabled_debug[LOG_LAST]; // global
+bool assertEnabled = true;
 
 /*
  * This list _must_ match the enum in debug.h!
@@ -382,3 +383,8 @@
 {
 	return enabled_debug[codePart];
 }
+
+void debugDisableAssert()
+{
+	assertEnabled = false;
+}
Index: lib/framework/debug.h
===
--- lib/framework/debug.h	(revision 6523)
+++ lib/framework/debug.h	(working copy)
@@ -51,6 +51,9 @@
 /** Stores name of the last function or event called by scripts. */
 extern char last_called_script_event[MAX_EVENT_NAME_LEN];
 
+/** Whether asserts are currently enabled. */
+extern bool assertEnabled;
+
 /**
  * ASSERT helper macro to allow some debug functions to use an alternate
  * calling location.
@@ -78,7 +81,7 @@
 		  location_description, (#expr), last_called_script_event) \
 		) \
 	), \
-	assert(expr) \
+	assertEnabled ? assert(expr) : (void)0 \
 )
 
 /**
@@ -226,4 +229,6 @@
 /** Checks if a particular debub flag was enabled */
 extern bool debugPartEnabled(code_part codePart);
 
+void debugDisableAssert(void);
+
 #endif // __INCLUDED_LIB_FRAMEWORK_DEBUG_H__
___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev