Debug tensorflow unit tests
<p>I find the <a href="http://stackoverflow.com/questions/34204551/run-tensorflow-unit-tests">link</a> which shows how to run the unit tests.</p>

<p>And I think it could get a better understanding about the source code by debug the unit tests.</p>

<p>I can debug the source code as the tensorflow python application run. But I don't know how to debug the unit test. I am new to bazel and gdb debug.</p>

<p>To summarize:</p>

<ul>
<li>you have to make sure the test binary is built first: either by running <code>bazel test &lt;target&gt;</code> or with <code>bazel build &lt;target&gt;</code> or with <code>bazel build -c dbg &lt;target&gt;</code>. The last one gives fully debuggable executables that give you line numbers in gdb backtrace.</li>
<li>The binary is in the same directory as the BUILD file (ie, if you have <code>tensorflow/core/BUILD</code>, then the binary will be under <code>bazel-bin/tensorflow/core</code>)</li>
<li>You can find the name of bazel  that includes given <code>.cc</code> file by using bazel query. IE, for <code>common_shape_fns_test</code> you can find that target name is <code>//tensorflow/core:framework_common_shape_fns_test</code> by using command below</li>
</ul>

<p>.</p>

<pre><code>fullname=$(bazel query tensorflow/core/framework/common_shape_fns_test.cc)
bazel query "attr('srcs', $fullname, ${fullname//:*/}:*)"
</code></pre>

python c++ machine-learning gdb tensorflow