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

[android] Make native debugging test apps a little easier #112993

Closed
wants to merge 2 commits into from

Conversation

steveisok
Copy link
Member

@steveisok steveisok commented Feb 27, 2025

This change adds block in the AndroidAppBuilder where it'll copy .dbg files into the apk lib/arch folder and rename the extension to .so. When you build the test, you can open the apk in Android Studio and you won't have to hunt very far to manually associate the symbol libraries.

To native debug the runtime in android studio, all runtime native lib symbols need to end in .so as opposed to .dbg. We have yet to find a way for Android Studio to automatically pick this up and so you have to manually associate libs to symbol libs in the UI. The UI filters based on .so and that is the reason for the rename.

To native debug the runtime in android studio, all runtime native lib symbols need to end in .so as opposed to .dbg. We have yet to find the way for Android Studio to automatically pick this up and so you have to manually associate libs to symbol lib in the UI. The UI filters based on .so and that is the reason for the rename.

This change adds a target in the test build where it'll copy .dbg files into the apk lib/arch folder and rename the extension to .so. When you build the test, you can open the apk in Android Studio and you won't have to hunt very far to associate the symbol libraries.
@Copilot Copilot bot review requested due to automatic review settings February 27, 2025 18:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR streamlines the native debugging process for Android test apps by copying .dbg files and renaming them to .so, enabling Android Studio to more easily associate the symbol libraries.

  • Adds a new conditional block to copy and rename .dbg files to .so
  • Integrates the newly renamed files into the APK using the AAPT tool

Reviewed Changes

File Description
src/tasks/AndroidAppBuilder/ApkBuilder.cs Adds logic to duplicate .dbg files with a .so extension for native debugging support

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR simplifies native debugging of Android test apps by automatically copying and renaming .dbg files to .so files so that Android Studio can easily associate symbol libraries.

  • Adds a conditional branch to copy the debug symbols as .so files
  • Invokes AAPT to include the renamed debug symbols in the APK

Reviewed Changes

File Description
src/tasks/AndroidAppBuilder/ApkBuilder.cs Adds logic to copy .dbg files as .so files and update the APK accordingly

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


if (!StripDebugSymbols)
{
// symbol files need to end in .so.so so they'll show up in android studio
Copy link
Preview

Copilot AI Feb 27, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment mentions '.so.so' which appears to be a typo given that the file is renamed to '.so'. Consider updating the comment to match the intended behavior.

Suggested change
// symbol files need to end in .so.so so they'll show up in android studio
// symbol files need to end in .so so they'll show up in android studio

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
if (!StripDebugSymbols)
{
// symbol files need to end in .so.so so they'll show up in android studio
string debugLib = dynamicLib + ".dbg";
Copy link
Member

Choose a reason for hiding this comment

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

Is the .dbg extension Windows-specific?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, linux specific I think.

Copy link
Member

Choose a reason for hiding this comment

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

Right, the symbols are for the target, not host.

@kotlarmilos kotlarmilos self-requested a review February 27, 2025 20:17
Copy link
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

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

not sure I'm a fan of this, why not just tell people to disable symbol stripping ?

@@ -493,6 +493,20 @@ public ApkBuilder(TaskLoggingHelper logger)
// NOTE: we can run android-strip tool from NDK to shrink native binaries here even more.

File.Copy(dynamicLib, Path.Combine(OutputDir, destRelative), true);

if (!StripDebugSymbols)
Copy link
Member

Choose a reason for hiding this comment

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

this is backwards, it should only do this if debug symbols are stripped otherwise they'll be embedded.
this also shouldn't be done in librarybuilder mode

@steveisok
Copy link
Member Author

not sure I'm a fan of this, why not just tell people to disable symbol stripping ?

At least on coreclr it doesn't work. Possibly something to fix but in the meantime this is helpful.

@steveisok
Copy link
Member Author

After another pass, -keepnativesymbols actually just works. This is unnecessary.

@steveisok steveisok closed this Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants