mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-05-30 17:00:49 +00:00
iUpdate for running under asan/lsan when memory usage stats from the system are useless.
This commit is contained in:
parent
411969d430
commit
4f12e6921c
1 changed files with 41 additions and 13 deletions
54
EcProcess.m
54
EcProcess.m
|
@ -914,6 +914,8 @@ ecFullName()
|
||||||
return [name autorelease];
|
return [name autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GNUSTEP_WITH_ASAN
|
||||||
|
#else
|
||||||
static EcAlarmSeverity memAlarm = EcAlarmSeverityMajor;
|
static EcAlarmSeverity memAlarm = EcAlarmSeverityMajor;
|
||||||
static NSString *memType = nil;
|
static NSString *memType = nil;
|
||||||
static NSString *memUnit = @"KB";
|
static NSString *memUnit = @"KB";
|
||||||
|
@ -1015,6 +1017,7 @@ setMemBase()
|
||||||
memWarn = memMinr = memMajr = memCrit = 0;
|
memWarn = memMinr = memMajr = memCrit = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Returns the found command, or nil if none is found, or an empty string
|
/* Returns the found command, or nil if none is found, or an empty string
|
||||||
* if there was a match but it was in the array of commands to be blockd.
|
* if there was a match but it was in the array of commands to be blockd.
|
||||||
|
@ -2410,6 +2413,9 @@ static NSString *noFiles = @"No log files to archive";
|
||||||
descriptorsMaximum = [cmdDefs integerForKey: @"DescriptorsMaximum"];
|
descriptorsMaximum = [cmdDefs integerForKey: @"DescriptorsMaximum"];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GNUSTEP_WITH_ASAN
|
||||||
|
// No use trying to look at process memory size
|
||||||
|
#else
|
||||||
setMemAlarm([cmdDefs stringForKey: @"MemoryAlarm"]);
|
setMemAlarm([cmdDefs stringForKey: @"MemoryAlarm"]);
|
||||||
|
|
||||||
memAllowed = (uint64_t)[cmdDefs integerForKey: @"MemoryAllowed"];
|
memAllowed = (uint64_t)[cmdDefs integerForKey: @"MemoryAllowed"];
|
||||||
|
@ -2431,6 +2437,7 @@ static NSString *noFiles = @"No log files to archive";
|
||||||
memMaximum = 0; // Disabled
|
memMaximum = 0; // Disabled
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* GNUSTEP_WITH_ASAN */
|
||||||
|
|
||||||
str = [cmdDefs stringForKey: @"CoreSize"];
|
str = [cmdDefs stringForKey: @"CoreSize"];
|
||||||
if (nil == str)
|
if (nil == str)
|
||||||
|
@ -5331,6 +5338,20 @@ With two parameters ('maximum' and a number),\n\
|
||||||
[self cmdPrintf: @"Memory statistics are turned off NOW.\n"];
|
[self cmdPrintf: @"Memory statistics are turned off NOW.\n"];
|
||||||
[cmdDefs setCommand: @"NO" forKey: [cmdDefs key: @"Memory"]];
|
[cmdDefs setCommand: @"NO" forKey: [cmdDefs key: @"Memory"]];
|
||||||
}
|
}
|
||||||
|
#if GNUSTEP_WITH_ASAN
|
||||||
|
else if ([word isEqual: @"leakscheck"] || [word isEqual: @"leak"])
|
||||||
|
{
|
||||||
|
if (__lsan_do_recoverable_leak_check())
|
||||||
|
{
|
||||||
|
s = @"Memory leaks found and logged!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = @"No memory leaks found.";
|
||||||
|
}
|
||||||
|
[self cmdPrintf: @"%@\n", s];
|
||||||
|
}
|
||||||
|
#else
|
||||||
else if ([word isEqual: @"alarm"])
|
else if ([word isEqual: @"alarm"])
|
||||||
{
|
{
|
||||||
if (nil == (s = [cmdDefs stringForKey: @"MemoryAlarm"]))
|
if (nil == (s = [cmdDefs stringForKey: @"MemoryAlarm"]))
|
||||||
|
@ -5368,18 +5389,6 @@ With two parameters ('maximum' and a number),\n\
|
||||||
}
|
}
|
||||||
[self cmdPrintf: @"MemoryMaximum setting is %@.\n", s];
|
[self cmdPrintf: @"MemoryMaximum setting is %@.\n", s];
|
||||||
}
|
}
|
||||||
#if GNUSTEP_WITH_ASAN
|
|
||||||
else if ([word isEqual: @"leakscheck"] || [word isEqual: @"leak"])
|
|
||||||
{
|
|
||||||
if (__lsan_do_recoverable_leak_check())
|
|
||||||
{
|
|
||||||
[self cmdPrintf: @"Memory leaks found and logged!\n"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[self cmdPrintf: @"No memory leaks found.\n"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5399,8 +5408,18 @@ With two parameters ('maximum' and a number),\n\
|
||||||
{
|
{
|
||||||
NSString *op = [[msg objectAtIndex: 1] lowercaseString];
|
NSString *op = [[msg objectAtIndex: 1] lowercaseString];
|
||||||
NSString *arg = [msg objectAtIndex: 2];
|
NSString *arg = [msg objectAtIndex: 2];
|
||||||
NSInteger val = [arg integerValue];
|
|
||||||
|
|
||||||
|
#if GNUSTEP_WITH_ASAN
|
||||||
|
if ([op isEqual: @"alarm"]
|
||||||
|
|| [op isEqual: @"allowed"]
|
||||||
|
|| [op isEqual: @"idle"]
|
||||||
|
|| [op isEqual: @"maximum"] || [op isEqual: @"max"])
|
||||||
|
{
|
||||||
|
[self cmdPrintf: @"Command meaningless: built with asan/lsan.\n"];
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
NSInteger val = [arg integerValue];
|
||||||
|
|
||||||
if ([op isEqual: @"alarm"])
|
if ([op isEqual: @"alarm"])
|
||||||
{
|
{
|
||||||
arg = [arg stringByTrimmingSpaces];
|
arg = [arg stringByTrimmingSpaces];
|
||||||
|
@ -5489,6 +5508,7 @@ With two parameters ('maximum' and a number),\n\
|
||||||
}
|
}
|
||||||
[self _memCheck];
|
[self _memCheck];
|
||||||
}
|
}
|
||||||
|
#endif /* GNUSTEP_WITH_ASAN */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Class c = NSClassFromString(arg);
|
Class c = NSClassFromString(arg);
|
||||||
|
@ -5602,6 +5622,9 @@ With two parameters ('maximum' and a number),\n\
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GNUSTEP_WITH_ASAN
|
||||||
|
[self cmdPrintf: @"Unknown memory usage: built with asan/lsan.\n"];
|
||||||
|
#else
|
||||||
if (memTime <= 0.0)
|
if (memTime <= 0.0)
|
||||||
{
|
{
|
||||||
s = @"";
|
s = @"";
|
||||||
|
@ -5667,6 +5690,7 @@ With two parameters ('maximum' and a number),\n\
|
||||||
[self cmdPrintf: @"Alarms are raised when memory usage"
|
[self cmdPrintf: @"Alarms are raised when memory usage"
|
||||||
@" is above: %"PRIu64"%@.\n", limit / memSize, memUnit];
|
@" is above: %"PRIu64"%@.\n", limit / memSize, memUnit];
|
||||||
}
|
}
|
||||||
|
#endif /* GNUSTEP_WITH_ASAN */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6331,6 +6355,9 @@ With two parameters ('maximum' and a number),\n\
|
||||||
|
|
||||||
- (void) _memCheck
|
- (void) _memCheck
|
||||||
{
|
{
|
||||||
|
#if GNUSTEP_WITH_ASAN
|
||||||
|
return; // Memory information is meaningless under san/lsan
|
||||||
|
#else
|
||||||
static EcAlarm *alarm = nil;
|
static EcAlarm *alarm = nil;
|
||||||
static char buf[64] = {0};
|
static char buf[64] = {0};
|
||||||
EcAlarmSeverity severity = EcAlarmSeverityCleared;
|
EcAlarmSeverity severity = EcAlarmSeverityCleared;
|
||||||
|
@ -6670,6 +6697,7 @@ With two parameters ('maximum' and a number),\n\
|
||||||
msg: @"%@ memory usage %"PRIu64"%@ (reserved: %"PRIu64"%@)",
|
msg: @"%@ memory usage %"PRIu64"%@ (reserved: %"PRIu64"%@)",
|
||||||
memType, memLast/memSize, memUnit, excLast/memSize, memUnit];
|
memType, memLast/memSize, memUnit, excLast/memSize, memUnit];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) _moveLog: (NSString*)name to: (NSDate*)when
|
- (NSString*) _moveLog: (NSString*)name to: (NSDate*)when
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue