mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Revised NSDebugLog() stuff
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2899 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3e828bffdb
commit
b45c31a805
7 changed files with 60 additions and 18 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,4 +1,4 @@
|
|||
Fri Aug 4 09:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Fri Aug 4 10:55:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* src/GNUmakefile: Removed NSAllocateObject.m and
|
||||
NSDeallocateObject.m (contents merged into NSObject.m).
|
||||
|
@ -7,6 +7,14 @@ Fri Aug 4 09:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|||
modified to cache an objects zone with it - in order to maintain
|
||||
(or better) current performance when we get the NSZone code fixed
|
||||
to work with malloced memory.
|
||||
* src/include/NSObjCRuntime.h: Removed NSDebugLog()
|
||||
* src/include/NSDebug.h: Added new version of NSDebugLog()
|
||||
* src/include/NSProcessInfo.h: Added [-debugArray] method.
|
||||
* src/NSProcessInfo.m: Added [-debugArray] method and modified to
|
||||
parse arguments list and remove debug options, putting them in a
|
||||
mutable array (returned by [-debugArray]).
|
||||
* src/externs.m: Removed NSDebugLogging.
|
||||
* src/NSBundle.m: Modified to use new version of NSDebugLog().
|
||||
|
||||
Thu Aug 3 15:35:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
|
|
|
@ -53,12 +53,36 @@ extern int errno;
|
|||
* was last called.
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG
|
||||
extern void GSDebugAllocationAdd(Class c);
|
||||
extern void GSDebugAllocationRemove(Class c);
|
||||
|
||||
extern BOOL GSDebugAllocationActive(BOOL active);
|
||||
extern int GSDebugAllocationCount(Class c);
|
||||
extern const char* GSDebugAllocationList(BOOL changeFlag);
|
||||
#endif
|
||||
|
||||
|
||||
/* Debug logging which can be enabled/disabled by defining DEBUG
|
||||
when compiling and also setting values in the mutable array
|
||||
that is set up by NSProcessInfo.
|
||||
This array is initialised by NSProcess info using the
|
||||
'--GNU-Debug=...' command line argument. Each command-line argument
|
||||
of that form is removed from NSProcessInfos list of arguments and the
|
||||
variable part (...) is added to the array.
|
||||
For instance, to debug the NSBundle class, run your program with
|
||||
'--GNU-Debug=NSBundle'
|
||||
You can of course supply multiple '--GNU-Debug=...' arguments to
|
||||
output debug information on more than one thing.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#define NSDebugLog(level, format, args...) \
|
||||
do { if ([[[NSProcessInfo processInfo] debugArray] containsObject: level]) \
|
||||
NSLog(format, ## args); } while (0)
|
||||
#else
|
||||
#define NSDebugLog(level, format, args...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,16 +43,6 @@ extern NSLog_printf_handler *_NSLog_printf_handler;
|
|||
extern void NSLog (NSString* format, ...);
|
||||
extern void NSLogv (NSString* format, va_list args);
|
||||
|
||||
/* Debug logging which can be enabled/disabled by defining DEBUG
|
||||
when compiling and also setting the NSDebugLogging variable */
|
||||
#ifdef DEBUG
|
||||
extern int NSDebugLogging;
|
||||
#define NSDebugLog(format, args...) \
|
||||
do { if (NSDebugLogging) NSLog(format, ## args); } while (0)
|
||||
#else
|
||||
#define NSDebugLog(format, args...)
|
||||
#endif
|
||||
|
||||
#ifndef YES
|
||||
#define YES 1
|
||||
#endif YES
|
||||
|
|
|
@ -48,6 +48,10 @@
|
|||
/* Specifying a Process Name */
|
||||
- (void)setProcessName:(NSString *)newName;
|
||||
|
||||
/* GNUstep extension this is a list of debug levels set using the
|
||||
* --GNU-Debug=... command line option. */
|
||||
- (NSMutableArray*) debugArray;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __NSProcessInfo_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
|
@ -255,7 +256,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
if ([s isEqual: gnustep_target_cpu])
|
||||
path = [path stringByDeletingLastPathComponent];
|
||||
|
||||
NSDebugLog(@"(NSBundle): Found main in %@\n", path);
|
||||
NSDebugLog(@"NSBundle", @"(NSBundle): Found main in %@\n", path);
|
||||
/* We do alloc and init separately so initWithPath: knows
|
||||
we are the _mainBundle */
|
||||
_mainBundle = [NSBundle alloc];
|
||||
|
@ -338,7 +339,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
|
||||
if (stat([path cString], &statbuf) != 0)
|
||||
{
|
||||
NSDebugLog(@"Could not access path %s for bundle", [path cString]);
|
||||
NSDebugLog(@"NSBundle", @"Could not access path %s for bundle", [path cString]);
|
||||
//[self dealloc];
|
||||
//return nil;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,9 @@ static NSArray* _gnu_arguments = nil;
|
|||
// Dictionary of environment vars and their values
|
||||
static NSMutableDictionary* _gnu_environment = nil;
|
||||
|
||||
// Array of debug levels set.
|
||||
static NSMutableArray* _debug_array = nil;
|
||||
|
||||
/*************************************************************************
|
||||
*** Implementing the Libobjects main function
|
||||
*************************************************************************/
|
||||
|
@ -143,9 +146,18 @@ _gnu_process_args(int argc, char *argv[], char *env[])
|
|||
/* Copy the argument list */
|
||||
{
|
||||
id obj_argv[argc];
|
||||
int added = 0;
|
||||
|
||||
_debug_array = [[NSMutableArray alloc] init];
|
||||
for (i = 1; i < argc; i++)
|
||||
obj_argv[i-1] = [NSString stringWithCString:argv[i]];
|
||||
_gnu_arguments = [[NSArray alloc] initWithObjects:obj_argv count:argc-1];
|
||||
{
|
||||
NSString *str = [NSString stringWithCString:argv[i]];
|
||||
if ([str hasPrefix: @"--GNU-Debug="])
|
||||
[_debug_array addObject: [str substringFromIndex: 12]];
|
||||
else
|
||||
obj_argv[added++] = str;
|
||||
}
|
||||
_gnu_arguments = [[NSArray alloc] initWithObjects:obj_argv count:added];
|
||||
}
|
||||
|
||||
/* Copy the evironment list */
|
||||
|
@ -347,6 +359,11 @@ int main(int argc, char *argv[], char *env[])
|
|||
return _gnu_arguments;
|
||||
}
|
||||
|
||||
- (NSMutableArray*) debugArray
|
||||
{
|
||||
return _debug_array;
|
||||
}
|
||||
|
||||
- (NSDictionary *)environment
|
||||
{
|
||||
return _gnu_environment;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
|
@ -34,9 +35,6 @@
|
|||
creating the potential for deadlock. */
|
||||
NSRecursiveLock *gnustep_global_lock = nil;
|
||||
|
||||
/* Set this variable to print NSDebugLog messages */
|
||||
int NSDebugLogging = NO;
|
||||
|
||||
/* Connection Notification Strings. */
|
||||
|
||||
NSString *ConnectionBecameInvalidNotification =
|
||||
|
|
Loading…
Reference in a new issue