buck icon indicating copy to clipboard operation
buck copied to clipboard

How To Debug (Using breakpoint) buck build?

Open rifqimfahmi opened this issue 6 years ago • 4 comments

I have been trying to wrap around my head with buck build but still doesn't know how to debug the build. Especially using breakpoint in IntelliJ. The troubleshooting section in the docs https://buck.build/concept/troubleshooting.html doesn't really help me achieve what I want. I usually develop an Android App.

I know I can use the chrome://tracing page to find out where the build is failed, but i still can't figure out how the buck build work behind the scene such as in which point the code is starting or adding breakpoint to evaluate variables.

Can you tell me how to add breakpoint when building with buck? Also can it achieved by using Intellij IDEA? Thank you

rifqimfahmi avatar Jan 17 '20 13:01 rifqimfahmi

Copied from FB internal wiki:

USING IDE AND REMOTE DEBUGGER, HELPS TO DEBUG THINGS END TO END

You can use a remote debugger to debug your local buck.

From terminal, run

  • your buck command, prepending it with NO_BUCKD=1 and BUCK_DEBUG_MODE=1 e.g. NO_BUCKD=1 BUCK_DEBUG_MODE=1 buck build //src/com/facebook/buck/cli:main. Buck will then pause and wait for IntelliJ. The terminal should look like it's hanging at this point.

  • In IntelliJ, use Debug Buck configuration under Remote debug section (which points to localhost:8888). This configuration should already be available in your Run / Debug configurations.

Screen Shot 2019-10-25 at 1.37.49 PM 1.png NOTE: If there is something occupying port 8888, kill it with fire: lsof -i:8888 | tail +2 | awk '{ print $2 }' | xargs -L1 kill -9

v-jizhang avatar Jan 22 '20 21:01 v-jizhang

image

v-jizhang avatar Jan 22 '20 21:01 v-jizhang

Thank you @v-jizhang will try it later, haven't got the time

rifqimfahmi avatar Feb 12 '20 06:02 rifqimfahmi

This is really helpful, huge thanks to you both for the question and the answer!

For some reason quite extensive googling didn't point me at any docs,
and finally this is the only right place to get help on such question... 😫

RAM237 avatar Aug 23 '20 12:08 RAM237