Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually calculate location of objdump in gradle plugin #136

Merged
merged 7 commits into from
Dec 12, 2018

Conversation

fractalwrench
Copy link
Contributor

Goal

The bugsnag gradle plugin relies on objdump to upload shared object mapping files, which deobfuscate stacktraces in NDK projects. The plugin relies on the NdkHandler and Toolchain classes to calculate the location of objdump on disk. These classes are internal APIs within the Android Gradle Plugin (AGP), and have been removed in v3.4.0-alpha.

The bugsnag gradle plugin will throw an Error when attempting to load these classes, which will break the build for any NDK project depending on our plugin and AGP 3.4.0. This changeset alters the plugin to perform the calculation manually, and removes the dependency on these classes.

N.B. a design doc is available which covers the goal in more detail

Changeset

  • Removed dependency on Toolchain, NdkHandler, and Abi classes which were internal to the AGP.
  • Add Abi classes which contains pre-calculated information on the names of ABIs, and the expected location of objdump.
  • Remove dead code which parses the CMake toolchain options
  • Calculate the location of objdump manually, using the OS name, ABI, and NDK installation directory.
  • Add an objdumpPaths property to the bugsnag plugin extension which allows users to override the calculation location on a per-ABI basis

Tests

  • Updated the mazerunner NDK fixture to build all supported ABIs, rather than just x86 and armeabi-v7a. The scenarios have been updated to verify that for each ABI a mapping file is uploaded.
  • Added a mazerunner scenario to verify that setting a value in the objdumpPaths property overrides the calculated objdump location.
  • Added a parameterized unit test that covers all the potential objdump locations we
    support.

Discussion

Linked issues

Fixes #134

Updates the NDK fixture project to use bugsnag-android-ndk v4+, and to build all the default
supported abis, rather than just armeabi-v7a and x86. The scenarios have also been updated to check
that the correct architecture is set.
Verifies that the calculated location of objdump follows a given pattern when the ABI, os name, and
NDK directory differ.
Calculates the location of objdump manually. The location of the file depends on 3 factors: the ABI
of the shared object file being processed, the operating system, and the installation location of
the NDK bundle.
If the objdump location changes in future versions of the AGP, it would be helpful to override the
objdump location on a per-ABI basis - which this property provides. A mazerunner scenario has been
added to verify the behaviour.
@fractalwrench fractalwrench changed the base branch from next to master December 5, 2018 11:51
return "windows-x86_64"
}
} else {
return "unknown"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there something better we can do here? such as raising an exception or logging a warning? Tell people to use the objdumpPaths option? I think once you reach this branch and it builds a string that we know won't work, the error message will be confusing or missing enough detail to work out what went wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good suggestion - I've updated the function to return null if the osName can't be calculated. I've then added a null check for ABI + osName, which throws an exception that will ultimately be caught and logged to warn that objdump couldn't be found.

Copy link
Contributor

@bengourley bengourley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with @Pezzah.

@fractalwrench fractalwrench merged commit d24fde9 into master Dec 12, 2018
@fractalwrench fractalwrench deleted the calculate-objdump-manually branch December 12, 2018 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependency on internal AGP API breaks on AGP 3.4
3 participants