Allow to not get versionCode with heap_profile script.

Change-Id: I1d084e00aab4ebbc2fd78067eb7ebf42f5878c25
diff --git a/tools/heap_profile b/tools/heap_profile
index 7ed9d42..72c0342 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -70,6 +70,13 @@
   os.chmod(local_file, 0o755)
   return local_file
 
+PACKAGES_LIST_CFG='''data_sources {{
+  config {{
+    name: "android.packages_list"
+  }}
+}}
+'''
+
 
 CFG_IDENT = '      '
 CFG='''buffers {{
@@ -78,12 +85,6 @@
 
 data_sources {{
   config {{
-    name: "android.packages_list"
-  }}
-}}
-
-data_sources {{
-  config {{
     name: "android.heapprofd"
     heapprofd_config {{
 
@@ -134,6 +135,8 @@
   parser.add_argument("--disable-selinux", action="store_true",
                       help="Disable SELinux enforcement for duration of "
                       "profile.")
+  parser.add_argument("--no-versions", action="store_true",
+                      help="Do not get version information about APKs.")
   parser.add_argument("--shmem-size", help="Size of buffer between client and "
                       "heapprofd. Default 8MiB. Needs to be a power of two "
                       "multiple of 4096, at least 8192.", type=int,
@@ -147,6 +150,8 @@
                       "only for heapprofd development.")
   parser.add_argument("--trace-to-text-binary",
                       help="Path to local trace to text. For debugging.")
+  parser.add_argument("--print-config", action="store_true",
+                      help="Print config instead of running. For debugging.")
 
   args = parser.parse_args()
 
@@ -210,6 +215,12 @@
                    duration=args.duration, target_cfg=target_cfg,
                    continuous_dump_cfg=continuous_dump_cfg,
                    shmem_size=args.shmem_size)
+  if not args.no_versions:
+    cfg += PACKAGES_LIST_CFG
+
+  if args.print_config:
+    print(cfg)
+    return 0
 
   if args.disable_selinux:
     enforcing = subprocess.check_output(['adb', 'shell', 'getenforce'])