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 studio debugging c++ #648

Closed
weinixuehao opened this issue Apr 24, 2020 · 3 comments
Closed

android studio debugging c++ #648

weinixuehao opened this issue Apr 24, 2020 · 3 comments

Comments

@weinixuehao
Copy link

04/24 21:07:06: Launching 'edgedetectiongpu:edgedetectiongpu'. $ adb shell am start -n "com.google.mediapipe.apps.edgedetectiongpu/com.google.mediapipe.apps.edgedetectiongpu.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D Connecting to com.google.mediapipe.apps.edgedetectiongpu Waiting for application to start debug server Connecting to com.google.mediapipe.apps.edgedetectiongpu Now Launching Native Debug Session Attention! No symbol directories found - please check your native debug configuration

Both cmdline and android studio have tried to build but still not hit breakpoint.
rm-linux-androideabi-readelf --debug-dump can see debug info.

@weinixuehao
Copy link
Author

weinixuehao commented Apr 26, 2020

I using Profile or debug apk feature in android studio to debug my project which can hit breakpoint and left project pane has a cpp source dir.
image

Below is mediapipe that can only hit breakpoint by add symbolic breakpoint but no source file show, I guess there is no cpp dir compared to myproject.
image

Using bazel project to run debug is the same as above
image

I really need dynamic debugging to read the code and trace the code context, It is difficult to understand the code of the entire project by printing the log or you have a better way?

@jiuqiant

@weinixuehao
Copy link
Author

weinixuehao commented Apr 26, 2020

I finally succeeded! !
1、Clean up the bazel-out directory
2、Modify edit configuration file with follow -c
dbg
--strip=never
--config=android_arm64
--sandbox_debug
-s
3、Using profile apk or debug to import apk then click add button to auto search debug symbols by selecting mediapipe root dir

ps:But i am not sure which step solved that problem or all are need, I hope it helps others.
image

I'm still curious about how you debug the code?
@jiuqiant

@weinixuehao
Copy link
Author

weinixuehao commented May 3, 2020

@jiuqiant

--sandbox_debug must add otherwise the darwin-sandbox folder is empty which contain source code. As show below.
image
If it is empty that will able not to add breakpoint in android studio, I do not understand why debug symbols point to sandbox folder?
I found https://stackoverflow.com/questions/54543744/how-to-avoid-deleting-cached-files-after-build-in-bazel, sandbox will be delete after building end if without --sandbox_debug

ps:
Please using --spawn_strategy=local instead of --sandbox_debug because using --sandbox_debug will produce redundant debug symbol files and rebuilding it will stuck due to delete stale sandbox files warning which spent lot of times to finish. hope to help those people who need to debug native code c++ with android studio. if has a better answer or my explanation is not completely correct please tell me.

summary:seems to be a bug on mac osx more details in below:
1、bazelbuild/bazel#2537
2、bazelbuild/bazel#6327

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

No branches or pull requests

1 participant