Merge "gdbclient.py: Add --env flag."
diff --git a/build/product_sdk.mk b/build/product_sdk.mk
index 52ef9a4..e8a89ca 100644
--- a/build/product_sdk.mk
+++ b/build/product_sdk.mk
@@ -34,7 +34,6 @@
apksigner \
bcc_compat \
bios.bin \
- commons-compress-1.0 \
deployagent \
dexdump \
dmtracedump \
diff --git a/build/sdk.atree b/build/sdk.atree
index 24b997d..974f39b 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -98,37 +98,41 @@
prebuilts/sdk/renderscript/lib/javalib.jar build-tools/${PLATFORM_NAME}/renderscript/lib/androidx-rs.jar
prebuilts/sdk/renderscript/lib/javalib_legacy.jar build-tools/${PLATFORM_NAME}/renderscript/lib/renderscript-v8.jar
-prebuilts/sdk/renderscript/lib/arm/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/armeabi-v7a/libc.so
-prebuilts/sdk/renderscript/lib/arm/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/armeabi-v7a/libm.so
-prebuilts/sdk/renderscript/lib/arm/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/armeabi-v7a/libcompiler_rt.a
-prebuilts/sdk/renderscript/lib/arm/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/armeabi-v7a/libRSSupport.so
-prebuilts/sdk/renderscript/lib/arm/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/armeabi-v7a/librsjni.so
-prebuilts/sdk/renderscript/lib/arm/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/armeabi-v7a/libblasV8.so
-prebuilts/sdk/renderscript/lib/arm/librsrt_arm.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/armeabi-v7a/libclcore.bc
+prebuilts/sdk/renderscript/lib/arm/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/armeabi-v7a/libc.so
+prebuilts/sdk/renderscript/lib/arm/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/armeabi-v7a/libm.so
+prebuilts/sdk/renderscript/lib/arm/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/armeabi-v7a/libcompiler_rt.a
+prebuilts/sdk/renderscript/lib/arm/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/armeabi-v7a/libRSSupport.so
+prebuilts/sdk/renderscript/lib/arm/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/armeabi-v7a/librsjni.so
+prebuilts/sdk/renderscript/lib/arm/librsjni_androidx.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/armeabi-v7a/librsjni_androidx.so
+prebuilts/sdk/renderscript/lib/arm/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/armeabi-v7a/libblasV8.so
+prebuilts/sdk/renderscript/lib/arm/librsrt_arm.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/armeabi-v7a/libclcore.bc
-prebuilts/sdk/renderscript/lib/x86/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86/libc.so
-prebuilts/sdk/renderscript/lib/x86/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86/libm.so
-prebuilts/sdk/renderscript/lib/x86/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86/libcompiler_rt.a
-prebuilts/sdk/renderscript/lib/x86/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86/libRSSupport.so
-prebuilts/sdk/renderscript/lib/x86/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86/librsjni.so
-prebuilts/sdk/renderscript/lib/x86/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/x86/libblasV8.so
-prebuilts/sdk/renderscript/lib/x86/librsrt_x86.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/x86/libclcore.bc
+prebuilts/sdk/renderscript/lib/x86/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86/libc.so
+prebuilts/sdk/renderscript/lib/x86/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86/libm.so
+prebuilts/sdk/renderscript/lib/x86/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86/libcompiler_rt.a
+prebuilts/sdk/renderscript/lib/x86/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86/libRSSupport.so
+prebuilts/sdk/renderscript/lib/x86/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86/librsjni.so
+prebuilts/sdk/renderscript/lib/x86/librsjni_androidx.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86/librsjni_androidx.so
+prebuilts/sdk/renderscript/lib/x86/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/x86/libblasV8.so
+prebuilts/sdk/renderscript/lib/x86/librsrt_x86.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/x86/libclcore.bc
prebuilts/sdk/renderscript/lib/arm64/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/arm64-v8a/libc.so
prebuilts/sdk/renderscript/lib/arm64/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/arm64-v8a/libm.so
prebuilts/sdk/renderscript/lib/arm64/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/arm64-v8a/libcompiler_rt.a
prebuilts/sdk/renderscript/lib/arm64/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/arm64-v8a/libRSSupport.so
prebuilts/sdk/renderscript/lib/arm64/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/arm64-v8a/librsjni.so
+prebuilts/sdk/renderscript/lib/arm64/librsjni_androidx.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/arm64-v8a/librsjni_androidx.so
prebuilts/sdk/renderscript/lib/arm64/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/arm64-v8a/libblasV8.so
prebuilts/sdk/renderscript/lib/arm64/librsrt_arm64.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/arm64-v8a/libclcore.bc
-prebuilts/sdk/renderscript/lib/x86_64/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86_64/libc.so
-prebuilts/sdk/renderscript/lib/x86_64/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86_64/libm.so
-prebuilts/sdk/renderscript/lib/x86_64/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86_64/libcompiler_rt.a
-prebuilts/sdk/renderscript/lib/x86_64/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86_64/libRSSupport.so
-prebuilts/sdk/renderscript/lib/x86_64/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86_64/librsjni.so
-prebuilts/sdk/renderscript/lib/x86_64/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/x86_64/libblasV8.so
-prebuilts/sdk/renderscript/lib/x86_64/librsrt_x86_64.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/x86_64/libclcore.bc
+prebuilts/sdk/renderscript/lib/x86_64/libc.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86_64/libc.so
+prebuilts/sdk/renderscript/lib/x86_64/libm.so build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86_64/libm.so
+prebuilts/sdk/renderscript/lib/x86_64/libcompiler_rt.a build-tools/${PLATFORM_NAME}/renderscript/lib/intermediates/x86_64/libcompiler_rt.a
+prebuilts/sdk/renderscript/lib/x86_64/libRSSupport.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86_64/libRSSupport.so
+prebuilts/sdk/renderscript/lib/x86_64/librsjni.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86_64/librsjni.so
+prebuilts/sdk/renderscript/lib/x86_64/librsjni_androidx.so build-tools/${PLATFORM_NAME}/renderscript/lib/packaged/x86_64/librsjni_androidx.so
+prebuilts/sdk/renderscript/lib/x86_64/libblasV8.so build-tools/${PLATFORM_NAME}/renderscript/lib/blas/x86_64/libblasV8.so
+prebuilts/sdk/renderscript/lib/x86_64/librsrt_x86_64.bc build-tools/${PLATFORM_NAME}/renderscript/lib/bc/x86_64/libclcore.bc
# apksigner
bin/apksigner build-tools/${PLATFORM_NAME}/apksigner
@@ -403,7 +407,6 @@
development/samples/AppNavigation samples/${PLATFORM_NAME}/legacy/AppNavigation
development/samples/BackupRestore samples/${PLATFORM_NAME}/legacy/BackupRestore
development/samples/BasicGLSurfaceView samples/${PLATFORM_NAME}/legacy/BasicGLSurfaceView
-development/samples/BluetoothHDP samples/${PLATFORM_NAME}/legacy/BluetoothHDP
development/samples/ContactManager samples/${PLATFORM_NAME}/legacy/ContactManager
development/samples/CrossCompatibility samples/${PLATFORM_NAME}/legacy/CrossCompatibility
development/samples/CubeLiveWallpaper samples/${PLATFORM_NAME}/legacy/CubeLiveWallpaper
diff --git a/samples/BluetoothHDP/Android.mk b/samples/BluetoothHDP/Android.mk
deleted file mode 100644
index 3c7c49f..0000000
--- a/samples/BluetoothHDP/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := samples
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := BluetoothHDP
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/samples/BluetoothHDP/AndroidManifest.xml b/samples/BluetoothHDP/AndroidManifest.xml
deleted file mode 100644
index 21723d1..0000000
--- a/samples/BluetoothHDP/AndroidManifest.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 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.
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.bluetooth.health"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="14"
- android:targetSdkVersion="14" />
- <uses-permission android:name="android.permission.BLUETOOTH" />
-
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".BluetoothHDPActivity"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <service android:name=".BluetoothHDPService" />
- </application>
-</manifest>
diff --git a/samples/BluetoothHDP/_index.jd b/samples/BluetoothHDP/_index.jd
deleted file mode 100644
index 526e318..0000000
--- a/samples/BluetoothHDP/_index.jd
+++ /dev/null
@@ -1,16 +0,0 @@
-page.tags="Bluetooth", "HDP", "Health"
-sample.group=Connectivity
-@jd:body
-
-<p>A sample application that demonstrates how to communicate with a Bluetooth Health Device Profile (HDP) device. This feature is available on Android 4.0 (API level 14) or above platforms. The Android Bluetooth Health API lets you create
-applications that use Bluetooth to communicate with health devices that support
-Bluetooth, such as heart-rate monitors, blood meters, thermometers, scales, and
-so on. For a list of supported devices and their corresponding device data
-specialization codes, refer to <strong>Bluetooth Assigned Numbers</strong> at <a
-href="http://www.bluetooth.org">www.bluetooth.org</a>. Note that these values
-are also referenced in the ISO/IEEE 11073-20601 [7] specification as
-MDC_DEV_SPEC_PROFILE_* in the Nomenclature Codes Annex.</p>
-
-<p>The application manages connection with Bluetooth HDP-enabled devices. Possible device type include blood pressure monitor, glucose meter, thermometer, etc. Upon connection, the application retrieves raw data sent from the device. Note that in order to interpret the data, a parser that conforms to the IEEE 11073-xxxxx specifications would be required.</p>
-
-<img alt="" src="../images/BluetoothHDP.png" />
\ No newline at end of file
diff --git a/samples/BluetoothHDP/res/drawable-hdpi/icon.png b/samples/BluetoothHDP/res/drawable-hdpi/icon.png
deleted file mode 100644
index e43c502..0000000
--- a/samples/BluetoothHDP/res/drawable-hdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/samples/BluetoothHDP/res/drawable-mdpi/icon.png b/samples/BluetoothHDP/res/drawable-mdpi/icon.png
deleted file mode 100644
index 8d9e9df..0000000
--- a/samples/BluetoothHDP/res/drawable-mdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/samples/BluetoothHDP/res/drawable-xhdpi/icon.png b/samples/BluetoothHDP/res/drawable-xhdpi/icon.png
deleted file mode 100644
index 1aea335..0000000
--- a/samples/BluetoothHDP/res/drawable-xhdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/samples/BluetoothHDP/res/drawable-xhdpi/led_off.png b/samples/BluetoothHDP/res/drawable-xhdpi/led_off.png
deleted file mode 100644
index 884533c..0000000
--- a/samples/BluetoothHDP/res/drawable-xhdpi/led_off.png
+++ /dev/null
Binary files differ
diff --git a/samples/BluetoothHDP/res/drawable-xhdpi/led_on.png b/samples/BluetoothHDP/res/drawable-xhdpi/led_on.png
deleted file mode 100644
index 6542b00..0000000
--- a/samples/BluetoothHDP/res/drawable-xhdpi/led_on.png
+++ /dev/null
Binary files differ
diff --git a/samples/BluetoothHDP/res/drawable/led_indicator.xml b/samples/BluetoothHDP/res/drawable/led_indicator.xml
deleted file mode 100644
index d6140c8..0000000
--- a/samples/BluetoothHDP/res/drawable/led_indicator.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 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.
--->
-<level-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:maxLevel="0" android:drawable="@drawable/led_off" />
- <item android:maxLevel="1" android:drawable="@drawable/led_on" />
-</level-list>
diff --git a/samples/BluetoothHDP/res/layout/console.xml b/samples/BluetoothHDP/res/layout/console.xml
deleted file mode 100644
index 8d8a3fe..0000000
--- a/samples/BluetoothHDP/res/layout/console.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- <LinearLayout android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_margin="5dp">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/app_registration"
- android:textSize="20sp"
- android:textStyle="bold" />
- <LinearLayout android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:gravity="center" >
- <Button android:id="@+id/button_register_app"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:minWidth="130dp"
- android:text="@string/register" />
- <Button android:id="@+id/button_unregister_app"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:minWidth="130dp"
- android:text="@string/unregister" />
- </LinearLayout>
-
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/channel_connection"
- android:textSize="20sp"
- android:textStyle="bold" />
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/channel_connection_desc"
- android:textSize="14sp" />
- <LinearLayout android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:gravity="center" >
- <Button android:id="@+id/button_connect_channel"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:minWidth="130dp"
- android:text="@string/connect" />
- <Button android:id="@+id/button_disconnect_channel"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:minWidth="130dp"
- android:text="@string/disconnect" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:orientation="horizontal" >
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/connection_state"
- android:textSize="20sp"
- android:textStyle="bold" />
- <Space android:layout_width="10dp"
- android:layout_height="0px" />
- <TextView android:id="@+id/connect_ind"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/disconnected"
- android:textSize="18sp"/>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:orientation="horizontal" >
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/data_ind"
- android:textSize="20sp"
- android:textStyle="bold" />
- <Space android:layout_width="10dp"
- android:layout_height="0px" />
- <ImageView android:id="@+id/data_ind"
- android:layout_width="20dp"
- android:layout_height="20dp"
- android:layout_marginTop="4dp"
- android:src="@drawable/led_indicator" />
- </LinearLayout>
- <View android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="#FFFFFF"/>
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:text="@string/status_msg"
- android:textSize="20sp"
- android:textStyle="bold" />
- <TextView android:id="@+id/status_msg"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/empty"
- android:textSize="18sp"
- android:layout_margin="10dp"/>
- </LinearLayout>
-</ScrollView>
diff --git a/samples/BluetoothHDP/res/values/strings.xml b/samples/BluetoothHDP/res/values/strings.xml
deleted file mode 100644
index 21e3a84..0000000
--- a/samples/BluetoothHDP/res/values/strings.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 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.
--->
-<resources>
- <string name="app_name">HDP Sample</string>
- <string name="app_registration">App Registration</string>
- <string name="bluetooth_not_available">Bluetooth is not available</string>
- <string name="bluetooth_health_profile_not_available">Bluetooth health profile is not available</string>
- <string name="channel_connection">Channel Connection</string>
- <string name="channel_connection_desc">(some devices automatically initiate connection)</string>
- <string name="connect">Connect</string>
- <string name="connected">CONNECTED</string>
- <string name="connection_state">Connection State</string>
- <string name="data_ind">Data Indicator</string>
- <string name="disconnect">Disconnect</string>
- <string name="disconnected">DISCONNECTED</string>
- <string name="empty"> </string>
- <string name="none">None...</string>
- <string name="ok">Okay</string>
- <string name="read_data">Reading data...</string>
- <string name="read_data_done">Done with reading data...</string>
- <string name="register">Register</string>
- <string name="select_device">Select a device</string>
- <string name="status_create_channel">Create channel status: %d</string>
- <string name="status_destroy_channel">Destroy channel status: %d</string>
- <string name="status_msg">Status Message</string>
- <string name="status_reg">App registration status: %d</string>
- <string name="status_unreg">App unregistration status: %d</string>
- <string name="unregister">Unregister</string>
-</resources>
diff --git a/samples/BluetoothHDP/src/com/example/bluetooth/health/BluetoothHDPActivity.java b/samples/BluetoothHDP/src/com/example/bluetooth/health/BluetoothHDPActivity.java
deleted file mode 100644
index ca8b182..0000000
--- a/samples/BluetoothHDP/src/com/example/bluetooth/health/BluetoothHDPActivity.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.example.bluetooth.health;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-/**
- * Main user interface for the Sample application. All Bluetooth health-related
- * operations happen in {@link BluetoothHDPService}. This activity passes messages to and from
- * the service.
- */
-public class BluetoothHDPActivity extends Activity {
- private static final String TAG = "BluetoothHealthActivity";
-
- // Use the appropriate IEEE 11073 data types based on the devices used.
- // Below are some examples. Refer to relevant Bluetooth HDP specifications for detail.
- // 0x1007 - blood pressure meter
- // 0x1008 - body thermometer
- // 0x100F - body weight scale
- private static final int HEALTH_PROFILE_SOURCE_DATA_TYPE = 0x1007;
-
- private static final int REQUEST_ENABLE_BT = 1;
-
- private TextView mConnectIndicator;
- private ImageView mDataIndicator;
- private TextView mStatusMessage;
-
- private BluetoothAdapter mBluetoothAdapter;
- private BluetoothDevice[] mAllBondedDevices;
- private BluetoothDevice mDevice;
- private int mDeviceIndex = 0;
- private Resources mRes;
- private Messenger mHealthService;
- private boolean mHealthServiceBound;
-
- // Handles events sent by {@link HealthHDPService}.
- private Handler mIncomingHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- // Application registration complete.
- case BluetoothHDPService.STATUS_HEALTH_APP_REG:
- mStatusMessage.setText(
- String.format(mRes.getString(R.string.status_reg),
- msg.arg1));
- break;
- // Application unregistration complete.
- case BluetoothHDPService.STATUS_HEALTH_APP_UNREG:
- mStatusMessage.setText(
- String.format(mRes.getString(R.string.status_unreg),
- msg.arg1));
- break;
- // Reading data from HDP device.
- case BluetoothHDPService.STATUS_READ_DATA:
- mStatusMessage.setText(mRes.getString(R.string.read_data));
- mDataIndicator.setImageLevel(1);
- break;
- // Finish reading data from HDP device.
- case BluetoothHDPService.STATUS_READ_DATA_DONE:
- mStatusMessage.setText(mRes.getString(R.string.read_data_done));
- mDataIndicator.setImageLevel(0);
- break;
- // Channel creation complete. Some devices will automatically establish
- // connection.
- case BluetoothHDPService.STATUS_CREATE_CHANNEL:
- mStatusMessage.setText(
- String.format(mRes.getString(R.string.status_create_channel),
- msg.arg1));
- mConnectIndicator.setText(R.string.connected);
- break;
- // Channel destroy complete. This happens when either the device disconnects or
- // there is extended inactivity.
- case BluetoothHDPService.STATUS_DESTROY_CHANNEL:
- mStatusMessage.setText(
- String.format(mRes.getString(R.string.status_destroy_channel),
- msg.arg1));
- mConnectIndicator.setText(R.string.disconnected);
- break;
- default:
- super.handleMessage(msg);
- }
- }
- };
-
- private final Messenger mMessenger = new Messenger(mIncomingHandler);
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Check for Bluetooth availability on the Android platform.
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- if (mBluetoothAdapter == null) {
- Toast.makeText(this, R.string.bluetooth_not_available, Toast.LENGTH_LONG);
- finish();
- return;
- }
- setContentView(R.layout.console);
- mConnectIndicator = (TextView) findViewById(R.id.connect_ind);
- mStatusMessage = (TextView) findViewById(R.id.status_msg);
- mDataIndicator = (ImageView) findViewById(R.id.data_ind);
- mRes = getResources();
- mHealthServiceBound = false;
-
- // Initiates application registration through {@link BluetoothHDPService}.
- Button registerAppButton = (Button) findViewById(R.id.button_register_app);
- registerAppButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- sendMessage(BluetoothHDPService.MSG_REG_HEALTH_APP,
- HEALTH_PROFILE_SOURCE_DATA_TYPE);
- }
- });
-
- // Initiates application unregistration through {@link BluetoothHDPService}.
- Button unregisterAppButton = (Button) findViewById(R.id.button_unregister_app);
- unregisterAppButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- sendMessage(BluetoothHDPService.MSG_UNREG_HEALTH_APP, 0);
- }
- });
-
- // Initiates channel creation through {@link BluetoothHDPService}. Some devices will
- // initiate the channel connection, in which case, it is not necessary to do this in the
- // application. When pressed, the user is asked to select from one of the bonded devices
- // to connect to.
- Button connectButton = (Button) findViewById(R.id.button_connect_channel);
- connectButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- mAllBondedDevices =
- (BluetoothDevice[]) mBluetoothAdapter.getBondedDevices().toArray(
- new BluetoothDevice[0]);
-
- if (mAllBondedDevices.length > 0) {
- int deviceCount = mAllBondedDevices.length;
- if (mDeviceIndex < deviceCount) mDevice = mAllBondedDevices[mDeviceIndex];
- else {
- mDeviceIndex = 0;
- mDevice = mAllBondedDevices[0];
- }
- String[] deviceNames = new String[deviceCount];
- int i = 0;
- for (BluetoothDevice device : mAllBondedDevices) {
- deviceNames[i++] = device.getName();
- }
- SelectDeviceDialogFragment deviceDialog =
- SelectDeviceDialogFragment.newInstance(deviceNames, mDeviceIndex);
- deviceDialog.show(getFragmentManager(), "deviceDialog");
- }
- }
- });
-
- // Initiates channel disconnect through {@link BluetoothHDPService}.
- Button disconnectButton = (Button) findViewById(R.id.button_disconnect_channel);
- disconnectButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- disconnectChannel();
- }
- });
- registerReceiver(mReceiver, initIntentFilter());
- }
-
- // Sets up communication with {@link BluetoothHDPService}.
- private ServiceConnection mConnection = new ServiceConnection() {
- public void onServiceConnected(ComponentName name, IBinder service) {
- mHealthServiceBound = true;
- Message msg = Message.obtain(null, BluetoothHDPService.MSG_REG_CLIENT);
- msg.replyTo = mMessenger;
- mHealthService = new Messenger(service);
- try {
- mHealthService.send(msg);
- } catch (RemoteException e) {
- Log.w(TAG, "Unable to register client to service.");
- e.printStackTrace();
- }
- }
-
- public void onServiceDisconnected(ComponentName name) {
- mHealthService = null;
- mHealthServiceBound = false;
- }
- };
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (mHealthServiceBound) unbindService(mConnection);
- unregisterReceiver(mReceiver);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- // If Bluetooth is not on, request that it be enabled.
- if (!mBluetoothAdapter.isEnabled()) {
- Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
- } else {
- initialize();
- }
- }
-
- /**
- * Ensures user has turned on Bluetooth on the Android device.
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_ENABLE_BT:
- if (resultCode == Activity.RESULT_OK) {
- initialize();
- } else {
- finish();
- return;
- }
- }
- }
-
- /**
- * Used by {@link SelectDeviceDialogFragment} to record the bonded Bluetooth device selected
- * by the user.
- *
- * @param position Position of the bonded Bluetooth device in the array.
- */
- public void setDevice(int position) {
- mDevice = this.mAllBondedDevices[position];
- mDeviceIndex = position;
- }
-
- private void connectChannel() {
- sendMessageWithDevice(BluetoothHDPService.MSG_CONNECT_CHANNEL);
- }
-
- private void disconnectChannel() {
- sendMessageWithDevice(BluetoothHDPService.MSG_DISCONNECT_CHANNEL);
- }
-
- private void initialize() {
- // Starts health service.
- Intent intent = new Intent(this, BluetoothHDPService.class);
- startService(intent);
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
-
- // Intent filter and broadcast receive to handle Bluetooth on event.
- private IntentFilter initIntentFilter() {
- IntentFilter filter = new IntentFilter();
- filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
- return filter;
- }
-
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
- if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR) ==
- BluetoothAdapter.STATE_ON) {
- initialize();
- }
- }
- }
- };
-
- // Sends a message to {@link BluetoothHDPService}.
- private void sendMessage(int what, int value) {
- if (mHealthService == null) {
- Log.d(TAG, "Health Service not connected.");
- return;
- }
-
- try {
- mHealthService.send(Message.obtain(null, what, value, 0));
- } catch (RemoteException e) {
- Log.w(TAG, "Unable to reach service.");
- e.printStackTrace();
- }
- }
-
- // Sends an update message, along with an HDP BluetoothDevice object, to
- // {@link BluetoothHDPService}. The BluetoothDevice object is needed by the channel creation
- // method.
- private void sendMessageWithDevice(int what) {
- if (mHealthService == null) {
- Log.d(TAG, "Health Service not connected.");
- return;
- }
-
- try {
- mHealthService.send(Message.obtain(null, what, mDevice));
- } catch (RemoteException e) {
- Log.w(TAG, "Unable to reach service.");
- e.printStackTrace();
- }
- }
-
- /**
- * Dialog to display a list of bonded Bluetooth devices for user to select from. This is
- * needed only for channel connection initiated from the application.
- */
- public static class SelectDeviceDialogFragment extends DialogFragment {
-
- public static SelectDeviceDialogFragment newInstance(String[] names, int position) {
- SelectDeviceDialogFragment frag = new SelectDeviceDialogFragment();
- Bundle args = new Bundle();
- args.putStringArray("names", names);
- args.putInt("position", position);
- frag.setArguments(args);
- return frag;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- String[] deviceNames = getArguments().getStringArray("names");
- int position = getArguments().getInt("position", -1);
- if (position == -1) position = 0;
- return new AlertDialog.Builder(getActivity())
- .setTitle(R.string.select_device)
- .setPositiveButton(R.string.ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- ((BluetoothHDPActivity) getActivity()).connectChannel();
- }
- })
- .setSingleChoiceItems(deviceNames, position,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- ((BluetoothHDPActivity) getActivity()).setDevice(which);
- }
- }
- )
- .create();
- }
- }
-}
diff --git a/samples/BluetoothHDP/src/com/example/bluetooth/health/BluetoothHDPService.java b/samples/BluetoothHDP/src/com/example/bluetooth/health/BluetoothHDPService.java
deleted file mode 100644
index f090aa7..0000000
--- a/samples/BluetoothHDP/src/com/example/bluetooth/health/BluetoothHDPService.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.example.bluetooth.health;
-
-import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothHealth;
-import android.bluetooth.BluetoothHealthAppConfiguration;
-import android.bluetooth.BluetoothHealthCallback;
-import android.bluetooth.BluetoothProfile;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.ParcelFileDescriptor;
-import android.os.RemoteException;
-import android.util.Log;
-import android.widget.Toast;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-
-/**
- * This Service encapsulates Bluetooth Health API to establish, manage, and disconnect
- * communication between the Android device and a Bluetooth HDP-enabled device. Possible HDP
- * device type includes blood pressure monitor, glucose meter, thermometer, etc.
- *
- * As outlined in the
- * <a href="http://developer.android.com/reference/android/bluetooth/BluetoothHealth.html">BluetoothHealth</a>
- * documentation, the steps involve:
- * 1. Get a reference to the BluetoothHealth proxy object.
- * 2. Create a BluetoothHealth callback and register an application configuration that acts as a
- * Health SINK.
- * 3. Establish connection to a health device. Some devices will initiate the connection. It is
- * unnecessary to carry out this step for those devices.
- * 4. When connected successfully, read / write to the health device using the file descriptor.
- * The received data needs to be interpreted using a health manager which implements the
- * IEEE 11073-xxxxx specifications.
- * 5. When done, close the health channel and unregister the application. The channel will
- * also close when there is extended inactivity.
- */
-public class BluetoothHDPService extends Service {
- private static final String TAG = "BluetoothHDPService";
-
- public static final int RESULT_OK = 0;
- public static final int RESULT_FAIL = -1;
-
- // Status codes sent back to the UI client.
- // Application registration complete.
- public static final int STATUS_HEALTH_APP_REG = 100;
- // Application unregistration complete.
- public static final int STATUS_HEALTH_APP_UNREG = 101;
- // Channel creation complete.
- public static final int STATUS_CREATE_CHANNEL = 102;
- // Channel destroy complete.
- public static final int STATUS_DESTROY_CHANNEL = 103;
- // Reading data from Bluetooth HDP device.
- public static final int STATUS_READ_DATA = 104;
- // Done with reading data.
- public static final int STATUS_READ_DATA_DONE = 105;
-
- // Message codes received from the UI client.
- // Register client with this service.
- public static final int MSG_REG_CLIENT = 200;
- // Unregister client from this service.
- public static final int MSG_UNREG_CLIENT = 201;
- // Register health application.
- public static final int MSG_REG_HEALTH_APP = 300;
- // Unregister health application.
- public static final int MSG_UNREG_HEALTH_APP = 301;
- // Connect channel.
- public static final int MSG_CONNECT_CHANNEL = 400;
- // Disconnect channel.
- public static final int MSG_DISCONNECT_CHANNEL = 401;
-
- private BluetoothHealthAppConfiguration mHealthAppConfig;
- private BluetoothAdapter mBluetoothAdapter;
- private BluetoothHealth mBluetoothHealth;
- private BluetoothDevice mDevice;
- private int mChannelId;
-
- private Messenger mClient;
-
- // Handles events sent by {@link HealthHDPActivity}.
- private class IncomingHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- // Register UI client to this service so the client can receive messages.
- case MSG_REG_CLIENT:
- Log.d(TAG, "Activity client registered");
- mClient = msg.replyTo;
- break;
- // Unregister UI client from this service.
- case MSG_UNREG_CLIENT:
- mClient = null;
- break;
- // Register health application.
- case MSG_REG_HEALTH_APP:
- registerApp(msg.arg1);
- break;
- // Unregister health application.
- case MSG_UNREG_HEALTH_APP:
- unregisterApp();
- break;
- // Connect channel.
- case MSG_CONNECT_CHANNEL:
- mDevice = (BluetoothDevice) msg.obj;
- connectChannel();
- break;
- // Disconnect channel.
- case MSG_DISCONNECT_CHANNEL:
- mDevice = (BluetoothDevice) msg.obj;
- disconnectChannel();
- break;
- default:
- super.handleMessage(msg);
- }
- }
- }
-
- final Messenger mMessenger = new Messenger(new IncomingHandler());
-
- /**
- * Make sure Bluetooth and health profile are available on the Android device. Stop service
- * if they are not available.
- */
- @Override
- public void onCreate() {
- super.onCreate();
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
- // Bluetooth adapter isn't available. The client of the service is supposed to
- // verify that it is available and activate before invoking this service.
- stopSelf();
- return;
- }
- if (!mBluetoothAdapter.getProfileProxy(this, mBluetoothServiceListener,
- BluetoothProfile.HEALTH)) {
- Toast.makeText(this, R.string.bluetooth_health_profile_not_available,
- Toast.LENGTH_LONG);
- stopSelf();
- return;
- }
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- Log.d(TAG, "BluetoothHDPService is running.");
- return START_STICKY;
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return mMessenger.getBinder();
- };
-
- // Register health application through the Bluetooth Health API.
- private void registerApp(int dataType) {
- mBluetoothHealth.registerSinkAppConfiguration(TAG, dataType, mHealthCallback);
- }
-
- // Unregister health application through the Bluetooth Health API.
- private void unregisterApp() {
- mBluetoothHealth.unregisterAppConfiguration(mHealthAppConfig);
- }
-
- // Connect channel through the Bluetooth Health API.
- private void connectChannel() {
- Log.i(TAG, "connectChannel()");
- mBluetoothHealth.connectChannelToSource(mDevice, mHealthAppConfig);
- }
-
- // Disconnect channel through the Bluetooth Health API.
- private void disconnectChannel() {
- Log.i(TAG, "disconnectChannel()");
- mBluetoothHealth.disconnectChannel(mDevice, mHealthAppConfig, mChannelId);
- }
-
- // Callbacks to handle connection set up and disconnection clean up.
- private final BluetoothProfile.ServiceListener mBluetoothServiceListener =
- new BluetoothProfile.ServiceListener() {
- public void onServiceConnected(int profile, BluetoothProfile proxy) {
- if (profile == BluetoothProfile.HEALTH) {
- mBluetoothHealth = (BluetoothHealth) proxy;
- if (Log.isLoggable(TAG, Log.DEBUG))
- Log.d(TAG, "onServiceConnected to profile: " + profile);
- }
- }
-
- public void onServiceDisconnected(int profile) {
- if (profile == BluetoothProfile.HEALTH) {
- mBluetoothHealth = null;
- }
- }
- };
-
- private final BluetoothHealthCallback mHealthCallback = new BluetoothHealthCallback() {
- // Callback to handle application registration and unregistration events. The service
- // passes the status back to the UI client.
- public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
- int status) {
- if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
- mHealthAppConfig = null;
- sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL);
- } else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
- mHealthAppConfig = config;
- sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK);
- } else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
- status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
- sendMessage(STATUS_HEALTH_APP_UNREG,
- status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
- RESULT_OK : RESULT_FAIL);
- }
- }
-
- // Callback to handle channel connection state changes.
- // Note that the logic of the state machine may need to be modified based on the HDP device.
- // When the HDP device is connected, the received file descriptor is passed to the
- // ReadThread to read the content.
- public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
- BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
- int channelId) {
- if (Log.isLoggable(TAG, Log.DEBUG))
- Log.d(TAG, String.format("prevState\t%d ----------> newState\t%d",
- prevState, newState));
- if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
- newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
- if (config.equals(mHealthAppConfig)) {
- mChannelId = channelId;
- sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK);
- (new ReadThread(fd)).start();
- } else {
- sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
- }
- } else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
- newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
- sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
- } else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
- if (config.equals(mHealthAppConfig)) {
- sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK);
- } else {
- sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL);
- }
- }
- }
- };
-
- // Sends an update message to registered UI client.
- private void sendMessage(int what, int value) {
- if (mClient == null) {
- Log.d(TAG, "No clients registered.");
- return;
- }
-
- try {
- mClient.send(Message.obtain(null, what, value, 0));
- } catch (RemoteException e) {
- // Unable to reach client.
- e.printStackTrace();
- }
- }
-
- // Thread to read incoming data received from the HDP device. This sample application merely
- // reads the raw byte from the incoming file descriptor. The data should be interpreted using
- // a health manager which implements the IEEE 11073-xxxxx specifications.
- private class ReadThread extends Thread {
- private ParcelFileDescriptor mFd;
-
- public ReadThread(ParcelFileDescriptor fd) {
- super();
- mFd = fd;
- }
-
- @Override
- public void run() {
- FileInputStream fis = new FileInputStream(mFd.getFileDescriptor());
- final byte data[] = new byte[8192];
- try {
- while(fis.read(data) > -1) {
- // At this point, the application can pass the raw data to a parser that
- // has implemented the IEEE 11073-xxxxx specifications. Instead, this sample
- // simply indicates that some data has been received.
- sendMessage(STATUS_READ_DATA, 0);
- }
- } catch(IOException ioe) {}
- if (mFd != null) {
- try {
- mFd.close();
- } catch (IOException e) { /* Do nothing. */ }
- }
- sendMessage(STATUS_READ_DATA_DONE, 0);
- }
- }
-}
diff --git a/samples/ToyVpn/res/layout/form.xml b/samples/ToyVpn/res/layout/form.xml
index 0f62e17..00cd55b 100644
--- a/samples/ToyVpn/res/layout/form.xml
+++ b/samples/ToyVpn/res/layout/form.xml
@@ -31,6 +31,30 @@
<TextView style="@style/item" android:text="@string/secret"/>
<EditText style="@style/item" android:id="@+id/secret" android:password="true"/>
+ <TextView style="@style/item" android:text="@string/proxyhost"/>
+ <EditText style="@style/item" android:id="@+id/proxyhost"/>
+
+ <TextView style="@style/item" android:text="@string/proxyport"/>
+ <EditText style="@style/item" android:id="@+id/proxyport" android:inputType="number"/>
+
+ <TextView style="@style/item" android:text="@string/packages"/>
+ <RadioGroup
+ style="@style/item"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <RadioButton
+ android:id="@+id/allowed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/allowed"/>
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/disallowed"/>
+ </RadioGroup>
+ <EditText style="@style/item" android:id="@+id/packages"/>
+
<Button style="@style/item" android:id="@+id/connect" android:text="@string/connect"/>
<Button style="@style/item" android:id="@+id/disconnect" android:text="@string/disconnect"/>
diff --git a/samples/ToyVpn/res/values/strings.xml b/samples/ToyVpn/res/values/strings.xml
index d5e06ba..c084fa5 100644
--- a/samples/ToyVpn/res/values/strings.xml
+++ b/samples/ToyVpn/res/values/strings.xml
@@ -23,8 +23,20 @@
<string name="secret">Shared Secret:</string>
<string name="connect">Connect!</string>
<string name="disconnect">Disconnect!</string>
+ <string name="proxyhost">HTTP proxy hostname</string>
+ <string name="proxyport">HTTP proxy port</string>
+
+ <string name="packages">Packages (comma separated):</string>
+ <string name="allowed">Allow</string>
+ <string name="disallowed">Disallow</string>
<string name="connecting">ToyVPN is connecting...</string>
<string name="connected">ToyVPN is connected!</string>
<string name="disconnected">ToyVPN is disconnected!</string>
+ <string name="incomplete_proxy_settings">
+ Incomplete proxy settings. For HTTP proxy we require both hostname and port settings.
+ </string>
+ <string name="unknown_package_names">
+ Some of the specified package names do not correspond to any installed packages.
+ </string>
</resources>
diff --git a/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnClient.java b/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnClient.java
index c6a72e9..6a4c161 100644
--- a/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnClient.java
+++ b/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnClient.java
@@ -21,7 +21,14 @@
import android.content.SharedPreferences;
import android.net.VpnService;
import android.os.Bundle;
+import android.widget.RadioButton;
import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Set;
+import java.util.stream.Collectors;
public class ToyVpnClient extends Activity {
public interface Prefs {
@@ -29,6 +36,10 @@
String SERVER_ADDRESS = "server.address";
String SERVER_PORT = "server.port";
String SHARED_SECRET = "shared.secret";
+ String PROXY_HOSTNAME = "proxyhost";
+ String PROXY_PORT = "proxyport";
+ String ALLOW = "allow";
+ String PACKAGES = "packages";
}
@Override
@@ -36,22 +47,64 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.form);
- final TextView serverAddress = (TextView) findViewById(R.id.address);
- final TextView serverPort = (TextView) findViewById(R.id.port);
- final TextView sharedSecret = (TextView) findViewById(R.id.secret);
+ final TextView serverAddress = findViewById(R.id.address);
+ final TextView serverPort = findViewById(R.id.port);
+ final TextView sharedSecret = findViewById(R.id.secret);
+ final TextView proxyHost = findViewById(R.id.proxyhost);
+ final TextView proxyPort = findViewById(R.id.proxyport);
+
+ final RadioButton allowed = findViewById(R.id.allowed);
+ final TextView packages = findViewById(R.id.packages);
final SharedPreferences prefs = getSharedPreferences(Prefs.NAME, MODE_PRIVATE);
serverAddress.setText(prefs.getString(Prefs.SERVER_ADDRESS, ""));
- serverPort.setText(prefs.getString(Prefs.SERVER_PORT, ""));
+ int serverPortPrefValue = prefs.getInt(Prefs.SERVER_PORT, 0);
+ serverPort.setText(String.valueOf(serverPortPrefValue == 0 ? "" : serverPortPrefValue));
sharedSecret.setText(prefs.getString(Prefs.SHARED_SECRET, ""));
+ proxyHost.setText(prefs.getString(Prefs.PROXY_HOSTNAME, ""));
+ int proxyPortPrefValue = prefs.getInt(Prefs.PROXY_PORT, 0);
+ proxyPort.setText(proxyPortPrefValue == 0 ? "" : String.valueOf(proxyPortPrefValue));
+
+ allowed.setChecked(prefs.getBoolean(Prefs.ALLOW, true));
+ packages.setText(String.join(", ", prefs.getStringSet(
+ Prefs.PACKAGES, Collections.emptySet())));
findViewById(R.id.connect).setOnClickListener(v -> {
+ if (!checkProxyConfigs(proxyHost.getText().toString(),
+ proxyPort.getText().toString())) {
+ return;
+ }
+
+ final Set<String> packageSet =
+ Arrays.stream(packages.getText().toString().split(","))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.toSet());
+ if (!checkPackages(packageSet)) {
+ return;
+ }
+
+ int serverPortNum;
+ try {
+ serverPortNum = Integer.parseInt(serverPort.getText().toString());
+ } catch (NumberFormatException e) {
+ serverPortNum = 0;
+ }
+ int proxyPortNum;
+ try {
+ proxyPortNum = Integer.parseInt(proxyPort.getText().toString());
+ } catch (NumberFormatException e) {
+ proxyPortNum = 0;
+ }
prefs.edit()
.putString(Prefs.SERVER_ADDRESS, serverAddress.getText().toString())
- .putString(Prefs.SERVER_PORT, serverPort.getText().toString())
+ .putInt(Prefs.SERVER_PORT, serverPortNum)
.putString(Prefs.SHARED_SECRET, sharedSecret.getText().toString())
+ .putString(Prefs.PROXY_HOSTNAME, proxyHost.getText().toString())
+ .putInt(Prefs.PROXY_PORT, proxyPortNum)
+ .putBoolean(Prefs.ALLOW, allowed.isChecked())
+ .putStringSet(Prefs.PACKAGES, packageSet)
.commit();
-
Intent intent = VpnService.prepare(ToyVpnClient.this);
if (intent != null) {
startActivityForResult(intent, 0);
@@ -64,6 +117,26 @@
});
}
+ private boolean checkProxyConfigs(String proxyHost, String proxyPort) {
+ final boolean hasIncompleteProxyConfigs = proxyHost.isEmpty() != proxyPort.isEmpty();
+ if (hasIncompleteProxyConfigs) {
+ Toast.makeText(this, R.string.incomplete_proxy_settings, Toast.LENGTH_SHORT).show();
+ }
+ return !hasIncompleteProxyConfigs;
+ }
+
+ private boolean checkPackages(Set<String> packageNames) {
+ final boolean hasCorrectPackageNames = packageNames.isEmpty() ||
+ getPackageManager().getInstalledPackages(0).stream()
+ .map(pi -> pi.packageName)
+ .collect(Collectors.toSet())
+ .containsAll(packageNames);
+ if (!hasCorrectPackageNames) {
+ Toast.makeText(this, R.string.unknown_package_names, Toast.LENGTH_SHORT).show();
+ }
+ return hasCorrectPackageNames;
+ }
+
@Override
protected void onActivityResult(int request, int result, Intent data) {
if (result == RESULT_OK) {
diff --git a/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnConnection.java b/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnConnection.java
index 6644ecd..46897d9 100644
--- a/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnConnection.java
+++ b/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnConnection.java
@@ -19,8 +19,11 @@
import static java.nio.charset.StandardCharsets.US_ASCII;
import android.app.PendingIntent;
+import android.content.pm.PackageManager;
+import android.net.ProxyInfo;
import android.net.VpnService;
import android.os.ParcelFileDescriptor;
+import android.text.TextUtils;
import android.util.Log;
import java.io.FileInputStream;
@@ -31,6 +34,7 @@
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
public class ToyVpnConnection implements Runnable {
@@ -83,14 +87,34 @@
private PendingIntent mConfigureIntent;
private OnEstablishListener mOnEstablishListener;
+ // Proxy settings
+ private String mProxyHostName;
+ private int mProxyHostPort;
+
+ // Allowed/Disallowed packages for VPN usage
+ private final boolean mAllow;
+ private final Set<String> mPackages;
+
public ToyVpnConnection(final VpnService service, final int connectionId,
- final String serverName, final int serverPort, final byte[] sharedSecret) {
+ final String serverName, final int serverPort, final byte[] sharedSecret,
+ final String proxyHostName, final int proxyHostPort, boolean allow,
+ final Set<String> packages) {
mService = service;
mConnectionId = connectionId;
mServerName = serverName;
mServerPort= serverPort;
mSharedSecret = sharedSecret;
+
+ if (!TextUtils.isEmpty(proxyHostName)) {
+ mProxyHostName = proxyHostName;
+ }
+ if (proxyHostPort > 0) {
+ // The port value is always an integer due to the configured inputType.
+ mProxyHostPort = proxyHostPort;
+ }
+ mAllow = allow;
+ mPackages = packages;
}
/**
@@ -117,7 +141,7 @@
// We try to create the tunnel several times.
// TODO: The better way is to work with ConnectivityManager, trying only when the
- // network is available.
+ // network is available.
// Here we just use a counter to keep things simple.
for (int attempt = 0; attempt < 10; ++attempt) {
// Reset the counter if we were connected.
@@ -309,11 +333,23 @@
// Create a new interface using the builder and save the parameters.
final ParcelFileDescriptor vpnInterface;
+ for (String packageName : mPackages) {
+ try {
+ if (mAllow) {
+ builder.addAllowedApplication(packageName);
+ } else {
+ builder.addDisallowedApplication(packageName);
+ }
+ } catch (PackageManager.NameNotFoundException e){
+ Log.w(getTag(), "Package not available: " + packageName, e);
+ }
+ }
+ builder.setSession(mServerName).setConfigureIntent(mConfigureIntent);
+ if (!TextUtils.isEmpty(mProxyHostName)) {
+ builder.setHttpProxy(ProxyInfo.buildDirectProxy(mProxyHostName, mProxyHostPort));
+ }
synchronized (mService) {
- vpnInterface = builder
- .setSession(mServerName)
- .setConfigureIntent(mConfigureIntent)
- .establish();
+ vpnInterface = builder.establish();
if (mOnEstablishListener != null) {
mOnEstablishListener.onEstablish(vpnInterface);
}
diff --git a/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnService.java b/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnService.java
index 5e42d9d..8b28f34 100644
--- a/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnService.java
+++ b/samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnService.java
@@ -17,8 +17,9 @@
package com.example.android.toyvpn;
import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.VpnService;
@@ -30,6 +31,8 @@
import android.widget.Toast;
import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -101,17 +104,15 @@
final SharedPreferences prefs = getSharedPreferences(ToyVpnClient.Prefs.NAME, MODE_PRIVATE);
final String server = prefs.getString(ToyVpnClient.Prefs.SERVER_ADDRESS, "");
final byte[] secret = prefs.getString(ToyVpnClient.Prefs.SHARED_SECRET, "").getBytes();
- final int port;
- try {
- port = Integer.parseInt(prefs.getString(ToyVpnClient.Prefs.SERVER_PORT, ""));
- } catch (NumberFormatException e) {
- Log.e(TAG, "Bad port: " + prefs.getString(ToyVpnClient.Prefs.SERVER_PORT, null), e);
- return;
- }
-
- // Kick off a connection.
+ final boolean allow = prefs.getBoolean(ToyVpnClient.Prefs.ALLOW, true);
+ final Set<String> packages =
+ prefs.getStringSet(ToyVpnClient.Prefs.PACKAGES, Collections.emptySet());
+ final int port = prefs.getInt(ToyVpnClient.Prefs.SERVER_PORT, 0);
+ final String proxyHost = prefs.getString(ToyVpnClient.Prefs.PROXY_HOSTNAME, "");
+ final int proxyPort = prefs.getInt(ToyVpnClient.Prefs.PROXY_PORT, 0);
startConnection(new ToyVpnConnection(
- this, mNextConnectionId.getAndIncrement(), server, port, secret));
+ this, mNextConnectionId.getAndIncrement(), server, port, secret,
+ proxyHost, proxyPort, allow, packages));
}
private void startConnection(final ToyVpnConnection connection) {
@@ -121,13 +122,11 @@
// Handler to mark as connected once onEstablish is called.
connection.setConfigureIntent(mConfigureIntent);
- connection.setOnEstablishListener(new ToyVpnConnection.OnEstablishListener() {
- public void onEstablish(ParcelFileDescriptor tunInterface) {
- mHandler.sendEmptyMessage(R.string.connected);
+ connection.setOnEstablishListener(tunInterface -> {
+ mHandler.sendEmptyMessage(R.string.connected);
- mConnectingThread.compareAndSet(thread, null);
- setConnection(new Connection(thread, tunInterface));
- }
+ mConnectingThread.compareAndSet(thread, null);
+ setConnection(new Connection(thread, tunInterface));
});
thread.start();
}
@@ -159,7 +158,13 @@
}
private void updateForegroundNotification(final int message) {
- startForeground(1, new Notification.Builder(this)
+ final String NOTIFICATION_CHANNEL_ID = "ToyVpn";
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(
+ NOTIFICATION_SERVICE);
+ mNotificationManager.createNotificationChannel(new NotificationChannel(
+ NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_ID,
+ NotificationManager.IMPORTANCE_DEFAULT));
+ startForeground(1, new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_vpn)
.setContentText(getString(message))
.setContentIntent(mConfigureIntent)
diff --git a/samples/WiFiDirectDemo/Android.mk b/samples/WiFiDirectDemo/Android.mk
index 36c5d45..5a76260 100644
--- a/samples/WiFiDirectDemo/Android.mk
+++ b/samples/WiFiDirectDemo/Android.mk
@@ -6,6 +6,9 @@
# Only compile source java files in this apk.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_STATIC_ANDROID_LIBRARIES += \
+ android-support-v4
+
LOCAL_PACKAGE_NAME := WiFiDirectDemo
LOCAL_SDK_VERSION := current
diff --git a/samples/WiFiDirectDemo/AndroidManifest.xml b/samples/WiFiDirectDemo/AndroidManifest.xml
index d25fdc0..44985e8 100644
--- a/samples/WiFiDirectDemo/AndroidManifest.xml
+++ b/samples/WiFiDirectDemo/AndroidManifest.xml
@@ -2,7 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.wifidirect"
android:versionCode="1" android:versionName="1.0">
- <uses-sdk android:minSdkVersion="14" />
+ <!-- runtime permission check API is on Android 6.0 or higher -->
+ <uses-sdk android:minSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
@@ -10,6 +11,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Google Play filtering -->
<uses-feature android:name="android.hardware.wifi.direct" android:required="true"/>
@@ -29,6 +31,16 @@
</intent-filter>
</activity>
+ <provider
+ android:name="android.support.v4.content.FileProvider"
+ android:authorities="com.example.android.wifidirect.fileprovider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/provider_paths" />
+ </provider>
+
<!-- Used for transferring files after a successful connection -->
<service android:enabled="true" android:name=".FileTransferService" />
diff --git a/samples/WiFiDirectDemo/res/xml/provider_paths.xml b/samples/WiFiDirectDemo/res/xml/provider_paths.xml
new file mode 100644
index 0000000..28fb406
--- /dev/null
+++ b/samples/WiFiDirectDemo/res/xml/provider_paths.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+ <external-files-path name="received" path="received"/>
+</paths>
diff --git a/samples/WiFiDirectDemo/src/com/example/android/wifidirect/DeviceDetailFragment.java b/samples/WiFiDirectDemo/src/com/example/android/wifidirect/DeviceDetailFragment.java
index f74afae..c999ece 100644
--- a/samples/WiFiDirectDemo/src/com/example/android/wifidirect/DeviceDetailFragment.java
+++ b/samples/WiFiDirectDemo/src/com/example/android/wifidirect/DeviceDetailFragment.java
@@ -19,7 +19,6 @@
import android.app.Fragment;
import android.app.ProgressDialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.net.wifi.WpsInfo;
@@ -29,7 +28,7 @@
import android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.Environment;
+import android.support.v4.content.FileProvider;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -228,8 +227,8 @@
Log.d(WiFiDirectActivity.TAG, "Server: Socket opened");
Socket client = serverSocket.accept();
Log.d(WiFiDirectActivity.TAG, "Server: connection done");
- final File f = new File(Environment.getExternalStorageDirectory() + "/"
- + context.getPackageName() + "/wifip2pshared-" + System.currentTimeMillis()
+ final File f = new File(context.getExternalFilesDir("received"),
+ "wifip2pshared-" + System.currentTimeMillis()
+ ".jpg");
File dirs = new File(f.getParent());
@@ -256,9 +255,16 @@
protected void onPostExecute(String result) {
if (result != null) {
statusText.setText("File copied - " + result);
+
+ File recvFile = new File(result);
+ Uri fileUri = FileProvider.getUriForFile(
+ context,
+ "com.example.android.wifidirect.fileprovider",
+ recvFile);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.parse("file://" + result), "image/*");
+ intent.setDataAndType(fileUri, "image/*");
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(intent);
}
diff --git a/samples/WiFiDirectDemo/src/com/example/android/wifidirect/WiFiDirectActivity.java b/samples/WiFiDirectDemo/src/com/example/android/wifidirect/WiFiDirectActivity.java
index 2e51c3d..aaec708 100644
--- a/samples/WiFiDirectDemo/src/com/example/android/wifidirect/WiFiDirectActivity.java
+++ b/samples/WiFiDirectDemo/src/com/example/android/wifidirect/WiFiDirectActivity.java
@@ -16,17 +16,20 @@
package com.example.android.wifidirect;
+import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.net.wifi.p2p.WifiP2pConfig;
import android.net.wifi.p2p.WifiP2pDevice;
import android.net.wifi.p2p.WifiP2pManager;
import android.net.wifi.p2p.WifiP2pManager.ActionListener;
import android.net.wifi.p2p.WifiP2pManager.Channel;
import android.net.wifi.p2p.WifiP2pManager.ChannelListener;
+import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
@@ -48,6 +51,9 @@
public class WiFiDirectActivity extends Activity implements ChannelListener, DeviceActionListener {
public static final String TAG = "wifidirectdemo";
+
+ private static final int PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION = 1001;
+
private WifiP2pManager manager;
private boolean isWifiP2pEnabled = false;
private boolean retryChannel = false;
@@ -64,6 +70,19 @@
}
@Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ int[] grantResults) {
+ switch (requestCode) {
+ case PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION:
+ if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
+ Log.e(TAG, "Coarse location permission is not granted!");
+ finish();
+ }
+ break;
+ }
+ }
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
@@ -77,6 +96,15 @@
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
+ && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
+ WiFiDirectActivity.PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
+ // After this point you wait for callback in
+ // onRequestPermissionsResult(int, String[], int[]) overridden method
+ }
}
/** register the BroadcastReceiver with the intent values to be matched */
diff --git a/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/ChatManager.java b/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/ChatManager.java
index d537f10..52fb7a0 100644
--- a/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/ChatManager.java
+++ b/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/ChatManager.java
@@ -65,12 +65,18 @@
}
}
- public void write(byte[] buffer) {
- try {
- oStream.write(buffer);
- } catch (IOException e) {
- Log.e(TAG, "Exception during write", e);
- }
+ public void write(String msg) {
+ byte[] buffer = msg.getBytes();
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ oStream.write(buffer);
+ } catch (IOException e) {
+ Log.e(TAG, "Exception during write", e);
+ }
+ }
+ };
+ thread.start();
}
}
diff --git a/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/WiFiChatFragment.java b/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/WiFiChatFragment.java
index e4a1858..1c9dcab 100644
--- a/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/WiFiChatFragment.java
+++ b/samples/WiFiDirectServiceDiscovery/src/com/example/android/wifidirect/discovery/WiFiChatFragment.java
@@ -43,8 +43,7 @@
@Override
public void onClick(View arg0) {
if (chatManager != null) {
- chatManager.write(chatLine.getText().toString()
- .getBytes());
+ chatManager.write(chatLine.getText().toString());
pushMessage("Me: " + chatLine.getText().toString());
chatLine.setText("");
chatLine.clearFocus();
diff --git a/scripts/gdbclient.py b/scripts/gdbclient.py
index 19a4a17..e612f3b 100755
--- a/scripts/gdbclient.py
+++ b/scripts/gdbclient.py
@@ -17,11 +17,13 @@
import adb
import argparse
+import json
import logging
import os
import re
import subprocess
import sys
+import textwrap
# Shared functions across gdbclient.py and ndk-gdb.py.
import gdbrunner
@@ -64,6 +66,11 @@
parser.add_argument(
"--user", nargs="?", default="root",
help="user to run commands as on the device [default: root]")
+ parser.add_argument(
+ "--setup-forwarding", default=None, choices=["gdb", "vscode"],
+ help=("Setup the gdbserver and port forwarding. Prints commands or " +
+ ".vscode/launch.json configuration needed to connect the debugging " +
+ "client to the server."))
parser.add_argument(
"--env", nargs=1, action="append", metavar="VAR=VALUE",
@@ -157,33 +164,60 @@
return (binary_file, pid, run_cmd)
+def generate_vscode_script(gdbpath, root, sysroot, binary_name, port, dalvik_gdb_script, solib_search_path):
+ # TODO It would be nice if we didn't need to copy this or run the
+ # gdbclient.py program manually. Doing this would probably require
+ # writing a vscode extension or modifying an existing one.
+ res = {
+ "name": "(gdbclient.py) Attach {} (port: {})".format(binary_name.split("/")[-1], port),
+ "type": "cppdbg",
+ "request": "launch", # Needed for gdbserver.
+ "cwd": root,
+ "program": binary_name,
+ "MIMode": "gdb",
+ "miDebuggerServerAddress": "localhost:{}".format(port),
+ "miDebuggerPath": gdbpath,
+ "setupCommands": [
+ {
+ # Required for vscode.
+ "description": "Enable pretty-printing for gdb",
+ "text": "-enable-pretty-printing",
+ "ignoreFailures": True,
+ },
+ {
+ "description": "gdb command: dir",
+ "text": "-environment-directory {}".format(root),
+ "ignoreFailures": False
+ },
+ {
+ "description": "gdb command: set solib-search-path",
+ "text": "-gdb-set solib-search-path {}".format(":".join(solib_search_path)),
+ "ignoreFailures": False
+ },
+ {
+ "description": "gdb command: set solib-absolute-prefix",
+ "text": "-gdb-set solib-absolute-prefix {}".format(sysroot),
+ "ignoreFailures": False
+ },
+ ]
+ }
+ if dalvik_gdb_script:
+ res["setupCommands"].append({
+ "description": "gdb command: source art commands",
+ "text": "-interpreter-exec console \"source {}\"".format(dalvik_gdb_script),
+ "ignoreFailures": False,
+ })
+ return json.dumps(res, indent=4)
-def generate_gdb_script(sysroot, binary_file, is64bit, port, connect_timeout=5):
- # Generate a gdb script.
- # TODO: Detect the zygote and run 'art-on' automatically.
- root = os.environ["ANDROID_BUILD_TOP"]
- symbols_dir = os.path.join(sysroot, "system", "lib64" if is64bit else "lib")
- vendor_dir = os.path.join(sysroot, "vendor", "lib64" if is64bit else "lib")
-
- solib_search_path = []
- symbols_paths = ["", "hw", "ssl/engines", "drm", "egl", "soundfx"]
- vendor_paths = ["", "hw", "egl"]
- solib_search_path += [os.path.join(symbols_dir, x) for x in symbols_paths]
- solib_search_path += [os.path.join(vendor_dir, x) for x in vendor_paths]
+def generate_gdb_script(root, sysroot, binary_name, port, dalvik_gdb_script, solib_search_path, connect_timeout):
solib_search_path = ":".join(solib_search_path)
gdb_commands = ""
- gdb_commands += "file '{}'\n".format(binary_file.name)
+ gdb_commands += "file '{}'\n".format(binary_name)
gdb_commands += "directory '{}'\n".format(root)
gdb_commands += "set solib-absolute-prefix {}\n".format(sysroot)
gdb_commands += "set solib-search-path {}\n".format(solib_search_path)
-
- dalvik_gdb_script = os.path.join(root, "development", "scripts", "gdb",
- "dalvik.gdb")
- if not os.path.exists(dalvik_gdb_script):
- logging.warning(("couldn't find {} - ART debugging options will not " +
- "be available").format(dalvik_gdb_script))
- else:
+ if dalvik_gdb_script:
gdb_commands += "source {}\n".format(dalvik_gdb_script)
# Try to connect for a few seconds, sometimes the device gdbserver takes
@@ -213,6 +247,33 @@
return gdb_commands
+def generate_setup_script(gdbpath, sysroot, binary_file, is64bit, port, debugger, connect_timeout=5):
+ # Generate a setup script.
+ # TODO: Detect the zygote and run 'art-on' automatically.
+ root = os.environ["ANDROID_BUILD_TOP"]
+ symbols_dir = os.path.join(sysroot, "system", "lib64" if is64bit else "lib")
+ vendor_dir = os.path.join(sysroot, "vendor", "lib64" if is64bit else "lib")
+
+ solib_search_path = []
+ symbols_paths = ["", "hw", "ssl/engines", "drm", "egl", "soundfx"]
+ vendor_paths = ["", "hw", "egl"]
+ solib_search_path += [os.path.join(symbols_dir, x) for x in symbols_paths]
+ solib_search_path += [os.path.join(vendor_dir, x) for x in vendor_paths]
+
+ dalvik_gdb_script = os.path.join(root, "development", "scripts", "gdb", "dalvik.gdb")
+ if not os.path.exists(dalvik_gdb_script):
+ logging.warning(("couldn't find {} - ART debugging options will not " +
+ "be available").format(dalvik_gdb_script))
+ dalvik_gdb_script = None
+
+ if debugger == "vscode":
+ return generate_vscode_script(
+ gdbpath, root, sysroot, binary_file.name, port, dalvik_gdb_script, solib_search_path)
+ elif debugger == "gdb":
+ return generate_gdb_script(root, sysroot, binary_file.name, port, dalvik_gdb_script, solib_search_path, connect_timeout)
+ else:
+ raise Exception("Unknown debugger type " + debugger)
+
def main():
required_env = ["ANDROID_BUILD_TOP",
@@ -266,12 +327,6 @@
gdbrunner.forward_gdbserver_port(device, local=args.port,
remote="tcp:{}".format(args.port))
- # Generate a gdb script.
- gdb_commands = generate_gdb_script(sysroot=sysroot,
- binary_file=binary_file,
- is64bit=is64bit,
- port=args.port)
-
# Find where gdb is
if sys.platform.startswith("linux"):
platform_name = "linux-x86"
@@ -279,14 +334,39 @@
platform_name = "darwin-x86"
else:
sys.exit("Unknown platform: {}".format(sys.platform))
+
gdb_path = os.path.join(root, "prebuilts", "gdb", platform_name, "bin",
"gdb")
+ # Generate a gdb script.
+ setup_commands = generate_setup_script(gdbpath=gdb_path,
+ sysroot=sysroot,
+ binary_file=binary_file,
+ is64bit=is64bit,
+ port=args.port,
+ debugger=args.setup_forwarding or "gdb")
- # Print a newline to separate our messages from the GDB session.
- print("")
+ if not args.setup_forwarding:
+ # Print a newline to separate our messages from the GDB session.
+ print("")
- # Start gdb.
- gdbrunner.start_gdb(gdb_path, gdb_commands)
+ # Start gdb.
+ gdbrunner.start_gdb(gdb_path, setup_commands)
+ else:
+ print("")
+ print setup_commands
+ print("")
+ if args.setup_forwarding == "vscode":
+ print textwrap.dedent("""
+ Paste the above json into .vscode/launch.json and start the debugger as
+ normal. Press enter in this terminal once debugging is finished to shutdown
+ the gdbserver and close all the ports.""")
+ else:
+ print textwrap.dedent("""
+ Paste the above gdb commands into the gdb frontend to setup the gdbserver
+ connection. Press enter in this terminal once debugging is finished to
+ shutdown the gdbserver and close all the ports.""")
+ print("")
+ raw_input("Press enter to shutdown gdbserver")
if __name__ == "__main__":
main()
diff --git a/sdk/build_tools_source.prop_template b/sdk/build_tools_source.prop_template
index f0c887b..d89d102 100644
--- a/sdk/build_tools_source.prop_template
+++ b/sdk/build_tools_source.prop_template
@@ -1,3 +1,3 @@
Pkg.UserSrc=false
-Pkg.Revision=${PLATFORM_SDK_VERSION}.0.2
+Pkg.Revision=${PLATFORM_SDK_VERSION}.0.3
#Pkg.Revision=28.0.0
diff --git a/sdk/plat_tools_source.prop_template b/sdk/plat_tools_source.prop_template
index 2f6b7b0..7b629b3 100644
--- a/sdk/plat_tools_source.prop_template
+++ b/sdk/plat_tools_source.prop_template
@@ -1,2 +1,2 @@
Pkg.UserSrc=false
-Pkg.Revision=28.0.1
+Pkg.Revision=28.0.2
diff --git a/sys-img/advancedFeatures.ini b/sys-img/advancedFeatures.ini
index d2ed42c..70dec80 100644
--- a/sys-img/advancedFeatures.ini
+++ b/sys-img/advancedFeatures.ini
@@ -4,6 +4,7 @@
GLESDynamicVersion = on
GLDMA = on
EncryptUserData = on
+IntelPerformanceMonitoringUnit = on
SystemAsRoot = on
Wifi = on
KernelDeviceTreeBlobSupport = on
diff --git a/sys-img/images_arm64-v8a_source.prop_template b/sys-img/images_arm64-v8a_source.prop_template
index c2c3851..54f52d5 100644
--- a/sys-img/images_arm64-v8a_source.prop_template
+++ b/sys-img/images_arm64-v8a_source.prop_template
@@ -1,6 +1,6 @@
Pkg.Desc=Android SDK System Image
Pkg.UserSrc=false
-Pkg.Revision=4
+Pkg.Revision=1
AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=arm64-v8a
diff --git a/sys-img/images_armeabi-v7a_source.prop_template b/sys-img/images_armeabi-v7a_source.prop_template
index 6322547..a2ae522 100644
--- a/sys-img/images_armeabi-v7a_source.prop_template
+++ b/sys-img/images_armeabi-v7a_source.prop_template
@@ -1,6 +1,6 @@
Pkg.Desc=Android SDK System Image
Pkg.UserSrc=false
-Pkg.Revision=4
+Pkg.Revision=1
AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=armeabi-v7a
diff --git a/sys-img/images_armeabi_source.prop_template b/sys-img/images_armeabi_source.prop_template
index ebfec29..280fa9b 100644
--- a/sys-img/images_armeabi_source.prop_template
+++ b/sys-img/images_armeabi_source.prop_template
@@ -1,6 +1,6 @@
Pkg.Desc=Android SDK System Image
Pkg.UserSrc=false
-Pkg.Revision=4
+Pkg.Revision=1
AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=armeabi
diff --git a/sys-img/images_x86_64_source.prop_template b/sys-img/images_x86_64_source.prop_template
index 7f7af45..5b6b90a 100644
--- a/sys-img/images_x86_64_source.prop_template
+++ b/sys-img/images_x86_64_source.prop_template
@@ -1,6 +1,6 @@
Pkg.Desc=Android SDK System Image
Pkg.UserSrc=false
-Pkg.Revision=4
+Pkg.Revision=1
AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=x86_64
diff --git a/sys-img/images_x86_source.prop_template b/sys-img/images_x86_source.prop_template
index ef470a0..a437d6d 100644
--- a/sys-img/images_x86_source.prop_template
+++ b/sys-img/images_x86_source.prop_template
@@ -1,6 +1,6 @@
Pkg.Desc=Android SDK System Image
Pkg.UserSrc=false
-Pkg.Revision=4
+Pkg.Revision=1
AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=x86
diff --git a/vndk/snapshot/OWNERS b/vndk/snapshot/OWNERS
index c567ff6..0c6b741 100644
--- a/vndk/snapshot/OWNERS
+++ b/vndk/snapshot/OWNERS
@@ -1,2 +1,2 @@
andrewhsieh@google.com
-jaeshin@google.com
+justinyun@google.com
diff --git a/vndk/snapshot/check_gpl_license.py b/vndk/snapshot/check_gpl_license.py
index 0b3b89a..fcee1f8 100644
--- a/vndk/snapshot/check_gpl_license.py
+++ b/vndk/snapshot/check_gpl_license.py
@@ -36,16 +36,23 @@
MANIFEST_XML = utils.MANIFEST_FILE_NAME
MODULE_PATHS_TXT = utils.MODULE_PATHS_FILE_NAME
- def __init__(self, install_dir, android_build_top, temp_artifact_dir):
+ def __init__(self, install_dir, android_build_top, temp_artifact_dir,
+ remote_git):
"""GPLChecker constructor.
Args:
install_dir: string, absolute path to the prebuilts/vndk/v{version}
directory where the build files will be generated.
android_build_top: string, absolute path to ANDROID_BUILD_TOP
+ temp_artifact_dir: string, temp directory to hold build artifacts
+ fetched from Android Build server.
+ remote_git: string, remote name to fetch and check if the revision of
+ VNDK snapshot is included in the source if it is not in the current
+ git repository.
"""
self._android_build_top = android_build_top
self._install_dir = install_dir
+ self._remote_git = remote_git
self._manifest_file = os.path.join(temp_artifact_dir,
self.MANIFEST_XML)
self._notice_files_dir = os.path.join(install_dir,
@@ -140,14 +147,16 @@
'Checking if the parent of revision {rev} exists in {proj}'.
format(rev=revision, proj=git_project_path))
try:
- cmd = ['git', '-C', path, 'fetch', 'goog', revision]
+ cmd = ['git', '-C', path, 'fetch', self._remote_git, revision]
utils.check_call(cmd)
cmd = ['git', '-C', path, 'rev-parse', 'FETCH_HEAD^2']
parent_revision = utils.check_output(cmd).strip()
except subprocess.CalledProcessError as error:
logging.error(
- 'Failed to get parent of revision {rev}: {err}'.format(
- rev=revision, err=error))
+ 'Failed to get parent of revision {rev} from "{remote}": '
+ '{err}'.format(
+ rev=revision, remote=self._remote_git, err=error))
+ logging.error('Try --remote to manually set remote name')
raise
else:
if not _check_rev_list(parent_revision):
@@ -227,6 +236,11 @@
parser.add_argument('-b', '--branch', help='Branch to pull manifest from.')
parser.add_argument('--build', help='Build number to pull manifest from.')
parser.add_argument(
+ '--remote',
+ default='aosp',
+ help=('Remote name to fetch and check if the revision of VNDK snapshot '
+ 'is included in the source to conform GPL license. default=aosp'))
+ parser.add_argument(
'-v',
'--verbose',
action='count',
@@ -248,6 +262,7 @@
args = get_args()
vndk_version = args.vndk_version
install_dir = os.path.join(PREBUILTS_VNDK_DIR, 'v{}'.format(vndk_version))
+ remote = args.remote
if not os.path.isdir(install_dir):
raise ValueError(
'Please provide valid VNDK version. {} does not exist.'
@@ -264,7 +279,7 @@
manifest_dest)
license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP,
- temp_artifact_dir)
+ temp_artifact_dir, remote)
try:
license_checker.check_gpl_projects()
except ValueError as error:
diff --git a/vndk/snapshot/gen_buildfiles.py b/vndk/snapshot/gen_buildfiles.py
index 35697aa..f504f55 100644
--- a/vndk/snapshot/gen_buildfiles.py
+++ b/vndk/snapshot/gen_buildfiles.py
@@ -25,9 +25,10 @@
class GenBuildFile(object):
- """Generates Android.mk and Android.bp for VNDK snapshot.
+ """Generates Android.bp for VNDK snapshot.
VNDK snapshot directory structure under prebuilts/vndk/v{version}:
+ Android.bp
{SNAPSHOT_ARCH}/
Android.bp
arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
@@ -52,7 +53,6 @@
(various *.txt configuration files, e.g. ld.config.*.txt)
... (other {SNAPSHOT_ARCH}/ directories)
common/
- Android.mk
Android.bp
NOTICE_FILES/
(license files, e.g. libfoo.so.txt)
@@ -77,7 +77,7 @@
self._vndk_version = vndk_version
self._etc_paths = self._get_etc_paths()
self._snapshot_archs = utils.get_snapshot_archs(install_dir)
- self._mkfile = os.path.join(install_dir, utils.ANDROID_MK_PATH)
+ self._root_bpfile = os.path.join(install_dir, utils.ROOT_BP_PATH)
self._common_bpfile = os.path.join(install_dir, utils.COMMON_BP_PATH)
self._vndk_core = self._parse_lib_list('vndkcore.libraries.txt')
self._vndk_sp = self._parse_lib_list(
@@ -122,30 +122,27 @@
'*.txt'))
return [os.path.splitext(os.path.basename(p))[0] for p in notice_paths]
- def generate_android_mk(self):
- """Autogenerates Android.mk."""
+ def generate_root_android_bp(self):
+ """Autogenerates Android.bp."""
- logging.info('Generating Android.mk for snapshot v{}'.format(
+ logging.info('Generating Android.bp for snapshot v{}'.format(
self._vndk_version))
etc_buildrules = []
for prebuilt in self.ETC_MODULES:
- # Starting from P (VNDK version >= 28), ld.config.VER.txt is not
- # installed as a prebuilt but is built and installed from the
- # source tree at the time the VNDK snapshot is installed to the
- # system.img.
- if prebuilt == 'ld.config.txt' and self._vndk_version >= 28:
+ # ld.config.VER.txt is not installed as a prebuilt but is built and
+ # installed from thesource tree at the time the VNDK snapshot is
+ # installed to the system.img.
+ if prebuilt == 'ld.config.txt':
continue
etc_buildrules.append(self._gen_etc_prebuilt(prebuilt))
- with open(self._mkfile, 'w') as mkfile:
- mkfile.write(self._gen_autogen_msg('#'))
- mkfile.write('\n')
- mkfile.write('LOCAL_PATH := $(call my-dir)\n')
- mkfile.write('\n')
- mkfile.write('\n\n'.join(etc_buildrules))
- mkfile.write('\n')
+ with open(self._root_bpfile, 'w') as bpfile:
+ bpfile.write(self._gen_autogen_msg('/'))
+ bpfile.write('\n')
+ bpfile.write('\n'.join(etc_buildrules))
+ bpfile.write('\n')
- logging.info('Successfully generated {}'.format(self._mkfile))
+ logging.info('Successfully generated {}'.format(self._root_bpfile))
def generate_common_android_bp(self):
"""Autogenerates common/Android.bp."""
@@ -266,19 +263,22 @@
etc_path = self._etc_paths[prebuilt]
etc_sub_path = etc_path[etc_path.index('/') + 1:]
- return ('#######################################\n'
- '# {prebuilt}\n'
- 'include $(CLEAR_VARS)\n'
- 'LOCAL_MODULE := {versioned_name}\n'
- 'LOCAL_SRC_FILES := ../$(TARGET_ARCH)/{etc_sub_path}\n'
- 'LOCAL_MODULE_CLASS := ETC\n'
- 'LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)\n'
- 'LOCAL_MODULE_STEM := $(LOCAL_MODULE)\n'
- 'include $(BUILD_PREBUILT)\n'.format(
- prebuilt=prebuilt,
- versioned_name=self._get_versioned_name(
- prebuilt, None, is_etc=True),
- etc_sub_path=etc_sub_path))
+ prebuilt_etc = ('prebuilt_etc {{\n'
+ '{ind}name: "{versioned_name}",\n'
+ '{ind}target: {{\n'.format(
+ ind=self.INDENT,
+ versioned_name=self._get_versioned_name(
+ prebuilt, None, is_etc=True)))
+ for arch in self._snapshot_archs:
+ prebuilt_etc += ('{ind}{ind}android_{arch}: {{\n'
+ '{ind}{ind}{ind}src: "{arch}/{etc_sub_path}",\n'
+ '{ind}{ind}}},\n'.format(
+ ind=self.INDENT,
+ arch=arch,
+ etc_sub_path=etc_sub_path))
+ prebuilt_etc += ('{ind}}},\n'
+ '}}\n'.format(ind=self.INDENT))
+ return prebuilt_etc
def _gen_notice_filegroup(self, module):
"""Generates a notice filegroup build rule for a given module.
@@ -524,7 +524,7 @@
utils.set_logging_config(args.verbose)
buildfile_generator = GenBuildFile(install_dir, vndk_version)
- buildfile_generator.generate_android_mk()
+ buildfile_generator.generate_root_android_bp()
buildfile_generator.generate_common_android_bp()
buildfile_generator.generate_android_bp()
diff --git a/vndk/snapshot/update.py b/vndk/snapshot/update.py
index 9f05a33..2a8441e 100644
--- a/vndk/snapshot/update.py
+++ b/vndk/snapshot/update.py
@@ -115,8 +115,10 @@
shutil.rmtree(notices_dir_per_arch)
-def revise_ld_config_txt_if_needed(vndk_version):
+def post_processe_files_if_needed(vndk_version):
"""For O-MR1, replaces unversioned VNDK directories with versioned ones.
+ Also, renames ld.config.txt, llndk.libraries.txt and vndksp.libraries.txt
+ files to have version suffix.
Unversioned VNDK directories: /system/${LIB}/vndk[-sp]
Versioned VNDK directories: /system/${LIB}/vndk[-sp]-27
@@ -124,6 +126,13 @@
Args:
vndk_version: int, version of VNDK snapshot
"""
+ def add_version_suffix(file_name):
+ logging.info('Rename {} to have version suffix'.format(vndk_version))
+ target_files = glob.glob(
+ os.path.join(utils.CONFIG_DIR_PATH_PATTERN, file_name))
+ for target_file in target_files:
+ name, ext = os.path.splitext(target_file)
+ os.rename(target_file, name + '.' + str(vndk_version) + ext)
if vndk_version == 27:
logging.info('Revising ld.config.txt for O-MR1...')
re_pattern = '(system\/\${LIB}\/vndk(?:-sp)?)([:/]|$)'
@@ -136,10 +145,16 @@
with open(ld_config_file, 'w') as file:
file.write(revised)
+ files_to_add_version_suffix = ('ld.config.txt',
+ 'llndk.libraries.txt',
+ 'vndksp.libraries.txt')
+ for file_to_rename in files_to_add_version_suffix:
+ add_version_suffix(file_to_rename)
+
def update_buildfiles(buildfile_generator):
- logging.info('Generating Android.mk file...')
- buildfile_generator.generate_android_mk()
+ logging.info('Generating root Android.bp file...')
+ buildfile_generator.generate_root_android_bp()
logging.info('Generating common/Android.bp file...')
buildfile_generator.generate_common_android_bp()
@@ -185,6 +200,11 @@
action='store_true',
help='Perform the update in the current branch. Do not repo start.')
parser.add_argument(
+ '--remote',
+ default='aosp',
+ help=('Remote name to fetch and check if the revision of VNDK snapshot '
+ 'is included in the source to conform GPL license. default=aosp'))
+ parser.add_argument(
'-v',
'--verbose',
action='count',
@@ -243,14 +263,14 @@
install_snapshot(args.branch, args.build, local, install_dir,
temp_artifact_dir)
gather_notice_files(install_dir)
- revise_ld_config_txt_if_needed(vndk_version)
+ post_processe_files_if_needed(vndk_version)
buildfile_generator = GenBuildFile(install_dir, vndk_version)
update_buildfiles(buildfile_generator)
if not local:
license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP,
- temp_artifact_dir)
+ temp_artifact_dir, args.remote)
check_gpl_license(license_checker)
logging.info(
'Successfully updated VNDK snapshot v{}'.format(vndk_version))
diff --git a/vndk/snapshot/utils.py b/vndk/snapshot/utils.py
index eae7b88..7fed128 100644
--- a/vndk/snapshot/utils.py
+++ b/vndk/snapshot/utils.py
@@ -25,9 +25,9 @@
# Global Keys
# All paths are relative to install_dir: prebuilts/vndk/v{version}
+ROOT_BP_PATH = 'Android.bp'
COMMON_DIR_NAME = 'common'
COMMON_DIR_PATH = COMMON_DIR_NAME
-ANDROID_MK_PATH = os.path.join(COMMON_DIR_PATH, 'Android.mk')
COMMON_BP_PATH = os.path.join(COMMON_DIR_PATH, 'Android.bp')
CONFIG_DIR_PATH_PATTERN = '*/configs'
MANIFEST_FILE_NAME = 'manifest.xml'
diff --git a/vndk/tools/build_mixed b/vndk/tools/build_mixed
index 677376e..09d9292 100755
--- a/vndk/tools/build_mixed
+++ b/vndk/tools/build_mixed
@@ -19,6 +19,8 @@
echo " to override the existing vbmeta.img of device. Optional."
echo "-s is used to fetch and flash both product.img and system.img from"
echo " the system_build_dir for devices with a product partition."
+ echo " product.img will be removed if system_build_dir does not have"
+ echo " product.img when -s option is declared."
echo " By default, only system.img is flashed to the target device for"
echo " independent system update. No parameter required. Optional"
echo "system_build_dir is the path to the system build"
@@ -134,6 +136,7 @@
)
if [[ "$INCLUDE_PRODUCT" == true ]]; then
+ unzip -l "$SYSTEM_TARGET_FILES_ARCHIVE" | grep -q IMAGES/product.img &&
EXTRACT_FILE_LIST+=(IMAGES/product.img)
fi
@@ -200,7 +203,13 @@
# Overwrite artifacts in the device archive to create the Mixed Build artifacts.
cp "$SYSTEM_IMAGES_DIR"/system.img "$DEVICE_IMAGES_DIR"/
if [[ "$INCLUDE_PRODUCT" == true ]]; then
- cp "$SYSTEM_IMAGES_DIR"/product.img "$DEVICE_IMAGES_DIR"/
+ if [[ -f "$SYSTEM_IMAGES_DIR"/product.img ]]; then
+ cp "$SYSTEM_IMAGES_DIR"/product.img "$DEVICE_IMAGES_DIR"/
+ else
+ rm -f "$DEVICE_IMAGES_DIR"/product.img
+ # Removed product partition from required partition list
+ sed -i "/partition-exists=product$/d" "$DEVICE_IMAGES_DIR"/android-info.txt
+ fi
fi
# Only override vbmeta if it is already present since fastboot update will try
@@ -228,3 +237,5 @@
# Overwrite the image archive with the Mixed Build archive.
OUT_ARCHIVE="$DIST_DIR"/"$(basename $DEVICE_ARCHIVE)"
cp "$DEVICE_IMAGES_DIR"/mixed.zip "$OUT_ARCHIVE"
+# Overwrite android-info.txt with the updated one.
+cp "$DEVICE_IMAGES_DIR"/android-info.txt "$DIST_DIR"/
diff --git a/vndk/tools/definition-tool/.pylintrc b/vndk/tools/definition-tool/.pylintrc
new file mode 100644
index 0000000..528ac1c
--- /dev/null
+++ b/vndk/tools/definition-tool/.pylintrc
@@ -0,0 +1,8 @@
+[MESSAGES CONTROL]
+
+disable=
+ fixme,
+ invalid-name,
+ missing-docstring,
+ ungrouped-imports,
+ useless-object-inheritance,
diff --git a/vndk/tools/definition-tool/tests/compat.py b/vndk/tools/definition-tool/tests/compat.py
index 9f41853..8981237 100644
--- a/vndk/tools/definition-tool/tests/compat.py
+++ b/vndk/tools/definition-tool/tests/compat.py
@@ -1,39 +1,52 @@
#!/usr/bin/env python3
-import os
+# pylint: disable=unused-import,import-error
+
import sys
+
try:
from tempfile import TemporaryDirectory
except ImportError:
import shutil
import tempfile
+
class TemporaryDirectory(object):
def __init__(self, suffix='', prefix='tmp', dir=None):
+ # pylint: disable=redefined-builtin
self.name = tempfile.mkdtemp(suffix, prefix, dir)
+
def __del__(self):
self.cleanup()
+
def __enter__(self):
return self.name
+
def __exit__(self, exc, value, tb):
self.cleanup()
+
def cleanup(self):
if self.name:
shutil.rmtree(self.name)
self.name = None
+
if sys.version_info >= (3, 0):
from os import makedirs
else:
+ import os
+
+
def makedirs(path, exist_ok):
if exist_ok and os.path.exists(path):
return
- return os.makedirs(path)
+ os.makedirs(path)
+
if sys.version_info >= (3, 0):
from io import StringIO
@@ -45,6 +58,8 @@
from unittest.mock import patch
except ImportError:
import contextlib
+
+
@contextlib.contextmanager
def patch(target, mock):
obj, attr = target.rsplit('.')
@@ -55,3 +70,20 @@
yield
finally:
setattr(obj, attr, original_value)
+
+
+if sys.version_info >= (3, 2):
+ from unittest import TestCase
+else:
+ import unittest
+
+
+ class TestCase(unittest.TestCase):
+ def assertRegex(self, text, expected_regex, msg=None):
+ # pylint: disable=deprecated-method
+ self.assertRegexpMatches(text, expected_regex, msg)
+
+
+ def assertNotRegex(self, text, unexpected_regex, msg=None):
+ # pylint: disable=deprecated-method
+ self.assertNotRegexpMatches(text, unexpected_regex, msg)
diff --git a/vndk/tools/definition-tool/tests/ndk_toolchain.py b/vndk/tools/definition-tool/tests/ndk_toolchain.py
old mode 100755
new mode 100644
index 8ad9144..e040787
--- a/vndk/tools/definition-tool/tests/ndk_toolchain.py
+++ b/vndk/tools/definition-tool/tests/ndk_toolchain.py
@@ -2,13 +2,13 @@
from __future__ import print_function
-import argparse
import collections
import os
import re
import subprocess
import sys
+
def detect_ndk_dir():
ndk_dir = os.getenv('NDK')
if not ndk_dir:
@@ -28,6 +28,7 @@
return ndk_dir
+
def detect_api_level(ndk_dir):
try:
apis = []
@@ -42,6 +43,7 @@
except IOError:
raise ValueError('failed to find latest api')
+
def detect_host():
if sys.platform.startswith('linux'):
return 'linux-x86_64'
@@ -49,15 +51,19 @@
return 'darwin-x86_64'
raise NotImplementedError('unknown host platform')
+
def get_gcc_dir(ndk_dir, arch, host):
return os.path.join(ndk_dir, 'toolchains', arch, 'prebuilt', host)
+
def get_clang_dir(ndk_dir, host):
return os.path.join(ndk_dir, 'toolchains', 'llvm', 'prebuilt', host)
+
def get_platform_dir(ndk_dir, api, subdirs):
return os.path.join(ndk_dir, 'platforms', api, *subdirs)
+
class Target(object):
def __init__(self, name, triple, cflags, ldflags, gcc_toolchain_dir,
clang_dir, ndk_include, ndk_lib):
@@ -71,6 +77,7 @@
self.ndk_include = ndk_include
self.ndk_lib = ndk_lib
+
def check_paths(self):
def check_path(path):
if os.path.exists(path):
@@ -79,7 +86,7 @@
return False
ld_exeutable = os.path.join(
- self.gcc_toolchain_dir, 'bin', self.target_triple + '-ld')
+ self.gcc_toolchain_dir, 'bin', self.target_triple + '-ld')
success = check_path(self.gcc_toolchain_dir)
success &= check_path(ld_exeutable)
@@ -88,6 +95,7 @@
success &= check_path(self.ndk_lib)
return success
+
def compile(self, obj_file, src_file, cflags):
clang = os.path.join(self.clang_dir, 'bin', 'clang')
@@ -100,6 +108,7 @@
cmd.extend(self.target_cflags)
subprocess.check_call(cmd)
+
def link(self, out_file, obj_files, ldflags):
if '-shared' in ldflags:
crtbegin = os.path.join(self.ndk_lib, 'crtbegin_so.o')
@@ -124,6 +133,7 @@
cmd.append('-Wl,-pie')
subprocess.check_call(cmd)
+
def create_targets(ndk_dir=None, api=None, host=None):
if ndk_dir is None:
ndk_dir = detect_ndk_dir()
@@ -135,68 +145,47 @@
targets = collections.OrderedDict()
targets['arm'] = Target(
- 'arm', 'arm-linux-androideabi', [],[],
- get_gcc_dir(ndk_dir, 'arm-linux-androideabi-4.9', host),
- get_clang_dir(ndk_dir, host),
- get_platform_dir(ndk_dir, api, ['arch-arm', 'usr', 'include']),
- get_platform_dir(ndk_dir, api, ['arch-arm', 'usr', 'lib']))
+ 'arm', 'arm-linux-androideabi', [], [],
+ get_gcc_dir(ndk_dir, 'arm-linux-androideabi-4.9', host),
+ get_clang_dir(ndk_dir, host),
+ get_platform_dir(ndk_dir, api, ['arch-arm', 'usr', 'include']),
+ get_platform_dir(ndk_dir, api, ['arch-arm', 'usr', 'lib']))
targets['arm64'] = Target(
- 'arm64', 'aarch64-linux-android', [], [],
- get_gcc_dir(ndk_dir, 'aarch64-linux-android-4.9', host),
- get_clang_dir(ndk_dir, host),
- get_platform_dir(ndk_dir, api, ['arch-arm64', 'usr', 'include']),
- get_platform_dir(ndk_dir, api, ['arch-arm64', 'usr', 'lib']))
+ 'arm64', 'aarch64-linux-android', [], [],
+ get_gcc_dir(ndk_dir, 'aarch64-linux-android-4.9', host),
+ get_clang_dir(ndk_dir, host),
+ get_platform_dir(ndk_dir, api, ['arch-arm64', 'usr', 'include']),
+ get_platform_dir(ndk_dir, api, ['arch-arm64', 'usr', 'lib']))
targets['x86'] = Target(
- 'x86', 'i686-linux-android', ['-m32'], ['-m32'],
- get_gcc_dir(ndk_dir, 'x86-4.9', host),
- get_clang_dir(ndk_dir, host),
- get_platform_dir(ndk_dir, api, ['arch-x86', 'usr', 'include']),
- get_platform_dir(ndk_dir, api, ['arch-x86', 'usr', 'lib']))
+ 'x86', 'i686-linux-android', ['-m32'], ['-m32'],
+ get_gcc_dir(ndk_dir, 'x86-4.9', host),
+ get_clang_dir(ndk_dir, host),
+ get_platform_dir(ndk_dir, api, ['arch-x86', 'usr', 'include']),
+ get_platform_dir(ndk_dir, api, ['arch-x86', 'usr', 'lib']))
targets['x86_64'] = Target(
- 'x86_64', 'x86_64-linux-android', ['-m64'], ['-m64'],
- get_gcc_dir(ndk_dir, 'x86_64-4.9', host),
- get_clang_dir(ndk_dir, host),
- get_platform_dir(ndk_dir, api, ['arch-x86_64', 'usr', 'include']),
- get_platform_dir(ndk_dir, api, ['arch-x86_64', 'usr', 'lib64']))
+ 'x86_64', 'x86_64-linux-android', ['-m64'], ['-m64'],
+ get_gcc_dir(ndk_dir, 'x86_64-4.9', host),
+ get_clang_dir(ndk_dir, host),
+ get_platform_dir(ndk_dir, api, ['arch-x86_64', 'usr', 'include']),
+ get_platform_dir(ndk_dir, api, ['arch-x86_64', 'usr', 'lib64']))
targets['mips'] = Target(
- 'mips', 'mipsel-linux-android', [], [],
- get_gcc_dir(ndk_dir, 'mipsel-linux-android-4.9', host),
- get_clang_dir(ndk_dir, host),
- get_platform_dir(ndk_dir, api, ['arch-mips', 'usr', 'include']),
- get_platform_dir(ndk_dir, api, ['arch-mips', 'usr', 'lib']))
+ 'mips', 'mipsel-linux-android', [], [],
+ get_gcc_dir(ndk_dir, 'mipsel-linux-android-4.9', host),
+ get_clang_dir(ndk_dir, host),
+ get_platform_dir(ndk_dir, api, ['arch-mips', 'usr', 'include']),
+ get_platform_dir(ndk_dir, api, ['arch-mips', 'usr', 'lib']))
targets['mips64'] = Target(
- 'mips64', 'mips64el-linux-android',
- ['-march=mips64el', '-mcpu=mips64r6'],
- ['-march=mips64el', '-mcpu=mips64r6'],
- get_gcc_dir(ndk_dir, 'mips64el-linux-android-4.9', host),
- get_clang_dir(ndk_dir, host),
- get_platform_dir(ndk_dir, api, ['arch-mips64', 'usr', 'include']),
- get_platform_dir(ndk_dir, api, ['arch-mips64', 'usr', 'lib64']))
+ 'mips64', 'mips64el-linux-android',
+ ['-march=mips64el', '-mcpu=mips64r6'],
+ ['-march=mips64el', '-mcpu=mips64r6'],
+ get_gcc_dir(ndk_dir, 'mips64el-linux-android-4.9', host),
+ get_clang_dir(ndk_dir, host),
+ get_platform_dir(ndk_dir, api, ['arch-mips64', 'usr', 'include']),
+ get_platform_dir(ndk_dir, api, ['arch-mips64', 'usr', 'lib64']))
return targets
-
-def main():
- parser = argparse.ArgumentParser(
- description='Dry-run NDK toolchain detection')
- parser.add_argument('--ndk-dir')
- parser.add_argument('--api-level')
- parser.add_argument('--host')
- args = parser.parse_args()
-
- targets = create_targets(args.ndk_dir, args.api_level, args.host)
-
- success = True
- for name, target in targets.items():
- success &= target.check_paths()
- if not success:
- sys.exit(1)
-
- print('succeed')
-
-if __name__ == '__main__':
- main()
diff --git a/vndk/tools/definition-tool/tests/run.py b/vndk/tools/definition-tool/tests/run.py
deleted file mode 100755
index 2d2352b..0000000
--- a/vndk/tools/definition-tool/tests/run.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-import os
-import unittest
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument('--verbose', '-v', action='store_true')
- args = parser.parse_args()
-
- verbosity = 2 if args.verbose else 1
-
- loader = unittest.TestLoader()
- tests = loader.discover(os.path.dirname(__file__), 'test_*.py')
- runner = unittest.runner.TextTestRunner(verbosity=verbosity)
- runner.run(tests)
-
-if __name__ == '__main__':
- main()
diff --git a/vndk/tools/definition-tool/tests/run.sh b/vndk/tools/definition-tool/tests/run.sh
new file mode 100755
index 0000000..3a31145
--- /dev/null
+++ b/vndk/tools/definition-tool/tests/run.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -ex
+
+#
+# Copyright (C) 2018 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.
+#
+
+cd "$(dirname "$0")/.."
+
+python3 -m unittest discover "$@"
+python -m unittest discover "$@"
diff --git a/vndk/tools/definition-tool/tests/test_command_deps_insight.py b/vndk/tools/definition-tool/tests/test_command_deps_insight.py
old mode 100755
new mode 100644
index d0b0bb1..37e7b4e
--- a/vndk/tools/definition-tool/tests/test_command_deps_insight.py
+++ b/vndk/tools/definition-tool/tests/test_command_deps_insight.py
@@ -2,16 +2,13 @@
from __future__ import print_function
-import os
-import sys
import unittest
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from compat import StringIO, patch
from vndk_definition_tool import (
DepsInsightCommand, ModuleInfo, PT_SYSTEM, PT_VENDOR)
-from utils import GraphBuilder
+
+from .compat import StringIO, patch
+from .utils import GraphBuilder
class DepsInsightCommandTest(unittest.TestCase):
@@ -48,41 +45,63 @@
def test_serialize_data_with_all_deps(self):
- """compute_degenerated_vndk() should not remove bad dependencies from
- the output of deps-insight. This test checks the existance of bad
- dependencies."""
+ # compute_degenerated_vndk() should not remove bad dependencies from
+ # the output of deps-insight. This test checks the existance of bad
+ # dependencies.
gb = GraphBuilder()
- libfwk = gb.add_lib32(PT_SYSTEM, 'libfwk')
- libvndk = gb.add_lib32(PT_SYSTEM, 'libvndk',
- dt_needed=['libvnd_bad.so'], extra_dir='vndk')
- libvndk_sp = gb.add_lib32(PT_SYSTEM, 'libutils',
- dt_needed=['libvnd_bad.so'],
- extra_dir='vndk-sp')
- libvnd = gb.add_lib32(PT_VENDOR, 'libvnd',
- dt_needed=['libvndk.so', 'libutils.so'])
- libvnd_bad = gb.add_lib32(PT_VENDOR, 'libvnd_bad', extra_dir='vndk-sp')
+
+ libsystem = gb.add_lib32(PT_SYSTEM, 'libsystem')
+
+ libsystem2 = gb.add_lib32(
+ PT_SYSTEM, 'libsystem2', dt_needed=['libsystem.so'])
+
+ libvndk = gb.add_lib32(
+ PT_SYSTEM, 'libvndk', dt_needed=['libvendor_bad.so'],
+ extra_dir='vndk')
+
+ libvendor = gb.add_lib32(
+ PT_VENDOR, 'libvendor', dt_needed=['libvndk.so'])
+
+ libvendor_bad = gb.add_lib32(
+ PT_VENDOR, 'libvendor_bad', extra_dir='vndk')
+
gb.resolve()
with patch('sys.stderr', StringIO()):
vndk_sets = gb.graph.compute_degenerated_vndk(set(), None)
- self.assertNotIn(libvnd_bad, libvndk.deps_good)
- self.assertNotIn(libvnd_bad, libvndk_sp.deps_good)
+ self.assertNotIn(libvendor_bad, libvndk.deps_good)
strs, mods = DepsInsightCommand.serialize_data(
- list(gb.graph.all_libs()), vndk_sets, ModuleInfo())
+ list(gb.graph.all_libs()), vndk_sets, ModuleInfo())
+ # libsystem
+ deps = self._get_module_deps(strs, mods, libsystem.path)
+ self.assertFalse(deps)
+ users = self._get_module_users(strs, mods, libsystem.path)
+ self.assertIn(libsystem2.path, users)
+
+ # libsystem2
+ deps = self._get_module_deps(strs, mods, libsystem2.path)
+ self.assertIn(libsystem.path, deps)
+ users = self._get_module_users(strs, mods, libsystem2.path)
+ self.assertFalse(users)
+
+ # libvndk
deps = self._get_module_deps(strs, mods, libvndk.path)
- self.assertIn(libvnd_bad.path, deps)
+ self.assertIn(libvendor_bad.path, deps)
+ users = self._get_module_users(strs, mods, libvndk.path)
+ self.assertIn(libvendor.path, users)
- deps = self._get_module_deps(strs, mods, libvndk_sp.path)
- self.assertIn(libvnd_bad.path, deps)
+ # libvendor
+ deps = self._get_module_deps(strs, mods, libvendor.path)
+ self.assertIn(libvndk.path, deps)
+ users = self._get_module_users(strs, mods, libvendor.path)
+ self.assertFalse(users)
- users = self._get_module_users(strs, mods, libvnd_bad.path)
+ # libvendor_bad
+ deps = self._get_module_deps(strs, mods, libvendor_bad.path)
+ self.assertFalse(deps)
+ users = self._get_module_users(strs, mods, libvendor_bad.path)
self.assertIn(libvndk.path, users)
- self.assertIn(libvndk_sp.path, users)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_dex_file.py b/vndk/tools/definition-tool/tests/test_dex_file.py
old mode 100755
new mode 100644
index fe2644f..9c09ced
--- a/vndk/tools/definition-tool/tests/test_dex_file.py
+++ b/vndk/tools/definition-tool/tests/test_dex_file.py
@@ -4,15 +4,13 @@
import os
import subprocess
-import sys
import unittest
import zipfile
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from compat import TemporaryDirectory
from vndk_definition_tool import DexFileReader, UnicodeSurrogateDecodeError
+from .compat import TemporaryDirectory
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
INPUT_DIR = os.path.join(SCRIPT_DIR, 'testdata', 'test_dex_file')
@@ -42,7 +40,7 @@
b'\xed\xa0\x81\xed\xb0\x80'.decode('mutf-8'))
- def test_decode(self):
+ def test_decode_exception(self):
# Low surrogate does not come after high surrogate
with self.assertRaises(UnicodeSurrogateDecodeError):
b'\xed\xa0\x81\x40'.decode('mutf-8')
@@ -122,7 +120,3 @@
self.assertIn(b'world', strs)
self.assertIn(b'foo', strs)
self.assertIn(b'bar', strs)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_elf.py b/vndk/tools/definition-tool/tests/test_elf.py
old mode 100755
new mode 100644
index a45fb58..035a1af
--- a/vndk/tools/definition-tool/tests/test_elf.py
+++ b/vndk/tools/definition-tool/tests/test_elf.py
@@ -2,16 +2,14 @@
from __future__ import print_function
-import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
import tempfile
import unittest
-from compat import StringIO
from vndk_definition_tool import Elf_Sym, ELF
+from .compat import StringIO
+
+
class ElfSymTest(unittest.TestCase):
def setUp(self):
self.sym_local = Elf_Sym(0, 0, 4, 0, 0, 1)
@@ -19,21 +17,25 @@
self.sym_weak = Elf_Sym(0, 0, 4, 33, 0, 1)
self.sym_undef = Elf_Sym(0, 0, 4, 16, 0, 0)
+
def test_is_local(self):
self.assertTrue(self.sym_local.is_local)
self.assertFalse(self.sym_global.is_local)
self.assertFalse(self.sym_weak.is_local)
+
def test_is_global(self):
self.assertFalse(self.sym_local.is_global)
self.assertTrue(self.sym_global.is_global)
self.assertFalse(self.sym_weak.is_global)
+
def test_is_weak(self):
self.assertFalse(self.sym_local.is_weak)
self.assertFalse(self.sym_global.is_weak)
self.assertTrue(self.sym_weak.is_weak)
+
def test_is_undef(self):
self.assertFalse(self.sym_global.is_undef)
self.assertTrue(self.sym_undef.is_undef)
@@ -44,12 +46,14 @@
self.assertEqual(ELF.ELFCLASS32, ELF.get_ei_class_from_name('32'))
self.assertEqual(ELF.ELFCLASS64, ELF.get_ei_class_from_name('64'))
+
def test_get_ei_data_from_name(self):
self.assertEqual(ELF.ELFDATA2LSB,
ELF.get_ei_data_from_name('Little-Endian'))
self.assertEqual(ELF.ELFDATA2MSB,
ELF.get_ei_data_from_name('Big-Endian'))
+
def test_get_e_machine_from_name(self):
self.assertEqual(0, ELF.get_e_machine_from_name('EM_NONE'))
self.assertEqual(3, ELF.get_e_machine_from_name('EM_386'))
@@ -58,6 +62,7 @@
self.assertEqual(62, ELF.get_e_machine_from_name('EM_X86_64'))
self.assertEqual(183, ELF.get_e_machine_from_name('EM_AARCH64'))
+
def test_repr(self):
elf = ELF()
self.assertEqual(elf, eval(repr(elf)))
@@ -67,6 +72,7 @@
dt_needed=['c', 'd'], exported_symbols={'e', 'f', 'g'})
self.assertEqual(elf, eval(repr(elf)))
+
def test_class_name(self):
self.assertEqual('None', ELF().elf_class_name)
@@ -80,6 +86,7 @@
self.assertFalse(elf.is_32bit)
self.assertTrue(elf.is_64bit)
+
def test_endianness(self):
self.assertEqual('None', ELF().elf_data_name)
self.assertEqual('Little-Endian',
@@ -87,6 +94,7 @@
self.assertEqual('Big-Endian',
ELF(None, ELF.ELFDATA2MSB).elf_data_name)
+
def test_machine_name(self):
self.assertEqual('EM_NONE', ELF(e_machine=0).elf_machine_name)
self.assertEqual('EM_386', ELF(e_machine=3).elf_machine_name)
@@ -95,6 +103,7 @@
self.assertEqual('EM_X86_64', ELF(e_machine=62).elf_machine_name)
self.assertEqual('EM_AARCH64', ELF(e_machine=183).elf_machine_name)
+
def test_dt_rpath_runpath(self):
elf = ELF()
self.assertEqual([], elf.dt_rpath)
@@ -104,6 +113,7 @@
self.assertEqual(['a'], elf.dt_rpath)
self.assertEqual(['b'], elf.dt_runpath)
+
def test_dump(self):
elf = ELF(ELF.ELFCLASS32, ELF.ELFDATA2LSB, 183, ['a'], ['b'],
['libc.so', 'libm.so'], {'hello', 'world'}, {'d', 'e'})
@@ -130,6 +140,7 @@
'IMP_SYMBOL\te\n',
actual_output)
+
def test_parse_dump_file(self):
data = ('EI_CLASS\t64\n'
'EI_DATA\t\tLittle-Endian\n'
@@ -190,6 +201,7 @@
elf = ELF(dt_needed=['libc.so'])
self.assertFalse(elf.is_jni_lib())
+
def test_jni_symbols(self):
elf = ELF(imported_symbols={'JNI_CreateJavaVM'})
self.assertTrue(elf.is_jni_lib())
@@ -208,7 +220,3 @@
elf = ELF(exported_symbols={'printf'})
self.assertFalse(elf.is_jni_lib())
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_elf_link_data.py b/vndk/tools/definition-tool/tests/test_elf_link_data.py
old mode 100755
new mode 100644
index e850307..7191919
--- a/vndk/tools/definition-tool/tests/test_elf_link_data.py
+++ b/vndk/tools/definition-tool/tests/test_elf_link_data.py
@@ -2,10 +2,6 @@
from __future__ import print_function
-import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
import unittest
from vndk_definition_tool import ELFLinkData, PT_SYSTEM, PT_VENDOR
@@ -25,6 +21,7 @@
self.z.add_needed_dep(self.w)
self.z.add_dlopen_dep(self.w)
+
def test_add_dep_and_accessors(self):
self.assertIn(self.y, self.x.deps_needed_all)
self.assertIn(self.x, self.y.users_needed_all)
@@ -36,6 +33,7 @@
self.assertNotIn(self.z, self.x.deps_needed_all)
self.assertNotIn(self.x, self.z.users_needed_all)
+
def test_remove_dep(self):
self.assertIn(self.y, self.x.deps_needed_all)
self.assertIn(self.x, self.y.users_needed_all)
@@ -51,6 +49,7 @@
self.assertNotIn(self.y, self.x.deps_needed)
self.assertNotIn(self.x, self.y.users_needed)
+
def test_num_deps(self):
self.assertEqual(2, self.x.num_deps)
self.assertEqual(0, self.y.num_deps)
@@ -60,6 +59,7 @@
# NEEDED and DLOPEN are counted twice.
self.assertEqual(2, self.z.num_deps)
+
def test_num_users(self):
self.assertEqual(0, self.x.num_users)
self.assertEqual(1, self.y.num_users)
@@ -69,22 +69,26 @@
# NEEDED and DLOPEN are counted twice.
self.assertEqual(2, self.w.num_users)
+
def test_has_dep(self):
self.assertTrue(self.x.has_dep(self.y))
self.assertTrue(self.x.has_dep(self.z))
self.assertFalse(self.x.has_dep(self.x))
self.assertFalse(self.x.has_dep(self.w))
+
def test_has_user(self):
self.assertTrue(self.y.has_user(self.x))
self.assertTrue(self.z.has_user(self.x))
self.assertFalse(self.x.has_user(self.x))
self.assertFalse(self.w.has_user(self.x))
+
def test_is_system_lib(self):
self.assertTrue(self.x.is_system_lib())
self.assertFalse(self.v.is_system_lib())
+
def test_get_dep_linked_symbols(self):
self.x.linked_symbols['c'] = self.y
self.x.linked_symbols['b'] = self.y
@@ -100,7 +104,3 @@
self.assertEqual(['w', 'x', 'y', 'z'],
self.x.get_dep_linked_symbols(self.z))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_elf_linker.py b/vndk/tools/definition-tool/tests/test_elf_linker.py
old mode 100755
new mode 100644
index 01038a0..ba2c9a8
--- a/vndk/tools/definition-tool/tests/test_elf_linker.py
+++ b/vndk/tools/definition-tool/tests/test_elf_linker.py
@@ -1,23 +1,16 @@
#!/usr/bin/env python3
-import os
import re
-import sys
import tempfile
-import unittest
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from compat import StringIO, patch
-from utils import GraphBuilder
from vndk_definition_tool import (
- ELF, ELFLinker, GenericRefs, PT_SYSTEM, PT_VENDOR, VNDKLibDir)
+ ELF, GenericRefs, PT_SYSTEM, PT_VENDOR, VNDKLibDir)
+
+from .compat import StringIO, TestCase, patch
+from .utils import GraphBuilder
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-
-
-class ELFLinkerTest(unittest.TestCase):
+class ELFLinkerTest(TestCase):
def _create_normal_graph(self):
gb = GraphBuilder()
@@ -102,7 +95,6 @@
def test_deps(self):
gb = self._create_normal_graph()
- graph = gb.graph
# Check the dependencies of libc.so.
node = gb.graph.get_lib('/system/lib/libc.so')
@@ -323,6 +315,7 @@
# Create generic reference.
class MockGenericRefs(object):
+ # pylint: disable=too-few-public-methods
def classify_lib(self, lib):
if 'libllvm_vendor' in lib.path:
return GenericRefs.NEW_LIB
@@ -393,36 +386,36 @@
libc_32, libc_64 = gb.add_multilib(PT_SYSTEM, 'libc')
libvndk_a_32, libvndk_a_64 = gb.add_multilib(
- PT_SYSTEM, 'libvndk_a', extra_dir='vndk-28',
- dt_needed=['libc.so', 'libvndk_b.so', 'libvndk_sp_b.so'])
+ PT_SYSTEM, 'libvndk_a', extra_dir='vndk-28',
+ dt_needed=['libc.so', 'libvndk_b.so', 'libvndk_sp_b.so'])
libvndk_b_32, libvndk_b_64 = gb.add_multilib(
- PT_SYSTEM, 'libvndk_b', extra_dir='vndk-28',
- dt_needed=['libc.so', 'libvndk_sp_b.so'])
+ PT_SYSTEM, 'libvndk_b', extra_dir='vndk-28',
+ dt_needed=['libc.so', 'libvndk_sp_b.so'])
libvndk_c_32, libvndk_c_64 = gb.add_multilib(
- PT_VENDOR, 'libvndk_c', extra_dir='vndk-28',
- dt_needed=['libc.so', 'libvndk_d.so', 'libvndk_sp_d.so'])
+ PT_VENDOR, 'libvndk_c', extra_dir='vndk-28',
+ dt_needed=['libc.so', 'libvndk_d.so', 'libvndk_sp_d.so'])
libvndk_d_32, libvndk_d_64 = gb.add_multilib(
- PT_VENDOR, 'libvndk_d', extra_dir='vndk-28',
- dt_needed=['libc.so', 'libvndk_sp_d.so'])
+ PT_VENDOR, 'libvndk_d', extra_dir='vndk-28',
+ dt_needed=['libc.so', 'libvndk_sp_d.so'])
libvndk_sp_a_32, libvndk_sp_a_64 = gb.add_multilib(
- PT_SYSTEM, 'libvndk_sp_a', extra_dir='vndk-sp-28',
- dt_needed=['libc.so', 'libvndk_sp_b.so'])
+ PT_SYSTEM, 'libvndk_sp_a', extra_dir='vndk-sp-28',
+ dt_needed=['libc.so', 'libvndk_sp_b.so'])
libvndk_sp_b_32, libvndk_sp_b_64 = gb.add_multilib(
- PT_SYSTEM, 'libvndk_sp_b', extra_dir='vndk-sp-28',
- dt_needed=['libc.so'])
+ PT_SYSTEM, 'libvndk_sp_b', extra_dir='vndk-sp-28',
+ dt_needed=['libc.so'])
libvndk_sp_c_32, libvndk_sp_c_64 = gb.add_multilib(
- PT_VENDOR, 'libvndk_sp_c', extra_dir='vndk-sp-28',
- dt_needed=['libc.so', 'libvndk_sp_d.so'])
+ PT_VENDOR, 'libvndk_sp_c', extra_dir='vndk-sp-28',
+ dt_needed=['libc.so', 'libvndk_sp_d.so'])
libvndk_sp_d_32, libvndk_sp_d_64 = gb.add_multilib(
- PT_VENDOR, 'libvndk_sp_d', extra_dir='vndk-sp-28',
- dt_needed=['libc.so'])
+ PT_VENDOR, 'libvndk_sp_d', extra_dir='vndk-sp-28',
+ dt_needed=['libc.so'])
gb.resolve(VNDKLibDir.create_from_version('28'), '28')
@@ -467,7 +460,7 @@
self.assertIn(libvndk_sp_d_64, libvndk_sp_c_64.deps_all)
-class ELFLinkerDlopenDepsTest(unittest.TestCase):
+class ELFLinkerDlopenDepsTest(TestCase):
def test_add_dlopen_deps(self):
gb = GraphBuilder()
liba = gb.add_lib32(PT_SYSTEM, 'liba')
@@ -548,8 +541,8 @@
def test_add_dlopen_deps_error(self):
gb = GraphBuilder()
- liba = gb.add_lib32(PT_SYSTEM, 'liba')
- libb = gb.add_lib32(PT_SYSTEM, 'libb')
+ gb.add_lib32(PT_SYSTEM, 'liba')
+ gb.add_lib32(PT_SYSTEM, 'libb')
gb.resolve()
with tempfile.NamedTemporaryFile(mode='w') as tmp_file:
@@ -560,11 +553,7 @@
with patch('sys.stderr', stderr):
gb.graph.add_dlopen_deps(tmp_file.name)
- self.assertRegexpMatches(
- stderr.getvalue(),
- 'error:' + re.escape(tmp_file.name) + ':1: ' +
- 'Failed to add dlopen dependency from .* to .*\\.\n')
-
-
-if __name__ == '__main__':
- unittest.main()
+ self.assertRegex(
+ stderr.getvalue(),
+ 'error:' + re.escape(tmp_file.name) + ':1: ' +
+ 'Failed to add dlopen dependency from .* to .*\\.\n')
diff --git a/vndk/tools/definition-tool/tests/test_elf_resolver.py b/vndk/tools/definition-tool/tests/test_elf_resolver.py
old mode 100755
new mode 100644
index 29973e3..f6257f5
--- a/vndk/tools/definition-tool/tests/test_elf_resolver.py
+++ b/vndk/tools/definition-tool/tests/test_elf_resolver.py
@@ -2,14 +2,11 @@
from __future__ import print_function
-import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
import unittest
from vndk_definition_tool import ELFResolver
+
class ELFResolverTest(unittest.TestCase):
def setUp(self):
lib_set = {
@@ -24,50 +21,51 @@
self.resolver = ELFResolver(lib_set, ['/system/lib', '/vendor/lib'])
+
def test_get_candidates(self):
r = self.resolver
self.assertEqual(
- ['/system/lib/libx.so', '/vendor/lib/libx.so'],
- list(r.get_candidates('/system/lib/libreq.so', 'libx.so')))
+ ['/system/lib/libx.so', '/vendor/lib/libx.so'],
+ list(r.get_candidates('/system/lib/libreq.so', 'libx.so')))
self.assertEqual(
- ['/C/libx.so', '/system/lib/libx.so', '/vendor/lib/libx.so'],
- list(r.get_candidates('/system/lib/libreq.so', 'libx.so',
- ['/C'])))
+ ['/C/libx.so', '/system/lib/libx.so', '/vendor/lib/libx.so'],
+ list(r.get_candidates('/system/lib/libreq.so', 'libx.so', ['/C'])))
self.assertEqual(
- ['/C/libx.so', '/D/libx.so', '/system/lib/libx.so',
- '/vendor/lib/libx.so'],
- list(r.get_candidates('/system/lib/libreq.so', 'libx.so',
- ['/C', '/D'])))
+ ['/C/libx.so', '/D/libx.so', '/system/lib/libx.so',
+ '/vendor/lib/libx.so'],
+ list(r.get_candidates('/system/lib/libreq.so', 'libx.so',
+ ['/C', '/D'])))
self.assertEqual(
- ['/E/libx.so', '/system/lib/libx.so', '/vendor/lib/libx.so'],
- list(r.get_candidates('/system/lib/libreq.so', 'libx.so', None,
- ['/E'])))
+ ['/E/libx.so', '/system/lib/libx.so', '/vendor/lib/libx.so'],
+ list(r.get_candidates('/system/lib/libreq.so', 'libx.so', None,
+ ['/E'])))
self.assertEqual(
- ['/E/libx.so', '/F/libx.so', '/system/lib/libx.so',
- '/vendor/lib/libx.so'],
- list(r.get_candidates('/system/lib/libreq.so', 'libx.so', None,
- ['/E', '/F'])))
+ ['/E/libx.so', '/F/libx.so', '/system/lib/libx.so',
+ '/vendor/lib/libx.so'],
+ list(r.get_candidates('/system/lib/libreq.so', 'libx.so', None,
+ ['/E', '/F'])))
self.assertEqual(
- ['/C/libx.so', '/D/libx.so', '/E/libx.so', '/F/libx.so',
- '/system/lib/libx.so', '/vendor/lib/libx.so'],
- list(r.get_candidates('/system/lib/libreq.so', 'libx.so',
- ['/C', '/D'], ['/E', '/F'])))
+ ['/C/libx.so', '/D/libx.so', '/E/libx.so', '/F/libx.so',
+ '/system/lib/libx.so', '/vendor/lib/libx.so'],
+ list(r.get_candidates('/system/lib/libreq.so', 'libx.so',
+ ['/C', '/D'], ['/E', '/F'])))
# Test app-specific search paths.
self.assertEqual(
- ['/system/app/example/lib/armeabi-v7a/libx.so',
- '/C/libx.so', '/D/libx.so', '/E/libx.so', '/F/libx.so',
- '/system/lib/libx.so', '/vendor/lib/libx.so'],
- list(r.get_candidates(
- '/system/app/example/lib/armeabi-v7a/libreq.so',
- 'libx.so',
- ['/C', '/D'], ['/E', '/F'])))
+ ['/system/app/example/lib/armeabi-v7a/libx.so',
+ '/C/libx.so', '/D/libx.so', '/E/libx.so', '/F/libx.so',
+ '/system/lib/libx.so', '/vendor/lib/libx.so'],
+ list(r.get_candidates(
+ '/system/app/example/lib/armeabi-v7a/libreq.so',
+ 'libx.so',
+ ['/C', '/D'], ['/E', '/F'])))
+
def test_resolve(self):
r = self.resolver
@@ -76,23 +74,19 @@
self.assertEqual(None, r.resolve('/system/lib/libreq.so', 'libe.so'))
self.assertEqual(
- 'e',
- r.resolve('/system/lib/libreq.so', 'libe.so',
- dt_rpath=['/system/lib/hw']))
+ 'e',
+ r.resolve('/system/lib/libreq.so', 'libe.so',
+ dt_rpath=['/system/lib/hw']))
self.assertEqual(
- 'e',
- r.resolve('/system/lib/libreq.so', 'libe.so',
- dt_runpath=['/system/lib/hw']))
+ 'e',
+ r.resolve('/system/lib/libreq.so', 'libe.so',
+ dt_runpath=['/system/lib/hw']))
self.assertEqual(
- 'a2',
- r.resolve('/system/lib/libreq.so', 'liba.so',
- dt_rpath=['/vendor/lib']))
+ 'a2',
+ r.resolve('/system/lib/libreq.so', 'liba.so',
+ dt_rpath=['/vendor/lib']))
self.assertEqual(
- 'a2',
- r.resolve('/system/lib/libreq.so', 'liba.so',
- dt_runpath=['/vendor/lib']))
-
-
-if __name__ == '__main__':
- unittest.main()
+ 'a2',
+ r.resolve('/system/lib/libreq.so', 'liba.so',
+ dt_runpath=['/vendor/lib']))
diff --git a/vndk/tools/definition-tool/tests/test_elfdump.py b/vndk/tools/definition-tool/tests/test_elfdump.py
old mode 100755
new mode 100644
index 2c0b230..18db2fd
--- a/vndk/tools/definition-tool/tests/test_elfdump.py
+++ b/vndk/tools/definition-tool/tests/test_elfdump.py
@@ -2,23 +2,20 @@
from __future__ import print_function
-import argparse
-import collections
-import difflib
import os
import re
import subprocess
import sys
import unittest
-from compat import TemporaryDirectory, makedirs
-import ndk_toolchain
+from .compat import TemporaryDirectory, makedirs
+from .ndk_toolchain import create_targets
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
VNDK_DEF_TOOL = os.path.join(SCRIPT_DIR, '..', 'vndk_definition_tool.py')
-INPUT_DIR = os.path.join(SCRIPT_DIR ,'testdata', 'test_elfdump', 'input')
+INPUT_DIR = os.path.join(SCRIPT_DIR, 'testdata', 'test_elfdump', 'input')
EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'testdata', 'test_elfdump', 'expected')
test_dir_base = None
@@ -31,7 +28,7 @@
class ELFDumpTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
- cls.targets = ndk_toolchain.create_targets()
+ cls.targets = create_targets()
if test_dir_base:
cls.test_dir_base = test_dir_base
@@ -41,11 +38,13 @@
cls._build_fixtures(cls.target_name)
+
@classmethod
def tearDownClass(cls):
if not test_dir_base:
cls.tmp_dir.cleanup()
+
@classmethod
def _build_fixtures(cls, target_name):
target = cls.targets[target_name]
@@ -97,6 +96,7 @@
['-shared', '-lc', '-Wl,-rpath,/system/lib:/vendor/lib',
'-Wl,--enable-new-dtags'])
+
def _remove_size_lines(self, lines):
"""Remove file size information because they may vary."""
prefixes = (
@@ -109,6 +109,7 @@
patt = re.compile('|'.join('(?:' + re.escape(x) +')' for x in prefixes))
return [line for line in lines if not patt.match(line)]
+
def _assert_equal_to_file(self, expected_file_name, actual):
actual = actual.splitlines(True)
expected_file_path = os.path.join(self.expected_dir, expected_file_name)
@@ -117,10 +118,12 @@
self.assertEqual(self._remove_size_lines(expected),
self._remove_size_lines(actual))
+
def _test_main_out(self):
out_file = os.path.join(self.test_dir, 'main.out')
self._assert_equal_to_file('main.out.txt', run_elf_dump(out_file))
+
def _test_libtest(self, expected_file_name, lib_name):
lib_file = os.path.join(self.test_dir, lib_name)
self._assert_equal_to_file(expected_file_name, run_elf_dump(lib_file))
@@ -149,38 +152,15 @@
class_name = 'ELFDumpTest_' + target_name
globals()[class_name] = type(
- class_name, (ELFDumpTest,),
- dict(test_main=test_main,
- test_libtest=test_libtest,
- test_libtest_rpath=test_libtest_rpath,
- test_libtest_rpath_multi=test_libtest_rpath_multi,
- test_libtest_runpath=test_libtest_runpath,
- test_libtest_runpath_multi=test_libtest_runpath_multi,
- target_name=target_name))
+ class_name, (ELFDumpTest,),
+ dict(test_main=test_main,
+ test_libtest=test_libtest,
+ test_libtest_rpath=test_libtest_rpath,
+ test_libtest_rpath_multi=test_libtest_rpath_multi,
+ test_libtest_runpath=test_libtest_runpath,
+ test_libtest_runpath_multi=test_libtest_runpath_multi,
+ target_name=target_name))
for target in ('arm', 'arm64', 'mips', 'mips64', 'x86', 'x86_64'):
create_target_test(target)
-
-
-def main():
- # Parse command line arguments.
- parser = argparse.ArgumentParser()
- parser.add_argument('--test-dir', help='directory for temporary files')
- parser.add_argument('--expected-dir', help='directory with expected output')
- args, unittest_args = parser.parse_known_args()
-
- # Convert command line options.
- global expected_dir
- global test_dir_base
-
- if args.expected_dir:
- expected_dir = args.expected_dir
- if args.test_dir:
- test_dir_base = args.test_dir
-
- # Run unit test.
- unittest.main(argv=[sys.argv[0]] + unittest_args)
-
-if __name__ == '__main__':
- main()
diff --git a/vndk/tools/definition-tool/tests/test_generic_refs.py b/vndk/tools/definition-tool/tests/test_generic_refs.py
old mode 100755
new mode 100644
index c887d19..2448169
--- a/vndk/tools/definition-tool/tests/test_generic_refs.py
+++ b/vndk/tools/definition-tool/tests/test_generic_refs.py
@@ -3,13 +3,8 @@
from __future__ import print_function
import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-import argparse
import unittest
-from compat import TemporaryDirectory, makedirs
from vndk_definition_tool import GenericRefs
@@ -17,11 +12,13 @@
class MockELF(object):
+ # pylint: disable=too-few-public-methods
def __init__(self, exported_symbols):
self.exported_symbols = exported_symbols
class MockLib(object):
+ # pylint: disable=too-few-public-methods
def __init__(self, path, exported_symbols):
self.path = path
self.elf = MockELF(exported_symbols)
@@ -39,6 +36,7 @@
self.ref.add('/system/lib64/libm.so',
MockELF({'cos', 'sin', 'tan'}))
+
def test_create_from_sym_dir(self):
input_dir = os.path.join(SCRIPT_DIR, 'testdata', 'test_generic_refs')
@@ -60,6 +58,7 @@
self.assertEqual({'cos', 'sin', 'tan'},
g.refs['/system/lib64/libm.so'].exported_symbols)
+
def test_classify_lib(self):
libc_sub = MockLib('/system/lib/libc.so', {'fclose', 'fopen', 'fread'})
libc_sup = MockLib('/system/lib/libc.so',
@@ -75,6 +74,7 @@
self.ref.classify_lib(libc_eq))
self.assertEqual(GenericRefs.NEW_LIB, self.ref.classify_lib(libfoo))
+
def test_is_equivalent_lib(self):
libc_sub = MockLib('/system/lib/libc.so', {'fclose', 'fopen', 'fread'})
libc_sup = MockLib('/system/lib/libc.so',
@@ -87,12 +87,9 @@
self.assertTrue(self.ref.is_equivalent_lib(libc_eq))
+
def test_has_same_name_lib(self):
self.assertTrue(self.ref.has_same_name_lib(
MockLib('/vendor/lib/libc.so', {})))
self.assertFalse(self.ref.has_same_name_lib(
MockLib('/vendor/lib/lib_does_not_exist.so', {})))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_module_info.py b/vndk/tools/definition-tool/tests/test_module_info.py
old mode 100755
new mode 100644
index 2da17b4..b9a7cdd
--- a/vndk/tools/definition-tool/tests/test_module_info.py
+++ b/vndk/tools/definition-tool/tests/test_module_info.py
@@ -3,9 +3,6 @@
from __future__ import print_function
import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
import unittest
from vndk_definition_tool import ModuleInfo
@@ -18,6 +15,7 @@
m = ModuleInfo.load_from_path_or_default(None)
self.assertEqual([], m.get_module_path('/system/lib64/libA.so'))
+
def test_get_module_path(self):
json_path = os.path.join(SCRIPT_DIR, 'testdata', 'test_module_info',
'module-info.json')
@@ -33,8 +31,4 @@
m.get_module_path('/system/lib64/hw/libC.so'))
self.assertEqual(
- [], m.get_module_path('/system/lib64/libdoes_not_exist.so'))
-
-
-if __name__ == '__main__':
- unittest.main()
+ [], m.get_module_path('/system/lib64/libdoes_not_exist.so'))
diff --git a/vndk/tools/definition-tool/tests/test_tagged_dict.py b/vndk/tools/definition-tool/tests/test_tagged_dict.py
old mode 100755
new mode 100644
index 58ec396..1dce19b
--- a/vndk/tools/definition-tool/tests/test_tagged_dict.py
+++ b/vndk/tools/definition-tool/tests/test_tagged_dict.py
@@ -2,17 +2,14 @@
from __future__ import print_function
-import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
import tempfile
import unittest
-from compat import StringIO
from vndk_definition_tool import TaggedDict, TaggedPathDict, TaggedLibDict, \
NUM_PARTITIONS, PT_SYSTEM, PT_VENDOR
+from .compat import StringIO
+
_TEST_DATA = '''Path,Tag
/system/lib/lib_ll_ndk.so,ll-ndk
@@ -103,37 +100,38 @@
tagged_paths = TaggedPathDict()
self.assertEqual(
- ['/system/lib/libc.so'],
- list(tagged_paths._enumerate_paths('/system/lib/libc.so')))
+ ['/system/lib/libc.so'],
+ list(tagged_paths._enumerate_paths('/system/lib/libc.so')))
self.assertEqual(
- ['/system/lib/libc.so', '/system/lib64/libc.so'],
- list(tagged_paths._enumerate_paths('/system/${LIB}/libc.so')))
+ ['/system/lib/libc.so', '/system/lib64/libc.so'],
+ list(tagged_paths._enumerate_paths('/system/${LIB}/libc.so')))
self.assertEqual(
- ['/system/lib/vndk/libutils.so',
- '/system/lib64/vndk/libutils.so'],
- list(tagged_paths._enumerate_paths(
- '/system/${LIB}/vndk${VNDK_VER}/libutils.so')))
+ ['/system/lib/vndk/libutils.so',
+ '/system/lib64/vndk/libutils.so'],
+ list(tagged_paths._enumerate_paths(
+ '/system/${LIB}/vndk${VNDK_VER}/libutils.so')))
tagged_paths = TaggedPathDict(['current', '27', '28'])
self.assertEqual(
- ['/system/lib/vndk/libutils.so',
- '/system/lib64/vndk/libutils.so',
- '/system/lib/vndk-27/libutils.so',
- '/system/lib64/vndk-27/libutils.so',
- '/system/lib/vndk-28/libutils.so',
- '/system/lib64/vndk-28/libutils.so'],
- list(tagged_paths._enumerate_paths(
- '/system/${LIB}/vndk${VNDK_VER}/libutils.so')))
+ ['/system/lib/vndk/libutils.so',
+ '/system/lib64/vndk/libutils.so',
+ '/system/lib/vndk-27/libutils.so',
+ '/system/lib64/vndk-27/libutils.so',
+ '/system/lib/vndk-28/libutils.so',
+ '/system/lib64/vndk-28/libutils.so'],
+ list(tagged_paths._enumerate_paths(
+ '/system/${LIB}/vndk${VNDK_VER}/libutils.so')))
self.assertEqual(
- ['/system/lib/vndk/libutils.so',
- '/system/lib/vndk-27/libutils.so',
- '/system/lib/vndk-28/libutils.so'],
- list(tagged_paths._enumerate_paths(
- '/system/lib/vndk${VNDK_VER}/libutils.so')))
+ ['/system/lib/vndk/libutils.so',
+ '/system/lib/vndk-27/libutils.so',
+ '/system/lib/vndk-28/libutils.so'],
+ list(tagged_paths._enumerate_paths(
+ '/system/lib/vndk${VNDK_VER}/libutils.so')))
+
def test_load_from_csv_empty(self):
try:
@@ -218,8 +216,8 @@
self.assertEqual('vndk_sp_indirect',
d.get_path_tag('/system/lib/lib_vndk_sp_indirect.so'))
self.assertEqual(
- 'vndk_sp_indirect_private',
- d.get_path_tag('/system/lib/lib_vndk_sp_indirect_private.so'))
+ 'vndk_sp_indirect_private',
+ d.get_path_tag('/system/lib/lib_vndk_sp_indirect_private.so'))
self.assertEqual('vndk', d.get_path_tag('/system/lib/lib_vndk.so'))
self.assertEqual('fwk_only',
d.get_path_tag('/system/lib/lib_fwk_only.so'))
@@ -368,17 +366,19 @@
def __init__(self):
self.lib_pt = [dict() for i in range(NUM_PARTITIONS)]
+
def add(self, path):
partition = PT_VENDOR if path.startswith('/vendor') else PT_SYSTEM
lib = MockELFLinkData(path)
self.lib_pt[partition][path] = lib
return lib
+
def compute_sp_lib(self, generic_refs=None):
vendor_libs = self.lib_pt[PT_VENDOR].values()
return MockSPLibResult(
- set(v for v in vendor_libs if 'lib_sp_hal.so' in v.path),
- set(v for v in vendor_libs if 'lib_sp_hal_dep.so' in v.path))
+ set(v for v in vendor_libs if 'lib_sp_hal.so' in v.path),
+ set(v for v in vendor_libs if 'lib_sp_hal_dep.so' in v.path))
class TaggedLibDictTest(unittest.TestCase):
@@ -389,13 +389,13 @@
self.lib_ll_ndk = self.graph.add('/system/lib/lib_ll_ndk.so')
self.lib_ll_ndk_indirect = \
- self.graph.add('/system/lib/lib_ll_ndk_indirect.so')
+ self.graph.add('/system/lib/lib_ll_ndk_indirect.so')
self.lib_vndk_sp = self.graph.add('/system/lib/lib_vndk_sp.so')
self.lib_vndk_sp_indirect = \
- self.graph.add('/system/lib/lib_vndk_sp_indirect.so')
+ self.graph.add('/system/lib/lib_vndk_sp_indirect.so')
self.lib_vndk_sp_indirect_private = \
- self.graph.add('/system/lib/lib_vndk_sp_indirect_private.so')
+ self.graph.add('/system/lib/lib_vndk_sp_indirect_private.so')
self.lib_vndk = self.graph.add('/system/lib/lib_vndk.so')
@@ -408,7 +408,7 @@
self.lib_vnd_only = self.graph.add('/vendor/lib/lib_vnd_only.so')
self.tagged_libs = TaggedLibDict.create_from_graph(
- self.graph, self.tagged_paths)
+ self.graph, self.tagged_paths)
def test_create_from_graph(self):
@@ -456,7 +456,3 @@
self.assertEqual('fwk_only', tag)
tag = d.get_path_tag(MockELFLinkData('/vendor/lib/unknown.so'))
self.assertEqual('vnd_only', tag)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_vndk.py b/vndk/tools/definition-tool/tests/test_vndk.py
old mode 100755
new mode 100644
index 196a15b..ac55f8f
--- a/vndk/tools/definition-tool/tests/test_vndk.py
+++ b/vndk/tools/definition-tool/tests/test_vndk.py
@@ -2,18 +2,13 @@
from __future__ import print_function
-import os
-import sys
-import unittest
+from vndk_definition_tool import (PT_SYSTEM, PT_VENDOR)
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from compat import StringIO, patch
-from vndk_definition_tool import (ELF, ELFLinker, PT_SYSTEM, PT_VENDOR)
-from utils import GraphBuilder
+from .compat import StringIO, TestCase, patch
+from .utils import GraphBuilder
-class ELFLinkerVNDKTest(unittest.TestCase):
+class ELFLinkerVNDKTest(TestCase):
def test_normalize_partition_tags_bad_vendor_deps(self):
"""Check whether normalize_partition_tags() hides the dependencies from
the system partition to the vendor partition if the dependencies are
@@ -31,10 +26,10 @@
with patch('sys.stderr', stderr):
gb.graph.normalize_partition_tags(set(), None)
- self.assertRegexpMatches(
- stderr.getvalue(),
- 'error: .*: system exe/lib must not depend on vendor lib .*. '
- 'Assume such dependency does not exist.')
+ self.assertRegex(
+ stderr.getvalue(),
+ 'error: .*: system exe/lib must not depend on vendor lib .*. '
+ 'Assume such dependency does not exist.')
self.assertNotIn(libvnd, libfwk.deps_needed)
self.assertNotIn(libfwk, libvnd.users_needed)
@@ -74,7 +69,7 @@
"""Check the computation of vndk without generic references."""
gb = GraphBuilder()
- libfwk = gb.add_lib32(PT_SYSTEM, 'libfwk')
+ gb.add_lib32(PT_SYSTEM, 'libfwk')
libvndk = gb.add_lib32(PT_SYSTEM, 'libvndk', extra_dir='vndk')
libvndk_sp = gb.add_lib32(PT_SYSTEM, 'libutils', extra_dir='vndk-sp')
libvnd = gb.add_lib32(PT_VENDOR, 'libvnd',
@@ -94,15 +89,17 @@
"""Check the computation of vndk without generic references."""
gb = GraphBuilder()
- libfwk = gb.add_lib32(PT_SYSTEM, 'libfwk')
- libvndk = gb.add_lib32(PT_SYSTEM, 'libvndk',
- dt_needed=['libvnd_bad.so'], extra_dir='vndk')
- libvndk_sp = gb.add_lib32(PT_SYSTEM, 'libutils',
- dt_needed=['libvnd_bad.so'],
- extra_dir='vndk-sp')
- libvnd = gb.add_lib32(PT_VENDOR, 'libvnd',
- dt_needed=['libvndk.so', 'libutils.so'])
+
+ libvndk = gb.add_lib32(
+ PT_SYSTEM, 'libvndk', dt_needed=['libvnd_bad.so'],
+ extra_dir='vndk')
+
+ libvndk_sp = gb.add_lib32(
+ PT_SYSTEM, 'libutils', dt_needed=['libvnd_bad.so'],
+ extra_dir='vndk-sp')
+
libvnd_bad = gb.add_lib32(PT_VENDOR, 'libvnd_bad', extra_dir='vndk-sp')
+
gb.resolve()
self.assertIn(libvnd_bad, libvndk.deps_all)
@@ -136,7 +133,3 @@
self.assertIn(libEGL_chipset, vndk_sets.sp_hal)
self.assertNotIn(libEGL_chipset, vndk_sets.ll_ndk_indirect)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/vndk/tools/definition-tool/tests/test_vndk_lib_dir.py b/vndk/tools/definition-tool/tests/test_vndk_lib_dir.py
old mode 100755
new mode 100644
index 0a323e5..a1a2a8c
--- a/vndk/tools/definition-tool/tests/test_vndk_lib_dir.py
+++ b/vndk/tools/definition-tool/tests/test_vndk_lib_dir.py
@@ -2,13 +2,11 @@
import os
import posixpath
-import sys
import unittest
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from vndk_definition_tool import VNDKLibDir
-from compat import StringIO
-from vndk_definition_tool import ELF, VNDKLibDir
+from .compat import StringIO
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -22,92 +20,92 @@
def test_create_vndk_sp_dir_name(self):
self.assertEqual(
- 'vndk-sp', VNDKLibDir.create_vndk_sp_dir_name('current'))
+ 'vndk-sp', VNDKLibDir.create_vndk_sp_dir_name('current'))
self.assertEqual(
- 'vndk-sp-28', VNDKLibDir.create_vndk_sp_dir_name('28'))
+ 'vndk-sp-28', VNDKLibDir.create_vndk_sp_dir_name('28'))
def test_create_vndk_dir_name(self):
self.assertEqual(
- 'vndk', VNDKLibDir.create_vndk_dir_name('current'))
+ 'vndk', VNDKLibDir.create_vndk_dir_name('current'))
self.assertEqual(
- 'vndk-28', VNDKLibDir.create_vndk_dir_name('28'))
+ 'vndk-28', VNDKLibDir.create_vndk_dir_name('28'))
def test_extract_vndk_version_from_name(self):
self.assertEqual(
- 'current', VNDKLibDir.extract_version_from_name('vndk'))
+ 'current', VNDKLibDir.extract_version_from_name('vndk'))
self.assertEqual(
- 'current', VNDKLibDir.extract_version_from_name('vndk-sp'))
+ 'current', VNDKLibDir.extract_version_from_name('vndk-sp'))
self.assertEqual(
- '28', VNDKLibDir.extract_version_from_name('vndk-28'))
+ '28', VNDKLibDir.extract_version_from_name('vndk-28'))
self.assertEqual(
- '28', VNDKLibDir.extract_version_from_name('vndk-sp-28'))
+ '28', VNDKLibDir.extract_version_from_name('vndk-sp-28'))
self.assertEqual(
- 'p', VNDKLibDir.extract_version_from_name('vndk-p'))
+ 'p', VNDKLibDir.extract_version_from_name('vndk-p'))
self.assertEqual(
- 'p', VNDKLibDir.extract_version_from_name('vndk-sp-p'))
+ 'p', VNDKLibDir.extract_version_from_name('vndk-sp-p'))
def test_extract_vndk_version_from_path(self):
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk/libexample.so')
+ '/system/lib64/vndk/libexample.so')
self.assertEqual('current', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk-sp/libexample.so')
+ '/system/lib64/vndk-sp/libexample.so')
self.assertEqual('current', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk-28/libexample.so')
+ '/system/lib64/vndk-28/libexample.so')
self.assertEqual('28', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk-sp-28/libexample.so')
+ '/system/lib64/vndk-sp-28/libexample.so')
self.assertEqual('28', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk-p/libexample.so')
+ '/system/lib64/vndk-p/libexample.so')
self.assertEqual('p', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk-sp-p/libexample.so')
+ '/system/lib64/vndk-sp-p/libexample.so')
self.assertEqual('p', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/vndk-sp-p/hw/libexample.so')
+ '/system/lib64/vndk-sp-p/hw/libexample.so')
self.assertEqual('p', ans)
ans = VNDKLibDir.extract_version_from_path(
- '/system/lib64/libexample.so')
+ '/system/lib64/libexample.so')
self.assertEqual(None, ans)
def test_is_in_vndk_sp_dir(self):
self.assertFalse(VNDKLibDir.is_in_vndk_sp_dir('/system/lib/liba.so'))
self.assertFalse(
- VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk/liba.so'))
+ VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk/liba.so'))
self.assertFalse(
- VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-28/liba.so'))
+ VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-28/liba.so'))
self.assertFalse(
- VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-spec/liba.so'))
+ VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-spec/liba.so'))
self.assertTrue(
- VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-sp/liba.so'))
+ VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-sp/liba.so'))
self.assertTrue(
- VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-sp-28/liba.so'))
+ VNDKLibDir.is_in_vndk_sp_dir('/system/lib/vndk-sp-28/liba.so'))
def test_is_in_vndk_dir(self):
self.assertFalse(VNDKLibDir.is_in_vndk_dir('/system/lib/liba.so'))
self.assertTrue(VNDKLibDir.is_in_vndk_dir('/system/lib/vndk/liba.so'))
self.assertTrue(
- VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-28/liba.so'))
+ VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-28/liba.so'))
self.assertTrue(
- VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-spec/liba.so'))
+ VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-spec/liba.so'))
self.assertFalse(
- VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-sp/liba.so'))
+ VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-sp/liba.so'))
self.assertFalse(
- VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-sp-28/liba.so'))
+ VNDKLibDir.is_in_vndk_dir('/system/lib/vndk-sp-28/liba.so'))
def test_create_vndk_search_paths(self):
@@ -126,7 +124,7 @@
]
vndk_sp_dirs, vndk_dirs = \
- VNDKLibDir.create_vndk_search_paths(lib_dir, version)
+ VNDKLibDir.create_vndk_search_paths(lib_dir, version)
self.assertEqual(expected_vndk_sp, vndk_sp_dirs)
self.assertEqual(expected_vndk, vndk_dirs)
@@ -139,35 +137,34 @@
def test_create_from_dirs_unversioned(self):
input_dir = os.path.join(
- SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir',
- 'vndk_unversioned')
+ SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir', 'vndk_unversioned')
vndk_lib_dirs = VNDKLibDir.create_from_dirs(
- [os.path.join(input_dir, 'system')],
- [os.path.join(input_dir, 'vendor')])
+ [os.path.join(input_dir, 'system')],
+ [os.path.join(input_dir, 'vendor')])
self.assertIn('current', vndk_lib_dirs)
def test_create_from_dirs_versioned(self):
input_dir = os.path.join(
- SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir', 'vndk_versioned')
+ SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir', 'vndk_versioned')
vndk_lib_dirs = VNDKLibDir.create_from_dirs(
- [os.path.join(input_dir, 'system')],
- [os.path.join(input_dir, 'vendor')])
+ [os.path.join(input_dir, 'system')],
+ [os.path.join(input_dir, 'vendor')])
self.assertIn('28', vndk_lib_dirs)
def test_create_from_dirs_versioned_multiple(self):
input_dir = os.path.join(
- SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir',
- 'vndk_versioned_multiple')
+ SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir',
+ 'vndk_versioned_multiple')
vndk_lib_dirs = VNDKLibDir.create_from_dirs(
- [os.path.join(input_dir, 'system')],
- [os.path.join(input_dir, 'vendor')])
+ [os.path.join(input_dir, 'system')],
+ [os.path.join(input_dir, 'vendor')])
self.assertIn('28', vndk_lib_dirs)
self.assertIn('29', vndk_lib_dirs)
@@ -175,11 +172,11 @@
def test_create_from_dirs_versioned_32bit_only(self):
input_dir = os.path.join(
- SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir', 'vndk_32')
+ SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir', 'vndk_32')
vndk_lib_dirs = VNDKLibDir.create_from_dirs(
- [os.path.join(input_dir, 'system')],
- [os.path.join(input_dir, 'vendor')])
+ [os.path.join(input_dir, 'system')],
+ [os.path.join(input_dir, 'vendor')])
self.assertIn('28', vndk_lib_dirs)
@@ -196,8 +193,8 @@
def test_get_ro_vndk_version(self):
input_dir = os.path.join(
- SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir',
- 'vndk_versioned_multiple')
+ SCRIPT_DIR, 'testdata', 'test_vndk_lib_dir',
+ 'vndk_versioned_multiple')
vendor_dirs = [os.path.join(input_dir, 'vendor')]
@@ -206,22 +203,17 @@
def test_sorted_versions(self):
self.assertEqual(
- ['20', '10', '2', '1'],
- VNDKLibDir.sorted_version(['1', '2', '10', '20']))
+ ['20', '10', '2', '1'],
+ VNDKLibDir.sorted_version(['1', '2', '10', '20']))
self.assertEqual(
- ['b', 'a', '20', '10', '2', '1'],
- VNDKLibDir.sorted_version(['1', '2', '10', '20', 'a', 'b']))
+ ['b', 'a', '20', '10', '2', '1'],
+ VNDKLibDir.sorted_version(['1', '2', '10', '20', 'a', 'b']))
self.assertEqual(
- ['a', '10b', '10', '2', '1'],
- VNDKLibDir.sorted_version(['1', '2', '10', 'a', '10b']))
+ ['a', '10b', '10', '2', '1'],
+ VNDKLibDir.sorted_version(['1', '2', '10', 'a', '10b']))
self.assertEqual(
- ['current', 'd', 'a', '10', '1'],
- VNDKLibDir.sorted_version(['1', '10', 'a', 'd', 'current']))
-
-
-
-if __name__ == '__main__':
- unittest.main()
+ ['current', 'd', 'a', '10', '1'],
+ VNDKLibDir.sorted_version(['1', '10', 'a', 'd', 'current']))
diff --git a/vndk/tools/definition-tool/tests/utils.py b/vndk/tools/definition-tool/tests/utils.py
index 6c61a34..2781233 100644
--- a/vndk/tools/definition-tool/tests/utils.py
+++ b/vndk/tools/definition-tool/tests/utils.py
@@ -1,13 +1,8 @@
#!/usr/bin/env python3
import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from compat import StringIO
-from vndk_definition_tool import (
- ELF, ELFLinker, PT_SYSTEM, PT_VENDOR, VNDKLibDir)
+from vndk_definition_tool import (ELF, ELFLinker, PT_SYSTEM, PT_VENDOR)
class GraphBuilder(object):
@@ -16,16 +11,19 @@
PT_VENDOR: 'vendor',
}
+
_LIB_DIRS = {
ELF.ELFCLASS32: 'lib',
ELF.ELFCLASS64: 'lib64',
}
+
def __init__(self):
self.graph = ELFLinker()
- def add_lib(self, partition, klass, name, dt_needed=[],
- exported_symbols=set(), imported_symbols=set(),
+
+ def add_lib(self, partition, klass, name, dt_needed=tuple(),
+ exported_symbols=tuple(), imported_symbols=tuple(),
extra_dir=None):
"""Create and add a shared library to ELFLinker."""
@@ -37,27 +35,30 @@
path = os.path.join(lib_dir, name + '.so')
elf = ELF(klass, ELF.ELFDATA2LSB, dt_needed=dt_needed,
- exported_symbols=exported_symbols,
- imported_symbols=imported_symbols)
+ exported_symbols=set(exported_symbols),
+ imported_symbols=set(imported_symbols))
lib = self.graph.add_lib(partition, path, elf)
setattr(self, name + '_' + elf.elf_class_name, lib)
return lib
- def add_lib32(self, partition, name, dt_needed=[],
- exported_symbols=set(), imported_symbols=set(),
+
+ def add_lib32(self, partition, name, dt_needed=tuple(),
+ exported_symbols=tuple(), imported_symbols=tuple(),
extra_dir=None):
return self.add_lib(partition, ELF.ELFCLASS32, name, dt_needed,
exported_symbols, imported_symbols, extra_dir)
- def add_lib64(self, partition, name, dt_needed=[],
- exported_symbols=set(), imported_symbols=set(),
+
+ def add_lib64(self, partition, name, dt_needed=tuple(),
+ exported_symbols=tuple(), imported_symbols=tuple(),
extra_dir=None):
return self.add_lib(partition, ELF.ELFCLASS64, name, dt_needed,
exported_symbols, imported_symbols, extra_dir)
- def add_multilib(self, partition, name, dt_needed=[],
- exported_symbols=set(), imported_symbols=set(),
+
+ def add_multilib(self, partition, name, dt_needed=tuple(),
+ exported_symbols=tuple(), imported_symbols=tuple(),
extra_dir=None):
"""Add 32-bit / 64-bit shared libraries to ELFLinker."""
return (
@@ -67,6 +68,7 @@
exported_symbols, imported_symbols, extra_dir)
)
+
def resolve(self, vndk_lib_dirs=None, ro_vndk_version=None):
if vndk_lib_dirs is not None:
self.graph.vndk_lib_dirs = vndk_lib_dirs
diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py
index d62fcfd..ea3ee66 100755
--- a/vndk/tools/definition-tool/vndk_definition_tool.py
+++ b/vndk/tools/definition-tool/vndk_definition_tool.py
@@ -39,7 +39,7 @@
def makedirs(path, exist_ok):
if exist_ok and os.path.isdir(path):
return
- return os.makedirs(path)
+ os.makedirs(path)
class mmap(mmap):
def __enter__(self):
@@ -50,14 +50,14 @@
def __getitem__(self, key):
res = super(mmap, self).__getitem__(key)
- if type(key) == int:
+ if isinstance(key, int):
return ord(res)
return res
class Py3Bytes(bytes):
def __getitem__(self, key):
res = super(Py3Bytes, self).__getitem__(key)
- if type(key) == int:
+ if isinstance(key, int):
return ord(res)
return Py3Bytes(res)
@@ -135,7 +135,8 @@
raise UnicodeDecodeError('mutf-8', input, start, i + 1, reason)
def raise_surrogate_error(start, reason):
- raise UnicodeSurrogateDecodeError('mutf-8', input, start, i + 1, reason)
+ raise UnicodeSurrogateDecodeError(
+ 'mutf-8', input, start, i + 1, reason)
for i, byte in enumerate_bytes(input):
if (byte & 0x80) == 0x00:
@@ -165,7 +166,7 @@
raise_error(i, 'invalid start byte')
if num_next == 0:
- if code >= 0xd800 and code <= 0xdbff: # High surrogate
+ if 0xd800 <= code <= 0xdbff: # High surrogate
if code_surrogate is not None:
raise_surrogate_error(
start_surrogate, 'invalid high surrogate')
@@ -173,10 +174,11 @@
start_surrogate = start
continue
- if code >= 0xdc00 and code <= 0xdfff: # Low surrogate
+ if 0xdc00 <= code <= 0xdfff: # Low surrogate
if code_surrogate is None:
raise_surrogate_error(start, 'invalid low surrogate')
- code = ((code_surrogate & 0x3f) << 10) | (code & 0x3f) + 0x10000
+ code = (((code_surrogate & 0x3f) << 10) |
+ (code & 0x3f) + 0x10000)
code_surrogate = None
start_surrogate = None
elif code_surrogate is not None:
@@ -283,28 +285,28 @@
#------------------------------------------------------------------------------
Elf_Hdr = collections.namedtuple(
- 'Elf_Hdr',
- 'ei_class ei_data ei_version ei_osabi e_type e_machine e_version '
- 'e_entry e_phoff e_shoff e_flags e_ehsize e_phentsize e_phnum '
- 'e_shentsize e_shnum e_shstridx')
+ 'Elf_Hdr',
+ 'ei_class ei_data ei_version ei_osabi e_type e_machine e_version '
+ 'e_entry e_phoff e_shoff e_flags e_ehsize e_phentsize e_phnum '
+ 'e_shentsize e_shnum e_shstridx')
Elf_Shdr = collections.namedtuple(
- 'Elf_Shdr',
- 'sh_name sh_type sh_flags sh_addr sh_offset sh_size sh_link sh_info '
- 'sh_addralign sh_entsize')
+ 'Elf_Shdr',
+ 'sh_name sh_type sh_flags sh_addr sh_offset sh_size sh_link sh_info '
+ 'sh_addralign sh_entsize')
Elf_Phdr = collections.namedtuple(
- 'Elf_Phdr',
- 'p_type p_offset p_vaddr p_paddr p_filesz p_memsz p_flags p_align')
+ 'Elf_Phdr',
+ 'p_type p_offset p_vaddr p_paddr p_filesz p_memsz p_flags p_align')
Elf_Dyn = collections.namedtuple('Elf_Dyn', 'd_tag d_val')
class Elf_Sym(collections.namedtuple(
- 'ELF_Sym', 'st_name st_value st_size st_info st_other st_shndx')):
+ 'ELF_Sym', 'st_name st_value st_size st_info st_other st_shndx')):
STB_LOCAL = 0
STB_GLOBAL = 1
@@ -312,22 +314,27 @@
SHN_UNDEF = 0
+
@property
def st_bind(self):
- return (self.st_info >> 4)
+ return self.st_info >> 4
+
@property
def is_local(self):
return self.st_bind == Elf_Sym.STB_LOCAL
+
@property
def is_global(self):
return self.st_bind == Elf_Sym.STB_GLOBAL
+
@property
def is_weak(self):
return self.st_bind == Elf_Sym.STB_WEAK
+
@property
def is_undef(self):
return self.st_shndx == Elf_Sym.SHN_UNDEF
@@ -379,6 +386,7 @@
EM_X86_64 = 62
EM_AARCH64 = 183
+
def _create_elf_machines(d):
elf_machine_ids = {}
for key, value in d.items():
@@ -398,14 +406,17 @@
return key
raise KeyError(dst)
+
@staticmethod
def get_ei_class_from_name(name):
return ELF._dict_find_key_by_value(ELF._ELF_CLASS_NAMES, name)
+
@staticmethod
def get_ei_data_from_name(name):
return ELF._dict_find_key_by_value(ELF._ELF_DATA_NAMES, name)
+
@staticmethod
def get_e_machine_from_name(name):
return ELF._dict_find_key_by_value(ELF.ELF_MACHINES, name)
@@ -429,50 +440,60 @@
self.dt_runpath = dt_runpath if dt_runpath is not None else []
self.dt_needed = dt_needed if dt_needed is not None else []
self.exported_symbols = \
- exported_symbols if exported_symbols is not None else set()
+ exported_symbols if exported_symbols is not None else set()
self.imported_symbols = \
- imported_symbols if imported_symbols is not None else set()
+ imported_symbols if imported_symbols is not None else set()
self.file_size = file_size
self.ro_seg_file_size = ro_seg_file_size
self.ro_seg_mem_size = ro_seg_mem_size
self.rw_seg_file_size = rw_seg_file_size
self.rw_seg_mem_size = rw_seg_mem_size
+
def __repr__(self):
args = (a + '=' + repr(getattr(self, a)) for a in self.__slots__)
return 'ELF(' + ', '.join(args) + ')'
+
def __eq__(self, rhs):
return all(getattr(self, a) == getattr(rhs, a) for a in self.__slots__)
+
@property
def elf_class_name(self):
return self._ELF_CLASS_NAMES.get(self.ei_class, 'None')
+
@property
def elf_data_name(self):
return self._ELF_DATA_NAMES.get(self.ei_data, 'None')
+
@property
def elf_machine_name(self):
return self.ELF_MACHINES.get(self.e_machine, str(self.e_machine))
+
@property
def is_32bit(self):
return self.ei_class == ELF.ELFCLASS32
+
@property
def is_64bit(self):
return self.ei_class == ELF.ELFCLASS64
+
@property
def sorted_exported_symbols(self):
return sorted(list(self.exported_symbols))
+
@property
def sorted_imported_symbols(self):
return sorted(list(self.imported_symbols))
+
def dump(self, file=None):
"""Print parsed ELF information to the file"""
file = file if file is not None else sys.stdout
@@ -496,6 +517,7 @@
for symbol in self.sorted_imported_symbols:
print('IMP_SYMBOL\t' + symbol, file=file)
+
# Extract zero-terminated buffer slice.
def _extract_zero_terminated_buf_slice(self, buf, offset):
"""Extract a zero-terminated buffer slice from the given offset"""
@@ -504,6 +526,7 @@
return buf[offset:]
return buf[offset:end]
+
# Extract c-style interned string from the buffer.
if sys.version_info >= (3, 0):
def _extract_zero_terminated_str(self, buf, offset):
@@ -515,6 +538,7 @@
"""Extract a c-style string from the given buffer and offset"""
return intern(self._extract_zero_terminated_buf_slice(buf, offset))
+
def _parse_from_buf_internal(self, buf):
"""Parse ELF image resides in the buffer"""
@@ -583,7 +607,8 @@
if self.is_32bit:
def parse_elf_sym(offset):
- return parse_struct(Elf_Sym, elf_sym_fmt, offset, 'bad elf sym')
+ return parse_struct(
+ Elf_Sym, elf_sym_fmt, offset, 'bad elf sym')
else:
def parse_elf_sym(offset):
try:
@@ -632,7 +657,7 @@
# Find .shstrtab section.
shstrtab_shdr_off = \
- header.e_shoff + header.e_shstridx * header.e_shentsize
+ header.e_shoff + header.e_shstridx * header.e_shentsize
shstrtab_shdr = parse_elf_shdr(shstrtab_shdr_off)
shstrtab_off = shstrtab_shdr.sh_offset
@@ -659,16 +684,17 @@
# Parse entries in .dynamic section.
assert struct.calcsize(elf_dyn_fmt) == dynamic_shdr.sh_entsize
dynamic_end = dynamic_off + dynamic_shdr.sh_size
- for ent_off in range(dynamic_off, dynamic_end, dynamic_shdr.sh_entsize):
+ for ent_off in range(
+ dynamic_off, dynamic_end, dynamic_shdr.sh_entsize):
ent = parse_elf_dyn(ent_off)
if ent.d_tag == ELF.DT_NEEDED:
self.dt_needed.append(extract_str(dynstr_off + ent.d_val))
elif ent.d_tag == ELF.DT_RPATH:
self.dt_rpath.extend(
- extract_str(dynstr_off + ent.d_val).split(':'))
+ extract_str(dynstr_off + ent.d_val).split(':'))
elif ent.d_tag == ELF.DT_RUNPATH:
self.dt_runpath.extend(
- extract_str(dynstr_off + ent.d_val).split(':'))
+ extract_str(dynstr_off + ent.d_val).split(':'))
# Parse exported symbols in .dynsym section.
dynsym_shdr = sections.get('.dynsym')
@@ -691,6 +717,7 @@
elif not ent.is_local:
exp_symbols.add(symbol_name)
+
def _parse_from_buf(self, buf):
"""Parse ELF image resides in the buffer"""
try:
@@ -698,6 +725,7 @@
except IndexError:
raise ELFError('bad offset')
+
def _parse_from_file(self, path):
"""Parse ELF image from the file path"""
with open(path, 'rb') as f:
@@ -707,13 +735,14 @@
with mmap(f.fileno(), st.st_size, access=ACCESS_READ) as image:
self._parse_from_buf(image)
+
def _parse_from_dump_lines(self, path, lines):
patt = re.compile('^([A-Za-z_]+)\t+(.*)$')
for line_no, line in enumerate(lines):
match = patt.match(line)
if not match:
- print('error: {}: {}: failed to parse'
- .format(path, line_no + 1), file=sys.stderr)
+ print('error: {}: {}: Failed to parse'
+ .format(path, line_no + 1), file=sys.stderr)
continue
key = match.group(1)
value = match.group(2)
@@ -746,18 +775,21 @@
self.imported_symbols.add(intern(value))
else:
print('error: {}: {}: unknown tag name: {}'
- .format(path, line_no + 1, key), file=sys.stderr)
+ .format(path, line_no + 1, key), file=sys.stderr)
+
def _parse_from_dump_file(self, path):
"""Load information from ELF dump file."""
with open(path, 'r') as f:
self._parse_from_dump_lines(path, f)
+
def _parse_from_dump_buf(self, buf):
"""Load information from ELF dump buffer."""
self._parse_from_dump_lines('<str:0x{:x}>'.format(id(buf)),
buf.splitlines())
+
@staticmethod
def load(path):
"""Create an ELF instance from the file path"""
@@ -765,6 +797,7 @@
elf._parse_from_file(path)
return elf
+
@staticmethod
def loads(buf):
"""Create an ELF instance from the buffer"""
@@ -772,6 +805,7 @@
elf._parse_from_buf(buf)
return elf
+
@staticmethod
def load_dump(path):
"""Create an ELF instance from a dump file path"""
@@ -779,6 +813,7 @@
elf._parse_from_dump_file(path)
return elf
+
@staticmethod
def load_dumps(buf):
"""Create an ELF instance from a dump file buffer"""
@@ -786,6 +821,7 @@
elf._parse_from_dump_buf(buf)
return elf
+
def is_jni_lib(self):
"""Test whether the ELF file looks like a JNI library."""
for name in ['libnativehelper.so', 'libandroid_runtime.so']:
@@ -903,8 +939,9 @@
for name in cls.generate_classes_dex_names():
try:
with zip_file.open(name) as dex_file:
- for s in cls.enumerate_dex_strings_buf(dex_file.read()):
- yield s
+ dex_file_content = dex_file.read()
+ for s in cls.enumerate_dex_strings_buf(dex_file_content):
+ yield s
except KeyError:
break
@@ -977,9 +1014,9 @@
# Parse vdex file header (w.r.t. version)
if version == b'000\x00':
VdexHeader = cls.VdexHeader0
- elif version >= b'001\x00' and version < b'016\x00':
+ elif b'001\x00' <= version < b'016\x00':
VdexHeader = cls.VdexHeader1
- elif version >= b'016\x00' and version < b'019\x00':
+ elif b'016\x00' <= version < b'019\x00':
VdexHeader = cls.VdexHeader16
elif version == b'019\x00':
VdexHeader = cls.VdexHeader19
@@ -1012,13 +1049,13 @@
else:
quickening_table_off_size = 0
- for i in range(vdex_header.number_of_dex_files):
+ for _ in range(vdex_header.number_of_dex_files):
# Skip quickening_table_off size
offset += quickening_table_off_size
# Check the dex file magic
dex_magic = buf[offset:offset + 4]
- if dex_magic != b'dex\n' and dex_magic != b'cdex':
+ if dex_magic not in (b'dex\n', b'cdex'):
raise ValueError('bad dex file offset {}'.format(offset))
dex_header = cls.Header.unpack_from(buf, offset)
@@ -1072,6 +1109,7 @@
_define_tag_constants(locals())
del _define_tag_constants
+
_TAG_ALIASES = {
'hl_ndk': 'fwk_only', # Treat HL-NDK as FWK-ONLY.
'sp_ndk': 'll_ndk',
@@ -1089,6 +1127,7 @@
'vndk_sp_private': 'vndk_sp_indirect_private',
}
+
@classmethod
def _normalize_tag(cls, tag):
tag = tag.lower().replace('-', '_')
@@ -1097,6 +1136,7 @@
raise ValueError('unknown lib tag ' + tag)
return tag
+
_LL_NDK_VIS = {'ll_ndk', 'll_ndk_indirect'}
_VNDK_SP_VIS = {'ll_ndk', 'vndk_sp', 'vndk_sp_indirect',
'vndk_sp_indirect_private', 'fwk_only_rs'}
@@ -1129,10 +1169,12 @@
del _LL_NDK_VIS, _VNDK_SP_VIS, _FWK_ONLY_VIS, _SP_HAL_VIS
+
@classmethod
def is_tag_visible(cls, from_tag, to_tag):
return to_tag in cls._TAG_VISIBILITY[from_tag]
+
def __init__(self, vndk_lib_dirs=None):
self._path_tag = dict()
for tag in self.TAGS:
@@ -1145,14 +1187,17 @@
self._vndk_suffixes = [VNDKLibDir.create_vndk_dir_suffix(version)
for version in vndk_lib_dirs]
+
def add(self, tag, lib):
lib_set = getattr(self, tag)
lib_set.add(lib)
self._path_tag[lib] = tag
+
def add_regex(self, tag, pattern):
self._regex_patterns.append((re.compile(pattern), tag))
+
def get_path_tag(self, lib):
try:
return self._path_tag[lib]
@@ -1165,36 +1210,45 @@
return self.get_path_tag_default(lib)
+
def get_path_tag_default(self, lib):
raise NotImplementedError()
+
def get_path_tag_bit(self, lib):
return self.TAGS[self.get_path_tag(lib)]
+
def is_path_visible(self, from_lib, to_lib):
return self.is_tag_visible(self.get_path_tag(from_lib),
self.get_path_tag(to_lib))
+
@staticmethod
def is_ll_ndk(tag_bit):
return bool(tag_bit & TaggedDict.LL_NDK)
+
@staticmethod
def is_vndk_sp(tag_bit):
return bool(tag_bit & TaggedDict.VNDK_SP)
+
@staticmethod
def is_vndk_sp_indirect(tag_bit):
return bool(tag_bit & TaggedDict.VNDK_SP_INDIRECT)
+
@staticmethod
def is_vndk_sp_indirect_private(tag_bit):
return bool(tag_bit & TaggedDict.VNDK_SP_INDIRECT_PRIVATE)
+
@staticmethod
def is_fwk_only_rs(tag_bit):
return bool(tag_bit & TaggedDict.FWK_ONLY_RS)
+
@staticmethod
def is_sp_hal(tag_bit):
return bool(tag_bit & TaggedDict.SP_HAL)
@@ -1222,17 +1276,20 @@
for row in reader:
self.add(self._normalize_tag(row[tag_col]), row[path_col])
+
@staticmethod
def create_from_csv(fp, vndk_lib_dirs=None):
d = TaggedPathDict(vndk_lib_dirs)
d.load_from_csv(fp)
return d
+
@staticmethod
def create_from_csv_path(path, vndk_lib_dirs=None):
with open(path, 'r') as fp:
return TaggedPathDict.create_from_csv(fp, vndk_lib_dirs)
+
def _enumerate_paths_with_lib(self, pattern):
if '${LIB}' in pattern:
yield pattern.replace('${LIB}', 'lib')
@@ -1240,6 +1297,7 @@
else:
yield pattern
+
def _enumerate_paths(self, pattern):
if '${VNDK_VER}' not in pattern:
for path in self._enumerate_paths_with_lib(pattern):
@@ -1250,6 +1308,7 @@
for path in self._enumerate_paths_with_lib(pattern_with_suffix):
yield path
+
def add(self, tag, path):
if path.startswith('[regex]'):
super(TaggedPathDict, self).add_regex(tag, path[7:])
@@ -1257,6 +1316,7 @@
for path in self._enumerate_paths(path):
super(TaggedPathDict, self).add(tag, path)
+
def get_path_tag_default(self, path):
return 'vnd_only' if path.startswith('/vendor') else 'fwk_only'
@@ -1267,11 +1327,13 @@
for tag in TaggedDict.TAGS:
setattr(self, tag, set())
+
def add(self, tag, lib):
lib_set = getattr(self, tag)
lib_set.add(lib)
self._path_tag[lib] = tag
+
@staticmethod
def create_from_graph(graph, tagged_paths, generic_refs=None):
d = TaggedLibDict()
@@ -1289,19 +1351,21 @@
d.add('vnd_only', lib)
return d
+
def get_path_tag(self, lib):
try:
return self._path_tag[lib]
except KeyError:
return self.get_path_tag_default(lib)
+
def get_path_tag_default(self, lib):
return 'vnd_only' if lib.path.startswith('/vendor') else 'fwk_only'
class LibProperties(object):
Properties = collections.namedtuple(
- 'Properties', 'vndk vndk_sp vendor_available rule')
+ 'Properties', 'vndk vndk_sp vendor_available rule')
def __init__(self, csv_file=None):
@@ -1316,8 +1380,8 @@
for name, vndk, vndk_sp, vendor_available, rule in reader:
self.modules[name] = self.Properties(
- vndk == 'True', vndk_sp == 'True',
- vendor_available == 'True', rule)
+ vndk == 'True', vndk_sp == 'True',
+ vendor_available == 'True', rule)
@classmethod
@@ -1358,7 +1422,7 @@
def scan_accessible_files(root):
- for base, dirs, files in os.walk(root):
+ for base, _, files in os.walk(root):
for filename in files:
path = os.path.join(base, filename)
if is_accessible(path):
@@ -1414,9 +1478,8 @@
SPLibResult = collections.namedtuple(
- 'SPLibResult',
- 'sp_hal sp_hal_dep vndk_sp_hal ll_ndk ll_ndk_indirect '
- 'vndk_sp_both')
+ 'SPLibResult',
+ 'sp_hal sp_hal_dep vndk_sp_hal ll_ndk ll_ndk_indirect vndk_sp_both')
VNDKLibTuple = defaultnamedtuple('VNDKLibTuple', 'vndk_sp vndk', [])
@@ -1450,19 +1513,18 @@
"""Extract VNDK version from a name."""
if name in {'vndk', 'vndk-sp'}:
return 'current'
- elif name.startswith('vndk-sp-'):
+ if name.startswith('vndk-sp-'):
return name[len('vndk-sp-'):]
- elif name.startswith('vndk-'):
+ if name.startswith('vndk-'):
return name[len('vndk-'):]
- else:
- return None
+ return None
@classmethod
def extract_path_component(cls, path, index):
"""Extract n-th path component from a posix path."""
start = 0
- for i in range(index):
+ for _ in range(index):
pos = path.find('/', start)
if pos == -1:
return None
@@ -1490,8 +1552,8 @@
return False
return (component == 'vndk' or
(component.startswith('vndk-') and
- not component == 'vndk-sp' and
- not component.startswith('vndk-sp-')))
+ not component == 'vndk-sp' and
+ not component.startswith('vndk-sp-')))
@classmethod
@@ -1509,10 +1571,10 @@
vndk_sp_name = cls.create_vndk_sp_dir_name(version)
vndk_name = cls.create_vndk_dir_name(version)
return VNDKLibTuple(
- [posixpath.join('/vendor', lib_dir, vndk_sp_name),
- posixpath.join('/system', lib_dir, vndk_sp_name)],
- [posixpath.join('/vendor', lib_dir, vndk_name),
- posixpath.join('/system', lib_dir, vndk_name)])
+ [posixpath.join('/vendor', lib_dir, vndk_sp_name),
+ posixpath.join('/system', lib_dir, vndk_sp_name)],
+ [posixpath.join('/vendor', lib_dir, vndk_name),
+ posixpath.join('/system', lib_dir, vndk_name)])
@classmethod
@@ -1606,7 +1668,8 @@
path = os.path.join(vendor_dir, 'default.prop')
try:
with open(path, 'r') as property_file:
- result = cls._get_property(property_file, 'ro.vndk.version')
+ result = cls._get_property(
+ property_file, 'ro.vndk.version')
if result is not None:
return result
except FileNotFoundError:
@@ -1668,6 +1731,7 @@
self.lib_set = lib_set
self.default_search_path = default_search_path
+
def get_candidates(self, requester, name, dt_rpath=None, dt_runpath=None):
# Search app-specific search paths.
if _APP_DIR_PATTERNS.match(requester):
@@ -1683,6 +1747,7 @@
for d in self.default_search_path:
yield os.path.join(d, name)
+
def resolve(self, requester, name, dt_rpath=None, dt_runpath=None):
for path in self.get_candidates(requester, name, dt_rpath, dt_runpath):
try:
@@ -1711,54 +1776,65 @@
self.unresolved_dt_needed = []
self.linked_symbols = dict()
+
@property
def is_ll_ndk(self):
return TaggedDict.is_ll_ndk(self._tag_bit)
+
@property
def is_vndk_sp(self):
return TaggedDict.is_vndk_sp(self._tag_bit)
+
@property
def is_vndk_sp_indirect(self):
return TaggedDict.is_vndk_sp_indirect(self._tag_bit)
+
@property
def is_vndk_sp_indirect_private(self):
return TaggedDict.is_vndk_sp_indirect_private(self._tag_bit)
+
@property
def is_fwk_only_rs(self):
return TaggedDict.is_fwk_only_rs(self._tag_bit)
+
@property
def is_sp_hal(self):
return TaggedDict.is_sp_hal(self._tag_bit)
+
def add_needed_dep(self, dst):
assert dst not in self.deps_needed_hidden
assert self not in dst.users_needed_hidden
self.deps_needed.add(dst)
dst.users_needed.add(self)
+
def add_dlopen_dep(self, dst):
assert dst not in self.deps_dlopen_hidden
assert self not in dst.users_dlopen_hidden
self.deps_dlopen.add(dst)
dst.users_dlopen.add(self)
+
def hide_needed_dep(self, dst):
self.deps_needed.remove(dst)
dst.users_needed.remove(self)
self.deps_needed_hidden.add(dst)
dst.users_needed_hidden.add(self)
+
def hide_dlopen_dep(self, dst):
self.deps_dlopen.remove(dst)
dst.users_dlopen.remove(self)
self.deps_dlopen_hidden.add(dst)
dst.users_dlopen_hidden.add(self)
+
@property
def num_deps(self):
"""Get the number of dependencies. If a library is linked by both
@@ -1766,23 +1842,28 @@
return (len(self.deps_needed) + len(self.deps_needed_hidden) +
len(self.deps_dlopen) + len(self.deps_dlopen_hidden))
+
@property
def deps_all(self):
return itertools.chain(self.deps_needed, self.deps_needed_hidden,
self.deps_dlopen, self.deps_dlopen_hidden)
+
@property
def deps_good(self):
return itertools.chain(self.deps_needed, self.deps_dlopen)
+
@property
def deps_needed_all(self):
return itertools.chain(self.deps_needed, self.deps_needed_hidden)
+
@property
def deps_dlopen_all(self):
return itertools.chain(self.deps_dlopen, self.deps_dlopen_hidden)
+
@property
def num_users(self):
"""Get the number of users. If a library is linked by both NEEDED and
@@ -1790,34 +1871,42 @@
return (len(self.users_needed) + len(self.users_needed_hidden) +
len(self.users_dlopen) + len(self.users_dlopen_hidden))
+
@property
def users_all(self):
return itertools.chain(self.users_needed, self.users_needed_hidden,
self.users_dlopen, self.users_dlopen_hidden)
+
@property
def users_good(self):
return itertools.chain(self.users_needed, self.users_dlopen)
+
@property
def users_needed_all(self):
return itertools.chain(self.users_needed, self.users_needed_hidden)
+
@property
def users_dlopen_all(self):
return itertools.chain(self.users_dlopen, self.users_dlopen_hidden)
+
def has_dep(self, dst):
return (dst in self.deps_needed or dst in self.deps_needed_hidden or
dst in self.deps_dlopen or dst in self.deps_dlopen_hidden)
+
def has_user(self, dst):
return (dst in self.users_needed or dst in self.users_needed_hidden or
dst in self.users_dlopen or dst in self.users_dlopen_hidden)
+
def is_system_lib(self):
return self.partition == PT_SYSTEM
+
def get_dep_linked_symbols(self, dep):
symbols = set()
for symbol, exp_lib in self.linked_symbols.items():
@@ -1825,6 +1914,7 @@
symbols.add(symbol)
return sorted(symbols)
+
def __lt__(self, rhs):
return self.path < rhs.path
@@ -1834,33 +1924,40 @@
libs.sort()
return libs
+
_VNDK_RESULT_FIELD_NAMES = (
- 'll_ndk', 'll_ndk_indirect',
- 'vndk_sp', 'vndk_sp_unused', 'vndk_sp_indirect',
- 'vndk_sp_indirect_unused', 'vndk_sp_indirect_private', 'vndk',
- 'vndk_indirect', 'fwk_only', 'fwk_only_rs', 'sp_hal', 'sp_hal_dep',
- 'vnd_only', 'vndk_ext', 'vndk_sp_ext', 'vndk_sp_indirect_ext',
- 'extra_vendor_libs')
+ 'll_ndk', 'll_ndk_indirect',
+ 'vndk_sp', 'vndk_sp_unused', 'vndk_sp_indirect',
+ 'vndk_sp_indirect_unused', 'vndk_sp_indirect_private', 'vndk',
+ 'vndk_indirect', 'fwk_only', 'fwk_only_rs', 'sp_hal', 'sp_hal_dep',
+ 'vnd_only', 'vndk_ext', 'vndk_sp_ext', 'vndk_sp_indirect_ext',
+ 'extra_vendor_libs')
+
VNDKResult = defaultnamedtuple('VNDKResult', _VNDK_RESULT_FIELD_NAMES, set())
+
_SIMPLE_VNDK_RESULT_FIELD_NAMES = (
- 'vndk_sp', 'vndk_sp_ext', 'extra_vendor_libs')
+ 'vndk_sp', 'vndk_sp_ext', 'extra_vendor_libs')
+
SimpleVNDKResult = defaultnamedtuple(
- 'SimpleVNDKResult', _SIMPLE_VNDK_RESULT_FIELD_NAMES, set())
+ 'SimpleVNDKResult', _SIMPLE_VNDK_RESULT_FIELD_NAMES, set())
class ELFLibDict(defaultnamedtuple('ELFLibDict', ('lib32', 'lib64'), {})):
def get_lib_dict(self, elf_class):
return self[elf_class - 1]
+
def add(self, path, lib):
self.get_lib_dict(lib.elf.ei_class)[path] = lib
+
def remove(self, lib):
del self.get_lib_dict(lib.elf.ei_class)[lib.path]
+
def get(self, path, default=None):
for lib_set in self:
res = lib_set.get(path, None)
@@ -1868,12 +1965,15 @@
return res
return default
+
def keys(self):
return itertools.chain(self.lib32.keys(), self.lib64.keys())
+
def values(self):
return itertools.chain(self.lib32.values(), self.lib64.values())
+
def items(self):
return itertools.chain(self.lib32.items(), self.lib64.items())
@@ -1891,26 +1991,30 @@
if tagged_paths is None:
script_dir = os.path.dirname(os.path.abspath(__file__))
dataset_path = os.path.join(
- script_dir, 'datasets', 'minimum_tag_file.csv')
+ script_dir, 'datasets', 'minimum_tag_file.csv')
self.tagged_paths = TaggedPathDict.create_from_csv_path(
- dataset_path, vndk_lib_dirs)
+ dataset_path, vndk_lib_dirs)
else:
self.tagged_paths = tagged_paths
self.ro_vndk_version = ro_vndk_version
+
def _add_lib_to_lookup_dict(self, lib):
self.lib_pt[lib.partition].add(lib.path, lib)
+
def _remove_lib_from_lookup_dict(self, lib):
self.lib_pt[lib.partition].remove(lib)
+
def add_lib(self, partition, path, elf):
lib = ELFLinkData(partition, path, elf,
self.tagged_paths.get_path_tag_bit(path))
self._add_lib_to_lookup_dict(lib)
return lib
+
def add_dlopen_dep(self, src_path, dst_path):
num_matches = 0
for elf_class in (ELF.ELFCLASS32, ELF.ELFCLASS64):
@@ -1923,6 +2027,7 @@
raise ValueError('Failed to add dlopen dependency from {} to {}'
.format(src_path, dst_path))
+
def _get_libs_in_elf_class(self, elf_class, path):
result = set()
if '${LIB}' in path:
@@ -1932,7 +2037,7 @@
patt = re.compile(path[7:])
for partition in range(NUM_PARTITIONS):
lib_set = self.lib_pt[partition].get_lib_dict(elf_class)
- for path ,lib in lib_set.items():
+ for path, lib in lib_set.items():
if patt.match(path):
result.add(lib)
else:
@@ -1943,6 +2048,7 @@
result.add(lib)
return result
+
def get_lib(self, path):
for lib_set in self.lib_pt:
lib = lib_set.get(path)
@@ -1950,6 +2056,7 @@
return lib
return None
+
def get_libs(self, paths, report_error=None):
result = set()
for path in paths:
@@ -1962,23 +2069,27 @@
result.add(lib)
return result
+
def all_libs(self):
for lib_set in self.lib_pt:
for lib in lib_set.values():
yield lib
+
def _compute_lib_dict(self, elf_class):
res = dict()
for lib_pt in self.lib_pt:
res.update(lib_pt.get_lib_dict(elf_class))
return res
+
@staticmethod
def _compile_path_matcher(root, subdirs):
dirs = [os.path.normpath(os.path.join(root, i)) for i in subdirs]
patts = ['(?:' + re.escape(i) + os.sep + ')' for i in dirs]
return re.compile('|'.join(patts))
+
def add_executables_in_dir(self, partition_name, partition, root,
alter_partition, alter_subdirs, ignored_subdirs,
scan_elf_files, unzip_files):
@@ -1988,7 +2099,8 @@
if alter_subdirs:
alter_patt = ELFLinker._compile_path_matcher(root, alter_subdirs)
if ignored_subdirs:
- ignored_patt = ELFLinker._compile_path_matcher(root, ignored_subdirs)
+ ignored_patt = ELFLinker._compile_path_matcher(
+ root, ignored_subdirs)
for path, elf in scan_elf_files(root, unzip_files):
# Ignore ELF files with unknown machine ID (eg. DSP).
@@ -1996,15 +2108,17 @@
continue
# Ignore ELF files with matched path.
- short_path = os.path.join('/', partition_name, path[prefix_len:])
if ignored_subdirs and ignored_patt.match(path):
continue
+ short_path = os.path.join('/', partition_name, path[prefix_len:])
+
if alter_subdirs and alter_patt.match(path):
self.add_lib(alter_partition, short_path, elf)
else:
self.add_lib(partition, short_path, elf)
+
def add_dlopen_deps(self, path):
patt = re.compile('([^:]*):\\s*(.*)')
with open(path, 'r') as dlopen_dep_file:
@@ -2018,6 +2132,7 @@
print('error:{}:{}: {}.'.format(path, line_no, e),
file=sys.stderr)
+
def _find_exported_symbol(self, symbol, libs):
"""Find the shared library with the exported symbol."""
for lib in libs:
@@ -2025,6 +2140,7 @@
return lib
return None
+
def _resolve_lib_imported_symbols(self, lib, imported_libs, generic_refs):
"""Resolve the imported symbols in a library."""
for symbol in lib.elf.imported_symbols:
@@ -2038,6 +2154,7 @@
if not ref_lib or not symbol in ref_lib.exported_symbols:
lib.imported_ext_symbols[imported_lib].add(symbol)
+
def _resolve_lib_dt_needed(self, lib, resolver):
imported_libs = []
for dt_needed in lib.elf.dt_needed:
@@ -2047,13 +2164,15 @@
candidates = list(resolver.get_candidates(
lib.path, dt_needed, lib.elf.dt_rpath, lib.elf.dt_runpath))
print('warning: {}: Missing needed library: {} Tried: {}'
- .format(lib.path, dt_needed, candidates), file=sys.stderr)
+ .format(lib.path, dt_needed, candidates),
+ file=sys.stderr)
lib.unresolved_dt_needed.append(dt_needed)
continue
lib.add_needed_dep(dep)
imported_libs.append(dep)
return imported_libs
+
def _resolve_lib_deps(self, lib, resolver, generic_refs):
# Resolve DT_NEEDED entries.
imported_libs = self._resolve_lib_dt_needed(lib, resolver)
@@ -2069,6 +2188,7 @@
# Resolve imported symbols.
self._resolve_lib_imported_symbols(lib, imported_libs, generic_refs)
+
def _resolve_lib_set_deps(self, lib_set, resolver, generic_refs):
for lib in lib_set:
self._resolve_lib_deps(lib, resolver, generic_refs)
@@ -2081,6 +2201,7 @@
'/vendor/' + lib_dir,
]
+
def _get_vendor_search_paths(self, lib_dir, vndk_sp_dirs, vndk_dirs):
vendor_lib_dirs = [
'/vendor/' + lib_dir + '/hw',
@@ -2119,11 +2240,11 @@
system_lib_dict = self.lib_pt[PT_SYSTEM].get_lib_dict(elf_class)
system_vndk_sp_libs, system_vndk_libs, system_libs = \
- vndk_lib_dirs.classify_vndk_libs(system_lib_dict.values())
+ vndk_lib_dirs.classify_vndk_libs(system_lib_dict.values())
vendor_lib_dict = self.lib_pt[PT_VENDOR].get_lib_dict(elf_class)
vendor_vndk_sp_libs, vendor_vndk_libs, vendor_libs = \
- vndk_lib_dirs.classify_vndk_libs(vendor_lib_dict.values())
+ vndk_lib_dirs.classify_vndk_libs(vendor_lib_dict.values())
# Resolve system libs.
search_paths = self._get_system_search_paths(lib_dir)
@@ -2133,28 +2254,29 @@
# Resolve vndk-sp libs
for version in vndk_lib_dirs:
vndk_sp_dirs, vndk_dirs = \
- vndk_lib_dirs.create_vndk_search_paths(lib_dir, version)
- vndk_sp_libs = system_vndk_sp_libs[version] | \
- vendor_vndk_sp_libs[version]
- search_paths = self._get_vndk_sp_search_paths(lib_dir, vndk_sp_dirs)
+ vndk_lib_dirs.create_vndk_search_paths(lib_dir, version)
+ vndk_sp_libs = \
+ system_vndk_sp_libs[version] | vendor_vndk_sp_libs[version]
+ search_paths = self._get_vndk_sp_search_paths(
+ lib_dir, vndk_sp_dirs)
resolver = ELFResolver(lib_dict, search_paths)
self._resolve_lib_set_deps(vndk_sp_libs, resolver, generic_refs)
# Resolve vndk libs
for version in vndk_lib_dirs:
vndk_sp_dirs, vndk_dirs = \
- vndk_lib_dirs.create_vndk_search_paths(lib_dir, version)
+ vndk_lib_dirs.create_vndk_search_paths(lib_dir, version)
vndk_libs = system_vndk_libs[version] | vendor_vndk_libs[version]
search_paths = self._get_vndk_search_paths(
- lib_dir, vndk_sp_dirs, vndk_dirs)
+ lib_dir, vndk_sp_dirs, vndk_dirs)
resolver = ELFResolver(lib_dict, search_paths)
self._resolve_lib_set_deps(vndk_libs, resolver, generic_refs)
# Resolve vendor libs.
vndk_sp_dirs, vndk_dirs = vndk_lib_dirs.create_vndk_search_paths(
- lib_dir, self.ro_vndk_version)
+ lib_dir, self.ro_vndk_version)
search_paths = self._get_vendor_search_paths(
- lib_dir, vndk_sp_dirs, vndk_dirs)
+ lib_dir, vndk_sp_dirs, vndk_dirs)
resolver = ELFResolver(lib_dict, search_paths)
self._resolve_lib_set_deps(vendor_libs, resolver, generic_refs)
@@ -2175,7 +2297,7 @@
ll_ndk = set(lib for lib in self.all_libs() if lib.is_ll_ndk)
ll_ndk_closure = self.compute_deps_closure(
- ll_ndk, is_ll_ndk_or_sp_hal, ignore_hidden_deps)
+ ll_ndk, is_ll_ndk_or_sp_hal, ignore_hidden_deps)
ll_ndk_indirect = ll_ndk_closure - ll_ndk
def is_ll_ndk(lib):
@@ -2183,7 +2305,7 @@
sp_hal = self.compute_predefined_sp_hal()
sp_hal_closure = self.compute_deps_closure(
- sp_hal, is_ll_ndk, ignore_hidden_deps)
+ sp_hal, is_ll_ndk, ignore_hidden_deps)
def is_aosp_lib(lib):
return (not generic_refs or
@@ -2204,6 +2326,7 @@
return SPLibResult(sp_hal, sp_hal_dep, vndk_sp_hal, ll_ndk,
ll_ndk_indirect, vndk_sp_both)
+
def normalize_partition_tags(self, sp_hals, generic_refs):
def is_system_lib_or_sp_hal(lib):
return lib.is_system_lib() or lib in sp_hals
@@ -2229,6 +2352,7 @@
file=sys.stderr)
lib.hide_dlopen_dep(dep)
+
@staticmethod
def _parse_action_on_ineligible_lib(arg):
follow = False
@@ -2244,6 +2368,7 @@
raise ValueError('unknown action \"{}\"'.format(flag))
return (follow, warn)
+
def compute_degenerated_vndk(self, generic_refs, tagged_paths=None,
action_ineligible_vndk_sp='warn',
action_ineligible_vndk='warn'):
@@ -2253,12 +2378,11 @@
# Find pre-defined libs.
fwk_only_rs = set(lib for lib in self.all_libs() if lib.is_fwk_only_rs)
predefined_vndk_sp = set(
- lib for lib in self.all_libs() if lib.is_vndk_sp)
+ lib for lib in self.all_libs() if lib.is_vndk_sp)
predefined_vndk_sp_indirect = set(
- lib for lib in self.all_libs() if lib.is_vndk_sp_indirect)
+ lib for lib in self.all_libs() if lib.is_vndk_sp_indirect)
predefined_vndk_sp_indirect_private = set(
- lib for lib in self.all_libs()
- if lib.is_vndk_sp_indirect_private)
+ lib for lib in self.all_libs() if lib.is_vndk_sp_indirect_private)
# FIXME: Don't squash VNDK-SP-Indirect-Private into VNDK-SP-Indirect.
predefined_vndk_sp_indirect |= predefined_vndk_sp_indirect_private
@@ -2292,7 +2416,7 @@
return lib.is_ll_ndk or lib in sp_hal or lib in sp_hal_dep
follow_ineligible_vndk_sp, warn_ineligible_vndk_sp = \
- self._parse_action_on_ineligible_lib(action_ineligible_vndk_sp)
+ self._parse_action_on_ineligible_lib(action_ineligible_vndk_sp)
vndk_sp = set()
for lib in itertools.chain(sp_hal, sp_hal_dep):
for dep in lib.deps_all:
@@ -2313,7 +2437,7 @@
return lib.is_ll_ndk or lib in vndk_sp or lib in fwk_only_rs
vndk_sp_indirect = self.compute_deps_closure(
- vndk_sp, is_not_vndk_sp_indirect, True)
+ vndk_sp, is_not_vndk_sp_indirect, True)
vndk_sp_indirect -= vndk_sp
# Find unused predefined VNDK-SP libs.
@@ -2326,11 +2450,12 @@
def is_not_vndk_sp_indirect_unused(lib):
return is_not_vndk_sp_indirect(lib) or lib in vndk_sp_indirect
vndk_sp_unused_deps = self.compute_deps_closure(
- vndk_sp_unused, is_not_vndk_sp_indirect_unused, True)
+ vndk_sp_unused, is_not_vndk_sp_indirect_unused, True)
vndk_sp_unused_deps -= vndk_sp_unused
- vndk_sp_indirect_unused = set(lib for lib in predefined_vndk_sp_indirect
- if VNDKLibDir.is_in_vndk_sp_dir(lib.path))
+ vndk_sp_indirect_unused = set(
+ lib for lib in predefined_vndk_sp_indirect
+ if VNDKLibDir.is_in_vndk_sp_dir(lib.path))
vndk_sp_indirect_unused -= vndk_sp_indirect
vndk_sp_indirect_unused -= vndk_sp_unused
vndk_sp_indirect_unused |= vndk_sp_unused_deps
@@ -2338,8 +2463,8 @@
# TODO: Compute VNDK-SP-Indirect-Private.
vndk_sp_indirect_private = set()
- assert not (vndk_sp & vndk_sp_indirect)
- assert not (vndk_sp_unused & vndk_sp_indirect_unused)
+ assert not vndk_sp & vndk_sp_indirect
+ assert not vndk_sp_unused & vndk_sp_indirect_unused
# Define helper functions for vndk_sp sets.
def is_vndk_sp_public(lib):
@@ -2365,7 +2490,7 @@
# Add the dependencies to vndk_sp_indirect if they are not vndk_sp.
closure = self.compute_deps_closure(
- {lib}, lambda lib: lib not in vndk_sp_indirect_unused, True)
+ {lib}, lambda lib: lib not in vndk_sp_indirect_unused, True)
closure.remove(lib)
vndk_sp_indirect_unused.difference_update(closure)
vndk_sp_indirect.update(closure)
@@ -2497,29 +2622,30 @@
is_vndk_sp(lib) or is_vndk(lib)
ll_ndk_indirect = self.compute_deps_closure(
- ll_ndk, is_not_ll_ndk_indirect, True)
+ ll_ndk, is_not_ll_ndk_indirect, True)
ll_ndk_indirect -= ll_ndk
# Return the VNDK classifications.
return VNDKResult(
- ll_ndk=ll_ndk,
- ll_ndk_indirect=ll_ndk_indirect,
- vndk_sp=vndk_sp,
- vndk_sp_indirect=vndk_sp_indirect,
- # vndk_sp_indirect_private=vndk_sp_indirect_private,
- vndk_sp_unused=vndk_sp_unused,
- vndk_sp_indirect_unused=vndk_sp_indirect_unused,
- vndk=vndk,
- vndk_indirect=vndk_indirect,
- # fwk_only=fwk_only,
- fwk_only_rs=fwk_only_rs,
- sp_hal=sp_hal,
- sp_hal_dep=sp_hal_dep,
- # vnd_only=vnd_only,
- vndk_ext=vndk_ext,
- vndk_sp_ext=vndk_sp_ext,
- vndk_sp_indirect_ext=vndk_sp_indirect_ext,
- extra_vendor_libs=extra_vendor_libs)
+ ll_ndk=ll_ndk,
+ ll_ndk_indirect=ll_ndk_indirect,
+ vndk_sp=vndk_sp,
+ vndk_sp_indirect=vndk_sp_indirect,
+ # vndk_sp_indirect_private=vndk_sp_indirect_private,
+ vndk_sp_unused=vndk_sp_unused,
+ vndk_sp_indirect_unused=vndk_sp_indirect_unused,
+ vndk=vndk,
+ vndk_indirect=vndk_indirect,
+ # fwk_only=fwk_only,
+ fwk_only_rs=fwk_only_rs,
+ sp_hal=sp_hal,
+ sp_hal_dep=sp_hal_dep,
+ # vnd_only=vnd_only,
+ vndk_ext=vndk_ext,
+ vndk_sp_ext=vndk_sp_ext,
+ vndk_sp_indirect_ext=vndk_sp_indirect_ext,
+ extra_vendor_libs=extra_vendor_libs)
+
@staticmethod
def _compute_closure(root_set, is_excluded, get_successors):
@@ -2535,6 +2661,7 @@
stack.append(succ)
return closure
+
@classmethod
def compute_deps_closure(cls, root_set, is_excluded,
ignore_hidden_deps=False):
@@ -2542,6 +2669,7 @@
(lambda x: x.deps_all)
return cls._compute_closure(root_set, is_excluded, get_successors)
+
@classmethod
def compute_users_closure(cls, root_set, is_excluded,
ignore_hidden_users=False):
@@ -2549,6 +2677,7 @@
(lambda x: x.users_all)
return cls._compute_closure(root_set, is_excluded, get_successors)
+
@staticmethod
def _create_internal(scan_elf_files, system_dirs, system_dirs_as_vendor,
system_dirs_ignored, vendor_dirs,
@@ -2557,23 +2686,23 @@
vndk_lib_dirs, unzip_files):
if vndk_lib_dirs is None:
vndk_lib_dirs = VNDKLibDir.create_from_dirs(
- system_dirs, vendor_dirs)
+ system_dirs, vendor_dirs)
ro_vndk_version = vndk_lib_dirs.find_vendor_vndk_version(vendor_dirs)
graph = ELFLinker(tagged_paths, vndk_lib_dirs, ro_vndk_version)
if system_dirs:
for path in system_dirs:
graph.add_executables_in_dir(
- 'system', PT_SYSTEM, path, PT_VENDOR,
- system_dirs_as_vendor, system_dirs_ignored,
- scan_elf_files, unzip_files)
+ 'system', PT_SYSTEM, path, PT_VENDOR,
+ system_dirs_as_vendor, system_dirs_ignored,
+ scan_elf_files, unzip_files)
if vendor_dirs:
for path in vendor_dirs:
graph.add_executables_in_dir(
- 'vendor', PT_VENDOR, path, PT_SYSTEM,
- vendor_dirs_as_system, vendor_dirs_ignored,
- scan_elf_files, unzip_files)
+ 'vendor', PT_VENDOR, path, PT_SYSTEM,
+ vendor_dirs_as_system, vendor_dirs_ignored,
+ scan_elf_files, unzip_files)
if extra_deps:
for path in extra_deps:
@@ -2583,6 +2712,7 @@
return graph
+
@staticmethod
def create(system_dirs=None, system_dirs_as_vendor=None,
system_dirs_ignored=None, vendor_dirs=None,
@@ -2590,10 +2720,10 @@
extra_deps=None, generic_refs=None, tagged_paths=None,
vndk_lib_dirs=None, unzip_files=True):
return ELFLinker._create_internal(
- scan_elf_files, system_dirs, system_dirs_as_vendor,
- system_dirs_ignored, vendor_dirs, vendor_dirs_as_system,
- vendor_dirs_ignored, extra_deps, generic_refs, tagged_paths,
- vndk_lib_dirs, unzip_files)
+ scan_elf_files, system_dirs, system_dirs_as_vendor,
+ system_dirs_ignored, vendor_dirs, vendor_dirs_as_system,
+ vendor_dirs_ignored, extra_deps, generic_refs, tagged_paths,
+ vndk_lib_dirs, unzip_files)
#------------------------------------------------------------------------------
@@ -2606,25 +2736,28 @@
EXPORT_SUPER_SET = 2
MODIFIED = 3
+
def __init__(self):
self.refs = dict()
self._lib_names = set()
+
def add(self, path, elf):
self.refs[path] = elf
self._lib_names.add(os.path.basename(path))
+
def _load_from_sym_dir(self, root):
root = os.path.abspath(root)
prefix_len = len(root) + 1
- for base, dirnames, filenames in os.walk(root):
+ for base, _, filenames in os.walk(root):
for filename in filenames:
if not filename.endswith('.sym'):
continue
path = os.path.join(base, filename)
lib_path = '/' + path[prefix_len:-4]
- with open(path, 'r') as f:
- self.add(lib_path, ELF.load_dump(path))
+ self.add(lib_path, ELF.load_dump(path))
+
@staticmethod
def create_from_sym_dir(root):
@@ -2632,18 +2765,21 @@
result._load_from_sym_dir(root)
return result
+
def _load_from_image_dir(self, root, prefix):
root = os.path.abspath(root)
root_len = len(root) + 1
for path, elf in scan_elf_files(root):
self.add(os.path.join(prefix, path[root_len:]), elf)
+
@staticmethod
def create_from_image_dir(root, prefix):
result = GenericRefs()
result._load_from_image_dir(root, prefix)
return result
+
def classify_lib(self, lib):
ref_lib = self.refs.get(lib.path)
if not ref_lib:
@@ -2655,9 +2791,11 @@
return GenericRefs.EXPORT_SUPER_SET
return GenericRefs.MODIFIED
+
def is_equivalent_lib(self, lib):
return self.classify_lib(lib) == GenericRefs.EXPORT_EQUAL
+
def has_same_name_lib(self, lib):
return os.path.basename(lib.path) in self._lib_names
@@ -2694,7 +2832,7 @@
def _enumerate_partition_paths(partition, root):
prefix_len = len(root) + 1
- for base, dirs, files in os.walk(root):
+ for base, _, files in os.walk(root):
for filename in files:
path = os.path.join(base, filename)
if not is_accessible(path):
@@ -2785,23 +2923,26 @@
mods = collections.defaultdict(set)
installed_path_patt = re.compile(
- '.*[\\\\/]target[\\\\/]product[\\\\/][^\\\\/]+([\\\\/].*)$')
- for name, module in json.items():
+ '.*[\\\\/]target[\\\\/]product[\\\\/][^\\\\/]+([\\\\/].*)$')
+ for module in json.values():
for path in module['installed']:
match = installed_path_patt.match(path)
if match:
for path in module['path']:
mods[match.group(1)].add(path)
- self._mods = { installed_path: sorted(src_dirs)
- for installed_path, src_dirs in mods.items() }
+ self._mods = {installed_path: sorted(src_dirs)
+ for installed_path, src_dirs in mods.items()}
+
def get_module_path(self, installed_path):
return self._mods.get(installed_path, [])
+
@staticmethod
def load(f):
return ModuleInfo(json.load(f))
+
@staticmethod
def load_from_path_or_default(path):
if not path:
@@ -2829,11 +2970,13 @@
class ELFDumpCommand(Command):
def __init__(self):
super(ELFDumpCommand, self).__init__(
- 'elfdump', help='Dump ELF .dynamic section')
+ 'elfdump', help='Dump ELF .dynamic section')
+
def add_argparser_options(self, parser):
parser.add_argument('path', help='path to an ELF file')
+
def main(self, args):
try:
ELF.load(args.path).dump()
@@ -2847,14 +2990,15 @@
class CreateGenericRefCommand(Command):
def __init__(self):
super(CreateGenericRefCommand, self).__init__(
- 'create-generic-ref', help='Create generic references')
+ 'create-generic-ref', help='Create generic references')
+
def add_argparser_options(self, parser):
parser.add_argument('dir')
- parser.add_argument(
- '--output', '-o', metavar='PATH', required=True,
- help='output directory')
+ parser.add_argument('-o', '--output', required=True,
+ help='output directory')
+
def main(self, args):
root = os.path.abspath(args.dir)
@@ -2871,76 +3015,82 @@
class ELFGraphCommand(Command):
- def add_argparser_options(self, parser):
+ def add_argparser_options(self, parser, is_tag_file_required=None):
parser.add_argument(
- '--load-extra-deps', action='append',
- help='load extra module dependencies')
+ '--load-extra-deps', action='append',
+ help='load extra module dependencies')
parser.add_argument(
- '--system', action='append',
- help='path to system partition contents')
+ '--system', action='append',
+ help='path to system partition contents')
parser.add_argument(
- '--vendor', action='append',
- help='path to vendor partition contents')
+ '--vendor', action='append',
+ help='path to vendor partition contents')
parser.add_argument(
- '--system-dir-as-vendor', action='append',
- help='sub directory of system partition that has vendor files')
+ '--system-dir-as-vendor', action='append',
+ help='sub directory of system partition that has vendor files')
parser.add_argument(
- '--system-dir-ignored', action='append',
- help='sub directory of system partition that must be ignored')
+ '--system-dir-ignored', action='append',
+ help='sub directory of system partition that must be ignored')
parser.add_argument(
- '--vendor-dir-as-system', action='append',
- help='sub directory of vendor partition that has system files')
+ '--vendor-dir-as-system', action='append',
+ help='sub directory of vendor partition that has system files')
parser.add_argument(
- '--vendor-dir-ignored', action='append',
- help='sub directory of vendor partition that must be ignored')
+ '--vendor-dir-ignored', action='append',
+ help='sub directory of vendor partition that must be ignored')
parser.add_argument(
- '--load-generic-refs',
- help='compare with generic reference symbols')
+ '--load-generic-refs',
+ help='compare with generic reference symbols')
parser.add_argument(
- '--aosp-system',
- help='compare with AOSP generic system image directory')
+ '--aosp-system',
+ help='compare with AOSP generic system image directory')
parser.add_argument(
- '--unzip-files', action='store_true', default=True,
- help='scan ELF files in zip files')
+ '--unzip-files', action='store_true', default=True,
+ help='scan ELF files in zip files')
parser.add_argument(
- '--no-unzip-files', action='store_false', dest='unzip_files',
- help='do not scan ELF files in zip files')
+ '--no-unzip-files', action='store_false', dest='unzip_files',
+ help='do not scan ELF files in zip files')
- parser.add_argument('--tag-file', help='lib tag file')
+ parser.add_argument(
+ '--tag-file', required=is_tag_file_required,
+ help='lib tag file')
+
def get_generic_refs_from_args(self, args):
if args.load_generic_refs:
return GenericRefs.create_from_sym_dir(args.load_generic_refs)
if args.aosp_system:
- return GenericRefs.create_from_image_dir(args.aosp_system,
- '/system')
+ return GenericRefs.create_from_image_dir(
+ args.aosp_system, '/system')
return None
+
def _check_arg_dir_exists(self, arg_name, dirs):
for path in dirs:
if not os.path.exists(path):
- print('error: Failed to find the directory "{}" specified in {}'
- .format(path, arg_name), file=sys.stderr)
+ print('error: Failed to find the directory "{}" specified in '
+ '"{}"'.format(path, arg_name), file=sys.stderr)
sys.exit(1)
if not os.path.isdir(path):
print('error: Path "{}" specified in {} is not a directory'
- .format(path, arg_name), file=sys.stderr)
+ .format(path, arg_name), file=sys.stderr)
sys.exit(1)
+
def check_dirs_from_args(self, args):
self._check_arg_dir_exists('--system', args.system)
self._check_arg_dir_exists('--vendor', args.vendor)
+
def create_from_args(self, args):
self.check_dirs_from_args(args)
@@ -2950,7 +3100,7 @@
if args.tag_file:
tagged_paths = TaggedPathDict.create_from_csv_path(
- args.tag_file, vndk_lib_dirs)
+ args.tag_file, vndk_lib_dirs)
else:
tagged_paths = None
@@ -2970,30 +3120,31 @@
def add_argparser_options(self, parser):
super(VNDKCommandBase, self).add_argparser_options(parser)
- parser.add_argument('--no-default-dlopen-deps', action='store_true',
- help='do not add default dlopen dependencies')
+ parser.add_argument(
+ '--no-default-dlopen-deps', action='store_true',
+ help='do not add default dlopen dependencies')
parser.add_argument(
- '--action-ineligible-vndk-sp', default='warn',
- help='action when a sp-hal uses non-vndk-sp libs '
- '(option: follow,warn,ignore)')
+ '--action-ineligible-vndk-sp', default='warn',
+ help='action when a sp-hal uses non-vndk-sp libs '
+ '(option: follow,warn,ignore)')
parser.add_argument(
- '--action-ineligible-vndk', default='warn',
- help='action when a vendor lib/exe uses fwk-only libs '
- '(option: follow,warn,ignore)')
+ '--action-ineligible-vndk', default='warn',
+ help='action when a vendor lib/exe uses fwk-only libs '
+ '(option: follow,warn,ignore)')
+
def create_from_args(self, args):
"""Create all essential data structures for VNDK computation."""
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- super(VNDKCommandBase, self).\
- create_from_args(args)
+ generic_refs, graph, tagged_paths, vndk_lib_dirs = \
+ super(VNDKCommandBase, self).create_from_args(args)
if not args.no_default_dlopen_deps:
script_dir = os.path.dirname(os.path.abspath(__file__))
- minimum_dlopen_deps = os.path.join(script_dir, 'datasets',
- 'minimum_dlopen_deps.txt')
+ minimum_dlopen_deps = os.path.join(
+ script_dir, 'datasets', 'minimum_dlopen_deps.txt')
graph.add_dlopen_deps(minimum_dlopen_deps)
return (generic_refs, graph, tagged_paths, vndk_lib_dirs)
@@ -3002,26 +3153,28 @@
class VNDKCommand(VNDKCommandBase):
def __init__(self):
super(VNDKCommand, self).__init__(
- 'vndk', help='Compute VNDK libraries set')
+ 'vndk', help='Compute VNDK libraries set')
+
def add_argparser_options(self, parser):
super(VNDKCommand, self).add_argparser_options(parser)
parser.add_argument(
- '--warn-incorrect-partition', action='store_true',
- help='warn about libraries only have cross partition linkages')
+ '--warn-incorrect-partition', action='store_true',
+ help='warn about libraries only have cross partition linkages')
parser.add_argument(
- '--full', action='store_true',
- help='print all classification')
+ '--full', action='store_true',
+ help='print all classification')
parser.add_argument(
- '--output-format', default='tag',
- help='output format for vndk classification')
+ '--output-format', default='tag',
+ help='output format for vndk classification')
parser.add_argument(
- '--file-size-output',
- help='output file for calculated file sizes')
+ '--file-size-output',
+ help='output file for calculated file sizes')
+
def _warn_incorrect_partition_lib_set(self, lib_set, partition, error_msg):
for lib in lib_set.values():
@@ -3030,16 +3183,18 @@
if all((user.partition != partition for user in lib.users_all)):
print(error_msg.format(lib.path), file=sys.stderr)
+
def _warn_incorrect_partition(self, graph):
self._warn_incorrect_partition_lib_set(
- graph.lib_pt[PT_VENDOR], PT_VENDOR,
- 'warning: {}: This is a vendor library with framework-only '
- 'usages.')
+ graph.lib_pt[PT_VENDOR], PT_VENDOR,
+ 'warning: {}: This is a vendor library with framework-only '
+ 'usages.')
self._warn_incorrect_partition_lib_set(
- graph.lib_pt[PT_SYSTEM], PT_SYSTEM,
- 'warning: {}: This is a framework library with vendor-only '
- 'usages.')
+ graph.lib_pt[PT_SYSTEM], PT_SYSTEM,
+ 'warning: {}: This is a framework library with vendor-only '
+ 'usages.')
+
@staticmethod
def _extract_simple_vndk_result(vndk_result):
@@ -3061,6 +3216,7 @@
getattr(results, tag).update(getattr(vndk_result, field_name))
return results
+
def _print_tags(self, vndk_lib, full, file=sys.stdout):
if full:
result_tags = _VNDK_RESULT_FIELD_NAMES
@@ -3076,19 +3232,18 @@
for lib in sorted_lib_path_list(libs):
print(tag, lib, file=file)
+
def _print_make(self, vndk_lib, file=sys.stdout):
def get_module_name(path):
- name = os.path.basename(path)
- root, ext = os.path.splitext(name)
- return root
+ return os.path.splitext(os.path.basename(path))[0]
def get_module_names(lib_set):
- return sorted({ get_module_name(lib.path) for lib in lib_set })
+ return sorted({get_module_name(lib.path) for lib in lib_set})
results = self._extract_simple_vndk_result(vndk_lib)
vndk_sp = get_module_names(results.vndk_sp)
vndk_sp_ext = get_module_names(results.vndk_sp_ext)
- extra_vendor_libs= get_module_names(results.extra_vendor_libs)
+ extra_vendor_libs = get_module_names(results.extra_vendor_libs)
def format_module_names(module_names):
return '\\\n ' + ' \\\n '.join(module_names)
@@ -3107,6 +3262,7 @@
file.write(template)
+
def _print_file_size_output(self, graph, vndk_lib, file=sys.stderr):
def collect_tags(lib):
tags = []
@@ -3122,9 +3278,10 @@
# Print the file size of all ELF files.
for lib in sorted(graph.all_libs()):
- writer.writerow((lib.path, collect_tags(lib), lib.elf.file_size,
- lib.elf.ro_seg_file_size, lib.elf.ro_seg_mem_size,
- lib.elf.rw_seg_file_size, lib.elf.rw_seg_mem_size))
+ writer.writerow((
+ lib.path, collect_tags(lib), lib.elf.file_size,
+ lib.elf.ro_seg_file_size, lib.elf.ro_seg_mem_size,
+ lib.elf.rw_seg_file_size, lib.elf.rw_seg_mem_size))
# Calculate the summation of each sets.
def calc_total_size(lib_set):
@@ -3170,17 +3327,17 @@
writer.writerow(SEPARATOR)
writer.writerow(['Total', None] + calc_total_size(graph.all_libs()))
+
def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ generic_refs, graph, tagged_paths, _ = self.create_from_args(args)
if args.warn_incorrect_partition:
self._warn_incorrect_partition(graph)
# Compute vndk heuristics.
vndk_lib = graph.compute_degenerated_vndk(
- generic_refs, tagged_paths, args.action_ineligible_vndk_sp,
- args.action_ineligible_vndk)
+ generic_refs, tagged_paths, args.action_ineligible_vndk_sp,
+ args.action_ineligible_vndk)
# Print results.
if args.output_format == 'make':
@@ -3198,15 +3355,17 @@
class DepsInsightCommand(VNDKCommandBase):
def __init__(self):
super(DepsInsightCommand, self).__init__(
- 'deps-insight', help='Generate HTML to show dependencies')
+ 'deps-insight', help='Generate HTML to show dependencies')
+
def add_argparser_options(self, parser):
super(DepsInsightCommand, self).add_argparser_options(parser)
parser.add_argument('--module-info')
- parser.add_argument(
- '--output', '-o', help='output directory')
+ parser.add_argument('-o', '--output', required=True,
+ help='output directory')
+
@staticmethod
def serialize_data(libs, vndk_lib, module_info):
@@ -3273,27 +3432,28 @@
return (strs, mods)
+
def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ generic_refs, graph, tagged_paths, _ = self.create_from_args(args)
module_info = ModuleInfo.load_from_path_or_default(args.module_info)
# Compute vndk heuristics.
vndk_lib = graph.compute_degenerated_vndk(
- generic_refs, tagged_paths, args.action_ineligible_vndk_sp,
- args.action_ineligible_vndk)
+ generic_refs, tagged_paths, args.action_ineligible_vndk_sp,
+ args.action_ineligible_vndk)
# Serialize data.
- strs, mods = self.serialize_data(list(graph.all_libs()), vndk_lib,
- module_info)
+ strs, mods = self.serialize_data(
+ list(graph.all_libs()), vndk_lib, module_info)
# Generate output files.
makedirs(args.output, exist_ok=True)
script_dir = os.path.dirname(os.path.abspath(__file__))
for name in ('index.html', 'insight.css', 'insight.js'):
- shutil.copyfile(os.path.join(script_dir, 'assets', 'insight', name),
- os.path.join(args.output, name))
+ shutil.copyfile(
+ os.path.join(script_dir, 'assets', 'insight', name),
+ os.path.join(args.output, name))
with open(os.path.join(args.output, 'insight-data.js'), 'w') as f:
f.write('''(function () {
@@ -3308,36 +3468,40 @@
class DepsCommand(ELFGraphCommand):
def __init__(self):
super(DepsCommand, self).__init__(
- 'deps', help='Print binary dependencies for debugging')
+ 'deps', help='Print binary dependencies for debugging')
+
def add_argparser_options(self, parser):
super(DepsCommand, self).add_argparser_options(parser)
parser.add_argument(
- '--revert', action='store_true',
- help='print usage dependency')
+ '--revert', action='store_true',
+ help='print usage dependency')
parser.add_argument(
- '--leaf', action='store_true',
- help='print binaries without dependencies or usages')
+ '--leaf', action='store_true',
+ help='print binaries without dependencies or usages')
parser.add_argument(
- '--symbols', action='store_true',
- help='print symbols')
+ '--symbols', action='store_true',
+ help='print symbols')
parser.add_argument(
- '--path-filter',
- help='filter paths by a regular expression')
+ '--path-filter',
+ help='filter paths by a regular expression')
parser.add_argument('--module-info')
+
def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ _, graph, _, _ = self.create_from_args(args)
module_info = ModuleInfo.load_from_path_or_default(args.module_info)
- path_filter = re.compile(args.path_filter) if args.path_filter else None
+ if args.path_filter:
+ path_filter = re.compile(args.path_filter)
+ else:
+ path_filter = None
if args.symbols:
def collect_symbols(user, definer):
@@ -3389,7 +3553,8 @@
class DepsClosureCommand(ELFGraphCommand):
def __init__(self):
super(DepsClosureCommand, self).__init__(
- 'deps-closure', help='Find transitive closure of dependencies')
+ 'deps-closure', help='Find transitive closure of dependencies')
+
def add_argparser_options(self, parser):
super(DepsClosureCommand, self).add_argparser_options(parser)
@@ -3409,6 +3574,7 @@
parser.add_argument('--enumerate', action='store_true',
help='print closure for each lib instead of union')
+
def print_deps_closure(self, root_libs, graph, is_excluded_libs,
is_reverted, indent):
if is_reverted:
@@ -3421,8 +3587,7 @@
def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ _, graph, _, _ = self.create_from_args(args)
# Find root/excluded libraries by their paths.
def report_error(path):
@@ -3454,14 +3619,16 @@
class DepsUnresolvedCommand(ELFGraphCommand):
def __init__(self):
super(DepsUnresolvedCommand, self).__init__(
- 'deps-unresolved',
- help='Show unresolved dt_needed entries or symbols')
+ 'deps-unresolved',
+ help='Show unresolved dt_needed entries or symbols')
+
def add_argparser_options(self, parser):
super(DepsUnresolvedCommand, self).add_argparser_options(parser)
parser.add_argument('--module-info')
parser.add_argument('--path-filter')
+
def _dump_unresolved(self, lib, module_info, delimiter):
if not lib.unresolved_symbols and not lib.unresolved_dt_needed:
return
@@ -3475,9 +3642,9 @@
for symbol in sorted(lib.unresolved_symbols):
print('\tUNRESOLVED_SYMBOL:', symbol)
+
def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ _, graph, _, _ = self.create_from_args(args)
module_info = ModuleInfo.load_from_path_or_default(args.module_info)
libs = graph.all_libs()
@@ -3494,14 +3661,11 @@
class ApkDepsCommand(ELFGraphCommand):
def __init__(self):
super(ApkDepsCommand, self).__init__(
- 'apk-deps', help='Print APK dependencies for debugging')
+ 'apk-deps', help='Print APK dependencies for debugging')
- def add_argparser_options(self, parser):
- super(ApkDepsCommand, self).add_argparser_options(parser)
def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ _, graph, _, _ = self.create_from_args(args)
apk_deps = scan_apk_dep(graph, args.system, args.vendor)
@@ -3518,14 +3682,17 @@
super(CheckDepCommandBase, self).__init__(*args, **kwargs)
self.delimiter = ''
+
def add_argparser_options(self, parser):
super(CheckDepCommandBase, self).add_argparser_options(parser)
parser.add_argument('--module-info')
+
def _print_delimiter(self):
print(self.delimiter, end='')
self.delimiter = '\n'
+
def _dump_dep(self, lib, bad_deps, module_info):
self._print_delimiter()
print(lib.path)
@@ -3538,6 +3705,7 @@
for symbol in lib.get_dep_linked_symbols(dep):
print('\t\t' + symbol)
+
def _dump_apk_dep(self, apk_path, bad_deps, module_info):
self._print_delimiter()
print(apk_path)
@@ -3552,7 +3720,7 @@
class CheckDepCommand(CheckDepCommandBase):
def __init__(self):
super(CheckDepCommand, self).__init__(
- 'check-dep', help='Check the eligible dependencies')
+ 'check-dep', help='Check the eligible dependencies')
def add_argparser_options(self, parser):
@@ -3622,8 +3790,8 @@
.format(lib.path, dep.path),
file=sys.stderr)
elif dep_properties.vndk:
- print('error: vendor lib "{}" depends on vndk "{}" but '
- 'it must be copied to /system/lib[64]/vndk.'
+ print('error: vendor lib "{}" depends on vndk "{}" '
+ 'but it must be copied to /system/lib[64]/vndk.'
.format(lib.path, dep.path),
file=sys.stderr)
else:
@@ -3638,7 +3806,7 @@
return num_errors
- def _check_dt_needed_ordering(self, graph, module_info):
+ def _check_dt_needed_ordering(self, graph):
"""Check DT_NEEDED entries order of all libraries"""
num_errors = 0
@@ -3692,25 +3860,25 @@
def main(self, args):
generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
+ self.create_from_args(args)
tagged_paths = TaggedPathDict.create_from_csv_path(
- args.tag_file, vndk_lib_dirs)
+ args.tag_file, vndk_lib_dirs)
tagged_libs = TaggedLibDict.create_from_graph(
- graph, tagged_paths, generic_refs)
+ graph, tagged_paths, generic_refs)
module_info = ModuleInfo.load_from_path_or_default(args.module_info)
lib_properties_path = \
- LibProperties.get_lib_properties_file_path(args.tag_file)
+ LibProperties.get_lib_properties_file_path(args.tag_file)
lib_properties = \
- LibProperties.load_from_path_or_default(lib_properties_path)
+ LibProperties.load_from_path_or_default(lib_properties_path)
num_errors = self._check_vendor_dep(graph, tagged_libs, lib_properties,
module_info)
if args.check_dt_needed_ordering:
- num_errors += self._check_dt_needed_ordering(graph, module_info)
+ num_errors += self._check_dt_needed_ordering(graph)
if args.check_apk:
num_errors += self._check_apk_dep(graph, args.system, args.vendor,
@@ -3722,8 +3890,8 @@
class DumpDexStringCommand(Command):
def __init__(self):
super(DumpDexStringCommand, self).__init__(
- 'dump-dex-string',
- help='Dump string literals defined in a dex file')
+ 'dump-dex-string',
+ help='Dump string literals defined in a dex file')
def add_argparser_options(self, parser):
@@ -3740,139 +3908,92 @@
print(repr(string))
-class CheckEligibleListCommand(CheckDepCommandBase):
- def __init__(self):
- super(CheckEligibleListCommand, self).__init__(
- 'check-eligible-list', help='Check the eligible list')
-
-
- def _check_eligible_vndk_dep(self, graph, tagged_libs, module_info):
- """Check whether eligible sets are self-contained."""
- num_errors = 0
-
- indirect_libs = (tagged_libs.ll_ndk_indirect |
- tagged_libs.vndk_sp_indirect_private |
- tagged_libs.fwk_only_rs)
-
- eligible_libs = (tagged_libs.ll_ndk | tagged_libs.vndk_sp |
- tagged_libs.vndk_sp_indirect | tagged_libs.vndk)
-
- # Check eligible vndk is self-contained.
- for lib in sorted(eligible_libs):
- bad_deps = []
- for dep in lib.deps_all:
- if dep not in eligible_libs and dep not in indirect_libs:
- print('error: eligible lib "{}" should not depend on '
- 'non-eligible lib "{}".'.format(lib.path, dep.path),
- file=sys.stderr)
- bad_deps.append(dep)
- num_errors += 1
- if bad_deps:
- self._dump_dep(lib, bad_deps, module_info)
-
- # Check the libbinder dependencies.
- for lib in sorted(eligible_libs):
- bad_deps = []
- for dep in lib.deps_all:
- if os.path.basename(dep.path) == 'libbinder.so':
- print('error: eligible lib "{}" should not depend on '
- 'libbinder.so.'.format(lib.path), file=sys.stderr)
- bad_deps.append(dep)
- num_errors += 1
- if bad_deps:
- self._dump_dep(lib, bad_deps, module_info)
-
- return num_errors
-
-
- def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
-
- tagged_paths = TaggedPathDict.create_from_csv_path(
- args.tag_file, vndk_lib_dirs)
- tagged_libs = TaggedLibDict.create_from_graph(
- graph, tagged_paths, generic_refs)
-
- module_info = ModuleInfo.load_from_path_or_default(args.module_info)
-
- num_errors = self._check_eligible_vndk_dep(graph, tagged_libs,
- module_info)
- return 0 if num_errors == 0 else 1
-
-
class DepGraphCommand(ELFGraphCommand):
def __init__(self):
super(DepGraphCommand, self).__init__(
- 'dep-graph', help='Show the eligible dependencies graph')
+ 'dep-graph', help='Visualize violating dependencies with HTML')
+
def add_argparser_options(self, parser):
- super(DepGraphCommand, self).add_argparser_options(parser)
+ super(DepGraphCommand, self).add_argparser_options(
+ parser, is_tag_file_required=True)
- parser.add_argument('--output', '-o', help='output directory')
+ parser.add_argument('-o', '--output', required=True,
+ help='output directory')
- def _get_tag_from_lib(self, lib, tagged_paths):
- tag_hierarchy = dict()
+
+ @staticmethod
+ def _create_tag_hierarchy():
+ hierarchy = dict()
for tag in TaggedPathDict.TAGS:
if tag in {'sp_hal', 'sp_hal_dep', 'vnd_only'}:
- tag_hierarchy[tag] = 'vendor.private.{}'.format(tag)
+ hierarchy[tag] = 'vendor.private.{}'.format(tag)
else:
vendor_visible = TaggedPathDict.is_tag_visible('vnd_only', tag)
pub = 'public' if vendor_visible else 'private'
- tag_hierarchy[tag] = 'system.{}.{}'.format(pub, tag)
+ hierarchy[tag] = 'system.{}.{}'.format(pub, tag)
+ return hierarchy
- return tag_hierarchy[tagged_paths.get_path_tag(lib.path)]
- def _check_if_allowed(self, my_tag, other_tag):
- my = my_tag.split('.')
- other = other_tag.split('.')
- if my[0] == 'system' and other[0] == 'vendor':
+ @staticmethod
+ def _get_lib_tag(hierarchy, tagged_paths, lib):
+ return hierarchy[tagged_paths.get_path_tag(lib.path)]
+
+
+ @staticmethod
+ def _is_dep_allowed(user_tag, dep_tag):
+ user_partition, _, _ = user_tag.split('.')
+ dep_partition, dep_visibility, _ = dep_tag.split('.')
+ if user_partition == 'system' and dep_partition == 'vendor':
return False
- if my[0] == 'vendor' and other[0] == 'system' \
- and other[1] == 'private':
- return False
+ if user_partition == 'vendor' and dep_partition == 'system':
+ if dep_visibility == 'private':
+ return False
return True
+
def _get_dep_graph(self, graph, tagged_paths):
+ hierarchy = self._create_tag_hierarchy()
+
+ # Build data and violate_libs.
data = []
- violate_libs = dict()
- system_libs = graph.lib_pt[PT_SYSTEM].values()
- vendor_libs = graph.lib_pt[PT_VENDOR].values()
- for lib in itertools.chain(system_libs, vendor_libs):
- tag = self._get_tag_from_lib(lib, tagged_paths)
- violate_count = 0
+ violate_libs = collections.defaultdict(list)
+
+ for lib in graph.all_libs():
+ lib_tag = self._get_lib_tag(hierarchy, tagged_paths, lib)
lib_item = {
'name': lib.path,
- 'tag': tag,
+ 'tag': lib_tag,
'depends': [],
'violates': [],
}
+ violate_count = 0
for dep in lib.deps_all:
- if self._check_if_allowed(tag,
- self._get_tag_from_lib(dep, tagged_paths)):
+ dep_tag = self._get_lib_tag(hierarchy, tagged_paths, dep)
+ if self._is_dep_allowed(lib_tag, dep_tag):
lib_item['depends'].append(dep.path)
else:
- lib_item['violates'].append([dep.path, lib.get_dep_linked_symbols(dep)])
- violate_count += 1;
+ lib_item['violates'].append([
+ dep.path, lib.get_dep_linked_symbols(dep)])
+ violate_count += 1
lib_item['violate_count'] = violate_count
if violate_count > 0:
- if not tag in violate_libs:
- violate_libs[tag] = []
- violate_libs[tag].append((lib.path, violate_count))
+ violate_libs[lib_tag].append((lib.path, violate_count))
data.append(lib_item)
+
+ # Sort data and violate_libs.
+ data.sort(
+ key=lambda lib_item: (lib_item['tag'], lib_item['violate_count']))
+ for libs in violate_libs.values():
+ libs.sort(key=lambda violate_item: violate_item[1], reverse=True)
+
return data, violate_libs
- def main(self, args):
- generic_refs, graph, tagged_paths, vndk_lib_dirs = \
- self.create_from_args(args)
- tagged_paths = TaggedPathDict.create_from_csv_path(
- args.tag_file, vndk_lib_dirs)
+ def main(self, args):
+ _, graph, tagged_paths, _ = self.create_from_args(args)
+
data, violate_libs = self._get_dep_graph(graph, tagged_paths)
- data.sort(key=lambda lib_item: (lib_item['tag'],
- lib_item['violate_count']))
- for libs in violate_libs.values():
- libs.sort(key=lambda libs: libs[1], reverse=True)
makedirs(args.output, exist_ok=True)
script_dir = os.path.dirname(os.path.abspath(__file__))
@@ -3880,8 +4001,8 @@
shutil.copyfile(os.path.join(script_dir, 'assets', 'visual', name),
os.path.join(args.output, name))
with open(os.path.join(args.output, 'dep-data.js'), 'w') as f:
- f.write('var violatedLibs = ' + json.dumps(violate_libs) +
- '\nvar depData = ' + json.dumps(data) + ';')
+ f.write('var violatedLibs = ' + json.dumps(violate_libs) + ';\n')
+ f.write('var depData = ' + json.dumps(data) + ';\n')
return 0
@@ -3894,7 +4015,7 @@
def register_subcmd(cmd):
subcmds[cmd.name] = cmd
cmd.add_argparser_options(
- subparsers.add_parser(cmd.name, help=cmd.help))
+ subparsers.add_parser(cmd.name, help=cmd.help))
register_subcmd(ELFDumpCommand())
register_subcmd(CreateGenericRefCommand())
@@ -3905,7 +4026,6 @@
register_subcmd(DepsUnresolvedCommand())
register_subcmd(ApkDepsCommand())
register_subcmd(CheckDepCommand())
- register_subcmd(CheckEligibleListCommand())
register_subcmd(DepGraphCommand())
register_subcmd(DumpDexStringCommand())
diff --git a/vndk/tools/header-checker/Android.bp b/vndk/tools/header-checker/Android.bp
index 7c9fe04..8edebdd 100644
--- a/vndk/tools/header-checker/Android.bp
+++ b/vndk/tools/header-checker/Android.bp
@@ -32,7 +32,7 @@
cppflags: [
"-fno-exceptions",
"-fno-rtti",
- "-std=c++14",
+ "-std=c++17",
],
target: {
@@ -146,11 +146,14 @@
srcs: [
"header-abi-util/src/abi_diff_helpers.cpp",
+ "header-abi-util/src/api_level.cpp",
"header-abi-util/src/collect_exported_headers.cpp",
+ "header-abi-util/src/exported_symbol_set.cpp",
"header-abi-util/src/ir_representation.cpp",
"header-abi-util/src/ir_representation_json.cpp",
"header-abi-util/src/ir_representation_protobuf.cpp",
"header-abi-util/src/so_file_parser.cpp",
+ "header-abi-util/src/string_utils.cpp",
"header-abi-util/src/version_script_parser.cpp",
],
@@ -173,3 +176,34 @@
export_include_dirs: ["header-abi-util/include"],
}
+
+cc_test_host {
+ name: "libheader-abi-util_test",
+
+ defaults: [
+ "header-checker-defaults",
+ ],
+
+ srcs: [
+ "header-abi-util/src/api_level_test.cpp",
+ "header-abi-util/src/exported_symbol_set_test.cpp",
+ "header-abi-util/src/string_utils_test.cpp",
+ "header-abi-util/src/version_script_parser_test.cpp",
+ ],
+
+ local_include_dirs: [
+ "header-abi-util/include",
+ ],
+
+ static_libs: [
+ "libgtest",
+ "libgtest_main",
+ "libheader-abi-util",
+ ],
+
+ shared_libs: [
+ "libc++_host",
+ ],
+
+ test_suites: ["general-tests"],
+}
diff --git a/vndk/tools/header-checker/TEST_MAPPING b/vndk/tools/header-checker/TEST_MAPPING
new file mode 100644
index 0000000..cce52c9
--- /dev/null
+++ b/vndk/tools/header-checker/TEST_MAPPING
@@ -0,0 +1,8 @@
+{
+ "presubmit" : [
+ {
+ "name" : "libheader-abi-util_test",
+ "host" : true
+ }
+ ]
+}
diff --git a/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp b/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp
index 3b81b9a..3da1ac1 100644
--- a/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp
+++ b/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp
@@ -52,8 +52,17 @@
"v", llvm::cl::desc("<version_script>"), llvm::cl::Optional,
llvm::cl::cat(header_linker_category));
+static llvm::cl::list<std::string> excluded_symbol_versions(
+ "exclude-symbol-version", llvm::cl::Optional,
+ llvm::cl::cat(header_linker_category));
+
+static llvm::cl::list<std::string> excluded_symbol_tags(
+ "exclude-symbol-tag", llvm::cl::Optional,
+ llvm::cl::cat(header_linker_category));
+
static llvm::cl::opt<std::string> api(
"api", llvm::cl::desc("<api>"), llvm::cl::Optional,
+ llvm::cl::init("current"),
llvm::cl::cat(header_linker_category));
static llvm::cl::opt<std::string> arch(
@@ -93,10 +102,14 @@
const std::string &so_file,
const std::string &linked_dump,
const std::string &arch,
- const std::string &api)
+ const std::string &api,
+ const std::vector<std::string> &excluded_symbol_versions,
+ const std::vector<std::string> &excluded_symbol_tags)
: dump_files_(dump_files), exported_header_dirs_(exported_header_dirs),
version_script_(version_script), so_file_(so_file),
- out_dump_name_(linked_dump), arch_(arch), api_(api) {}
+ out_dump_name_(linked_dump), arch_(arch), api_(api),
+ excluded_symbol_versions_(excluded_symbol_versions),
+ excluded_symbol_tags_(excluded_symbol_tags) {}
bool LinkAndDump();
@@ -125,6 +138,18 @@
bool LinkExportedSymbols(abi_util::IRDumper *ir_dumper);
+ bool LinkExportedSymbols(abi_util::IRDumper *ir_dumper,
+ const abi_util::ExportedSymbolSet &exported_symbols);
+
+ template <typename SymbolMap>
+ bool LinkExportedSymbols(abi_util::IRDumper *ir_dumper,
+ const SymbolMap &symbols);
+
+ // Check whether a symbol name is considered as exported. If both
+ // `shared_object_symbols_` and `version_script_symbols_` exists, the symbol
+ // name must pass the `HasSymbol()` test in both cases.
+ bool IsSymbolExported(const std::string &name) const;
+
private:
const std::vector<std::string> &dump_files_;
const std::vector<std::string> &exported_header_dirs_;
@@ -133,16 +158,14 @@
const std::string &out_dump_name_;
const std::string &arch_;
const std::string &api_;
- // TODO: Add to a map of std::sets instead.
+ const std::vector<std::string> &excluded_symbol_versions_;
+ const std::vector<std::string> &excluded_symbol_tags_;
+
std::set<std::string> exported_headers_;
- std::map<std::string, abi_util::ElfFunctionIR> function_decl_map_;
- std::map<std::string, abi_util::ElfObjectIR> globvar_decl_map_;
- // Version Script Regex Matching.
- std::set<std::string> functions_regex_matched_set;
- std::regex functions_vs_regex_;
- // Version Script Regex Matching.
- std::set<std::string> globvars_regex_matched_set;
- std::regex globvars_vs_regex_;
+
+ // Exported symbols
+ std::unique_ptr<abi_util::ExportedSymbolSet> shared_object_symbols_;
+ std::unique_ptr<abi_util::ExportedSymbolSet> version_script_symbols_;
};
static void DeDuplicateAbiElementsThread(
@@ -225,7 +248,9 @@
abi_util::IRDumper::CreateIRDumper(output_format, out_dump_name_);
assert(ir_dumper != nullptr);
- LinkExportedSymbols(ir_dumper.get());
+ if (!LinkExportedSymbols(ir_dumper.get())) {
+ return false;
+ }
if (!LinkTypes(greader.get(), ir_dumper.get()) ||
!LinkFunctions(greader.get(), ir_dumper.get()) ||
@@ -242,39 +267,6 @@
return true;
}
-static bool QueryRegexMatches(std::set<std::string> *regex_matched_link_set,
- const std::regex *vs_regex,
- const std::string &symbol) {
- assert(regex_matched_link_set != nullptr);
- assert(vs_regex != nullptr);
- if (regex_matched_link_set->find(symbol) != regex_matched_link_set->end()) {
- return false;
- }
- if (std::regex_search(symbol, *vs_regex)) {
- regex_matched_link_set->insert(symbol);
- return true;
- }
- return false;
-}
-
-static std::regex CreateRegexMatchExprFromSet(
- const std::set<std::string> &link_set) {
- std::string all_regex_match_str = "";
- std::set<std::string>::iterator it = link_set.begin();
- while (it != link_set.end()) {
- std::string regex_match_str_find_glob =
- abi_util::FindAndReplace(*it, "\\*", ".*");
- all_regex_match_str += "(\\b" + regex_match_str_find_glob + "\\b)";
- if (++it != link_set.end()) {
- all_regex_match_str += "|";
- }
- }
- if (all_regex_match_str == "") {
- return std::regex();
- }
- return std::regex(all_regex_match_str);
-}
-
template <typename T>
bool HeaderAbiLinker::LinkDecl(
abi_util::IRDumper *dst, const abi_util::AbiElementMap<T> &src,
@@ -316,15 +308,22 @@
LinkDecl(ir_dumper, reader->GetQualifiedTypes(), no_filter);
}
+bool HeaderAbiLinker::IsSymbolExported(const std::string &name) const {
+ if (shared_object_symbols_ && !shared_object_symbols_->HasSymbol(name)) {
+ return false;
+ }
+ if (version_script_symbols_ && !version_script_symbols_->HasSymbol(name)) {
+ return false;
+ }
+ return true;
+}
+
bool HeaderAbiLinker::LinkFunctions(
const abi_util::TextFormatToIRReader *reader,
abi_util::IRDumper *ir_dumper) {
assert(reader != nullptr);
auto symbol_filter = [this](const std::string &linker_set_key) {
- return function_decl_map_.find(linker_set_key) !=
- function_decl_map_.end() ||
- QueryRegexMatches(&functions_regex_matched_set, &functions_vs_regex_,
- linker_set_key);
+ return IsSymbolExported(linker_set_key);
};
return LinkDecl(ir_dumper, reader->GetFunctions(), symbol_filter);
}
@@ -334,18 +333,18 @@
abi_util::IRDumper *ir_dumper) {
assert(reader != nullptr);
auto symbol_filter = [this](const std::string &linker_set_key) {
- return globvar_decl_map_.find(linker_set_key) !=
- globvar_decl_map_.end() ||
- QueryRegexMatches(&globvars_regex_matched_set, &globvars_vs_regex_,
- linker_set_key);
+ return IsSymbolExported(linker_set_key);
};
return LinkDecl(ir_dumper, reader->GetGlobalVariables(), symbol_filter);
}
-template <typename T>
-static bool LinkExportedSymbols(abi_util::IRDumper *dst,
- const std::map<std::string, T> &symbols) {
+template <typename SymbolMap>
+bool HeaderAbiLinker::LinkExportedSymbols(abi_util::IRDumper *dst,
+ const SymbolMap &symbols) {
for (auto &&symbol : symbols) {
+ if (!IsSymbolExported(symbol.first)) {
+ continue;
+ }
if (!dst->AddElfSymbolMessageIR(&(symbol.second))) {
return false;
}
@@ -353,20 +352,37 @@
return true;
}
-// To be called right after parsing the .so file / version script.
+bool HeaderAbiLinker::LinkExportedSymbols(
+ abi_util::IRDumper *ir_dumper,
+ const abi_util::ExportedSymbolSet &exported_symbols) {
+ return (LinkExportedSymbols(ir_dumper, exported_symbols.GetFunctions()) &&
+ LinkExportedSymbols(ir_dumper, exported_symbols.GetVars()));
+}
+
bool HeaderAbiLinker::LinkExportedSymbols(abi_util::IRDumper *ir_dumper) {
- return ::LinkExportedSymbols(ir_dumper, function_decl_map_) &&
- ::LinkExportedSymbols(ir_dumper, globvar_decl_map_);
+ if (shared_object_symbols_) {
+ return LinkExportedSymbols(ir_dumper, *shared_object_symbols_);
+ }
+
+ if (version_script_symbols_) {
+ return LinkExportedSymbols(ir_dumper, *version_script_symbols_);
+ }
+
+ return false;
}
bool HeaderAbiLinker::ReadExportedSymbols() {
+ if (so_file_.empty() && version_script_.empty()) {
+ llvm::errs() << "Either shared lib or version script must be specified.\n";
+ return false;
+ }
+
if (!so_file_.empty()) {
if (!ReadExportedSymbolsFromSharedObjectFile()) {
llvm::errs() << "Failed to parse the shared library (.so file): "
<< so_file_ << "\n";
return false;
}
- return true;
}
if (!version_script_.empty()) {
@@ -375,29 +391,40 @@
<< "\n";
return false;
}
- return true;
}
- llvm::errs() << "Either shared lib or version script must be specified.\n";
- return false;
+ return true;
}
bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
- abi_util::VersionScriptParser version_script_parser(
- version_script_, arch_, api_);
- if (!version_script_parser.Parse()) {
+ std::optional<abi_util::ApiLevel> api_level = abi_util::ParseApiLevel(api_);
+ if (!api_level) {
+ llvm::errs() << "-api must be either \"current\" or an integer (e.g. 21)\n";
return false;
}
- function_decl_map_ = version_script_parser.GetFunctions();
- globvar_decl_map_ = version_script_parser.GetGlobVars();
+ std::ifstream stream(version_script_, std::ios_base::in);
+ if (!stream) {
+ llvm::errs() << "Failed to open version script file\n";
+ return false;
+ }
- std::set<std::string> function_regexs =
- version_script_parser.GetFunctionRegexs();
- std::set<std::string> globvar_regexs =
- version_script_parser.GetGlobVarRegexs();
- functions_vs_regex_ = CreateRegexMatchExprFromSet(function_regexs);
- globvars_vs_regex_ = CreateRegexMatchExprFromSet(globvar_regexs);
+ abi_util::VersionScriptParser parser;
+ parser.SetArch(arch_);
+ parser.SetApiLevel(api_level.value());
+ for (auto &&version : excluded_symbol_versions_) {
+ parser.AddExcludedSymbolVersion(version);
+ }
+ for (auto &&tag : excluded_symbol_tags_) {
+ parser.AddExcludedSymbolTag(tag);
+ }
+
+ version_script_symbols_ = parser.Parse(stream);
+ if (!version_script_symbols_) {
+ llvm::errs() << "Failed to parse version script file\n";
+ return false;
+ }
+
return true;
}
@@ -408,8 +435,12 @@
return false;
}
- function_decl_map_ = so_parser->GetFunctions();
- globvar_decl_map_ = so_parser->GetGlobVars();
+ shared_object_symbols_ = so_parser->Parse();
+ if (!shared_object_symbols_) {
+ llvm::errs() << "Failed to parse shared object file\n";
+ return false;
+ }
+
return true;
}
@@ -429,21 +460,26 @@
int main(int argc, const char **argv) {
HideIrrelevantCommandLineOptions();
-
llvm::cl::ParseCommandLineOptions(argc, argv, "header-linker");
+
if (so_file.empty() && version_script.empty()) {
llvm::errs() << "One of -so or -v needs to be specified\n";
return -1;
}
+
if (no_filter) {
static_cast<std::vector<std::string> &>(exported_header_dirs).clear();
}
+
HeaderAbiLinker Linker(dump_files, exported_header_dirs, version_script,
- so_file, linked_dump, arch, api);
+ so_file, linked_dump, arch, api,
+ excluded_symbol_versions,
+ excluded_symbol_tags);
if (!Linker.LinkAndDump()) {
llvm::errs() << "Failed to link and dump elements\n";
return -1;
}
+
return 0;
}
diff --git a/vndk/tools/header-checker/header-abi-util/include/api_level.h b/vndk/tools/header-checker/header-abi-util/include/api_level.h
new file mode 100644
index 0000000..11bcb66
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/include/api_level.h
@@ -0,0 +1,37 @@
+// Copyright (C) 2019 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.
+
+#ifndef API_LEVEL_H_
+#define API_LEVEL_H_
+
+#include <optional>
+#include <string>
+
+
+namespace abi_util {
+
+
+using ApiLevel = int;
+
+
+constexpr ApiLevel FUTURE_API_LEVEL = 10000;
+
+
+std::optional<ApiLevel> ParseApiLevel(const std::string &api);
+
+
+} // namespace abi_util
+
+
+#endif // API_LEVEL_H_
diff --git a/vndk/tools/header-checker/header-abi-util/include/exported_symbol_set.h b/vndk/tools/header-checker/header-abi-util/include/exported_symbol_set.h
new file mode 100644
index 0000000..886cb54
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/include/exported_symbol_set.h
@@ -0,0 +1,100 @@
+// Copyright (C) 2019 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.
+
+#ifndef EXPORTED_SYMBOL_SET_
+#define EXPORTED_SYMBOL_SET_
+
+#include "ir_representation.h"
+
+#include <functional>
+#include <map>
+#include <set>
+#include <string>
+
+
+namespace abi_util {
+
+
+class ExportedSymbolSet {
+ public:
+ using FunctionMap = std::map<std::string, ElfFunctionIR, std::less<>>;
+ using VarMap = std::map<std::string, ElfObjectIR, std::less<>>;
+ using NameSet = std::set<std::string, std::less<>>;
+ using GlobPatternSet = std::set<std::string, std::less<>>;
+
+
+ public:
+ ExportedSymbolSet() {}
+
+ const FunctionMap &GetFunctions() const {
+ return funcs_;
+ }
+
+ const VarMap &GetVars() const {
+ return vars_;
+ }
+
+ const GlobPatternSet &GetGlobPatterns() const {
+ return glob_patterns_;
+ }
+
+ const GlobPatternSet &GetDemangledCppGlobPatterns() const {
+ return demangled_cpp_glob_patterns_;
+ }
+
+ const NameSet &GetDemangledCppSymbols() const {
+ return demangled_cpp_symbols_;
+ }
+
+ bool HasSymbol(const std::string &symbol_name) const;
+
+ void AddFunction(const std::string &name,
+ ElfSymbolIR::ElfSymbolBinding binding);
+
+ void AddVar(const std::string &name, ElfSymbolIR::ElfSymbolBinding binding);
+
+ void AddGlobPattern(const std::string &pattern) {
+ glob_patterns_.insert(pattern);
+ }
+
+ void AddDemangledCppGlobPattern(const std::string &pattern) {
+ demangled_cpp_glob_patterns_.insert(pattern);
+ }
+
+ void AddDemangledCppSymbol(const std::string &pattern) {
+ demangled_cpp_symbols_.insert(pattern);
+ }
+
+
+ private:
+ bool HasDemangledCppSymbolsOrPatterns() const {
+ return (!demangled_cpp_glob_patterns_.empty() ||
+ !demangled_cpp_symbols_.empty());
+ }
+
+
+ private:
+ FunctionMap funcs_;
+ VarMap vars_;
+
+ GlobPatternSet glob_patterns_;
+ GlobPatternSet demangled_cpp_glob_patterns_;
+ NameSet demangled_cpp_symbols_;
+};
+
+
+} // namespace abi_util
+
+
+#endif // EXPORTED_SYMBOL_SET_
diff --git a/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h b/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h
index b19b8f3..3f5eeca 100644
--- a/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h
+++ b/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h
@@ -15,25 +15,28 @@
#ifndef SO_FILE_PARSER_H_
#define SO_FILE_PARSER_H_
+#include "exported_symbol_set.h"
#include "ir_representation.h"
#include <memory>
#include <map>
#include <string>
+
namespace abi_util {
+
class SoFileParser {
public:
static std::unique_ptr<SoFileParser> Create(const std::string &so_file_path);
virtual ~SoFileParser() {}
- virtual const std::map<std::string, ElfFunctionIR> &GetFunctions() const = 0;
-
- virtual const std::map<std::string, ElfObjectIR> &GetGlobVars() const = 0;
+ virtual std::unique_ptr<ExportedSymbolSet> Parse() = 0;
};
+
} // namespace abi_util
+
#endif // SO_FILE_PARSER_H_
diff --git a/vndk/tools/header-checker/header-abi-util/include/stl_utils.h b/vndk/tools/header-checker/header-abi-util/include/stl_utils.h
new file mode 100644
index 0000000..3a520ad
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/include/stl_utils.h
@@ -0,0 +1,33 @@
+// Copyright (C) 2019 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.
+
+#ifndef STL_UTILS_H_
+#define STL_UTILS_H_
+
+
+namespace abi_util {
+
+
+class FreeDeleter {
+ public:
+ inline void operator()(void *ptr) const {
+ ::free(ptr);
+ }
+};
+
+
+} // namespace abi_util
+
+
+#endif // STL_UTILS_
diff --git a/vndk/tools/header-checker/header-abi-util/include/string_utils.h b/vndk/tools/header-checker/header-abi-util/include/string_utils.h
new file mode 100644
index 0000000..d222a43
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/include/string_utils.h
@@ -0,0 +1,43 @@
+// Copyright (C) 2019 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.
+
+#ifndef STRING_UTILS_H_
+#define STRING_UTILS_H_
+
+#include <optional>
+#include <string>
+#include <vector>
+
+
+namespace abi_util {
+
+
+std::string_view Trim(std::string_view s);
+
+bool StartsWith(std::string_view s, std::string_view prefix);
+
+bool EndsWith(std::string_view s, std::string_view suffix);
+
+std::vector<std::string_view> Split(std::string_view s,
+ std::string_view delim_chars);
+
+std::optional<int> ParseInt(const std::string &s);
+
+bool IsGlobPattern(std::string_view s);
+
+
+} // namespace abi_util
+
+
+#endif // STRING_UTILS_H_
diff --git a/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h b/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h
index dd86fbf..7becddf 100644
--- a/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h
+++ b/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h
@@ -15,64 +15,117 @@
#ifndef VERSION_SCRIPT_PARSER_H_
#define VERSION_SCRIPT_PARSER_H_
+#include "api_level.h"
+#include "exported_symbol_set.h"
#include "ir_representation.h"
+#include <functional>
#include <map>
#include <set>
#include <string>
+
namespace abi_util {
+
class VersionScriptParser {
- public:
- enum LineScope {
- global,
- local,
+ private:
+ enum class LineScope {
+ GLOBAL,
+ LOCAL,
};
- VersionScriptParser(const std::string &version_script,
- const std::string &arch,
- const std::string &api);
- bool Parse();
- const std::map<std::string, ElfFunctionIR> &GetFunctions();
+ struct ParsedTags {
+ public:
+ unsigned has_arch_tags_ : 1;
+ unsigned has_current_arch_tag_ : 1;
+ unsigned has_introduced_tags_ : 1;
+ unsigned has_excluded_tags_ : 1;
+ unsigned has_future_tag_ : 1;
+ unsigned has_var_tag_ : 1;
+ ApiLevel introduced_;
- const std::map<std::string, ElfObjectIR> &GetGlobVars();
- const std::set<std::string> &GetFunctionRegexs();
+ public:
+ ParsedTags()
+ : has_arch_tags_(0), has_current_arch_tag_(0), has_introduced_tags_(0),
+ has_excluded_tags_(0), has_future_tag_(0), has_var_tag_(0),
+ introduced_(-1) {}
+ };
- const std::set<std::string> &GetGlobVarRegexs();
+
+ public:
+ class ErrorHandler {
+ public:
+ virtual ~ErrorHandler();
+
+ virtual void OnError(int line_no, const std::string &error_msg) = 0;
+ };
+
+
+ public:
+ VersionScriptParser();
+
+ void SetArch(const std::string &arch);
+
+ void SetApiLevel(ApiLevel api_level) {
+ api_level_ = api_level;
+ }
+
+ void AddExcludedSymbolVersion(const std::string &version) {
+ excluded_symbol_versions_.insert(version);
+ }
+
+ void AddExcludedSymbolTag(const std::string &tag) {
+ excluded_symbol_tags_.insert(tag);
+ }
+
+ void SetErrorHandler(std::unique_ptr<ErrorHandler> error_handler) {
+ error_handler_ = std::move(error_handler);
+ }
+
+ std::unique_ptr<ExportedSymbolSet> Parse(std::istream &version_script_stream);
+
private:
- bool ParseInnerBlock(std::ifstream &symbol_ifstream);
+ bool ReadLine(std::string &line);
- LineScope GetLineScope(std::string &line, LineScope scope);
+ bool ParseVersionBlock(bool ignore_symbols);
- bool ParseSymbolLine(const std::string &line);
+ bool ParseSymbolLine(const std::string &line, bool is_cpp_symbol);
- bool SymbolInArchAndApiVersion(const std::string &line,
- const std::string &arch, int api);
+ ParsedTags ParseSymbolTags(const std::string &line);
- bool SymbolExported(const std::string &line, const std::string &arch,
- int api);
+ bool IsSymbolExported(const ParsedTags &tags);
- int ApiStrToInt(const std::string &api);
-
- void AddToVars(std::string &symbol);
-
- void AddToFunctions(std::string &symbol);
private:
- const std::string &version_script_;
- const std::string &arch_;
- std::map<std::string, ElfFunctionIR> functions_;
- std::map<std::string, ElfObjectIR> globvars_;
- // Added to speed up version script parsing and linking.
- std::set<std::string> function_regexs_;
- std::set<std::string> globvar_regexs_;
- int api_;
+ void ReportError(const std::string &error_msg) {
+ if (error_handler_) {
+ error_handler_->OnError(line_no_, error_msg);
+ }
+ }
+
+
+ private:
+ std::unique_ptr<ErrorHandler> error_handler_;
+
+ std::string arch_;
+ std::string introduced_arch_tag_;
+ ApiLevel api_level_;
+
+ std::set<std::string, std::less<>> excluded_symbol_versions_;
+ std::set<std::string, std::less<>> excluded_symbol_tags_;
+
+ std::istream *stream_;
+ int line_no_;
+
+ std::unique_ptr<ExportedSymbolSet> exported_symbols_;
};
+
} // namespace abi_util
+
#endif // VERSION_SCRIPT_PARSER_H_
diff --git a/vndk/tools/header-checker/header-abi-util/src/api_level.cpp b/vndk/tools/header-checker/header-abi-util/src/api_level.cpp
new file mode 100644
index 0000000..dc0b216
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/api_level.cpp
@@ -0,0 +1,34 @@
+// Copyright (C) 2019 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.
+
+#include "api_level.h"
+
+#include "string_utils.h"
+
+#include <cassert>
+#include <string>
+
+
+namespace abi_util {
+
+
+std::optional<ApiLevel> ParseApiLevel(const std::string &api_level_str) {
+ if (api_level_str == "current") {
+ return FUTURE_API_LEVEL;
+ }
+ return ParseInt(api_level_str);
+}
+
+
+} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/api_level_test.cpp b/vndk/tools/header-checker/header-abi-util/src/api_level_test.cpp
new file mode 100644
index 0000000..3f6008c
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/api_level_test.cpp
@@ -0,0 +1,36 @@
+// Copyright (C) 2019 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.
+
+#include "api_level.h"
+
+#include <gtest/gtest.h>
+
+
+namespace abi_util {
+
+
+TEST(ApiLevelTest, ParseApiLevel) {
+ EXPECT_FALSE(ParseApiLevel(""));
+ EXPECT_FALSE(ParseApiLevel("A"));
+
+ EXPECT_TRUE(ParseApiLevel("current").has_value());
+ EXPECT_EQ(FUTURE_API_LEVEL, ParseApiLevel("current").value());
+
+ EXPECT_TRUE(ParseApiLevel("16").has_value());
+ EXPECT_EQ(16l, ParseApiLevel("16").value());
+}
+
+
+} // namespace abi_util
+
diff --git a/vndk/tools/header-checker/header-abi-util/src/exported_symbol_set.cpp b/vndk/tools/header-checker/header-abi-util/src/exported_symbol_set.cpp
new file mode 100644
index 0000000..13958eb
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/exported_symbol_set.cpp
@@ -0,0 +1,99 @@
+// Copyright (C) 2019 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.
+
+#include "exported_symbol_set.h"
+
+#include "ir_representation.h"
+#include "stl_utils.h"
+#include "string_utils.h"
+
+#include <fnmatch.h>
+#include <cxxabi.h>
+
+
+namespace abi_util {
+
+
+static inline bool IsCppSymbol(const std::string &name) {
+ return StartsWith(name, "_Z");
+}
+
+
+static inline bool HasMatchingGlobPattern(
+ const ExportedSymbolSet::GlobPatternSet &patterns, const char *text) {
+ for (auto &&pattern : patterns) {
+ if (fnmatch(pattern.c_str(), text, 0) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+static inline bool HasMatchingGlobPattern(
+ const ExportedSymbolSet::GlobPatternSet &patterns,
+ const std::string &text) {
+ return HasMatchingGlobPattern(patterns, text.c_str());
+}
+
+
+void ExportedSymbolSet::AddFunction(const std::string &name,
+ ElfSymbolIR::ElfSymbolBinding binding) {
+ funcs_.emplace(name, ElfFunctionIR(name, binding));
+}
+
+
+void ExportedSymbolSet::AddVar(const std::string &name,
+ ElfSymbolIR::ElfSymbolBinding binding) {
+ vars_.emplace(name, ElfObjectIR(name, binding));
+}
+
+
+bool ExportedSymbolSet::HasSymbol(const std::string &name) const {
+ if (funcs_.find(name) != funcs_.end()) {
+ return true;
+ }
+
+ if (vars_.find(name) != vars_.end()) {
+ return true;
+ }
+
+ if (HasMatchingGlobPattern(glob_patterns_, name)) {
+ return true;
+ }
+
+ if (IsCppSymbol(name) && HasDemangledCppSymbolsOrPatterns()) {
+ std::unique_ptr<char, FreeDeleter> demangled_name_c_str(
+ abi::__cxa_demangle(name.c_str(), nullptr, nullptr, nullptr));
+
+ if (demangled_name_c_str) {
+ std::string_view demangled_name(demangled_name_c_str.get());
+
+ if (demangled_cpp_symbols_.find(demangled_name) !=
+ demangled_cpp_symbols_.end()) {
+ return true;
+ }
+
+ if (HasMatchingGlobPattern(demangled_cpp_glob_patterns_,
+ demangled_name_c_str.get())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/exported_symbol_set_test.cpp b/vndk/tools/header-checker/header-abi-util/src/exported_symbol_set_test.cpp
new file mode 100644
index 0000000..f292996
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/exported_symbol_set_test.cpp
@@ -0,0 +1,132 @@
+// Copyright (C) 2019 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.
+
+#include "exported_symbol_set.h"
+
+#include "ir_representation.h"
+
+#include <gtest/gtest.h>
+
+
+namespace abi_util {
+
+
+TEST(ExportedSymbolSetTest, AddFunction) {
+ ExportedSymbolSet symbols;
+ symbols.AddFunction("global", ElfSymbolIR::ElfSymbolBinding::Global);
+ symbols.AddFunction("weak", ElfSymbolIR::ElfSymbolBinding::Weak);
+
+ const ExportedSymbolSet::FunctionMap &funcs = symbols.GetFunctions();
+
+ ASSERT_NE(funcs.end(), funcs.find("global"));
+ EXPECT_EQ(ElfSymbolIR::ElfSymbolBinding::Global,
+ funcs.at("global").GetBinding());
+
+ ASSERT_NE(funcs.end(), funcs.find("weak"));
+ EXPECT_EQ(ElfSymbolIR::ElfSymbolBinding::Weak,
+ funcs.at("weak").GetBinding());
+}
+
+
+TEST(ExportedSymbolSetTest, AddVar) {
+ ExportedSymbolSet symbols;
+ symbols.AddVar("global", ElfSymbolIR::ElfSymbolBinding::Global);
+ symbols.AddVar("weak", ElfSymbolIR::ElfSymbolBinding::Weak);
+
+ const ExportedSymbolSet::VarMap &vars = symbols.GetVars();
+
+ ASSERT_NE(vars.end(), vars.find("global"));
+ EXPECT_EQ(ElfSymbolIR::ElfSymbolBinding::Global,
+ vars.at("global").GetBinding());
+
+ ASSERT_NE(vars.end(), vars.find("weak"));
+ EXPECT_EQ(ElfSymbolIR::ElfSymbolBinding::Weak,
+ vars.at("weak").GetBinding());
+}
+
+
+TEST(ExportedSymbolSetTest, AddGlobPattern) {
+ ExportedSymbolSet symbols;
+ symbols.AddGlobPattern("test1*");
+
+ const ExportedSymbolSet::GlobPatternSet &globs = symbols.GetGlobPatterns();
+ ASSERT_NE(globs.end(), globs.find("test1*"));
+}
+
+
+TEST(ExportedSymbolSetTest, AddDemangledCppGlobPattern) {
+ ExportedSymbolSet symbols;
+ symbols.AddDemangledCppGlobPattern("test1*");
+
+ const ExportedSymbolSet::GlobPatternSet &globs =
+ symbols.GetDemangledCppGlobPatterns();
+ ASSERT_NE(globs.end(), globs.find("test1*"));
+}
+
+
+TEST(ExportedSymbolSetTest, AddDemangledCppSymbol) {
+ ExportedSymbolSet symbols;
+ symbols.AddDemangledCppSymbol("Test::test()");
+
+ const ExportedSymbolSet::NameSet &names = symbols.GetDemangledCppSymbols();
+ ASSERT_NE(names.end(), names.find("Test::test()"));
+}
+
+
+TEST(ExportedSymbolSetTest, HasSymbol) {
+ ExportedSymbolSet symbols;
+
+ symbols.AddFunction("global_func", ElfSymbolIR::ElfSymbolBinding::Global);
+ symbols.AddVar("global_var", ElfSymbolIR::ElfSymbolBinding::Global);
+
+ symbols.AddGlobPattern("test_glob1_*");
+ symbols.AddGlobPattern("test_glob2_[Aa]");
+ symbols.AddGlobPattern("test_glob3_?");
+
+ symbols.AddDemangledCppGlobPattern("Test1::*");
+ symbols.AddDemangledCppGlobPattern("Test2::[Aa]()");
+ symbols.AddDemangledCppGlobPattern("Test3::?()");
+ symbols.AddDemangledCppSymbol("Test4::test()");
+
+ // Test literal names
+ EXPECT_TRUE(symbols.HasSymbol("global_func"));
+ EXPECT_TRUE(symbols.HasSymbol("global_var"));
+
+ EXPECT_FALSE(symbols.HasSymbol(""));
+ EXPECT_FALSE(symbols.HasSymbol("no_such_function"));
+
+ // Test glob patterns
+ EXPECT_TRUE(symbols.HasSymbol("test_glob1_a"));
+ EXPECT_TRUE(symbols.HasSymbol("test_glob2_A"));
+ EXPECT_TRUE(symbols.HasSymbol("test_glob2_a"));
+ EXPECT_TRUE(symbols.HasSymbol("test_glob3_b"));
+
+ EXPECT_FALSE(symbols.HasSymbol("test_glob2_Ax"));
+ EXPECT_FALSE(symbols.HasSymbol("test_glob2_B"));
+ EXPECT_FALSE(symbols.HasSymbol("test_glob3_Bx"));
+
+ // Test C++ names and patterns
+ EXPECT_TRUE(symbols.HasSymbol("_ZN5Test14testEv"));
+ EXPECT_TRUE(symbols.HasSymbol("_ZN5Test21AEv"));
+ EXPECT_TRUE(symbols.HasSymbol("_ZN5Test21aEv"));
+ EXPECT_TRUE(symbols.HasSymbol("_ZN5Test31bEv"));
+ EXPECT_TRUE(symbols.HasSymbol("_ZN5Test44testEv"));
+
+ EXPECT_FALSE(symbols.HasSymbol("_ZN5Test22AxEv"));
+ EXPECT_FALSE(symbols.HasSymbol("_ZN5Test21bEv"));
+ EXPECT_FALSE(symbols.HasSymbol("_ZN5Test32BxEv"));
+}
+
+
+} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp b/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp
index fa4d975..001f9b9 100644
--- a/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp
+++ b/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp
@@ -21,8 +21,10 @@
#include <llvm/Object/ELFTypes.h>
#include <llvm/Object/SymbolSize.h>
+
namespace abi_util {
+
template <typename T>
static inline T UnWrap(llvm::Expected<T> value_or_error) {
if (!value_or_error) {
@@ -34,6 +36,7 @@
return std::move(value_or_error.get());
}
+
static abi_util::ElfSymbolIR::ElfSymbolBinding
LLVMToIRSymbolBinding(unsigned char binding) {
switch (binding) {
@@ -45,7 +48,8 @@
assert(0);
}
-template<typename T>
+
+template <typename T>
class ELFSoFileParser : public SoFileParser {
private:
LLVM_ELF_IMPORT_TYPES_ELFT(T)
@@ -57,12 +61,8 @@
~ELFSoFileParser() override {}
- const std::map<std::string, ElfFunctionIR> &GetFunctions() const override {
- return functions_;
- }
-
- const std::map<std::string, ElfObjectIR> &GetGlobVars() const override {
- return globvars_;
+ std::unique_ptr<ExportedSymbolSet> Parse() override {
+ return std::move(exported_symbols_);
}
private:
@@ -77,38 +77,44 @@
private:
const llvm::object::ELFObjectFile<T> *obj_;
- std::map<std::string, abi_util::ElfFunctionIR> functions_;
- std::map<std::string, abi_util::ElfObjectIR> globvars_;
+ std::unique_ptr<ExportedSymbolSet> exported_symbols_;
};
-template<typename T>
+
+template <typename T>
ELFSoFileParser<T>::ELFSoFileParser(const llvm::object::ELFObjectFile<T> *obj) {
assert(obj != nullptr);
+
+ exported_symbols_.reset(new ExportedSymbolSet());
+
for (auto symbol_it : obj->getDynamicSymbolIterators()) {
const Elf_Sym *elf_sym = obj->getSymbol(symbol_it.getRawDataRefImpl());
assert (elf_sym != nullptr);
if (!IsSymbolExported(elf_sym) || elf_sym->isUndefined()) {
continue;
}
+
abi_util::ElfSymbolIR::ElfSymbolBinding symbol_binding =
LLVMToIRSymbolBinding(elf_sym->getBinding());
- llvm::object::SymbolRef::Type type = UnWrap(symbol_it.getType());
std::string symbol_name = UnWrap(symbol_it.getName());
+
+ llvm::object::SymbolRef::Type type = UnWrap(symbol_it.getType());
if (type == llvm::object::SymbolRef::Type::ST_Function) {
- functions_.emplace(symbol_name,
- ElfFunctionIR(symbol_name, symbol_binding));
+ exported_symbols_->AddFunction(symbol_name, symbol_binding);
} else if (type == llvm::object::SymbolRef::Type::ST_Data) {
- globvars_.emplace(symbol_name, ElfObjectIR(symbol_name, symbol_binding));
+ exported_symbols_->AddVar(symbol_name, symbol_binding);
}
}
}
-template<typename T>
+
+template <typename T>
static std::unique_ptr<SoFileParser> CreateELFSoFileParser(
const llvm::object::ELFObjectFile<T> *elfo) {
return llvm::make_unique<ELFSoFileParser<T>>(elfo);
}
+
std::unique_ptr<SoFileParser> SoFileParser::Create(
const std::string &so_file_path) {
auto binary = llvm::object::createBinary(so_file_path);
@@ -149,4 +155,5 @@
return nullptr;
}
+
} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/string_utils.cpp b/vndk/tools/header-checker/header-abi-util/src/string_utils.cpp
new file mode 100644
index 0000000..b6a03d0
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/string_utils.cpp
@@ -0,0 +1,93 @@
+// Copyright (C) 2019 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.
+
+#include "string_utils.h"
+
+#include <cstdlib>
+#include <string>
+#include <utility>
+
+
+namespace abi_util {
+
+
+std::string_view Trim(std::string_view s) {
+ std::string::size_type start = s.find_first_not_of(" \t\r\n");
+ if (start == std::string::npos) {
+ return "";
+ }
+ std::string::size_type end = s.find_last_not_of(" \t\r\n");
+ if (end == std::string::npos) {
+ return s.substr(start);
+ }
+ return s.substr(start, end - start + 1);
+}
+
+
+bool StartsWith(std::string_view s, std::string_view prefix) {
+ return s.size() >= prefix.size() && s.compare(0, prefix.size(), prefix) == 0;
+}
+
+
+bool EndsWith(std::string_view s, std::string_view suffix) {
+ return (s.size() >= suffix.size() &&
+ s.compare(s.size() - suffix.size(), suffix.size(), suffix) == 0);
+}
+
+
+std::vector<std::string_view> Split(std::string_view s,
+ std::string_view delim_chars) {
+ std::vector<std::string_view> res;
+ std::string::size_type pos = 0;
+ while (true) {
+ pos = s.find_first_not_of(delim_chars, pos);
+ if (pos == std::string::npos) {
+ break;
+ }
+
+ std::string::size_type end = s.find_first_of(delim_chars, pos + 1);
+ if (end == std::string::npos) {
+ res.push_back(s.substr(pos));
+ break;
+ }
+
+ res.push_back(s.substr(pos, end - pos));
+ pos = end + 1;
+ }
+ return res;
+}
+
+
+std::optional<int> ParseInt(const std::string &s) {
+ const char *start = s.c_str();
+ if (*start == '\0') {
+ return {};
+ }
+
+ char *endptr = nullptr;
+ long int res = ::strtol(start, &endptr, 10);
+ if (*endptr != '\0') {
+ return {};
+ }
+
+ return static_cast<int>(res);
+}
+
+
+bool IsGlobPattern(std::string_view s) {
+ return s.find_first_of("*?[") != std::string::npos;
+}
+
+
+} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/string_utils_test.cpp b/vndk/tools/header-checker/header-abi-util/src/string_utils_test.cpp
new file mode 100644
index 0000000..7cc2bff
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/string_utils_test.cpp
@@ -0,0 +1,107 @@
+// Copyright (C) 2019 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.
+
+#include "string_utils.h"
+
+#include <gtest/gtest.h>
+
+
+namespace abi_util {
+
+
+TEST(StringUtilsTest, Trim) {
+ EXPECT_EQ("a b", Trim(" a b "));
+ EXPECT_EQ("a b", Trim(" a b"));
+ EXPECT_EQ("a b", Trim("a b "));
+ EXPECT_EQ("a b", Trim("a b"));
+ EXPECT_EQ("a b", Trim("\ta b\n"));
+}
+
+
+TEST(StringUtilsTest, StartsWith) {
+ EXPECT_TRUE(StartsWith("abcd", "ab"));
+ EXPECT_TRUE(StartsWith("a", "a"));
+ EXPECT_TRUE(StartsWith("a", ""));
+ EXPECT_TRUE(StartsWith("", ""));
+
+ EXPECT_FALSE(StartsWith("ab", "abcd"));
+ EXPECT_FALSE(StartsWith("", "ab"));
+}
+
+
+TEST(StringUtilsTest, EndsWith) {
+ EXPECT_TRUE(EndsWith("abcd", "cd"));
+ EXPECT_TRUE(EndsWith("d", "d"));
+ EXPECT_TRUE(EndsWith("d", ""));
+ EXPECT_TRUE(EndsWith("", ""));
+
+ EXPECT_FALSE(EndsWith("cd", "abcd"));
+ EXPECT_FALSE(EndsWith("", "cd"));
+}
+
+
+TEST(StringUtilsTest, Split) {
+ std::vector<std::string_view> xs;
+
+ xs = Split(" a bb ccc ", " ");
+ EXPECT_EQ(3, xs.size());
+ EXPECT_EQ("a", xs[0]);
+ EXPECT_EQ("bb", xs[1]);
+ EXPECT_EQ("ccc", xs[2]);
+
+ xs = Split("a", " ");
+ EXPECT_EQ(1, xs.size());
+ EXPECT_EQ("a", xs[0]);
+
+ xs = Split("a b", " ");
+ EXPECT_EQ(2, xs.size());
+ EXPECT_EQ("a", xs[0]);
+ EXPECT_EQ("b", xs[1]);
+
+ xs = Split("a \t \t \tb", " \t");
+ EXPECT_EQ(2, xs.size());
+ EXPECT_EQ("a", xs[0]);
+ EXPECT_EQ("b", xs[1]);
+}
+
+
+TEST(StringUtilsTest, ParseInt) {
+ EXPECT_FALSE(ParseInt(""));
+ EXPECT_FALSE(ParseInt("a"));
+ EXPECT_FALSE(ParseInt("0xa"));
+ EXPECT_FALSE(ParseInt("16h"));
+
+ EXPECT_TRUE(ParseInt("0").has_value());
+ EXPECT_EQ(0, ParseInt("0").value());
+
+ EXPECT_TRUE(ParseInt("16").has_value());
+ EXPECT_EQ(16, ParseInt("16").value());
+
+ EXPECT_TRUE(ParseInt("-16").has_value());
+ EXPECT_EQ(-16, ParseInt("-16").value());
+}
+
+
+TEST(StringUtilsTest, IsGlobPattern) {
+ EXPECT_TRUE(IsGlobPattern("*.so"));
+ EXPECT_TRUE(IsGlobPattern("[ab].txt"));
+ EXPECT_TRUE(IsGlobPattern("?.txt"));
+
+ EXPECT_FALSE(IsGlobPattern("name"));
+ EXPECT_FALSE(IsGlobPattern(".txt"));
+ EXPECT_FALSE(IsGlobPattern(""));
+}
+
+
+} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp b/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp
index 794b477..d9a717c 100644
--- a/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp
+++ b/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp
@@ -14,202 +14,283 @@
#include "version_script_parser.h"
-#include <llvm/Support/raw_ostream.h>
-#include <llvm/Support/FileSystem.h>
-#include <llvm/Support/Path.h>
+#include "exported_symbol_set.h"
+#include "string_utils.h"
-#include <fstream>
#include <iostream>
#include <memory>
#include <regex>
#include <set>
#include <string>
-#include <unordered_set>
#include <vector>
+
namespace abi_util {
-#define FUTURE_API 10000
-std::unordered_set<std::string> AllArches({
- "arm", "arm64", "x86", "x86_64", "mips", "mips64"});
+static constexpr char DEFAULT_ARCH[] = "arm64";
-static bool StringContains(const std::string &line,
- const std::string &substring) {
- return (line.find(substring) != std::string::npos);
+
+inline std::string GetIntroducedArchTag(const std::string &arch) {
+ return "introduced-" + arch + "=";
}
-static bool LineSatisfiesArch(const std::string &line,
- const std::string arch) {
- bool has_arch_tags = false;
- for (auto &&possible_arch : AllArches) {
- if (StringContains(line, possible_arch)) {
- has_arch_tags = true;
- break;
+
+VersionScriptParser::VersionScriptParser()
+ : arch_(DEFAULT_ARCH), introduced_arch_tag_(GetIntroducedArchTag(arch_)),
+ api_level_(FUTURE_API_LEVEL), stream_(nullptr), line_no_(0) {}
+
+
+void VersionScriptParser::SetArch(const std::string &arch) {
+ arch_ = arch;
+ introduced_arch_tag_ = GetIntroducedArchTag(arch);
+}
+
+
+VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
+ const std::string &line) {
+ static const char *const POSSIBLE_ARCHES[] = {
+ "arm", "arm64", "x86", "x86_64", "mips", "mips64"};
+
+ ParsedTags result;
+
+ std::string_view line_view(line);
+ std::string::size_type comment_pos = line_view.find('#');
+ if (comment_pos == std::string::npos) {
+ return result;
+ }
+
+ std::string_view comment_line = line_view.substr(comment_pos + 1);
+ std::vector<std::string_view> tags = Split(comment_line, " \t");
+
+ bool has_introduced_arch_tags = false;
+
+ for (auto &&tag : tags) {
+ // Check excluded tags.
+ if (excluded_symbol_tags_.find(tag) != excluded_symbol_tags_.end()) {
+ result.has_excluded_tags_ = true;
+ }
+
+ // Check the var tag.
+ if (tag == "var") {
+ result.has_var_tag_ = true;
+ continue;
+ }
+
+ // Check arch tags.
+ if (tag == arch_) {
+ result.has_arch_tags_ = true;
+ result.has_current_arch_tag_ = true;
+ continue;
+ }
+
+ for (auto &&possible_arch : POSSIBLE_ARCHES) {
+ if (tag == possible_arch) {
+ result.has_arch_tags_ = true;
+ break;
+ }
+ }
+
+ // Check introduced tags.
+ if (StartsWith(tag, "introduced=")) {
+ std::optional<ApiLevel> intro = ParseApiLevel(
+ std::string(tag.substr(sizeof("introduced=") - 1)));
+ if (!intro) {
+ ReportError("Bad introduced tag: " + std::string(tag));
+ } else {
+ if (!has_introduced_arch_tags) {
+ result.has_introduced_tags_ = true;
+ result.introduced_ = intro.value();
+ }
+ }
+ continue;
+ }
+
+ if (StartsWith(tag, introduced_arch_tag_)) {
+ std::optional<ApiLevel> intro = ParseApiLevel(
+ std::string(tag.substr(introduced_arch_tag_.size())));
+ if (!intro) {
+ ReportError("Bad introduced tag " + std::string(tag));
+ } else {
+ has_introduced_arch_tags = true;
+ result.has_introduced_tags_ = true;
+ result.introduced_ = intro.value();
+ }
+ continue;
+ }
+
+ // Check future tags.
+ if (tag == "future") {
+ result.has_future_tag_ = true;
+ continue;
}
}
- return (has_arch_tags && StringContains(line, arch)) || !has_arch_tags;
+
+ return result;
}
-VersionScriptParser::VersionScriptParser(const std::string &version_script,
- const std::string &arch,
- const std::string &api)
- : version_script_(version_script), arch_(arch), api_(ApiStrToInt(api)) {}
-int VersionScriptParser::ApiStrToInt(const std::string &api) {
- // Follow what build/soong/cc/gen_stub_libs.py does.
- if (api == "current") {
- return FUTURE_API;
+bool VersionScriptParser::IsSymbolExported(
+ const VersionScriptParser::ParsedTags &tags) {
+ if (tags.has_excluded_tags_) {
+ return false;
}
- return std::stoi(api);
+
+ if (tags.has_arch_tags_ && !tags.has_current_arch_tag_) {
+ return false;
+ }
+
+ if (tags.has_future_tag_) {
+ return api_level_ == FUTURE_API_LEVEL;
+ }
+
+ if (tags.has_introduced_tags_) {
+ return api_level_ >= tags.introduced_;
+ }
+
+ return true;
}
-bool VersionScriptParser::SymbolInArchAndApiVersion(const std::string &line,
- const std::string &arch,
- int api) {
- // If the tags do not have an "introduced" requirement, the symbol is
- // exported.
- if (!StringContains(line, "introduced") && LineSatisfiesArch(line, arch)) {
+
+bool VersionScriptParser::ParseSymbolLine(const std::string &line,
+ bool is_in_extern_cpp) {
+ // The symbol name comes before the ';'.
+ std::string::size_type pos = line.find(";");
+ if (pos == std::string::npos) {
+ ReportError("No semicolon at the end of the symbol line: " + line);
+ return false;
+ }
+
+ std::string symbol(Trim(line.substr(0, pos)));
+
+ ParsedTags tags = ParseSymbolTags(line);
+ if (!IsSymbolExported(tags)) {
return true;
}
- if (line == "future") {
- return api == FUTURE_API;
+
+ if (is_in_extern_cpp) {
+ if (IsGlobPattern(symbol)) {
+ exported_symbols_->AddDemangledCppGlobPattern(symbol);
+ } else {
+ exported_symbols_->AddDemangledCppSymbol(symbol);
+ }
+ return true;
}
- const std::string regex_match_string1 = " *introduced-" + arch + "=([0-9]+)";
- const std::string regex_match_string2 = " *introduced=([0-9]+)";
- std::smatch matcher1;
- std::smatch matcher2;
- std::regex match_clause1(regex_match_string1);
- std::regex match_clause2(regex_match_string2);
- int matched_api = -1;
- if (std::regex_search(line, matcher1, match_clause1)) {
- matched_api = std::stoi(matcher1.str(1));
- } else if ((std::regex_search(line, matcher2, match_clause2)) &&
- LineSatisfiesArch(line, arch)) {
- matched_api = std::stoi(matcher2.str(1));
+
+ if (IsGlobPattern(symbol)) {
+ exported_symbols_->AddGlobPattern(symbol);
+ return true;
}
- // If the arch specific tag / version specific tag was found and the api level
- // required was greater than the api level offered.
- return (matched_api <= 0 || api >= matched_api);
+
+ if (tags.has_var_tag_) {
+ exported_symbols_->AddVar(symbol, ElfSymbolIR::ElfSymbolBinding::Global);
+ } else {
+ exported_symbols_->AddFunction(symbol,
+ ElfSymbolIR::ElfSymbolBinding::Global);
+ }
+ return true;
}
-bool VersionScriptParser::SymbolExported(const std::string &line,
- const std::string &arch, int api) {
- // Empty line means that the symbol is exported
- if (line.empty() || SymbolInArchAndApiVersion(line, arch, api)) {
+
+bool VersionScriptParser::ParseVersionBlock(bool ignore_symbols) {
+ static const std::regex EXTERN_CPP_PATTERN(R"(extern\s*"[Cc]\+\+"\s*\{)");
+
+ LineScope scope = LineScope::GLOBAL;
+ bool is_in_extern_cpp = false;
+
+ while (true) {
+ std::string line;
+ if (!ReadLine(line)) {
+ break;
+ }
+
+ if (line.find("}") != std::string::npos) {
+ if (is_in_extern_cpp) {
+ is_in_extern_cpp = false;
+ continue;
+ }
+ return true;
+ }
+
+ // Check extern "c++"
+ if (std::regex_match(line, EXTERN_CPP_PATTERN)) {
+ is_in_extern_cpp = true;
+ continue;
+ }
+
+ // Check symbol visibility label
+ if (StartsWith(line, "local:")) {
+ scope = LineScope::LOCAL;
+ continue;
+ }
+ if (StartsWith(line, "global:")) {
+ scope = LineScope::GLOBAL;
+ continue;
+ }
+ if (scope != LineScope::GLOBAL) {
+ continue;
+ }
+
+ // Parse symbol line
+ if (!ignore_symbols) {
+ if (!ParseSymbolLine(line, is_in_extern_cpp)) {
+ return false;
+ }
+ }
+ }
+
+ ReportError("No matching closing parenthesis");
+ return false;
+}
+
+
+std::unique_ptr<ExportedSymbolSet> VersionScriptParser::Parse(
+ std::istream &stream) {
+ // Initialize the parser context
+ stream_ = &stream;
+ line_no_ = 0;
+ exported_symbols_.reset(new ExportedSymbolSet());
+
+ // Parse
+ while (true) {
+ std::string line;
+ if (!ReadLine(line)) {
+ break;
+ }
+
+ std::string::size_type lparen_pos = line.find("{");
+ if (lparen_pos == std::string::npos) {
+ ReportError("No version opening parenthesis" + line);
+ return nullptr;
+ }
+
+ std::string version(Trim(line.substr(0, lparen_pos - 1)));
+ bool exclude_symbol_version = (excluded_symbol_versions_.find(version) !=
+ excluded_symbol_versions_.end());
+
+ if (!ParseVersionBlock(exclude_symbol_version)) {
+ return nullptr;
+ }
+ }
+
+ return std::move(exported_symbols_);
+}
+
+
+bool VersionScriptParser::ReadLine(std::string &line) {
+ while (std::getline(*stream_, line)) {
+ ++line_no_;
+ line = std::string(Trim(line));
+ if (line.empty() || line[0] == '#') {
+ continue;
+ }
return true;
}
return false;
}
-void VersionScriptParser::AddToVars(std::string &symbol) {
- if (symbol.find("*") != std::string::npos) {
- globvar_regexs_.insert(symbol);
- } else {
- globvars_.emplace(
- symbol, ElfObjectIR(symbol, ElfSymbolIR::ElfSymbolBinding::Global));
- }
-}
-void VersionScriptParser::AddToFunctions(std::string &symbol) {
- if (symbol.find("*") != std::string::npos) {
- function_regexs_.insert(symbol);
- } else {
- functions_.emplace(
- symbol, ElfFunctionIR(symbol, ElfSymbolIR::ElfSymbolBinding::Global));
- }
-}
+VersionScriptParser::ErrorHandler::~ErrorHandler() {}
-bool VersionScriptParser::ParseSymbolLine(const std::string &line) {
- // The symbol lies before the ';' and the tags are after ';'
- std::string::size_type pos = line.find(";");
- if (pos == std::string::npos) {
- llvm::errs() << "Couldn't find end of symbol" << line <<"\n";
- return false;
- }
- std::string symbol = line.substr(0, pos);
- std::string::size_type last_space = symbol.find_last_of(' ');
- symbol = symbol.substr(last_space + 1, pos);
- std::string tags = line.substr(pos + 1);
- if (SymbolExported(tags, arch_, api_)) {
- if (StringContains(tags, "var")) {
- AddToVars(symbol);
- } else {
- AddToFunctions(symbol);
- }
- }
- return true;
-}
-
-typedef VersionScriptParser::LineScope LineScope;
-
-LineScope VersionScriptParser::GetLineScope(std::string &line,
- LineScope scope) {
- if (StringContains(line, "local:")) {
- scope = LineScope::local;
- }
- return scope;
-}
-
-bool VersionScriptParser::ParseInnerBlock(std::ifstream &symbol_ifstream) {
- std::string line = "";
- LineScope scope = LineScope::global;
-
- while (std::getline(symbol_ifstream, line)) {
- if (line.find("}") != std::string::npos) {
- break;
- }
- if (line.c_str()[0] == '#') {
- continue;
- }
- scope = GetLineScope(line, scope);
- if (scope != LineScope::global || StringContains(line, "global:")) {
- continue;
- }
- ParseSymbolLine(line);
- }
- return true;
-}
-
-const std::map<std::string, ElfFunctionIR> &
-VersionScriptParser::GetFunctions() {
- return functions_;
-}
-
-const std::map<std::string, ElfObjectIR> &VersionScriptParser::GetGlobVars() {
- return globvars_;
-}
-
-const std::set<std::string> &VersionScriptParser::GetFunctionRegexs() {
- return function_regexs_;
-}
-
-const std::set<std::string> &VersionScriptParser::GetGlobVarRegexs() {
- return globvar_regexs_;
-}
-
-bool VersionScriptParser::Parse() {
- std::ifstream symbol_ifstream(version_script_);
- if (!symbol_ifstream.is_open()) {
- llvm::errs() << "Failed to open version script file\n";
- return false;
- }
-
- std::string line;
- while (std::getline(symbol_ifstream, line)) {
- // Skip comment lines.
- if (line.c_str()[0] == '#') {
- continue;
- }
- if (StringContains(line, "{")) {
- if ((StringContains(line, "PRIVATE"))) {
- continue;
- }
- ParseInnerBlock(symbol_ifstream);
- }
- }
-
- return true;
-}
} // namespace abi_util
diff --git a/vndk/tools/header-checker/header-abi-util/src/version_script_parser_test.cpp b/vndk/tools/header-checker/header-abi-util/src/version_script_parser_test.cpp
new file mode 100644
index 0000000..c84f19d
--- /dev/null
+++ b/vndk/tools/header-checker/header-abi-util/src/version_script_parser_test.cpp
@@ -0,0 +1,430 @@
+// Copyright (C) 2019 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.
+
+#include "version_script_parser.h"
+
+#include <gtest/gtest.h>
+
+#include <map>
+#include <sstream>
+#include <string>
+
+
+namespace abi_util {
+
+
+TEST(VersionScriptParserTest, SmokeTest) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ foo1;
+ bar1; # var
+ local:
+ *;
+ };
+
+ LIBEX_2.0 {
+ global:
+ foo2;
+ bar2; # var
+ } LIBEX_1.0;
+ )TESTDATA";
+
+ VersionScriptParser parser;
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+ EXPECT_NE(funcs.end(), funcs.find("foo1"));
+ EXPECT_NE(funcs.end(), funcs.find("foo2"));
+ EXPECT_EQ(funcs.end(), funcs.find("bar1"));
+ EXPECT_EQ(funcs.end(), funcs.find("bar2"));
+
+ const ExportedSymbolSet::VarMap &vars = result->GetVars();
+ EXPECT_NE(vars.end(), vars.find("bar1"));
+ EXPECT_NE(vars.end(), vars.find("bar2"));
+ EXPECT_EQ(vars.end(), vars.find("foo1"));
+ EXPECT_EQ(vars.end(), vars.find("foo2"));
+}
+
+
+TEST(VersionScriptParserTest, ExcludeSymbolVersions) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ foo1;
+ bar1; # var
+ local:
+ *;
+ };
+
+ LIBEX_PRIVATE {
+ global:
+ foo2;
+ bar2; # var
+ } LIBEX_1.0;
+ )TESTDATA";
+
+ // excluded_symbol_versions = {}
+ {
+ VersionScriptParser parser;
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+ EXPECT_NE(funcs.end(), funcs.find("foo2"));
+
+ const ExportedSymbolSet::VarMap &vars = result->GetVars();
+ EXPECT_NE(vars.end(), vars.find("bar2"));
+ }
+
+ // excluded_symbol_versions = {"LIBEX_PRIVATE"}
+ {
+ VersionScriptParser parser;
+ parser.AddExcludedSymbolVersion("LIBEX_PRIVATE");
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+ EXPECT_EQ(funcs.end(), funcs.find("foo2"));
+
+ const ExportedSymbolSet::VarMap &vars = result->GetVars();
+ EXPECT_EQ(vars.end(), vars.find("bar2"));
+ }
+}
+
+
+TEST(VersionScriptParserTest, VisibilityLabels) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ global_f1;
+ global_v1; # var
+ local:
+ local_f2;
+ local_v2; # var
+ global:
+ global_f3;
+ global_v3; # var
+ global:
+ global_f4;
+ global_v4; # var
+ local:
+ local_f5;
+ local_v5; # var
+ local:
+ local_f6;
+ local_v6; # var
+ };
+ )TESTDATA";
+
+ VersionScriptParser parser;
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("global_f1"));
+ EXPECT_NE(funcs.end(), funcs.find("global_f3"));
+ EXPECT_NE(funcs.end(), funcs.find("global_f4"));
+
+ EXPECT_EQ(funcs.end(), funcs.find("local_f2"));
+ EXPECT_EQ(funcs.end(), funcs.find("local_f5"));
+ EXPECT_EQ(funcs.end(), funcs.find("local_f6"));
+
+ const ExportedSymbolSet::VarMap &vars = result->GetVars();
+
+ EXPECT_NE(vars.end(), vars.find("global_v1"));
+ EXPECT_NE(vars.end(), vars.find("global_v3"));
+ EXPECT_NE(vars.end(), vars.find("global_v4"));
+
+ EXPECT_EQ(vars.end(), vars.find("local_v2"));
+ EXPECT_EQ(vars.end(), vars.find("local_v5"));
+ EXPECT_EQ(vars.end(), vars.find("local_v6"));
+}
+
+
+TEST(VersionScriptParserTest, ParseSymbolTagsIntroduced) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ test1; # introduced=19
+ test2; # introduced=19 introduced-arm64=20
+ test3; # introduced-arm64=20 introduced=19
+ test4; # future
+ };
+ )TESTDATA";
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm64");
+ parser.SetApiLevel(18);
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_EQ(funcs.end(), funcs.find("test1"));
+ EXPECT_EQ(funcs.end(), funcs.find("test2"));
+ EXPECT_EQ(funcs.end(), funcs.find("test3"));
+ EXPECT_EQ(funcs.end(), funcs.find("test4"));
+ }
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm64");
+ parser.SetApiLevel(19);
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_EQ(funcs.end(), funcs.find("test2"));
+ EXPECT_EQ(funcs.end(), funcs.find("test3"));
+ EXPECT_EQ(funcs.end(), funcs.find("test4"));
+ }
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm");
+ parser.SetApiLevel(19);
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_NE(funcs.end(), funcs.find("test2"));
+ EXPECT_NE(funcs.end(), funcs.find("test3"));
+ EXPECT_EQ(funcs.end(), funcs.find("test4"));
+ }
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm64");
+ parser.SetApiLevel(20);
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_NE(funcs.end(), funcs.find("test2"));
+ EXPECT_NE(funcs.end(), funcs.find("test3"));
+ EXPECT_EQ(funcs.end(), funcs.find("test4"));
+ }
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm64");
+ parser.SetApiLevel(FUTURE_API_LEVEL);
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_NE(funcs.end(), funcs.find("test2"));
+ EXPECT_NE(funcs.end(), funcs.find("test3"));
+ EXPECT_NE(funcs.end(), funcs.find("test4"));
+ }
+}
+
+
+TEST(VersionScriptParserTest, ParseSymbolTagsArch) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ test1;
+ test2; # arm arm64
+ test3; # arm64
+ test4; # mips
+ };
+ )TESTDATA";
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm");
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_NE(funcs.end(), funcs.find("test2"));
+ EXPECT_EQ(funcs.end(), funcs.find("test3"));
+ EXPECT_EQ(funcs.end(), funcs.find("test4"));
+ }
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("arm64");
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_NE(funcs.end(), funcs.find("test2"));
+ EXPECT_NE(funcs.end(), funcs.find("test3"));
+ EXPECT_EQ(funcs.end(), funcs.find("test4"));
+ }
+
+ {
+ VersionScriptParser parser;
+ parser.SetArch("mips");
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_EQ(funcs.end(), funcs.find("test2"));
+ EXPECT_EQ(funcs.end(), funcs.find("test3"));
+ EXPECT_NE(funcs.end(), funcs.find("test4"));
+ }
+}
+
+
+TEST(VersionScriptParserTest, ExcludeSymbolTags) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ test1;
+ test2; # exclude-tag
+ };
+ )TESTDATA";
+
+ // exclude_symbol_tags = {}
+ {
+ VersionScriptParser parser;
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_NE(funcs.end(), funcs.find("test2"));
+ }
+
+ // exclude_symbol_tags = {"exclude-tag"}
+ {
+ VersionScriptParser parser;
+ parser.AddExcludedSymbolTag("exclude-tag");
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::FunctionMap &funcs = result->GetFunctions();
+
+ EXPECT_NE(funcs.end(), funcs.find("test1"));
+ EXPECT_EQ(funcs.end(), funcs.find("test2"));
+ }
+}
+
+
+TEST(VersionScriptParserTest, ParseExternCpp) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ test1;
+ extern "C++" {
+ Test2::test();
+ Test3::test();
+ Test4::*;
+ };
+ test5;
+ };
+ )TESTDATA";
+
+ VersionScriptParser parser;
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::NameSet &cpp_symbols =
+ result->GetDemangledCppSymbols();
+
+ EXPECT_NE(cpp_symbols.end(), cpp_symbols.find("Test2::test()"));
+ EXPECT_NE(cpp_symbols.end(), cpp_symbols.find("Test3::test()"));
+
+ EXPECT_EQ(cpp_symbols.end(), cpp_symbols.find("test1"));
+ EXPECT_EQ(cpp_symbols.end(), cpp_symbols.find("test4"));
+
+ const ExportedSymbolSet::GlobPatternSet &cpp_glob_patterns =
+ result->GetDemangledCppGlobPatterns();
+
+ EXPECT_NE(cpp_glob_patterns.end(), cpp_glob_patterns.find("Test4::*"));
+}
+
+
+TEST(VersionScriptParserTest, ParseGlobPattern) {
+ static const char testdata[] = R"TESTDATA(
+ LIBEX_1.0 {
+ global:
+ test1*;
+ test2[Aa];
+ test3?;
+ test4;
+ };
+ )TESTDATA";
+
+
+ VersionScriptParser parser;
+
+ std::istringstream stream(testdata);
+ std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
+ ASSERT_TRUE(result);
+
+ const ExportedSymbolSet::GlobPatternSet &glob_patterns =
+ result->GetGlobPatterns();
+
+ EXPECT_NE(glob_patterns.end(), glob_patterns.find("test1*"));
+ EXPECT_NE(glob_patterns.end(), glob_patterns.find("test2[Aa]"));
+ EXPECT_NE(glob_patterns.end(), glob_patterns.find("test3?"));
+
+ EXPECT_EQ(glob_patterns.end(), glob_patterns.find("test4"));
+}
+
+
+} // namespace abi_util
diff --git a/vndk/tools/header-checker/tests/gen_all.py b/vndk/tools/header-checker/tests/gen_all.py
index 9bb62e9..7b4f5d8 100755
--- a/vndk/tools/header-checker/tests/gen_all.py
+++ b/vndk/tools/header-checker/tests/gen_all.py
@@ -9,25 +9,18 @@
sys.path.insert(1, import_path)
from utils import run_header_abi_dumper
-from utils import copy_reference_dump_content
from module import Module
+from test import INPUT_DIR
+from test import EXPECTED_DIR
+from test import make_and_copy_reference_dumps
-SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
-INPUT_DIR = os.path.join(SCRIPT_DIR, 'input')
-EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected')
-REFERENCE_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps')
FILE_EXTENSIONS = ['h', 'hpp', 'hxx', 'cpp', 'cc', 'c']
-def make_and_copy_reference_dumps(module, default_cflags=[],
- reference_dump_dir=REFERENCE_DUMP_DIR):
- lsdump_content = module.make_dump(default_cflags)
- return copy_reference_dump_content(module.get_dump_name(), lsdump_content,
- reference_dump_dir, '', module.arch)
def main():
patt = re.compile(
- '^.*\\.(?:' + \
- '|'.join('(?:' + re.escape(ext) + ')' for ext in FILE_EXTENSIONS) + \
+ '^.*\\.(?:' +
+ '|'.join('(?:' + re.escape(ext) + ')' for ext in FILE_EXTENSIONS) +
')$')
input_dir_prefix_len = len(INPUT_DIR) + 1
for base, dirnames, filenames in os.walk(INPUT_DIR):
@@ -41,16 +34,17 @@
output_path = os.path.join(EXPECTED_DIR, input_rel_path)
print('generating', output_path, '...')
- output_content = run_header_abi_dumper(input_path, True)
+ output_content = run_header_abi_dumper(input_path)
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, 'w') as f:
f.write(output_content)
modules = Module.get_test_modules()
for module in modules:
- make_and_copy_reference_dumps(module)
+ print('Created abi dump at', make_and_copy_reference_dumps(module))
return 0
+
if __name__ == '__main__':
sys.exit(main())
diff --git a/vndk/tools/header-checker/tests/integration/version_script_example/Android.bp b/vndk/tools/header-checker/tests/integration/version_script_example/Android.bp
new file mode 100644
index 0000000..7228d3b
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/version_script_example/Android.bp
@@ -0,0 +1,23 @@
+//
+// Copyright (C) 2019 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.
+//
+
+cc_library {
+ name: "libversion_script_example",
+ srcs: [
+ "example.cpp",
+ ],
+ enabled: false,
+}
diff --git a/vndk/tools/header-checker/tests/integration/version_script_example/example.cpp b/vndk/tools/header-checker/tests/integration/version_script_example/example.cpp
new file mode 100644
index 0000000..5ada1f5
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/version_script_example/example.cpp
@@ -0,0 +1,6 @@
+#include "example.h"
+
+void test1() {}
+void test2() {}
+void Test3::test() {}
+void Test4::test() {}
diff --git a/vndk/tools/header-checker/tests/integration/version_script_example/example.h b/vndk/tools/header-checker/tests/integration/version_script_example/example.h
new file mode 100644
index 0000000..dd6079e
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/version_script_example/example.h
@@ -0,0 +1,12 @@
+extern "C" void test1();
+extern "C" void test2();
+
+class Test3 {
+ public:
+ void test();
+};
+
+class Test4 {
+ public:
+ void test();
+};
diff --git a/vndk/tools/header-checker/tests/integration/version_script_example/example.map.txt b/vndk/tools/header-checker/tests/integration/version_script_example/example.map.txt
new file mode 100644
index 0000000..24dd26d
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/version_script_example/example.map.txt
@@ -0,0 +1,17 @@
+LIBVERSION_SCRIPT_EXAMPLE_1.0 {
+ global:
+ test1; # mytag
+ extern "C++" {
+ Test3::*; # mytag
+ };
+ local:
+ *;
+};
+
+LIBVERSION_SCRIPT_EXAMPLE_PRIVATE {
+ global:
+ test2;
+ extern "C++" {
+ Test4::*;
+ };
+} LIBVERSION_SCRIPT_EXAMPLE_1.0;
diff --git a/vndk/tools/header-checker/tests/integration/version_script_example/prebuilts/libversion_script_example.so b/vndk/tools/header-checker/tests/integration/version_script_example/prebuilts/libversion_script_example.so
new file mode 100755
index 0000000..9a5cecd
--- /dev/null
+++ b/vndk/tools/header-checker/tests/integration/version_script_example/prebuilts/libversion_script_example.so
Binary files differ
diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py
index e25aa5c..3c28177 100755
--- a/vndk/tools/header-checker/tests/module.py
+++ b/vndk/tools/header-checker/tests/module.py
@@ -11,26 +11,25 @@
from utils import run_header_abi_dumper
from utils import run_header_abi_dumper_on_file
from utils import run_header_abi_linker
-from utils import TARGET_ARCHS
from utils import SOURCE_ABI_DUMP_EXT
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
-INPUT_DIR = os.path.join(SCRIPT_DIR, 'input')
-EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected')
-REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps')
ARCH_TARGET_CFLAGS = {
- 'arm': ['-target', 'arm-linux-androideabi'],
- 'arm64': ['-target', 'aarch64-linux-android'],
- 'x86': ['-target', 'i386-linux-androideabi'],
- 'x86_64': ['-target', 'x86_64-linux-android'],
- 'mips': ['-target', 'mips-linux-androideabi'],
- 'mips64': ['-target', 'mips64-linux-android'],
+ 'arm': ('-target', 'arm-linux-androideabi'),
+ 'arm64': ('-target', 'aarch64-linux-android'),
+ 'x86': ('-target', 'i386-linux-androideabi'),
+ 'x86_64': ('-target', 'x86_64-linux-android'),
+ 'mips': ('-target', 'mips-linux-androideabi'),
+ 'mips64': ('-target', 'mips64-linux-android'),
}
+TARGET_ARCHES = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64']
+
def relative_to_abs_path(relative_path):
return os.path.join(SCRIPT_DIR, relative_path)
+
def relative_to_abs_path_list(relative_path_list):
abs_paths = []
for relative_path in relative_path_list:
@@ -42,17 +41,16 @@
def __init__(self, name, arch, cflags, export_include_dirs):
self.name = name
self.arch = arch
- self.cflags = cflags
- self.arch_cflags = ['']
- if self.arch != '':
- self.arch_cflags = ARCH_TARGET_CFLAGS.get(self.arch)
- self.export_include_dirs = relative_to_abs_path_list(export_include_dirs)
+ self.cflags = tuple(cflags)
+ self.arch_cflags = ARCH_TARGET_CFLAGS.get(self.arch, tuple())
+ self.export_include_dirs = relative_to_abs_path_list(
+ export_include_dirs)
def get_dump_name(self):
"""Returns the module name followed by file extension."""
raise NotImplementedError()
- def make_dump(self, default_cflags):
+ def make_dump(self):
"""Returns the dump content as a string."""
raise NotImplementedError()
@@ -61,8 +59,10 @@
raise NotImplementedError()
def mutate_for_all_arches(self):
+ if self.arch:
+ return [self]
modules = []
- for target_arch in TARGET_ARCHS:
+ for target_arch in TARGET_ARCHES:
modules.append(self.mutate_for_arch(target_arch))
return modules
@@ -70,13 +70,12 @@
def get_test_modules():
modules = []
for module in TEST_MODULES.values():
- if module.arch == '':
- modules += module.mutate_for_all_arches()
+ modules += module.mutate_for_all_arches()
return modules
@staticmethod
- def get_test_module_by_name(name):
- return TEST_MODULES.get(name)
+ def get_test_modules_by_name(name):
+ return TEST_MODULES.get(name).mutate_for_all_arches()
class SdumpModule(Module):
@@ -90,9 +89,9 @@
def get_dump_name(self):
return self.name + '.sdump'
- def make_dump(self, default_cflags):
+ def make_dump(self):
return run_header_abi_dumper(
- self.src, remove_absolute_paths=True, cflags=self.cflags,
+ self.src, cflags=self.cflags,
export_include_dirs=self.export_include_dirs,
flags=self.dumper_flags)
@@ -102,8 +101,8 @@
class LsdumpModule(Module):
- def __init__(self, name, arch, srcs, version_script, cflags,
- export_include_dirs, api, dumper_flags=tuple(),
+ def __init__(self, name, srcs, version_script, export_include_dirs,
+ cflags=tuple(), arch='', api='current', dumper_flags=tuple(),
linker_flags=tuple()):
super(LsdumpModule, self).__init__(name, arch, cflags,
export_include_dirs)
@@ -116,28 +115,28 @@
def get_dump_name(self):
return self.name + SOURCE_ABI_DUMP_EXT
- def make_dump(self, default_cflags):
- """ For each source file, produce a .sdump file, and link them to form
- an lsump file"""
+ def make_dump(self):
+ """For each source file, produce a .sdump file, and link them to form
+ an lsump file."""
dumps_to_link = []
with tempfile.TemporaryDirectory() as tmp:
output_lsdump = os.path.join(tmp, self.get_dump_name())
for src in self.srcs:
- output_path = os.path.join(tmp, os.path.basename(src)) + '.sdump'
+ output_path = os.path.join(tmp,
+ os.path.basename(src) + '.sdump')
dumps_to_link.append(output_path)
run_header_abi_dumper_on_file(
src, output_path, self.export_include_dirs,
- self.cflags + self.arch_cflags + default_cflags,
+ self.cflags + self.arch_cflags,
self.dumper_flags)
return run_header_abi_linker(output_lsdump, dumps_to_link,
self.version_script, self.api,
self.arch, self.linker_flags)
def mutate_for_arch(self, target_arch):
- return LsdumpModule(self.name, target_arch, self.srcs,
- self.version_script, self.cflags,
- self.export_include_dirs, self.api,
- self.dumper_flags, self.linker_flags)
+ return LsdumpModule(self.name, self.srcs, self.version_script,
+ self.export_include_dirs, self.cflags, target_arch,
+ self.api, self.dumper_flags, self.linker_flags)
TEST_MODULES = [
@@ -159,9 +158,6 @@
],
version_script='integration/c_and_cpp/map.txt',
export_include_dirs=['integration/c_and_cpp/include'],
- cflags=[],
- arch='',
- api='current',
),
LsdumpModule(
name='libc_and_cpp_with_opaque_ptr_a',
@@ -172,8 +168,6 @@
version_script='integration/c_and_cpp/map.txt',
export_include_dirs=['integration/c_and_cpp/include'],
cflags=['-DOPAQUE_STRUCT_A=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libc_and_cpp_with_opaque_ptr_b',
@@ -184,8 +178,6 @@
version_script='integration/c_and_cpp/map.txt',
export_include_dirs=['integration/c_and_cpp/include'],
cflags=['-DOPAQUE_STRUCT_B=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libc_and_cpp_with_unused_struct',
@@ -196,8 +188,6 @@
version_script='integration/c_and_cpp/map.txt',
export_include_dirs=['integration/c_and_cpp/include'],
cflags=['-DINCLUDE_UNUSED_STRUCTS=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libc_and_cpp_with_unused_cstruct',
@@ -208,8 +198,6 @@
version_script='integration/c_and_cpp/map.txt',
export_include_dirs=['integration/c_and_cpp/include'],
cflags=['-DINCLUDE_UNUSED_STRUCTS=1', '-DMAKE_UNUSED_STRUCT_C=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp',
@@ -220,9 +208,6 @@
],
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
- cflags=[],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_odr',
@@ -234,8 +219,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DTEST_ODR'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_add_function',
@@ -247,8 +230,6 @@
version_script='integration/cpp/gold/map_add_function.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_ADD_FUNCTION=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_add_function_and_unexported_elf',
@@ -264,6 +245,16 @@
api='current',
),
LsdumpModule(
+ name='libgolden_cpp_add_function_sybmol_only',
+ srcs=[
+ 'integration/cpp/gold/golden_1.cpp',
+ 'integration/cpp/gold/high_volume_speaker.cpp',
+ 'integration/cpp/gold/low_volume_speaker.cpp',
+ ],
+ version_script='integration/cpp/gold/map_add_function.txt',
+ export_include_dirs=['integration/cpp/gold/include'],
+ ),
+ LsdumpModule(
name='libgolden_cpp_change_function_access',
srcs=[
'integration/cpp/gold/golden_1.cpp',
@@ -273,8 +264,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_CHANGE_FUNCTION_ACCESS=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_add_global_variable',
@@ -286,8 +275,6 @@
version_script='integration/cpp/gold/map_added_globvar.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_ADD_GLOBVAR=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_add_global_variable_private',
@@ -299,8 +286,6 @@
version_script='integration/cpp/gold/map_added_globvar.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_ADD_GLOBVAR=1', '-DGOLDEN_ADD_GLOBVAR_PRIVATE'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_return_type_diff',
@@ -312,8 +297,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_RETURN_TYPE_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_parameter_type_diff',
@@ -325,8 +308,6 @@
version_script='integration/cpp/gold/map_parameter_type_diff.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_PARAMETER_TYPE_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_vtable_diff',
@@ -338,8 +319,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_VTABLE_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_member_diff',
@@ -351,8 +330,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_MEMBER_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_member_fake_diff',
@@ -364,8 +341,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_MEMBER_FAKE_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_member_cv_diff',
@@ -377,8 +352,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_MEMBER_CV_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_change_member_access',
@@ -390,8 +363,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_CHANGE_MEMBER_ACCESS=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_member_integral_type_diff',
@@ -403,8 +374,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_MEMBER_INTEGRAL_TYPE_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_enum_diff',
@@ -416,8 +385,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_ENUM_DIFF=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_enum_extended',
@@ -429,8 +396,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_ENUM_EXTENSION=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_unreferenced_elf_symbol_removed',
@@ -441,18 +406,12 @@
],
version_script='integration/cpp/gold/map_elf_symbol_removed.txt',
export_include_dirs=['integration/cpp/gold/include'],
- cflags=[],
- arch='',
- api='current',
),
LsdumpModule(
name='libreproducability',
srcs=['integration/c_and_cpp/reproducability.c'],
version_script='integration/c_and_cpp/repro_map.txt',
export_include_dirs=['integration/c_and_cpp/include'],
- cflags=[],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_member_name_changed',
@@ -464,8 +423,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_function_pointer',
@@ -477,8 +434,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_FUNCTION_POINTER=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_function_pointer_parameter_added',
@@ -491,8 +446,6 @@
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_FUNCTION_POINTER_ADD_PARAM=1',
'-DGOLDEN_FUNCTION_POINTER=1'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_internal_public_struct',
@@ -505,8 +458,6 @@
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT',
'-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_internal_private_struct',
@@ -518,8 +469,6 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT'],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_inheritance_type_changed',
@@ -531,17 +480,12 @@
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
cflags=['-DGOLDEN_CHANGE_INHERITANCE_TYPE'],
- arch='',
- api='current',
),
LsdumpModule(
name='libpure_virtual_function',
srcs=['integration/cpp/pure_virtual/pure_virtual_function.cpp'],
export_include_dirs=['integration/cpp/pure_virtual/include'],
version_script='',
- cflags=[],
- arch='',
- api='current',
),
LsdumpModule(
name='libgolden_cpp_json',
@@ -552,12 +496,65 @@
],
version_script='integration/cpp/gold/map.txt',
export_include_dirs=['integration/cpp/gold/include'],
- cflags=[],
- arch='',
- api='current',
dumper_flags=['-output-format', 'Json'],
linker_flags=['-input-format', 'Json', '-output-format', 'Json']
),
+ LsdumpModule(
+ name='libversion_script_example',
+ arch='arm64',
+ srcs=[
+ 'integration/version_script_example/example.cpp',
+ ],
+ version_script='integration/version_script_example/example.map.txt',
+ export_include_dirs=['integration/version_script_example'],
+ dumper_flags=['-output-format', 'Json'],
+ linker_flags=[
+ '-input-format', 'Json',
+ '-output-format', 'Json',
+ '-so', relative_to_abs_path(
+ 'integration/version_script_example/prebuilts/' +
+ 'libversion_script_example.so'
+ ),
+ ]
+ ),
+ LsdumpModule(
+ name='libversion_script_example_no_private',
+ arch='arm64',
+ srcs=[
+ 'integration/version_script_example/example.cpp',
+ ],
+ version_script='integration/version_script_example/example.map.txt',
+ export_include_dirs=['integration/version_script_example'],
+ dumper_flags=['-output-format', 'Json'],
+ linker_flags=[
+ '-input-format', 'Json',
+ '-output-format', 'Json',
+ '-so', relative_to_abs_path(
+ 'integration/version_script_example/prebuilts/' +
+ 'libversion_script_example.so'
+ ),
+ '--exclude-symbol-version', 'LIBVERSION_SCRIPT_EXAMPLE_PRIVATE',
+ ]
+ ),
+ LsdumpModule(
+ name='libversion_script_example_no_mytag',
+ arch='arm64',
+ srcs=[
+ 'integration/version_script_example/example.cpp',
+ ],
+ version_script='integration/version_script_example/example.map.txt',
+ export_include_dirs=['integration/version_script_example'],
+ dumper_flags=['-output-format', 'Json'],
+ linker_flags=[
+ '-input-format', 'Json',
+ '-output-format', 'Json',
+ '-so', relative_to_abs_path(
+ 'integration/version_script_example/prebuilts/' +
+ 'libversion_script_example.so'
+ ),
+ '--exclude-symbol-tag', 'mytag',
+ ]
+ ),
]
TEST_MODULES = {m.name: m for m in TEST_MODULES}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_add_function_sybmol_only.so.lsdump
similarity index 73%
rename from vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
rename to vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_add_function_sybmol_only.so.lsdump
index d4d4ce7..bd1e283 100644
--- a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ b/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_add_function_sybmol_only.so.lsdump
@@ -1,14 +1,75 @@
record_types {
type_info {
+ name: "SuperSpeaker"
+ size: 8
+ alignment: 4
+ referenced_type: "type-1"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ linker_set_key: "SuperSpeaker"
+ self_type: "type-1"
+ }
+ fields {
+ referenced_type: "type-2"
+ field_offset: 32
+ field_name: "mSpeakderId"
+ access: private_access
+ }
+ vtable_layout {
+ vtable_components {
+ kind: OffsetToTop
+ mangled_component_name: ""
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: RTTI
+ mangled_component_name: "_ZTI12SuperSpeaker"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: CompleteDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD1Ev"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: DeletingDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD0Ev"
+ component_value: 0
+ is_pure: false
+ }
+ }
+ access: public_access
+ record_kind: class_kind
+ tag_info {
+ unique_id: "_ZTS12SuperSpeaker"
+ }
+}
+record_types {
+ type_info {
name: "HighVolumeSpeaker"
size: 8
alignment: 4
- referenced_type: "HighVolumeSpeaker"
+ referenced_type: "type-11"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
linker_set_key: "HighVolumeSpeaker"
+ self_type: "type-11"
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -17,31 +78,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI17HighVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -55,24 +122,25 @@
name: "LowVolumeSpeaker"
size: 16
alignment: 4
- referenced_type: "LowVolumeSpeaker"
+ referenced_type: "type-5"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "LowVolumeSpeaker"
+ self_type: "type-5"
}
fields {
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
field_offset: 64
field_name: "speaker_uint_t"
access: public_access
}
fields {
- referenced_type: "float *"
+ referenced_type: "type-7"
field_offset: 96
field_name: "speaker_float_star"
access: public_access
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -81,31 +149,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI16LowVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -114,84 +188,32 @@
unique_id: "_ZTS16LowVolumeSpeaker"
}
}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 8
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 32
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
enum_types {
type_info {
name: "SuperSpeaker::Volume"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker::Volume"
+ referenced_type: "type-8"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker::Volume"
+ self_type: "type-8"
}
- underlying_type: "unsigned int"
+ underlying_type: "type-6"
enum_fields {
enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
+ name: "SuperSpeaker::Loud"
}
enum_fields {
enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
+ name: "SuperSpeaker::Louder"
}
enum_fields {
enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
+ name: "SuperSpeaker::Loudest"
}
enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
+ enum_field_value: 0
+ name: "SuperSpeaker::Lower"
}
access: private_access
tag_info {
@@ -200,32 +222,24 @@
}
pointer_types {
type_info {
- name: "HighVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
name: "SuperSpeaker *"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker *"
+ self_type: "type-9"
+ }
+}
+pointer_types {
+ type_info {
+ name: "HighVolumeSpeaker *"
+ size: 4
+ alignment: 4
+ referenced_type: "type-11"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
+ linker_set_key: "HighVolumeSpeaker *"
+ self_type: "type-12"
}
}
pointer_types {
@@ -233,9 +247,21 @@
name: "float *"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "float *"
+ self_type: "type-7"
+ }
+}
+pointer_types {
+ type_info {
+ name: "LowVolumeSpeaker *"
+ size: 4
+ alignment: 4
+ referenced_type: "type-5"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
+ linker_set_key: "LowVolumeSpeaker *"
+ self_type: "type-4"
}
}
builtin_types {
@@ -243,9 +269,10 @@
name: "float"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: ""
linker_set_key: "float"
+ self_type: "type-3"
}
is_unsigned: false
is_integral: false
@@ -255,9 +282,10 @@
name: "int"
size: 4
alignment: 4
- referenced_type: "int"
+ referenced_type: "type-2"
source_file: ""
linker_set_key: "int"
+ self_type: "type-2"
}
is_unsigned: false
is_integral: true
@@ -267,9 +295,10 @@
name: "unsigned int"
size: 4
alignment: 4
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
source_file: ""
linker_set_key: "unsigned int"
+ self_type: "type-6"
}
is_unsigned: true
is_integral: true
@@ -279,127 +308,188 @@
name: "void"
size: 0
alignment: 0
- referenced_type: "void"
+ referenced_type: "type-10"
source_file: ""
linker_set_key: "void"
+ self_type: "type-10"
}
is_unsigned: false
is_integral: false
}
functions {
- return_type: "SuperSpeaker *"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::SpeakLouder"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeaker11SpeakLouderEv"
+ access: public_access
+}
+functions {
+ return_type: "type-9"
function_name: "SuperSpeaker::CreateSuperSpeaker"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "int"
+ referenced_type: "type-2"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
access: public_access
}
functions {
- return_type: "SuperSpeaker::Volume"
+ return_type: "type-8"
function_name: "SuperSpeaker::SpeakLoud"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "SuperSpeaker *"
+ referenced_type: "type-9"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::~SuperSpeaker"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeakerD2Ev"
+ access: public_access
+}
+functions {
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
access: public_access
}
functions {
- return_type: "HighVolumeSpeaker *"
+ return_type: "type-12"
function_name: "HighVolumeSpeaker::BadPractice"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
parameters {
- referenced_type: "float"
+ referenced_type: "type-3"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
access: public_access
}
elf_functions {
name: "_Z26test_virtual_function_callP12SuperSpeaker"
+ binding: Global
}
elf_functions {
name: "_ZN12NotReferenced"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker11SpeakLouderEv"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker9SpeakLoudEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN12SuperSpeakerD2Ev"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN16LowVolumeSpeakerD0Ev"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeaker13AddedFunctionEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeakerD0Ev"
+ binding: Global
}
elf_objects {
name: "_ZTV16LowVolumeSpeaker"
+ binding: Global
}
elf_objects {
name: "_ZTV17HighVolumeSpeaker"
+ binding: Global
}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_add_function_sybmol_only.so.lsdump
similarity index 73%
rename from vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
rename to vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_add_function_sybmol_only.so.lsdump
index c8dc7f9..7f2114f 100644
--- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_add_function_sybmol_only.so.lsdump
@@ -1,14 +1,75 @@
record_types {
type_info {
+ name: "SuperSpeaker"
+ size: 16
+ alignment: 8
+ referenced_type: "type-1"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ linker_set_key: "SuperSpeaker"
+ self_type: "type-1"
+ }
+ fields {
+ referenced_type: "type-2"
+ field_offset: 64
+ field_name: "mSpeakderId"
+ access: private_access
+ }
+ vtable_layout {
+ vtable_components {
+ kind: OffsetToTop
+ mangled_component_name: ""
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: RTTI
+ mangled_component_name: "_ZTI12SuperSpeaker"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: CompleteDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD1Ev"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: DeletingDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD0Ev"
+ component_value: 0
+ is_pure: false
+ }
+ }
+ access: public_access
+ record_kind: class_kind
+ tag_info {
+ unique_id: "_ZTS12SuperSpeaker"
+ }
+}
+record_types {
+ type_info {
name: "HighVolumeSpeaker"
size: 16
alignment: 8
- referenced_type: "HighVolumeSpeaker"
+ referenced_type: "type-11"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
linker_set_key: "HighVolumeSpeaker"
+ self_type: "type-11"
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -17,31 +78,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI17HighVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -55,24 +122,25 @@
name: "LowVolumeSpeaker"
size: 24
alignment: 8
- referenced_type: "LowVolumeSpeaker"
+ referenced_type: "type-5"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "LowVolumeSpeaker"
+ self_type: "type-5"
}
fields {
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
field_offset: 96
field_name: "speaker_uint_t"
access: public_access
}
fields {
- referenced_type: "float *"
+ referenced_type: "type-7"
field_offset: 128
field_name: "speaker_float_star"
access: public_access
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -81,31 +149,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI16LowVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -114,84 +188,32 @@
unique_id: "_ZTS16LowVolumeSpeaker"
}
}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 16
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 64
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
enum_types {
type_info {
name: "SuperSpeaker::Volume"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker::Volume"
+ referenced_type: "type-8"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker::Volume"
+ self_type: "type-8"
}
- underlying_type: "unsigned int"
+ underlying_type: "type-6"
enum_fields {
enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
+ name: "SuperSpeaker::Loud"
}
enum_fields {
enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
+ name: "SuperSpeaker::Louder"
}
enum_fields {
enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
+ name: "SuperSpeaker::Loudest"
}
enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
+ enum_field_value: 0
+ name: "SuperSpeaker::Lower"
}
access: private_access
tag_info {
@@ -200,32 +222,24 @@
}
pointer_types {
type_info {
- name: "HighVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
name: "SuperSpeaker *"
size: 8
alignment: 8
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker *"
+ self_type: "type-9"
+ }
+}
+pointer_types {
+ type_info {
+ name: "HighVolumeSpeaker *"
+ size: 8
+ alignment: 8
+ referenced_type: "type-11"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
+ linker_set_key: "HighVolumeSpeaker *"
+ self_type: "type-12"
}
}
pointer_types {
@@ -233,9 +247,21 @@
name: "float *"
size: 8
alignment: 8
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "float *"
+ self_type: "type-7"
+ }
+}
+pointer_types {
+ type_info {
+ name: "LowVolumeSpeaker *"
+ size: 8
+ alignment: 8
+ referenced_type: "type-5"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
+ linker_set_key: "LowVolumeSpeaker *"
+ self_type: "type-4"
}
}
builtin_types {
@@ -243,9 +269,10 @@
name: "float"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: ""
linker_set_key: "float"
+ self_type: "type-3"
}
is_unsigned: false
is_integral: false
@@ -255,9 +282,10 @@
name: "int"
size: 4
alignment: 4
- referenced_type: "int"
+ referenced_type: "type-2"
source_file: ""
linker_set_key: "int"
+ self_type: "type-2"
}
is_unsigned: false
is_integral: true
@@ -267,9 +295,10 @@
name: "unsigned int"
size: 4
alignment: 4
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
source_file: ""
linker_set_key: "unsigned int"
+ self_type: "type-6"
}
is_unsigned: true
is_integral: true
@@ -279,127 +308,188 @@
name: "void"
size: 0
alignment: 0
- referenced_type: "void"
+ referenced_type: "type-10"
source_file: ""
linker_set_key: "void"
+ self_type: "type-10"
}
is_unsigned: false
is_integral: false
}
functions {
- return_type: "SuperSpeaker *"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::SpeakLouder"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeaker11SpeakLouderEv"
+ access: public_access
+}
+functions {
+ return_type: "type-9"
function_name: "SuperSpeaker::CreateSuperSpeaker"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "int"
+ referenced_type: "type-2"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
access: public_access
}
functions {
- return_type: "SuperSpeaker::Volume"
+ return_type: "type-8"
function_name: "SuperSpeaker::SpeakLoud"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "SuperSpeaker *"
+ referenced_type: "type-9"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::~SuperSpeaker"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeakerD2Ev"
+ access: public_access
+}
+functions {
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
access: public_access
}
functions {
- return_type: "HighVolumeSpeaker *"
+ return_type: "type-12"
function_name: "HighVolumeSpeaker::BadPractice"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
parameters {
- referenced_type: "float"
+ referenced_type: "type-3"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
access: public_access
}
elf_functions {
name: "_Z26test_virtual_function_callP12SuperSpeaker"
+ binding: Global
}
elf_functions {
name: "_ZN12NotReferenced"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker11SpeakLouderEv"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker9SpeakLoudEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN12SuperSpeakerD2Ev"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN16LowVolumeSpeakerD0Ev"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeaker13AddedFunctionEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeakerD0Ev"
+ binding: Global
}
elf_objects {
name: "_ZTV16LowVolumeSpeaker"
+ binding: Global
}
elf_objects {
name: "_ZTV17HighVolumeSpeaker"
+ binding: Global
}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example.so.lsdump
new file mode 100644
index 0000000..3f8b02d
--- /dev/null
+++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example.so.lsdump
@@ -0,0 +1,121 @@
+{
+ "array_types" : [],
+ "builtin_types" :
+ [
+ {
+ "linker_set_key" : "void",
+ "name" : "void",
+ "referenced_type" : "type-1",
+ "self_type" : "type-1"
+ }
+ ],
+ "elf_functions" :
+ [
+ {
+ "name" : "_ZN5Test34testEv"
+ },
+ {
+ "name" : "_ZN5Test44testEv"
+ },
+ {
+ "name" : "test1"
+ },
+ {
+ "name" : "test2"
+ }
+ ],
+ "elf_objects" : [],
+ "enum_types" : [],
+ "function_types" : [],
+ "functions" :
+ [
+ {
+ "function_name" : "Test3::test",
+ "linker_set_key" : "_ZN5Test34testEv",
+ "parameters" :
+ [
+ {
+ "is_this_ptr" : true,
+ "referenced_type" : "type-3"
+ }
+ ],
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "function_name" : "Test4::test",
+ "linker_set_key" : "_ZN5Test44testEv",
+ "parameters" :
+ [
+ {
+ "is_this_ptr" : true,
+ "referenced_type" : "type-5"
+ }
+ ],
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "function_name" : "test1",
+ "linker_set_key" : "test1",
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "function_name" : "test2",
+ "linker_set_key" : "test2",
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ }
+ ],
+ "global_vars" : [],
+ "lvalue_reference_types" : [],
+ "pointer_types" :
+ [
+ {
+ "alignment" : 8,
+ "linker_set_key" : "Test3 *",
+ "name" : "Test3 *",
+ "referenced_type" : "type-2",
+ "self_type" : "type-3",
+ "size" : 8,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "alignment" : 8,
+ "linker_set_key" : "Test4 *",
+ "name" : "Test4 *",
+ "referenced_type" : "type-4",
+ "self_type" : "type-5",
+ "size" : 8,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ }
+ ],
+ "qualified_types" : [],
+ "record_types" :
+ [
+ {
+ "alignment" : 1,
+ "linker_set_key" : "Test3",
+ "name" : "Test3",
+ "record_kind" : "class",
+ "referenced_type" : "type-2",
+ "self_type" : "type-2",
+ "size" : 1,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h",
+ "unique_id" : "_ZTS5Test3"
+ },
+ {
+ "alignment" : 1,
+ "linker_set_key" : "Test4",
+ "name" : "Test4",
+ "record_kind" : "class",
+ "referenced_type" : "type-4",
+ "self_type" : "type-4",
+ "size" : 1,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h",
+ "unique_id" : "_ZTS5Test4"
+ }
+ ],
+ "rvalue_reference_types" : []
+}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example_no_mytag.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example_no_mytag.so.lsdump
new file mode 100644
index 0000000..f7c4559
--- /dev/null
+++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example_no_mytag.so.lsdump
@@ -0,0 +1,96 @@
+{
+ "array_types" : [],
+ "builtin_types" :
+ [
+ {
+ "linker_set_key" : "void",
+ "name" : "void",
+ "referenced_type" : "type-1",
+ "self_type" : "type-1"
+ }
+ ],
+ "elf_functions" :
+ [
+ {
+ "name" : "_ZN5Test44testEv"
+ },
+ {
+ "name" : "test2"
+ }
+ ],
+ "elf_objects" : [],
+ "enum_types" : [],
+ "function_types" : [],
+ "functions" :
+ [
+ {
+ "function_name" : "Test4::test",
+ "linker_set_key" : "_ZN5Test44testEv",
+ "parameters" :
+ [
+ {
+ "is_this_ptr" : true,
+ "referenced_type" : "type-5"
+ }
+ ],
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "function_name" : "test2",
+ "linker_set_key" : "test2",
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ }
+ ],
+ "global_vars" : [],
+ "lvalue_reference_types" : [],
+ "pointer_types" :
+ [
+ {
+ "alignment" : 8,
+ "linker_set_key" : "Test3 *",
+ "name" : "Test3 *",
+ "referenced_type" : "type-2",
+ "self_type" : "type-3",
+ "size" : 8,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "alignment" : 8,
+ "linker_set_key" : "Test4 *",
+ "name" : "Test4 *",
+ "referenced_type" : "type-4",
+ "self_type" : "type-5",
+ "size" : 8,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ }
+ ],
+ "qualified_types" : [],
+ "record_types" :
+ [
+ {
+ "alignment" : 1,
+ "linker_set_key" : "Test3",
+ "name" : "Test3",
+ "record_kind" : "class",
+ "referenced_type" : "type-2",
+ "self_type" : "type-2",
+ "size" : 1,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h",
+ "unique_id" : "_ZTS5Test3"
+ },
+ {
+ "alignment" : 1,
+ "linker_set_key" : "Test4",
+ "name" : "Test4",
+ "record_kind" : "class",
+ "referenced_type" : "type-4",
+ "self_type" : "type-4",
+ "size" : 1,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h",
+ "unique_id" : "_ZTS5Test4"
+ }
+ ],
+ "rvalue_reference_types" : []
+}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example_no_private.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example_no_private.so.lsdump
new file mode 100644
index 0000000..fcd69d8
--- /dev/null
+++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libversion_script_example_no_private.so.lsdump
@@ -0,0 +1,96 @@
+{
+ "array_types" : [],
+ "builtin_types" :
+ [
+ {
+ "linker_set_key" : "void",
+ "name" : "void",
+ "referenced_type" : "type-1",
+ "self_type" : "type-1"
+ }
+ ],
+ "elf_functions" :
+ [
+ {
+ "name" : "_ZN5Test34testEv"
+ },
+ {
+ "name" : "test1"
+ }
+ ],
+ "elf_objects" : [],
+ "enum_types" : [],
+ "function_types" : [],
+ "functions" :
+ [
+ {
+ "function_name" : "Test3::test",
+ "linker_set_key" : "_ZN5Test34testEv",
+ "parameters" :
+ [
+ {
+ "is_this_ptr" : true,
+ "referenced_type" : "type-3"
+ }
+ ],
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "function_name" : "test1",
+ "linker_set_key" : "test1",
+ "return_type" : "type-1",
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ }
+ ],
+ "global_vars" : [],
+ "lvalue_reference_types" : [],
+ "pointer_types" :
+ [
+ {
+ "alignment" : 8,
+ "linker_set_key" : "Test3 *",
+ "name" : "Test3 *",
+ "referenced_type" : "type-2",
+ "self_type" : "type-3",
+ "size" : 8,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ },
+ {
+ "alignment" : 8,
+ "linker_set_key" : "Test4 *",
+ "name" : "Test4 *",
+ "referenced_type" : "type-4",
+ "self_type" : "type-5",
+ "size" : 8,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h"
+ }
+ ],
+ "qualified_types" : [],
+ "record_types" :
+ [
+ {
+ "alignment" : 1,
+ "linker_set_key" : "Test3",
+ "name" : "Test3",
+ "record_kind" : "class",
+ "referenced_type" : "type-2",
+ "self_type" : "type-2",
+ "size" : 1,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h",
+ "unique_id" : "_ZTS5Test3"
+ },
+ {
+ "alignment" : 1,
+ "linker_set_key" : "Test4",
+ "name" : "Test4",
+ "record_kind" : "class",
+ "referenced_type" : "type-4",
+ "self_type" : "type-4",
+ "size" : 1,
+ "source_file" : "/development/vndk/tools/header-checker/tests/integration/version_script_example/example.h",
+ "unique_id" : "_ZTS5Test4"
+ }
+ ],
+ "rvalue_reference_types" : []
+}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_add_function_sybmol_only.so.lsdump
similarity index 73%
copy from vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
copy to vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_add_function_sybmol_only.so.lsdump
index d4d4ce7..bd1e283 100644
--- a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ b/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_add_function_sybmol_only.so.lsdump
@@ -1,14 +1,75 @@
record_types {
type_info {
+ name: "SuperSpeaker"
+ size: 8
+ alignment: 4
+ referenced_type: "type-1"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ linker_set_key: "SuperSpeaker"
+ self_type: "type-1"
+ }
+ fields {
+ referenced_type: "type-2"
+ field_offset: 32
+ field_name: "mSpeakderId"
+ access: private_access
+ }
+ vtable_layout {
+ vtable_components {
+ kind: OffsetToTop
+ mangled_component_name: ""
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: RTTI
+ mangled_component_name: "_ZTI12SuperSpeaker"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: CompleteDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD1Ev"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: DeletingDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD0Ev"
+ component_value: 0
+ is_pure: false
+ }
+ }
+ access: public_access
+ record_kind: class_kind
+ tag_info {
+ unique_id: "_ZTS12SuperSpeaker"
+ }
+}
+record_types {
+ type_info {
name: "HighVolumeSpeaker"
size: 8
alignment: 4
- referenced_type: "HighVolumeSpeaker"
+ referenced_type: "type-11"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
linker_set_key: "HighVolumeSpeaker"
+ self_type: "type-11"
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -17,31 +78,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI17HighVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -55,24 +122,25 @@
name: "LowVolumeSpeaker"
size: 16
alignment: 4
- referenced_type: "LowVolumeSpeaker"
+ referenced_type: "type-5"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "LowVolumeSpeaker"
+ self_type: "type-5"
}
fields {
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
field_offset: 64
field_name: "speaker_uint_t"
access: public_access
}
fields {
- referenced_type: "float *"
+ referenced_type: "type-7"
field_offset: 96
field_name: "speaker_float_star"
access: public_access
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -81,31 +149,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI16LowVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -114,84 +188,32 @@
unique_id: "_ZTS16LowVolumeSpeaker"
}
}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 8
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 32
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
enum_types {
type_info {
name: "SuperSpeaker::Volume"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker::Volume"
+ referenced_type: "type-8"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker::Volume"
+ self_type: "type-8"
}
- underlying_type: "unsigned int"
+ underlying_type: "type-6"
enum_fields {
enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
+ name: "SuperSpeaker::Loud"
}
enum_fields {
enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
+ name: "SuperSpeaker::Louder"
}
enum_fields {
enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
+ name: "SuperSpeaker::Loudest"
}
enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
+ enum_field_value: 0
+ name: "SuperSpeaker::Lower"
}
access: private_access
tag_info {
@@ -200,32 +222,24 @@
}
pointer_types {
type_info {
- name: "HighVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
name: "SuperSpeaker *"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker *"
+ self_type: "type-9"
+ }
+}
+pointer_types {
+ type_info {
+ name: "HighVolumeSpeaker *"
+ size: 4
+ alignment: 4
+ referenced_type: "type-11"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
+ linker_set_key: "HighVolumeSpeaker *"
+ self_type: "type-12"
}
}
pointer_types {
@@ -233,9 +247,21 @@
name: "float *"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "float *"
+ self_type: "type-7"
+ }
+}
+pointer_types {
+ type_info {
+ name: "LowVolumeSpeaker *"
+ size: 4
+ alignment: 4
+ referenced_type: "type-5"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
+ linker_set_key: "LowVolumeSpeaker *"
+ self_type: "type-4"
}
}
builtin_types {
@@ -243,9 +269,10 @@
name: "float"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: ""
linker_set_key: "float"
+ self_type: "type-3"
}
is_unsigned: false
is_integral: false
@@ -255,9 +282,10 @@
name: "int"
size: 4
alignment: 4
- referenced_type: "int"
+ referenced_type: "type-2"
source_file: ""
linker_set_key: "int"
+ self_type: "type-2"
}
is_unsigned: false
is_integral: true
@@ -267,9 +295,10 @@
name: "unsigned int"
size: 4
alignment: 4
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
source_file: ""
linker_set_key: "unsigned int"
+ self_type: "type-6"
}
is_unsigned: true
is_integral: true
@@ -279,127 +308,188 @@
name: "void"
size: 0
alignment: 0
- referenced_type: "void"
+ referenced_type: "type-10"
source_file: ""
linker_set_key: "void"
+ self_type: "type-10"
}
is_unsigned: false
is_integral: false
}
functions {
- return_type: "SuperSpeaker *"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::SpeakLouder"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeaker11SpeakLouderEv"
+ access: public_access
+}
+functions {
+ return_type: "type-9"
function_name: "SuperSpeaker::CreateSuperSpeaker"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "int"
+ referenced_type: "type-2"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
access: public_access
}
functions {
- return_type: "SuperSpeaker::Volume"
+ return_type: "type-8"
function_name: "SuperSpeaker::SpeakLoud"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "SuperSpeaker *"
+ referenced_type: "type-9"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::~SuperSpeaker"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeakerD2Ev"
+ access: public_access
+}
+functions {
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
access: public_access
}
functions {
- return_type: "HighVolumeSpeaker *"
+ return_type: "type-12"
function_name: "HighVolumeSpeaker::BadPractice"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
parameters {
- referenced_type: "float"
+ referenced_type: "type-3"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
access: public_access
}
elf_functions {
name: "_Z26test_virtual_function_callP12SuperSpeaker"
+ binding: Global
}
elf_functions {
name: "_ZN12NotReferenced"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker11SpeakLouderEv"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker9SpeakLoudEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN12SuperSpeakerD2Ev"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN16LowVolumeSpeakerD0Ev"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeaker13AddedFunctionEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeakerD0Ev"
+ binding: Global
}
elf_objects {
name: "_ZTV16LowVolumeSpeaker"
+ binding: Global
}
elf_objects {
name: "_ZTV17HighVolumeSpeaker"
+ binding: Global
}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
deleted file mode 100644
index d4d4ce7..0000000
--- a/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ /dev/null
@@ -1,405 +0,0 @@
-record_types {
- type_info {
- name: "HighVolumeSpeaker"
- size: 8
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker"
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI17HighVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS17HighVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "LowVolumeSpeaker"
- size: 16
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker"
- }
- fields {
- referenced_type: "unsigned int"
- field_offset: 64
- field_name: "speaker_uint_t"
- access: public_access
- }
- fields {
- referenced_type: "float *"
- field_offset: 96
- field_name: "speaker_float_star"
- access: public_access
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI16LowVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS16LowVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 8
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 32
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
-enum_types {
- type_info {
- name: "SuperSpeaker::Volume"
- size: 4
- alignment: 4
- referenced_type: "SuperSpeaker::Volume"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker::Volume"
- }
- underlying_type: "unsigned int"
- enum_fields {
- enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
- }
- enum_fields {
- enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
- }
- enum_fields {
- enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
- }
- enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
- }
- access: private_access
- tag_info {
- unique_id: "_ZTSN12SuperSpeaker6VolumeE"
- }
-}
-pointer_types {
- type_info {
- name: "HighVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "SuperSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "float *"
- size: 4
- alignment: 4
- referenced_type: "float"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "float *"
- }
-}
-builtin_types {
- type_info {
- name: "float"
- size: 4
- alignment: 4
- referenced_type: "float"
- source_file: ""
- linker_set_key: "float"
- }
- is_unsigned: false
- is_integral: false
-}
-builtin_types {
- type_info {
- name: "int"
- size: 4
- alignment: 4
- referenced_type: "int"
- source_file: ""
- linker_set_key: "int"
- }
- is_unsigned: false
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "unsigned int"
- size: 4
- alignment: 4
- referenced_type: "unsigned int"
- source_file: ""
- linker_set_key: "unsigned int"
- }
- is_unsigned: true
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "void"
- size: 0
- alignment: 0
- referenced_type: "void"
- source_file: ""
- linker_set_key: "void"
- }
- is_unsigned: false
- is_integral: false
-}
-functions {
- return_type: "SuperSpeaker *"
- function_name: "SuperSpeaker::CreateSuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "int"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
- access: public_access
-}
-functions {
- return_type: "SuperSpeaker::Volume"
- function_name: "SuperSpeaker::SpeakLoud"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "SuperSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
- access: public_access
-}
-functions {
- return_type: "HighVolumeSpeaker *"
- function_name: "HighVolumeSpeaker::BadPractice"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- parameters {
- referenced_type: "float"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
- access: public_access
-}
-elf_functions {
- name: "_Z26test_virtual_function_callP12SuperSpeaker"
-}
-elf_functions {
- name: "_ZN12NotReferenced"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker11SpeakLouderEv"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker9SpeakLoudEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker6ListenEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker6ListenEv"
-}
-elf_objects {
- name: "_ZTV16LowVolumeSpeaker"
-}
-elf_objects {
- name: "_ZTV17HighVolumeSpeaker"
-}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_add_function_sybmol_only.so.lsdump
similarity index 73%
copy from vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
copy to vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_add_function_sybmol_only.so.lsdump
index c8dc7f9..7f2114f 100644
--- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ b/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_add_function_sybmol_only.so.lsdump
@@ -1,14 +1,75 @@
record_types {
type_info {
+ name: "SuperSpeaker"
+ size: 16
+ alignment: 8
+ referenced_type: "type-1"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ linker_set_key: "SuperSpeaker"
+ self_type: "type-1"
+ }
+ fields {
+ referenced_type: "type-2"
+ field_offset: 64
+ field_name: "mSpeakderId"
+ access: private_access
+ }
+ vtable_layout {
+ vtable_components {
+ kind: OffsetToTop
+ mangled_component_name: ""
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: RTTI
+ mangled_component_name: "_ZTI12SuperSpeaker"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: CompleteDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD1Ev"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: DeletingDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD0Ev"
+ component_value: 0
+ is_pure: false
+ }
+ }
+ access: public_access
+ record_kind: class_kind
+ tag_info {
+ unique_id: "_ZTS12SuperSpeaker"
+ }
+}
+record_types {
+ type_info {
name: "HighVolumeSpeaker"
size: 16
alignment: 8
- referenced_type: "HighVolumeSpeaker"
+ referenced_type: "type-11"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
linker_set_key: "HighVolumeSpeaker"
+ self_type: "type-11"
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -17,31 +78,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI17HighVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -55,24 +122,25 @@
name: "LowVolumeSpeaker"
size: 24
alignment: 8
- referenced_type: "LowVolumeSpeaker"
+ referenced_type: "type-5"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "LowVolumeSpeaker"
+ self_type: "type-5"
}
fields {
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
field_offset: 96
field_name: "speaker_uint_t"
access: public_access
}
fields {
- referenced_type: "float *"
+ referenced_type: "type-7"
field_offset: 128
field_name: "speaker_float_star"
access: public_access
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -81,31 +149,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI16LowVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -114,84 +188,32 @@
unique_id: "_ZTS16LowVolumeSpeaker"
}
}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 16
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 64
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
enum_types {
type_info {
name: "SuperSpeaker::Volume"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker::Volume"
+ referenced_type: "type-8"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker::Volume"
+ self_type: "type-8"
}
- underlying_type: "unsigned int"
+ underlying_type: "type-6"
enum_fields {
enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
+ name: "SuperSpeaker::Loud"
}
enum_fields {
enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
+ name: "SuperSpeaker::Louder"
}
enum_fields {
enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
+ name: "SuperSpeaker::Loudest"
}
enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
+ enum_field_value: 0
+ name: "SuperSpeaker::Lower"
}
access: private_access
tag_info {
@@ -200,32 +222,24 @@
}
pointer_types {
type_info {
- name: "HighVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
name: "SuperSpeaker *"
size: 8
alignment: 8
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker *"
+ self_type: "type-9"
+ }
+}
+pointer_types {
+ type_info {
+ name: "HighVolumeSpeaker *"
+ size: 8
+ alignment: 8
+ referenced_type: "type-11"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
+ linker_set_key: "HighVolumeSpeaker *"
+ self_type: "type-12"
}
}
pointer_types {
@@ -233,9 +247,21 @@
name: "float *"
size: 8
alignment: 8
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "float *"
+ self_type: "type-7"
+ }
+}
+pointer_types {
+ type_info {
+ name: "LowVolumeSpeaker *"
+ size: 8
+ alignment: 8
+ referenced_type: "type-5"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
+ linker_set_key: "LowVolumeSpeaker *"
+ self_type: "type-4"
}
}
builtin_types {
@@ -243,9 +269,10 @@
name: "float"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: ""
linker_set_key: "float"
+ self_type: "type-3"
}
is_unsigned: false
is_integral: false
@@ -255,9 +282,10 @@
name: "int"
size: 4
alignment: 4
- referenced_type: "int"
+ referenced_type: "type-2"
source_file: ""
linker_set_key: "int"
+ self_type: "type-2"
}
is_unsigned: false
is_integral: true
@@ -267,9 +295,10 @@
name: "unsigned int"
size: 4
alignment: 4
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
source_file: ""
linker_set_key: "unsigned int"
+ self_type: "type-6"
}
is_unsigned: true
is_integral: true
@@ -279,127 +308,188 @@
name: "void"
size: 0
alignment: 0
- referenced_type: "void"
+ referenced_type: "type-10"
source_file: ""
linker_set_key: "void"
+ self_type: "type-10"
}
is_unsigned: false
is_integral: false
}
functions {
- return_type: "SuperSpeaker *"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::SpeakLouder"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeaker11SpeakLouderEv"
+ access: public_access
+}
+functions {
+ return_type: "type-9"
function_name: "SuperSpeaker::CreateSuperSpeaker"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "int"
+ referenced_type: "type-2"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
access: public_access
}
functions {
- return_type: "SuperSpeaker::Volume"
+ return_type: "type-8"
function_name: "SuperSpeaker::SpeakLoud"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "SuperSpeaker *"
+ referenced_type: "type-9"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::~SuperSpeaker"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeakerD2Ev"
+ access: public_access
+}
+functions {
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
access: public_access
}
functions {
- return_type: "HighVolumeSpeaker *"
+ return_type: "type-12"
function_name: "HighVolumeSpeaker::BadPractice"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
parameters {
- referenced_type: "float"
+ referenced_type: "type-3"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
access: public_access
}
elf_functions {
name: "_Z26test_virtual_function_callP12SuperSpeaker"
+ binding: Global
}
elf_functions {
name: "_ZN12NotReferenced"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker11SpeakLouderEv"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker9SpeakLoudEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN12SuperSpeakerD2Ev"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN16LowVolumeSpeakerD0Ev"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeaker13AddedFunctionEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeakerD0Ev"
+ binding: Global
}
elf_objects {
name: "_ZTV16LowVolumeSpeaker"
+ binding: Global
}
elf_objects {
name: "_ZTV17HighVolumeSpeaker"
+ binding: Global
}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
deleted file mode 100644
index c8dc7f9..0000000
--- a/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ /dev/null
@@ -1,405 +0,0 @@
-record_types {
- type_info {
- name: "HighVolumeSpeaker"
- size: 16
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker"
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI17HighVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS17HighVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "LowVolumeSpeaker"
- size: 24
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker"
- }
- fields {
- referenced_type: "unsigned int"
- field_offset: 96
- field_name: "speaker_uint_t"
- access: public_access
- }
- fields {
- referenced_type: "float *"
- field_offset: 128
- field_name: "speaker_float_star"
- access: public_access
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI16LowVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS16LowVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 16
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 64
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
-enum_types {
- type_info {
- name: "SuperSpeaker::Volume"
- size: 4
- alignment: 4
- referenced_type: "SuperSpeaker::Volume"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker::Volume"
- }
- underlying_type: "unsigned int"
- enum_fields {
- enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
- }
- enum_fields {
- enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
- }
- enum_fields {
- enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
- }
- enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
- }
- access: private_access
- tag_info {
- unique_id: "_ZTSN12SuperSpeaker6VolumeE"
- }
-}
-pointer_types {
- type_info {
- name: "HighVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "SuperSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "float *"
- size: 8
- alignment: 8
- referenced_type: "float"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "float *"
- }
-}
-builtin_types {
- type_info {
- name: "float"
- size: 4
- alignment: 4
- referenced_type: "float"
- source_file: ""
- linker_set_key: "float"
- }
- is_unsigned: false
- is_integral: false
-}
-builtin_types {
- type_info {
- name: "int"
- size: 4
- alignment: 4
- referenced_type: "int"
- source_file: ""
- linker_set_key: "int"
- }
- is_unsigned: false
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "unsigned int"
- size: 4
- alignment: 4
- referenced_type: "unsigned int"
- source_file: ""
- linker_set_key: "unsigned int"
- }
- is_unsigned: true
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "void"
- size: 0
- alignment: 0
- referenced_type: "void"
- source_file: ""
- linker_set_key: "void"
- }
- is_unsigned: false
- is_integral: false
-}
-functions {
- return_type: "SuperSpeaker *"
- function_name: "SuperSpeaker::CreateSuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "int"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
- access: public_access
-}
-functions {
- return_type: "SuperSpeaker::Volume"
- function_name: "SuperSpeaker::SpeakLoud"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "SuperSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
- access: public_access
-}
-functions {
- return_type: "HighVolumeSpeaker *"
- function_name: "HighVolumeSpeaker::BadPractice"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- parameters {
- referenced_type: "float"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
- access: public_access
-}
-elf_functions {
- name: "_Z26test_virtual_function_callP12SuperSpeaker"
-}
-elf_functions {
- name: "_ZN12NotReferenced"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker11SpeakLouderEv"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker9SpeakLoudEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker6ListenEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker6ListenEv"
-}
-elf_objects {
- name: "_ZTV16LowVolumeSpeaker"
-}
-elf_objects {
- name: "_ZTV17HighVolumeSpeaker"
-}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_add_function_sybmol_only.so.lsdump
similarity index 73%
copy from vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
copy to vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_add_function_sybmol_only.so.lsdump
index d4d4ce7..bd1e283 100644
--- a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ b/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_add_function_sybmol_only.so.lsdump
@@ -1,14 +1,75 @@
record_types {
type_info {
+ name: "SuperSpeaker"
+ size: 8
+ alignment: 4
+ referenced_type: "type-1"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ linker_set_key: "SuperSpeaker"
+ self_type: "type-1"
+ }
+ fields {
+ referenced_type: "type-2"
+ field_offset: 32
+ field_name: "mSpeakderId"
+ access: private_access
+ }
+ vtable_layout {
+ vtable_components {
+ kind: OffsetToTop
+ mangled_component_name: ""
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: RTTI
+ mangled_component_name: "_ZTI12SuperSpeaker"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: CompleteDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD1Ev"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: DeletingDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD0Ev"
+ component_value: 0
+ is_pure: false
+ }
+ }
+ access: public_access
+ record_kind: class_kind
+ tag_info {
+ unique_id: "_ZTS12SuperSpeaker"
+ }
+}
+record_types {
+ type_info {
name: "HighVolumeSpeaker"
size: 8
alignment: 4
- referenced_type: "HighVolumeSpeaker"
+ referenced_type: "type-11"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
linker_set_key: "HighVolumeSpeaker"
+ self_type: "type-11"
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -17,31 +78,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI17HighVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -55,24 +122,25 @@
name: "LowVolumeSpeaker"
size: 16
alignment: 4
- referenced_type: "LowVolumeSpeaker"
+ referenced_type: "type-5"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "LowVolumeSpeaker"
+ self_type: "type-5"
}
fields {
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
field_offset: 64
field_name: "speaker_uint_t"
access: public_access
}
fields {
- referenced_type: "float *"
+ referenced_type: "type-7"
field_offset: 96
field_name: "speaker_float_star"
access: public_access
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -81,31 +149,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI16LowVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -114,84 +188,32 @@
unique_id: "_ZTS16LowVolumeSpeaker"
}
}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 8
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 32
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
enum_types {
type_info {
name: "SuperSpeaker::Volume"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker::Volume"
+ referenced_type: "type-8"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker::Volume"
+ self_type: "type-8"
}
- underlying_type: "unsigned int"
+ underlying_type: "type-6"
enum_fields {
enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
+ name: "SuperSpeaker::Loud"
}
enum_fields {
enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
+ name: "SuperSpeaker::Louder"
}
enum_fields {
enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
+ name: "SuperSpeaker::Loudest"
}
enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
+ enum_field_value: 0
+ name: "SuperSpeaker::Lower"
}
access: private_access
tag_info {
@@ -200,32 +222,24 @@
}
pointer_types {
type_info {
- name: "HighVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
name: "SuperSpeaker *"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker *"
+ self_type: "type-9"
+ }
+}
+pointer_types {
+ type_info {
+ name: "HighVolumeSpeaker *"
+ size: 4
+ alignment: 4
+ referenced_type: "type-11"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
+ linker_set_key: "HighVolumeSpeaker *"
+ self_type: "type-12"
}
}
pointer_types {
@@ -233,9 +247,21 @@
name: "float *"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "float *"
+ self_type: "type-7"
+ }
+}
+pointer_types {
+ type_info {
+ name: "LowVolumeSpeaker *"
+ size: 4
+ alignment: 4
+ referenced_type: "type-5"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
+ linker_set_key: "LowVolumeSpeaker *"
+ self_type: "type-4"
}
}
builtin_types {
@@ -243,9 +269,10 @@
name: "float"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: ""
linker_set_key: "float"
+ self_type: "type-3"
}
is_unsigned: false
is_integral: false
@@ -255,9 +282,10 @@
name: "int"
size: 4
alignment: 4
- referenced_type: "int"
+ referenced_type: "type-2"
source_file: ""
linker_set_key: "int"
+ self_type: "type-2"
}
is_unsigned: false
is_integral: true
@@ -267,9 +295,10 @@
name: "unsigned int"
size: 4
alignment: 4
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
source_file: ""
linker_set_key: "unsigned int"
+ self_type: "type-6"
}
is_unsigned: true
is_integral: true
@@ -279,127 +308,188 @@
name: "void"
size: 0
alignment: 0
- referenced_type: "void"
+ referenced_type: "type-10"
source_file: ""
linker_set_key: "void"
+ self_type: "type-10"
}
is_unsigned: false
is_integral: false
}
functions {
- return_type: "SuperSpeaker *"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::SpeakLouder"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeaker11SpeakLouderEv"
+ access: public_access
+}
+functions {
+ return_type: "type-9"
function_name: "SuperSpeaker::CreateSuperSpeaker"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "int"
+ referenced_type: "type-2"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
access: public_access
}
functions {
- return_type: "SuperSpeaker::Volume"
+ return_type: "type-8"
function_name: "SuperSpeaker::SpeakLoud"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "SuperSpeaker *"
+ referenced_type: "type-9"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::~SuperSpeaker"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeakerD2Ev"
+ access: public_access
+}
+functions {
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
access: public_access
}
functions {
- return_type: "HighVolumeSpeaker *"
+ return_type: "type-12"
function_name: "HighVolumeSpeaker::BadPractice"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
parameters {
- referenced_type: "float"
+ referenced_type: "type-3"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
access: public_access
}
elf_functions {
name: "_Z26test_virtual_function_callP12SuperSpeaker"
+ binding: Global
}
elf_functions {
name: "_ZN12NotReferenced"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker11SpeakLouderEv"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker9SpeakLoudEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN12SuperSpeakerD2Ev"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN16LowVolumeSpeakerD0Ev"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeaker13AddedFunctionEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeakerD0Ev"
+ binding: Global
}
elf_objects {
name: "_ZTV16LowVolumeSpeaker"
+ binding: Global
}
elf_objects {
name: "_ZTV17HighVolumeSpeaker"
+ binding: Global
}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
deleted file mode 100644
index d4d4ce7..0000000
--- a/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ /dev/null
@@ -1,405 +0,0 @@
-record_types {
- type_info {
- name: "HighVolumeSpeaker"
- size: 8
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker"
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI17HighVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS17HighVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "LowVolumeSpeaker"
- size: 16
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker"
- }
- fields {
- referenced_type: "unsigned int"
- field_offset: 64
- field_name: "speaker_uint_t"
- access: public_access
- }
- fields {
- referenced_type: "float *"
- field_offset: 96
- field_name: "speaker_float_star"
- access: public_access
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI16LowVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS16LowVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 8
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 32
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
-enum_types {
- type_info {
- name: "SuperSpeaker::Volume"
- size: 4
- alignment: 4
- referenced_type: "SuperSpeaker::Volume"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker::Volume"
- }
- underlying_type: "unsigned int"
- enum_fields {
- enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
- }
- enum_fields {
- enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
- }
- enum_fields {
- enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
- }
- enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
- }
- access: private_access
- tag_info {
- unique_id: "_ZTSN12SuperSpeaker6VolumeE"
- }
-}
-pointer_types {
- type_info {
- name: "HighVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "SuperSpeaker *"
- size: 4
- alignment: 4
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "float *"
- size: 4
- alignment: 4
- referenced_type: "float"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "float *"
- }
-}
-builtin_types {
- type_info {
- name: "float"
- size: 4
- alignment: 4
- referenced_type: "float"
- source_file: ""
- linker_set_key: "float"
- }
- is_unsigned: false
- is_integral: false
-}
-builtin_types {
- type_info {
- name: "int"
- size: 4
- alignment: 4
- referenced_type: "int"
- source_file: ""
- linker_set_key: "int"
- }
- is_unsigned: false
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "unsigned int"
- size: 4
- alignment: 4
- referenced_type: "unsigned int"
- source_file: ""
- linker_set_key: "unsigned int"
- }
- is_unsigned: true
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "void"
- size: 0
- alignment: 0
- referenced_type: "void"
- source_file: ""
- linker_set_key: "void"
- }
- is_unsigned: false
- is_integral: false
-}
-functions {
- return_type: "SuperSpeaker *"
- function_name: "SuperSpeaker::CreateSuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "int"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
- access: public_access
-}
-functions {
- return_type: "SuperSpeaker::Volume"
- function_name: "SuperSpeaker::SpeakLoud"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "SuperSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
- access: public_access
-}
-functions {
- return_type: "HighVolumeSpeaker *"
- function_name: "HighVolumeSpeaker::BadPractice"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- parameters {
- referenced_type: "float"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
- access: public_access
-}
-elf_functions {
- name: "_Z26test_virtual_function_callP12SuperSpeaker"
-}
-elf_functions {
- name: "_ZN12NotReferenced"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker11SpeakLouderEv"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker9SpeakLoudEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker6ListenEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker6ListenEv"
-}
-elf_objects {
- name: "_ZTV16LowVolumeSpeaker"
-}
-elf_objects {
- name: "_ZTV17HighVolumeSpeaker"
-}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_add_function_sybmol_only.so.lsdump
similarity index 73%
copy from vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
copy to vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_add_function_sybmol_only.so.lsdump
index c8dc7f9..7f2114f 100644
--- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_add_function_sybmol_only.so.lsdump
@@ -1,14 +1,75 @@
record_types {
type_info {
+ name: "SuperSpeaker"
+ size: 16
+ alignment: 8
+ referenced_type: "type-1"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ linker_set_key: "SuperSpeaker"
+ self_type: "type-1"
+ }
+ fields {
+ referenced_type: "type-2"
+ field_offset: 64
+ field_name: "mSpeakderId"
+ access: private_access
+ }
+ vtable_layout {
+ vtable_components {
+ kind: OffsetToTop
+ mangled_component_name: ""
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: RTTI
+ mangled_component_name: "_ZTI12SuperSpeaker"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: FunctionPointer
+ mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
+ component_value: 0
+ is_pure: true
+ }
+ vtable_components {
+ kind: CompleteDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD1Ev"
+ component_value: 0
+ is_pure: false
+ }
+ vtable_components {
+ kind: DeletingDtorPointer
+ mangled_component_name: "_ZN12SuperSpeakerD0Ev"
+ component_value: 0
+ is_pure: false
+ }
+ }
+ access: public_access
+ record_kind: class_kind
+ tag_info {
+ unique_id: "_ZTS12SuperSpeaker"
+ }
+}
+record_types {
+ type_info {
name: "HighVolumeSpeaker"
size: 16
alignment: 8
- referenced_type: "HighVolumeSpeaker"
+ referenced_type: "type-11"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
linker_set_key: "HighVolumeSpeaker"
+ self_type: "type-11"
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -17,31 +78,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI17HighVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -55,24 +122,25 @@
name: "LowVolumeSpeaker"
size: 24
alignment: 8
- referenced_type: "LowVolumeSpeaker"
+ referenced_type: "type-5"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "LowVolumeSpeaker"
+ self_type: "type-5"
}
fields {
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
field_offset: 96
field_name: "speaker_uint_t"
access: public_access
}
fields {
- referenced_type: "float *"
+ referenced_type: "type-7"
field_offset: 128
field_name: "speaker_float_star"
access: public_access
}
base_specifiers {
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
is_virtual: false
access: public_access
}
@@ -81,31 +149,37 @@
kind: OffsetToTop
mangled_component_name: ""
component_value: 0
+ is_pure: false
}
vtable_components {
kind: RTTI
mangled_component_name: "_ZTI16LowVolumeSpeaker"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: FunctionPointer
mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: CompleteDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
component_value: 0
+ is_pure: false
}
vtable_components {
kind: DeletingDtorPointer
mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
component_value: 0
+ is_pure: false
}
}
access: public_access
@@ -114,84 +188,32 @@
unique_id: "_ZTS16LowVolumeSpeaker"
}
}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 16
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 64
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
enum_types {
type_info {
name: "SuperSpeaker::Volume"
size: 4
alignment: 4
- referenced_type: "SuperSpeaker::Volume"
+ referenced_type: "type-8"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker::Volume"
+ self_type: "type-8"
}
- underlying_type: "unsigned int"
+ underlying_type: "type-6"
enum_fields {
enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
+ name: "SuperSpeaker::Loud"
}
enum_fields {
enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
+ name: "SuperSpeaker::Louder"
}
enum_fields {
enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
+ name: "SuperSpeaker::Loudest"
}
enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
+ enum_field_value: 0
+ name: "SuperSpeaker::Lower"
}
access: private_access
tag_info {
@@ -200,32 +222,24 @@
}
pointer_types {
type_info {
- name: "HighVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
name: "SuperSpeaker *"
size: 8
alignment: 8
- referenced_type: "SuperSpeaker"
+ referenced_type: "type-1"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
linker_set_key: "SuperSpeaker *"
+ self_type: "type-9"
+ }
+}
+pointer_types {
+ type_info {
+ name: "HighVolumeSpeaker *"
+ size: 8
+ alignment: 8
+ referenced_type: "type-11"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
+ linker_set_key: "HighVolumeSpeaker *"
+ self_type: "type-12"
}
}
pointer_types {
@@ -233,9 +247,21 @@
name: "float *"
size: 8
alignment: 8
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
linker_set_key: "float *"
+ self_type: "type-7"
+ }
+}
+pointer_types {
+ type_info {
+ name: "LowVolumeSpeaker *"
+ size: 8
+ alignment: 8
+ referenced_type: "type-5"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
+ linker_set_key: "LowVolumeSpeaker *"
+ self_type: "type-4"
}
}
builtin_types {
@@ -243,9 +269,10 @@
name: "float"
size: 4
alignment: 4
- referenced_type: "float"
+ referenced_type: "type-3"
source_file: ""
linker_set_key: "float"
+ self_type: "type-3"
}
is_unsigned: false
is_integral: false
@@ -255,9 +282,10 @@
name: "int"
size: 4
alignment: 4
- referenced_type: "int"
+ referenced_type: "type-2"
source_file: ""
linker_set_key: "int"
+ self_type: "type-2"
}
is_unsigned: false
is_integral: true
@@ -267,9 +295,10 @@
name: "unsigned int"
size: 4
alignment: 4
- referenced_type: "unsigned int"
+ referenced_type: "type-6"
source_file: ""
linker_set_key: "unsigned int"
+ self_type: "type-6"
}
is_unsigned: true
is_integral: true
@@ -279,127 +308,188 @@
name: "void"
size: 0
alignment: 0
- referenced_type: "void"
+ referenced_type: "type-10"
source_file: ""
linker_set_key: "void"
+ self_type: "type-10"
}
is_unsigned: false
is_integral: false
}
functions {
- return_type: "SuperSpeaker *"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::SpeakLouder"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeaker11SpeakLouderEv"
+ access: public_access
+}
+functions {
+ return_type: "type-9"
function_name: "SuperSpeaker::CreateSuperSpeaker"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "int"
+ referenced_type: "type-2"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
access: public_access
}
functions {
- return_type: "SuperSpeaker::Volume"
+ return_type: "type-8"
function_name: "SuperSpeaker::SpeakLoud"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
parameters {
- referenced_type: "SuperSpeaker *"
+ referenced_type: "type-9"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
+ function_name: "SuperSpeaker::~SuperSpeaker"
+ source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
+ parameters {
+ referenced_type: "type-9"
+ default_arg: false
+ is_this_ptr: true
+ }
+ linker_set_key: "_ZN12SuperSpeakerD2Ev"
+ access: public_access
+}
+functions {
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "LowVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
parameters {
- referenced_type: "LowVolumeSpeaker *"
+ referenced_type: "type-4"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
access: public_access
}
functions {
- return_type: "HighVolumeSpeaker *"
+ return_type: "type-12"
function_name: "HighVolumeSpeaker::BadPractice"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
parameters {
- referenced_type: "float"
+ referenced_type: "type-3"
default_arg: false
+ is_this_ptr: false
}
linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Speak"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
access: public_access
}
functions {
- return_type: "void"
+ return_type: "type-10"
function_name: "HighVolumeSpeaker::Listen"
source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
parameters {
- referenced_type: "HighVolumeSpeaker *"
+ referenced_type: "type-12"
default_arg: false
+ is_this_ptr: true
}
linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
access: public_access
}
elf_functions {
name: "_Z26test_virtual_function_callP12SuperSpeaker"
+ binding: Global
}
elf_functions {
name: "_ZN12NotReferenced"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker11SpeakLouderEv"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
+ binding: Global
}
elf_functions {
name: "_ZN12SuperSpeaker9SpeakLoudEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN12SuperSpeakerD2Ev"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN16LowVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN16LowVolumeSpeakerD0Ev"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeaker13AddedFunctionEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker5SpeakEv"
+ binding: Global
}
elf_functions {
name: "_ZN17HighVolumeSpeaker6ListenEv"
+ binding: Global
+}
+elf_functions {
+ name: "_ZN17HighVolumeSpeakerD0Ev"
+ binding: Global
}
elf_objects {
name: "_ZTV16LowVolumeSpeaker"
+ binding: Global
}
elf_objects {
name: "_ZTV17HighVolumeSpeaker"
+ binding: Global
}
diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
deleted file mode 100644
index c8dc7f9..0000000
--- a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_fabricated_function_ast_removed.so.lsdump
+++ /dev/null
@@ -1,405 +0,0 @@
-record_types {
- type_info {
- name: "HighVolumeSpeaker"
- size: 16
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker"
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI17HighVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN17HighVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN17HighVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS17HighVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "LowVolumeSpeaker"
- size: 24
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker"
- }
- fields {
- referenced_type: "unsigned int"
- field_offset: 96
- field_name: "speaker_uint_t"
- access: public_access
- }
- fields {
- referenced_type: "float *"
- field_offset: 128
- field_name: "speaker_float_star"
- access: public_access
- }
- base_specifiers {
- referenced_type: "SuperSpeaker"
- is_virtual: false
- access: public_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI16LowVolumeSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN16LowVolumeSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN16LowVolumeSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS16LowVolumeSpeaker"
- }
-}
-record_types {
- type_info {
- name: "SuperSpeaker"
- size: 16
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker"
- }
- fields {
- referenced_type: "int"
- field_offset: 64
- field_name: "mSpeakderId"
- access: private_access
- }
- vtable_layout {
- vtable_components {
- kind: OffsetToTop
- mangled_component_name: ""
- component_value: 0
- }
- vtable_components {
- kind: RTTI
- mangled_component_name: "_ZTI12SuperSpeaker"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker5SpeakEv"
- component_value: 0
- }
- vtable_components {
- kind: FunctionPointer
- mangled_component_name: "_ZN12SuperSpeaker6ListenEv"
- component_value: 0
- }
- vtable_components {
- kind: CompleteDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD1Ev"
- component_value: 0
- }
- vtable_components {
- kind: DeletingDtorPointer
- mangled_component_name: "_ZN12SuperSpeakerD0Ev"
- component_value: 0
- }
- }
- access: public_access
- record_kind: class_kind
- tag_info {
- unique_id: "_ZTS12SuperSpeaker"
- }
-}
-enum_types {
- type_info {
- name: "SuperSpeaker::Volume"
- size: 4
- alignment: 4
- referenced_type: "SuperSpeaker::Volume"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker::Volume"
- }
- underlying_type: "unsigned int"
- enum_fields {
- enum_field_value: 1
- name: "SuperSpeaker::Volume::Loud"
- }
- enum_fields {
- enum_field_value: 2
- name: "SuperSpeaker::Volume::Louder"
- }
- enum_fields {
- enum_field_value: 3
- name: "SuperSpeaker::Volume::Loudest"
- }
- enum_fields {
- enum_field_value: 4
- name: "SuperSpeaker::Volume::Lower"
- }
- access: private_access
- tag_info {
- unique_id: "_ZTSN12SuperSpeaker6VolumeE"
- }
-}
-pointer_types {
- type_info {
- name: "HighVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "HighVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- linker_set_key: "HighVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "LowVolumeSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "LowVolumeSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "LowVolumeSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "SuperSpeaker *"
- size: 8
- alignment: 8
- referenced_type: "SuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- linker_set_key: "SuperSpeaker *"
- }
-}
-pointer_types {
- type_info {
- name: "float *"
- size: 8
- alignment: 8
- referenced_type: "float"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- linker_set_key: "float *"
- }
-}
-builtin_types {
- type_info {
- name: "float"
- size: 4
- alignment: 4
- referenced_type: "float"
- source_file: ""
- linker_set_key: "float"
- }
- is_unsigned: false
- is_integral: false
-}
-builtin_types {
- type_info {
- name: "int"
- size: 4
- alignment: 4
- referenced_type: "int"
- source_file: ""
- linker_set_key: "int"
- }
- is_unsigned: false
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "unsigned int"
- size: 4
- alignment: 4
- referenced_type: "unsigned int"
- source_file: ""
- linker_set_key: "unsigned int"
- }
- is_unsigned: true
- is_integral: true
-}
-builtin_types {
- type_info {
- name: "void"
- size: 0
- alignment: 0
- referenced_type: "void"
- source_file: ""
- linker_set_key: "void"
- }
- is_unsigned: false
- is_integral: false
-}
-functions {
- return_type: "SuperSpeaker *"
- function_name: "SuperSpeaker::CreateSuperSpeaker"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "int"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
- access: public_access
-}
-functions {
- return_type: "SuperSpeaker::Volume"
- function_name: "SuperSpeaker::SpeakLoud"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h"
- parameters {
- referenced_type: "SuperSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN12SuperSpeaker9SpeakLoudEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "LowVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/low_volume_speaker.h"
- parameters {
- referenced_type: "LowVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN16LowVolumeSpeaker6ListenEv"
- access: public_access
-}
-functions {
- return_type: "HighVolumeSpeaker *"
- function_name: "HighVolumeSpeaker::BadPractice"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- parameters {
- referenced_type: "float"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker11BadPracticeEf"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Speak"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker5SpeakEv"
- access: public_access
-}
-functions {
- return_type: "void"
- function_name: "HighVolumeSpeaker::Listen"
- source_file: "/development/vndk/tools/header-checker/tests/integration/cpp/gold/include/high_volume_speaker.h"
- parameters {
- referenced_type: "HighVolumeSpeaker *"
- default_arg: false
- }
- linker_set_key: "_ZN17HighVolumeSpeaker6ListenEv"
- access: public_access
-}
-elf_functions {
- name: "_Z26test_virtual_function_callP12SuperSpeaker"
-}
-elf_functions {
- name: "_ZN12NotReferenced"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker11SpeakLouderEv"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
-}
-elf_functions {
- name: "_ZN12SuperSpeaker9SpeakLoudEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN16LowVolumeSpeaker6ListenEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker11BadPracticeEf"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker5SpeakEv"
-}
-elf_functions {
- name: "_ZN17HighVolumeSpeaker6ListenEv"
-}
-elf_objects {
- name: "_ZTV16LowVolumeSpeaker"
-}
-elf_objects {
- name: "_ZTV17HighVolumeSpeaker"
-}
diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py
index 7540bc8..1ed8852 100755
--- a/vndk/tools/header-checker/tests/test.py
+++ b/vndk/tools/header-checker/tests/test.py
@@ -9,11 +9,9 @@
import_path = os.path.abspath(os.path.join(import_path, 'utils'))
sys.path.insert(1, import_path)
-from utils import (
- AOSP_DIR, SOURCE_ABI_DUMP_EXT, TARGET_ARCHS, read_output_content,
- run_abi_diff, run_header_abi_dumper)
+from utils import (AOSP_DIR, read_output_content, run_abi_diff,
+ run_header_abi_dumper)
from module import Module
-from gen_all import make_and_copy_reference_dumps
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -22,15 +20,41 @@
REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps')
-class MyTest(unittest.TestCase):
+def make_and_copy_reference_dumps(module, reference_dump_dir=REF_DUMP_DIR):
+ output_content = module.make_dump()
+
+ dump_dir = os.path.join(reference_dump_dir, module.arch)
+ os.makedirs(dump_dir, exist_ok=True)
+
+ dump_path = os.path.join(dump_dir, module.get_dump_name())
+ with open(dump_path, 'w') as f:
+ f.write(output_content)
+
+ return dump_path
+
+
+class HeaderCheckerTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.maxDiff = None
+ def setUp(self):
+ self.tmp_dir = None
+
+ def tearDown(self):
+ if self.tmp_dir:
+ self.tmp_dir.cleanup()
+ self.tmp_dir = None
+
+ def get_tmp_dir(self):
+ if not self.tmp_dir:
+ self.tmp_dir = tempfile.TemporaryDirectory()
+ return self.tmp_dir.name
+
def run_and_compare(self, input_path, expected_path, cflags=[]):
with open(expected_path, 'r') as f:
expected_output = f.read()
- actual_output = run_header_abi_dumper(input_path, True, cflags)
+ actual_output = run_header_abi_dumper(input_path, cflags)
self.assertEqual(actual_output, expected_output)
def run_and_compare_name(self, name, cflags=[]):
@@ -53,44 +77,43 @@
def prepare_and_run_abi_diff(self, old_ref_dump_path, new_ref_dump_path,
target_arch, expected_return_code, flags=[]):
self.run_and_compare_abi_diff(old_ref_dump_path, new_ref_dump_path,
- 'test', target_arch, expected_return_code,
- flags)
+ 'test', target_arch,
+ expected_return_code, flags)
- def create_ref_dump(self, module_bare, dir_name, target_arch):
- module = module_bare.mutate_for_arch(target_arch)
- return make_and_copy_reference_dumps(module, [], dir_name)
-
- def get_or_create_ref_dump(self, name, target_arch, dir_name, create):
- module = Module.get_test_module_by_name(name)
- if create == True:
- return self.create_ref_dump(module, dir_name, target_arch)
- return os.path.join(REF_DUMP_DIR, target_arch,
- module.get_dump_name() if module else name)
+ def get_or_create_ref_dump(self, module, create):
+ if create:
+ return make_and_copy_reference_dumps(module, self.get_tmp_dir())
+ return os.path.join(REF_DUMP_DIR, module.arch, module.get_dump_name())
def prepare_and_run_abi_diff_all_archs(self, old_lib, new_lib,
expected_return_code, flags=[],
create_old=False, create_new=True):
- with tempfile.TemporaryDirectory() as tmp:
- for target_arch in TARGET_ARCHS:
- old_ref_dump_path = self.get_or_create_ref_dump(
- old_lib, target_arch, tmp, create_old)
- new_ref_dump_path = self.get_or_create_ref_dump(
- new_lib, target_arch, tmp, create_new)
- self.prepare_and_run_abi_diff(
- old_ref_dump_path, new_ref_dump_path, target_arch,
- expected_return_code, flags)
+ old_modules = Module.get_test_modules_by_name(old_lib)
+ new_modules = Module.get_test_modules_by_name(new_lib)
+ self.assertEqual(len(old_modules), len(new_modules))
- def prepare_and_absolute_diff_all_archs(self, old_lib, new_lib,
- flags=[], create=True):
- with tempfile.TemporaryDirectory() as tmp:
- for target_arch in TARGET_ARCHS:
- old_ref_dump_path = self.get_or_create_ref_dump(
- old_lib, target_arch, tmp, False)
- new_ref_dump_path = self.get_or_create_ref_dump(
- new_lib, target_arch, tmp, create)
- self.assertEqual(
- read_output_content(old_ref_dump_path, AOSP_DIR),
- read_output_content(new_ref_dump_path, AOSP_DIR))
+ for old_module, new_module in zip(old_modules, new_modules):
+ self.assertEqual(old_module.arch, new_module.arch)
+ old_ref_dump_path = self.get_or_create_ref_dump(old_module,
+ create_old)
+ new_ref_dump_path = self.get_or_create_ref_dump(new_module,
+ create_new)
+ self.prepare_and_run_abi_diff(
+ old_ref_dump_path, new_ref_dump_path, new_module.arch,
+ expected_return_code, flags)
+
+ def prepare_and_absolute_diff_all_archs(self, old_lib, new_lib):
+ old_modules = Module.get_test_modules_by_name(old_lib)
+ new_modules = Module.get_test_modules_by_name(new_lib)
+ self.assertEqual(len(old_modules), len(new_modules))
+
+ for old_module, new_module in zip(old_modules, new_modules):
+ self.assertEqual(old_module.arch, new_module.arch)
+ old_ref_dump_path = self.get_or_create_ref_dump(old_module, False)
+ new_ref_dump_path = self.get_or_create_ref_dump(new_module, True)
+ self.assertEqual(
+ read_output_content(old_ref_dump_path, AOSP_DIR),
+ read_output_content(new_ref_dump_path, AOSP_DIR))
def test_example1_cpp(self):
self.run_and_compare_name_cpp('example1.cpp')
@@ -169,7 +192,13 @@
def test_libgolden_cpp_add_function_and_elf_symbol(self):
self.prepare_and_run_abi_diff_all_archs(
- "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", 4)
+ "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf",
+ 4)
+
+ def test_libgolden_cpp_fabricated_function_ast_removed_diff(self):
+ self.prepare_and_run_abi_diff_all_archs(
+ "libgolden_cpp_add_function_sybmol_only",
+ "libgolden_cpp_add_function", 0, [], False, False)
def test_libgolden_cpp_change_function_access(self):
self.prepare_and_run_abi_diff_all_archs(
@@ -212,11 +241,6 @@
self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp", "libgolden_cpp_enum_diff", 8)
- def test_libgolden_cpp_fabricated_function_ast_removed_diff(self):
- self.prepare_and_run_abi_diff_all_archs(
- "libgolden_cpp_fabricated_function_ast_removed.so.lsdump",
- "libgolden_cpp", 0, [], False)
-
def test_libgolden_cpp_member_fake_diff(self):
self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp", "libgolden_cpp_member_fake_diff", 0)
@@ -245,7 +269,8 @@
def test_libgolden_cpp_member_function_pointer_changed(self):
self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp_function_pointer",
- "libgolden_cpp_function_pointer_parameter_added", 8, [], True, True)
+ "libgolden_cpp_function_pointer_parameter_added", 8, [],
+ True, True)
def test_libgolden_cpp_internal_struct_access_upgraded(self):
self.prepare_and_run_abi_diff_all_archs(
@@ -284,6 +309,25 @@
["-input-format-old", "Json", "-input-format-new", "Json",
"-consider-opaque-types-different"])
+ def test_linker_shared_object_file_and_version_script(self):
+ base_dir = os.path.join(
+ SCRIPT_DIR, 'integration', 'version_script_example')
+
+ cases = [
+ 'libversion_script_example',
+ 'libversion_script_example_no_mytag',
+ 'libversion_script_example_no_private',
+ ]
+
+ for module_name in cases:
+ module = Module.get_test_modules_by_name(module_name)[0]
+ example_lsdump_old = self.get_or_create_ref_dump(module, False)
+ example_lsdump_new = self.get_or_create_ref_dump(module, True)
+ self.run_and_compare_abi_diff(
+ example_lsdump_old, example_lsdump_new,
+ module_name, "arm64", 0,
+ ["-input-format-old", "Json", "-input-format-new", "Json"])
+
if __name__ == '__main__':
unittest.main()
diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py
index 0631b8e..80e51d2 100755
--- a/vndk/tools/header-checker/utils/create_reference_dumps.py
+++ b/vndk/tools/header-checker/utils/create_reference_dumps.py
@@ -9,7 +9,8 @@
from utils import (
AOSP_DIR, COMPRESSED_SOURCE_ABI_DUMP_EXT, SOURCE_ABI_DUMP_EXT,
SOURCE_ABI_DUMP_EXT_END, SO_EXT, copy_reference_dumps, find_lib_lsdumps,
- get_build_vars_for_product, make_libraries, make_tree)
+ get_build_vars_for_product, get_module_variant_dir_name, make_libraries,
+ make_tree)
PRODUCTS_DEFAULT = ['aosp_arm_ab', 'aosp_arm', 'aosp_arm64', 'aosp_x86_ab',
@@ -64,13 +65,53 @@
return target.arch + target_arch_variant_str
+# FIXME (b/121986692): Before aosp/858259 is merged, apex mutator adds
+# `_platform` suffix if the module is used by some apex modules. This
+# workaround searches for lsdump with and without `_platform`.
+_WORKAROUND_APEX_PLATFORM_LSDUMPS = True
+
+if _WORKAROUND_APEX_PLATFORM_LSDUMPS:
+ def _find_lib_lsdumps_workaround(dir_name, lsdump_paths, libs):
+ dir_name_platform = dir_name + '_platform'
+
+ matched_lsdump_paths = set(find_lib_lsdumps(
+ dir_name, lsdump_paths, libs))
+
+ matched_lsdump_paths_platform = set(find_lib_lsdumps(
+ dir_name_platform, lsdump_paths, libs))
+
+ # Pick the lsdump file with latest modification time if both of them
+ # exist.
+ matched_lsdump_paths_replaced = set(
+ path.replace(dir_name, dir_name_platform)
+ for path in matched_lsdump_paths)
+
+ both = matched_lsdump_paths_replaced & matched_lsdump_paths_platform
+
+ for path_platform in both:
+ path = path_platform.replace(dir_name_platform, dir_name)
+ if os.stat(path).st_mtime >= os.stat(path_platform).st_mtime:
+ matched_lsdump_paths_platform.remove(path_platform)
+ else:
+ matched_lsdump_paths.remove(path)
+
+ return sorted(matched_lsdump_paths | matched_lsdump_paths_platform)
+
+
def find_and_copy_lib_lsdumps(target, ref_dump_dir_stem, ref_dump_dir_insertion,
core_or_vendor_shared_str, libs, lsdump_paths,
compress):
- arch_lsdump_paths = find_lib_lsdumps(target.arch, target.arch_variant,
- target.cpu_variant, lsdump_paths,
- core_or_vendor_shared_str,
- libs)
+ module_variant_dir_name = get_module_variant_dir_name(
+ target.arch, target.arch_variant, target.cpu_variant,
+ core_or_vendor_shared_str)
+
+ if _WORKAROUND_APEX_PLATFORM_LSDUMPS:
+ arch_lsdump_paths = _find_lib_lsdumps_workaround(
+ module_variant_dir_name, lsdump_paths, libs)
+ else:
+ arch_lsdump_paths = find_lib_lsdumps(
+ module_variant_dir_name, lsdump_paths, libs)
+
# Copy the contents of the lsdump into their corresponding reference ABI
# dumps directories.
return copy_reference_dumps(arch_lsdump_paths, ref_dump_dir_stem,
@@ -99,12 +140,12 @@
return ref_dump_dir_stem
-def make_libs_for_product(libs, llndk_mode, product):
- print('making libs for product:', product)
+def make_libs_for_product(libs, llndk_mode, product, variant):
+ print('making libs for', product + '-' + variant)
if libs:
- make_libraries(libs, product, llndk_mode)
+ make_libraries(libs, product, variant, llndk_mode)
else:
- make_tree(product)
+ make_tree(product, variant)
def find_and_remove_path(root_path, file_name=None):
@@ -219,7 +260,8 @@
if not args.no_make_lib:
# Build all the specified libs (or build the 'vndk' target if none
# of them are specified.)
- make_libs_for_product(args.libs, args.llndk, product)
+ make_libs_for_product(args.libs, args.llndk, product,
+ args.build_variant)
lsdump_paths = get_lsdump_paths(product, args.libs)
num_processed += create_source_abi_reference_dumps(
@@ -241,6 +283,8 @@
help='libs to create references for')
parser.add_argument('-products', action='append',
help='products to create references for')
+ parser.add_argument('--build-variant', default='userdebug',
+ help='build variant to create references for')
parser.add_argument('--compress', action='store_true',
help='compress reference dump with gzip')
parser.add_argument('-ref-dump-dir',
diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py
index 88982af..db08558 100644
--- a/vndk/tools/header-checker/utils/utils.py
+++ b/vndk/tools/header-checker/utils/utils.py
@@ -19,7 +19,8 @@
BUILTIN_HEADERS_DIR = (
os.path.join(AOSP_DIR, 'bionic', 'libc', 'include'),
os.path.join(AOSP_DIR, 'external', 'libcxx', 'include'),
- os.path.join(AOSP_DIR, 'prebuilts', 'clang-tools', 'linux-x86', 'clang-headers'),
+ os.path.join(AOSP_DIR, 'prebuilts', 'clang-tools', 'linux-x86',
+ 'clang-headers'),
)
EXPORTED_HEADERS_DIR = (
@@ -38,8 +39,6 @@
DEFAULT_HEADER_FLAGS = ["-dump-function-declarations"]
DEFAULT_FORMAT = 'ProtobufTextFormat'
-TARGET_ARCHS = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64']
-
def get_reference_dump_dir(reference_dump_dir_stem,
reference_dump_dir_insertion, lib_arch):
@@ -78,44 +77,30 @@
return reference_dump_path
-def copy_reference_dump_content(file_name, output_content,
- reference_dump_dir_stem,
- reference_dump_dir_insertion, lib_arch):
- reference_dump_dir = get_reference_dump_dir(reference_dump_dir_stem,
- reference_dump_dir_insertion,
- lib_arch)
- reference_dump_path = os.path.join(reference_dump_dir, file_name)
- os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True)
- with open(reference_dump_path, 'w') as f:
- f.write(output_content)
-
- print('Created abi dump at', reference_dump_path)
- return reference_dump_path
-
-
def read_output_content(output_path, replace_str):
with open(output_path, 'r') as f:
return f.read().replace(replace_str, '')
-def run_header_abi_dumper(input_path, remove_absolute_paths, cflags=tuple(),
+def run_header_abi_dumper(input_path, cflags=tuple(),
export_include_dirs=EXPORTED_HEADERS_DIR,
flags=tuple()):
+ """Run header-abi-dumper to dump ABI from `input_path` and return the
+ output."""
with tempfile.TemporaryDirectory() as tmp:
output_path = os.path.join(tmp, os.path.basename(input_path)) + '.dump'
run_header_abi_dumper_on_file(input_path, output_path,
export_include_dirs, cflags, flags)
- if remove_absolute_paths:
- return read_output_content(output_path, AOSP_DIR)
- with open(output_path, 'r') as f:
- return f.read()
+ return read_output_content(output_path, AOSP_DIR)
def run_header_abi_dumper_on_file(input_path, output_path,
export_include_dirs=tuple(), cflags=tuple(),
flags=tuple()):
+ """Run header-abi-dumper to dump ABI from `input_path` and the output is
+ written to `output_path`."""
input_ext = os.path.splitext(input_path)[1]
- cmd = ['header-abi-dumper', '-o', output_path, input_path,]
+ cmd = ['header-abi-dumper', '-o', output_path, input_path]
for dir in export_include_dirs:
cmd += ['-I', dir]
cmd += flags
@@ -153,57 +138,62 @@
return read_output_content(output_path, AOSP_DIR)
-def make_tree(product):
+def make_tree(product, variant):
# To aid creation of reference dumps.
make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j',
- 'vndk', 'findlsdumps', 'TARGET_PRODUCT=' + product]
+ 'vndk', 'findlsdumps', 'TARGET_PRODUCT=' + product,
+ 'TARGET_BUILD_VARIANT=' + variant]
subprocess.check_call(make_cmd, cwd=AOSP_DIR)
-def make_targets(targets, product):
- make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j']
- for target in targets:
- make_cmd.append(target)
- make_cmd.append('TARGET_PRODUCT=' + product)
+def make_targets(targets, product, variant):
+ make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j',
+ 'TARGET_PRODUCT=' + product, 'TARGET_BUILD_VARIANT=' + variant]
+ make_cmd += targets
subprocess.check_call(make_cmd, cwd=AOSP_DIR, stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
-def make_libraries(libs, product, llndk_mode):
+def make_libraries(libs, product, variant, llndk_mode):
# To aid creation of reference dumps. Makes lib.vendor for the current
# configuration.
lib_targets = []
for lib in libs:
lib = lib if llndk_mode else lib + VENDOR_SUFFIX
lib_targets.append(lib)
- make_targets(lib_targets, product)
+ make_targets(lib_targets, product, variant)
-def find_lib_lsdumps(target_arch, target_arch_variant,
- target_cpu_variant, lsdump_paths,
- core_or_vendor_shared_str, libs):
- """ Find the lsdump corresponding to lib_name for the given arch parameters
- if it exists"""
- assert 'ANDROID_PRODUCT_OUT' in os.environ
- cpu_variant = '_' + target_cpu_variant
- arch_variant = '_' + target_arch_variant
- arch_lsdump_paths = []
- if target_cpu_variant == 'generic' or target_cpu_variant is None or\
- target_cpu_variant == '':
- cpu_variant = ''
- if target_arch_variant == target_arch or target_arch_variant is None or\
- target_arch_variant == '':
+def get_module_variant_dir_name(arch, arch_variant, cpu_variant,
+ variant_suffix):
+ """Create module variant directory name from the target architecture, the
+ target architecture variant, the target CPU variant, and a variant suffix
+ (e.g. `_core_shared`, `_vendor_shared`, etc)."""
+
+ if not arch_variant or arch_variant == arch:
arch_variant = ''
+ else:
+ arch_variant = '_' + arch_variant
- target_dir = 'android_' + target_arch + arch_variant +\
- cpu_variant + core_or_vendor_shared_str
- for key in lsdump_paths:
- if libs and key not in libs:
+ if not cpu_variant or cpu_variant == 'generic':
+ cpu_variant = ''
+ else:
+ cpu_variant = '_' + cpu_variant
+
+ return 'android_' + arch + arch_variant + cpu_variant + variant_suffix
+
+
+def find_lib_lsdumps(module_variant_dir_name, lsdump_paths, libs):
+ """Find the lsdump corresponding to lib_name for the given module variant
+ if it exists."""
+ result = []
+ for lib_name, paths in lsdump_paths.items():
+ if libs and lib_name not in libs:
continue
- for path in lsdump_paths[key]:
- if target_dir in path:
- arch_lsdump_paths.append(os.path.join(AOSP_DIR, path.strip()))
- return arch_lsdump_paths
+ for path in paths:
+ if module_variant_dir_name in path.split(os.path.sep):
+ result.append(os.path.join(AOSP_DIR, path.strip()))
+ return result
def run_abi_diff(old_test_dump_path, new_test_dump_path, arch, lib_name,
@@ -226,26 +216,28 @@
return 0
-def get_build_vars_for_product(names, product=None):
+def get_build_vars_for_product(names, product=None, variant=None):
""" Get build system variable for the launched target."""
if product is None and 'ANDROID_PRODUCT_OUT' not in os.environ:
return None
- cmd = ''
- if product is not None:
- cmd += 'source build/envsetup.sh > /dev/null && '
- cmd += 'lunch ' + product + ' > /dev/null && '
- cmd += 'build/soong/soong_ui.bash --dumpvars-mode -vars \"'
- cmd += ' '.join(names)
- cmd += '\"'
+ env = os.environ.copy()
+ if product:
+ env['TARGET_PRODUCT'] = product
+ if variant:
+ env['TARGET_BUILD_VARIANT'] = variant
+ cmd = [
+ os.path.join('build', 'soong', 'soong_ui.bash'),
+ '--dumpvars-mode', '-vars', ' '.join(names),
+ ]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, cwd=AOSP_DIR, shell=True)
+ stderr=subprocess.PIPE, cwd=AOSP_DIR, env=env)
out, err = proc.communicate()
if proc.returncode != 0:
- print ("error: %s" % err.decode('utf-8'), file=sys.stderr)
+ print("error: %s" % err.decode('utf-8'), file=sys.stderr)
return None
build_vars = out.decode('utf-8').strip().splitlines()