Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added command for direct Xcode command line tool install (without need to download xcode)

...

Note: You can also just install XCode Command Line Tools for this setup.

xcode-select --install

1.2 Install brew

Refer here for the steps - https://brew.sh/

...

  1. File → Open → Select the MXNet directory.
    1. Setup VSCode for Debugging Python and C++ code
      • View → Debug
      • Click on the Current configuration drop-down (in screenshot below it says "No Configurations")
    • In the drop-down choose "Add Configuration"
    • Choose "Python" as the configuration type
    • And then you'll see the new configuration file "launch.json" with few default debug configurations. Delete all the contents and copy below provided launch.json.

 



Copy below snippet to 'launch.json' and save. We have 3 launch configurations below:

...

Let us debug a unit test to see how we can debug a Mix of Python and C++ codebase.

 


  1. Open 'incubator-mxnet/tests/python/unittest/test_operator.py
  2. Go to test case - 'test_new_softmax()'. We will debug softmax operator. (Note: You can copy the softmax test function to the top of file to avoid waiting for other tests to pass)
  3. Add breakpoint. You can click to left of the line number where you want to add a breakpoint for debugging.

 


  1. Go to softmax implementation code - 'incubator-mxnet/src/operator/nn/softmax-inl.h'
  2. Add breakpoint in the softmax function - 'inline void Softmax(..)'

 


Now, let us debug.

Step 1: Start Python code in debug mode

  1. Go back to the test_operator.py file. 
  2. Open Debug window: View→ Debug
  3. From the debug dropdown, select 'Python Launch Debug'. This was the debug configuration we had created in earlier steps. This will launch the current python file (test_operator.py) in debug mode.

 


At the top you can see the debugging controls. (Or, you can use shortcut commands, see appendix below)


  


Now, you should hit the debug point in your softmax test function like below.

 


Step 2: Start lldb debugger and attach to the python program being tested

 


From Debug dropdown, select 'lldb Attach Debug'. Select and start. Now, choose the 'test_operator.py' python process to attach.

 


 


You can now see that debug point is attached to the softmax CPP implementation code.

...

On the left, debug panel, you use 'python' and 'lldb' debugger to switch between 


  


Now, you can continue execution, debug, inspect values and more.

 


 


You can also use Debug console to inspect and debug.

...

  1. You can format an entire file with Format Document (⇧⌥F) or just the current selection with Format Selection (⌘K ⌘F) in right-click context menu.
  2. F10 → Step Over, F11 → Step Into, Shift+F11→ Step Out, F5 → Continue

 

...