Add GSExceptionStackTrace user default setting

This commit is contained in:
Richard Frith-Macdonald 2018-06-12 16:43:15 +01:00
parent 62511eeca2
commit 3b1324d73d
5 changed files with 36 additions and 2 deletions

View file

@ -1,3 +1,14 @@
2018-06-12 Richard Frith-Macdonald <rfm@gnu.org>
* Documentation/Base.gsdoc:
* Source/GSPrivate.h:
* Source/NSException.m:
* Source/NSUserDefaults.m:
Add boolean GSExceptionStackTrace user default to turn on inclusion
of stack trace information in the -description of an exception
(like the GNUSTEP_STACK_TRACE environment variable). Useful for
diagnostic logs of a long running server process.
2018-05-29 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSObject.m: avoid static initialisation macro for allocation

View file

@ -135,6 +135,18 @@ notice and this notice are preserved.
to the set given by the [NSProcessInfo-debugSet] method.
</p>
</desc>
<term>GSExceptionStackTrace</term>
<desc>
<p>
Setting the user default <code>GSExceptionStackTrace</code> to
<code>YES</code> will cause the stack trace at the point when
an exception occurs to be included as part of the text returned
by the -description method of the exception.<br />
That effect may also be obtained by setting the
GNUSTEP_STACK_TRACE environment variable before starting a
program.
</p>
</desc>
<term>GSLogSyslog</term>
<desc>
<p>
@ -314,6 +326,8 @@ notice and this notice are preserved.
When this is set to <em>YES</em> a human readable stack trace
(with function names and line numbers) is added to the output
of the description method of a raised exception object.<br />
NB. This behavior may also be enabled by setting the
GSExceptionStackTrace user default to YES.<br />
This only works if gnustep was built with support for it
using libbfd, so it may not be available on all systems.
</p>

View file

@ -257,6 +257,7 @@ typedef enum {
GSLogThread, // Include thread name in log message.
GSLogOffset, // Include time zone offset in message.
NSWriteOldStylePropertyLists, // Control PList output.
GSExceptionStackTrace, // Add trace to exception description.
GSUserDefaultMaxFlag // End marker.
} GSUserDefaultFlagType;

View file

@ -1311,7 +1311,8 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
GSPrivateArgZero(),
[[exception name] lossyCString], [[exception reason] lossyCString]);
fflush(stderr); /* NEEDED UNDER MINGW */
if (GSPrivateEnvironmentFlag("GNUSTEP_STACK_TRACE", NO) == YES)
if (GSPrivateEnvironmentFlag("GNUSTEP_STACK_TRACE", NO) == YES
|| GSPrivateDefaultsFlag(GSExceptionStackTrace) == YES)
{
fprintf(stderr, "Stack\n%s\n",
[[[exception _callStack] description] lossyCString]);
@ -1462,7 +1463,8 @@ callUncaughtHandler(id value)
if (_reserved != 0)
{
if (_e_stack != nil
&& GSPrivateEnvironmentFlag("GNUSTEP_STACK_TRACE", NO) == YES)
&& (GSPrivateEnvironmentFlag("GNUSTEP_STACK_TRACE", NO) == YES
|| GSPrivateDefaultsFlag(GSExceptionStackTrace) == YES))
{
if (_e_info != nil)
{

View file

@ -264,6 +264,8 @@ updateCache(NSUserDefaults *self)
= [self boolForKey: @"GSLogOffset"];
flags[NSWriteOldStylePropertyLists]
= [self boolForKey: @"NSWriteOldStylePropertyLists"];
flags[GSExceptionStackTrace]
= [self boolForKey: @"GSExceptionStackTrace"];
}
}
@ -636,6 +638,10 @@ newLanguages(NSArray *oldNames)
{
flags[NSWriteOldStylePropertyLists] = [val boolValue];
}
else if ([key isEqual: @"GSExceptionStackTrace"])
{
flags[GSExceptionStackTrace] = [val boolValue];
}
}
}
}