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
This commit is contained in:
Logan Chien
2017-05-24 02:09:56 +00:00
committed by Gerrit Code Review
2 changed files with 80 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -57,7 +57,8 @@ SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
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 @@ def create_vndk_lib_name_filter(file_list_path):
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 @@ def create_abi_reference_dump(out_dir, symbols_dir, api_level, show_commands,
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 @@ def main():
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 @@ def main():
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