Merge changes I2c8b84b6,I0ce00cca,I78a83448

* changes:
  vndk-abi: Use .dump for unmodified abi-compliance-tool
  vndk-abi: Integrate strip debug info
  Add Script to strip debug info from dump
diff --git a/vndk/tools/abi-tool/strip_debug_info.pl b/vndk/tools/abi-tool/strip_debug_info.pl
new file mode 100755
index 0000000..b0833d7
--- /dev/null
+++ b/vndk/tools/abi-tool/strip_debug_info.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+use Data::Dumper;
+
+@strip_keys = (
+    "Headers",
+    "NameSpaces",
+    "Sources",
+    "TypeInfo",
+    # in SymbolInfo
+    "Class",
+    "Header",
+    "Line",
+    "Param",
+    "Return",
+    "Source",
+    "SourceLine"
+);
+
+sub StripDebug {
+    my $arg = $_[0];
+    if (ref($arg) ne "HASH") {
+        return $arg;
+    }
+    my %out_hash = ();
+    while ((my $key, my $value) = each %{$arg}) {
+        if (not grep(/^$key$/, @strip_keys)) {
+            $out_hash{$key} = StripDebug($value);
+        }
+    }
+    return \%out_hash;
+}
+
+
+if ($#ARGV eq -1) {
+    die "Usage: $0 DUMP_1 DUMP_2 ...\n";
+}
+
+$Data::Dumper::Sortkeys = 1;
+for my $file_name (@ARGV) {
+    require $file_name;
+    $stripped = StripDebug($VAR1);
+
+    open(FILE, ">", $file_name) or die "Cannot open $file_name: $!";
+    print FILE Dumper($stripped);
+    close FILE;
+}
+
diff --git a/vndk/tools/abi-tool/vndk_abi_tool.py b/vndk/tools/abi-tool/vndk_abi_tool.py
index c42fc6a..41a8aac 100755
--- a/vndk/tools/abi-tool/vndk_abi_tool.py
+++ b/vndk/tools/abi-tool/vndk_abi_tool.py
@@ -57,7 +57,8 @@
 AOSP_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, *['..'] * 4))
 ABI_DUMPER = os.path.join(AOSP_DIR, 'external', 'abi-dumper', 'abi-dumper.pl')
 VTABLE_DUMPER = 'vndk-vtable-dumper'
-BINARY_ABI_DUMP_EXT = '.bdump'
+BINARY_ABI_DUMP_EXT = '.dump'
+STRIP_DEUBG_INFO = os.path.join(SCRIPT_DIR, 'strip_debug_info.pl')
 
 
 # Compilation targets.
@@ -213,8 +214,13 @@
         return patt.match(name)
     return accept_matched_filenames
 
+def run_cmd(cmd, show_commands):
+    if show_commands:
+        print(' '.join(cmd))
+    check_silent_call(cmd)
+
 def create_abi_reference_dump(out_dir, symbols_dir, api_level, show_commands,
-                              target, is_vndk_lib_name):
+                              target, is_vndk_lib_name, strip_debug_info):
     # Check command line tools.
     readelf = target.get_exe('readelf')
     objdump = target.get_exe('objdump')
@@ -251,11 +257,10 @@
 
             makedirs(os.path.dirname(out_path), exist_ok=True)
             cmd = cmd_base + [path, '-o', out_path]
-            if show_commands:
-                print('run:', ' '.join(cmd))
-            else:
-                print('process:', path)
-            check_silent_call(cmd)
+            print('# FILE:', path)
+            run_cmd(cmd, show_commands)
+            if strip_debug_info:
+                run_cmd([STRIP_DEUBG_INFO, out_path], show_commands)
             num_processed += 1
 
     return num_processed
@@ -304,7 +309,9 @@
     parser.add_argument('--target-build-variant', help='target build variant')
     parser.add_argument('--symbols-dir', help='unstripped symbols directory')
     parser.add_argument('--show-commands', action='store_true',
-                        help='Show the abi-dumper command')
+                        help='Show commands')
+    parser.add_argument('--strip-debug-info', action='store_true',
+                        help='Remove debug information from ABI dump files')
     args = parser.parse_args()
 
     # Check the symbols directory.
@@ -356,7 +363,8 @@
     for target in targets:
         num_processed += create_abi_reference_dump(
                 out_dir, symbols_dir, args.api_level, args.show_commands,
-                target, create_vndk_lib_name_filter(args.vndk_list))
+                target, create_vndk_lib_name_filter(args.vndk_list),
+                args.strip_debug_info)
 
     # Print a summary at the end.
     _TERM_WIDTH = 79