Author: rfm
Date: Thu May  8 12:49:24 2014
New Revision: 37868

URL: http://svn.gna.org/viewcvs/gnustep?rev=37868&view=rev
Log:
another mewmory allocation debug option

Modified:
    libs/ec/trunk/ChangeLog
    libs/ec/trunk/EcProcess.m

Modified: libs/ec/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=37868&r1=37867&r2=37868&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog     (original)
+++ libs/ec/trunk/ChangeLog     Thu May  8 12:49:24 2014
@@ -1,3 +1,9 @@
+2014-05-08  Richard Frith-Macdonald <[email protected]>
+
+       * EcProcess.m: add memory commands 'class' and 'list' to record
+       allocated instances of a specific class and list them... another
+       memory debugging option.
+
 2014-05-08  Richard Frith-Macdonald <[email protected]>
 
        * GNUmakefile: bump subminor version number for release

Modified: libs/ec/trunk/EcProcess.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=37868&r1=37867&r2=37868&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m   (original)
+++ libs/ec/trunk/EcProcess.m   Thu May  8 12:49:24 2014
@@ -3068,10 +3068,14 @@
          [self cmdPrintf: @"memory usage statistics.\n"];
          [self cmdPrintf: @"With the single parameter 'default', the "];
          [self cmdPrintf: @"gathering of memory usage statistics reverts "];
-         [self cmdPrintf: @"to the default setting."];
+         [self cmdPrintf: @"to the default setting.\n"];
+         [self cmdPrintf: @"With two parameters ('class' and a class name), "];
+         [self cmdPrintf: @"new instances of the class are recorded.\n"];
+         [self cmdPrintf: @"With two parameters ('list' and a class), "];
+         [self cmdPrintf: @"recorded instances of the class are reported.\n"];
          [self cmdPrintf: @"\n"];
        }
-      else if ([msg count] > 1)
+      else if ([msg count] == 2)
        {
          NSString      *word = [msg objectAtIndex: 1];
 
@@ -3124,6 +3128,45 @@
              [cmdDefs setCommand: @"NO" forKey: @"Memory"];
            }
        }
+      else if ([msg count] == 3)
+        {
+          NSString      *name = [msg objectAtIndex: 2];
+          Class         c = NSClassFromString(name);
+
+          if (Nil == c)
+            {
+             [self cmdPrintf: @"Unable to find class '%@'.\n", name];
+            }
+          else
+            {
+              NSString  *op = [msg objectAtIndex: 1];
+
+              if ([op caseInsensitiveCompare: @"class"] == NSOrderedSame)
+                {
+                  GSDebugAllocationActiveRecordingObjects(c);
+                  [self cmdPrintf: @"Recording instances of '%@'.\n", name];
+                }
+              else if ([op caseInsensitiveCompare: @"list"] == NSOrderedSame)
+                {
+                  NSArray       *array;
+                  NSUInteger    count;
+                  NSUInteger    index;
+
+                  array = GSDebugAllocationListRecordedObjects(c);
+                  [self cmdPrintf: @"Current instances of '%@':\n", name];
+                  count = [array count];
+                  for (index = 0; index < count; index++)
+                    {
+                      [self cmdPrintf: @"%6lu %@\n",
+                        (unsigned long)index, [array objectAtIndex: index]];
+                    }
+                }
+              else
+                {
+                  [self cmdPrintf: @"Unknown memory command '%@'.\n", op];
+                }
+            }
+        }
       else
        {
          [self cmdPrintf: @"\n%@ on %@ running since %@\n\n",


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to