From e0f2c62ff4b225a5a297cdaa9035f1ea32caa694 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 11 Feb 2022 22:16:19 +0000 Subject: Add tool for injecting tracing code into a method. This tool rewrites the bytecode in the designated JAR files to produce tracing calls on enter and exit, while making sure to close the tracing span even on exceptions being thrown. The idea is mostly to reduce the amount of noise within methods when just trying to add some tracing. Test: atest --host TraceInjectionTests Change-Id: If6acb72f34cbb83d9b041a62ee3d8c2abf74b69e Merged-In: If6acb72f34cbb83d9b041a62ee3d8c2abf74b69e --- tools/traceinjection/Android.bp | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tools/traceinjection/Android.bp (limited to 'tools/traceinjection/Android.bp') diff --git a/tools/traceinjection/Android.bp b/tools/traceinjection/Android.bp new file mode 100644 index 000000000000..1395c5f2e635 --- /dev/null +++ b/tools/traceinjection/Android.bp @@ -0,0 +1,49 @@ +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "frameworks_base_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["frameworks_base_license"], +} + +java_binary_host { + name: "traceinjection", + manifest: "manifest.txt", + srcs: ["src/**/*.java"], + static_libs: [ + "asm-7.0", + "asm-commons-7.0", + "asm-tree-7.0", + "asm-analysis-7.0", + "guava-21.0", + ], +} + +java_library_host { + name: "TraceInjectionTests-Uninjected", + srcs: ["test/**/*.java"], + static_libs: [ + "junit", + ], +} + +java_genrule_host { + name: "TraceInjectionTests-Injected", + srcs: [":TraceInjectionTests-Uninjected"], + tools: ["traceinjection"], + cmd: "$(location traceinjection) " + + " --annotation \"com/android/traceinjection/Trace\"" + + " --start \"com/android/traceinjection/InjectionTests.traceStart\"" + + " --end \"com/android/traceinjection/InjectionTests.traceEnd\"" + + " -o $(out) " + + " -i $(in)", + out: ["TraceInjectionTests-Injected.jar"], +} + +java_test_host { + name: "TraceInjectionTests", + static_libs: [ + "TraceInjectionTests-Injected", + ], +} -- cgit v1.2.3-59-g8ed1b