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

Feature: enable native code debugging via LLDB #1551

Conversation

davinctor
Copy link
Contributor

@davinctor davinctor commented Dec 20, 2020

Wix Goodness Squad Event

Description

To enable debug native (C/C++) code was added required changes to Android.mk file and build.gradles.

Changes

  • Added required to build.gradle and Android.mk config to enable native debugging with LLDB;
  • Fixed some warnings;

Screenshots / GIFs

Live demo of native code debug setup

output.mp4

Live debugging demo session
Live debugging demo session

Test code

To enable native code debugging please put NATIVE_DEBUG_ON=TRUE line to the end of android/local.properties file:

NATIVE_DEBUG_ON=TRUE

@karol-bisztyga
Copy link
Contributor

Hey! Thanks for your work! I just wanted to run this locally on my machine and couldn't set any breakpoints in c++, did it maybe happen to you as well? I'm using Android Studio 4.1

@davinctor
Copy link
Contributor Author

@karol-bisztyga Maybe it's because something is not installed from Android tools.

Screenshot 2020-12-21 at 17 59 58

Also, check please the first video where you have to enable Java+Native (or Native) debugging.

@davinctor
Copy link
Contributor Author

davinctor commented Dec 21, 2020

@karol-bisztyga ping me if you have any troubles with debugging in Android Studio, will try to help.
BTW, I am using Android Studio v4.1.1

@karol-bisztyga
Copy link
Contributor

I upgraded to studio 4.1.1, also have all those tools installed but the problem persists - I cannot set a breakpoint in c++ code, only java. I, obviously, went for dual debugger(native + java)(native alone doesn't work as well but it doesn't really make any difference as setting to native I still can set breakpoints in java code, they'd probably never be hit I guess).

@davinctor
Copy link
Contributor Author

@karol-bisztyga I want to describe steps to do in order to archive the results on the video:

  1. cd react-native-reanimated
  2. npm i (or yarn)
  3. cd Example
  4. npm i (or yarn)
  5. Open Android Studio and open react-native-reanimated/Example/android folder
  6. Run gradle sync
  7. Switch to Project view for project structure
  8. Expand ReanimatedExample folder and go to the react-native-reanimated project (Example) dependency.

So you should run Example project and inside it, you could debug and modify react-native-reanimated dependency.

The video with steps.

I know some steps are obvious and provided just to be clear.
Now you can use Android Studio to add some breakpoints.

Copy link
Contributor

@Szymon20000 Szymon20000 left a comment

Choose a reason for hiding this comment

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

Amazing Job! It was a problem that we could not solve for a long time.
Thank you!

@Szymon20000 Szymon20000 merged commit ac6fb10 into software-mansion:master Dec 28, 2020
@karol-bisztyga
Copy link
Contributor

Good job, sorry, I couldn't merge this as it sadly didn't work on my environment :( I hard reset android studio and still cannot get this running but 2 people from the team fired it up so it must be just a matter of my local problems.

@davinctor
Copy link
Contributor Author

@karol-bisztyga Leave a reply here please when you will be able to fix the issue with your local environment. Could be pretty useful!

@Ygl12337
Copy link

@karol-bisztyga Hi,Did you solve the problem ?I also encountered the same problem

@Ygl12337
Copy link

@karol-bisztyga Hi,Did you solve the problem ?I also encountered the same problem

I have solved!!
Just add "set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")" in CMakeLists

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.

None yet

5 participants