]> git.saurik.com Git - apple/system_cmds.git/blobdiff - kpgo.tproj/kpgo.c
system_cmds-735.tar.gz
[apple/system_cmds.git] / kpgo.tproj / kpgo.c
index 0b439cf7708b80d729d0c8d4834aac5cd399cebe..dacfc4c7c4b21b907a8e4db68bc420cfd2e141b2 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 2014 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2014-2016 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- * 
+ *
  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
  * Reserved.  This file contains Original Code and/or Modifications of
  * Original Code as defined in and that are subject to the Apple Public
@@ -10,7 +10,7 @@
  * except in compliance with the License.  Please obtain a copy of the
  * License at http://www.apple.com/publicsource and read it before using
  * this file.
- * 
+ *
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
@@ -18,7 +18,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  * License for the specific language governing rights and limitations
  * under the License."
- * 
+ *
  * @APPLE_LICENSE_HEADER_END@
  */
 
@@ -38,6 +38,7 @@ static void usage(char **argv)
         fprintf (stderr, "    -H   : grab data for the HIB segment\n");
         fprintf (stderr, "    -w   : wait for the kext to be unloaded\n");
         fprintf (stderr, "    -m   : request metadata\n");
+        fprintf (stderr, "    -R   : reset all counters\n");
        exit(1);
 }
 
@@ -49,8 +50,11 @@ int main(int argc, char **argv)
         uuid_t uuid;
         int c;
 
-        while ((c = getopt(argc, argv, "hHwm")) != EOF) {
+        while ((c = getopt(argc, argv, "hHwmR")) != EOF) {
             switch(c) {
+            case 'R':
+                flags |= PGO_RESET_ALL;
+                break;
             case 'H':
                 flags |= PGO_HIB;
                 break;
@@ -79,6 +83,19 @@ int main(int argc, char **argv)
             }
         }
 
+        if (flags & PGO_RESET_ALL) {
+            if (flags != PGO_RESET_ALL || uuidp) {
+                usage(argv);
+            }
+            ssize_t r = grab_pgo_data(NULL, PGO_RESET_ALL, NULL, 0);
+            if (r < 0)
+            {
+                perror("grab_pgo_data");
+                return 1;
+            }
+            return 0;
+        }
+
        ssize_t size = grab_pgo_data(uuidp, flags, NULL, 0);
 
        if (size < 0)
@@ -124,5 +141,4 @@ int main(int argc, char **argv)
         }
 
        return 0;
-
 }