Issue
I am debugging decode_raw_op_test from TensorFlow. The test file is written in python however it executes code from underlying C++ files.
Using pdb, I could debug python test file however it doesn't recognize c++ file. Is there a way in which we can debug underlying c++ code?
(I tried using gdb on decode_raw_op_test but it gives "File not in executable format: File format not recognized")
Solution
Debugging a mixed Python and C++ program is tricky. You can use gdb to debug the C++ parts of TensorFlow, however. There are two main ways to do this:
Run
pythonundergdb, rather than the test script itself. Let's say that your test script is inbazel-bin/tensorflow/python/kernel_tests/decode_raw_op_test. You would run the following command:$ gdb python bazel-bin/tensorflow/python/kernel_tests/decode_raw_op_test (gdb) runNote that
gdbdoes not have great support for debugging the Python parts of the code. I'd recommend narrowing down the test case that you run to a single, simple test, and setting a breakpoint on a TensorFlow C API method, such asTF_Run, which is the main entry point from Python into C++ in TensorFlow.Attach
gdbto a running process. You can get the process ID of the Python test usingpsand then run (where$PIDis the process ID):$ gdb -p $PIDYou will probably need to arrange for your Python code to block so that there's time to attach. Calling the
raw_input()function is an easy way to do this.
Answered By - mrry Answer Checked By - Robin (Python.Easybugfix Admin)
Post a Comment
Post a Comment