Cannot debug tensorflow using gdb on macOS
<p>I am trying to debug TensorFlow using GDB on macOS Sierra. I followed the instructions on the <a href="https://gist.github.com/Mistobaan/738e76c3a5bb1f9bcc52e2809a23a7a1#run-python-test" rel="nofollow">post</a>.After I installed developer version of tensorflow for debug I tried to use gdb to attach a python session.</p>

<p>When I run <code>gdb -p &lt;pid&gt;</code>:</p>

<pre><code>GNU gdb (GDB) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin16.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/gdb/bugs/&gt;.
Find the GDB manual and other documentation resources online at:
&lt;http://www.gnu.org/software/gdb/documentation/&gt;.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 18822
Reading symbols from /Users/dtong/.virtualenvs/tensorflow/bin/python3.5...(no debugging symbols found)...done.

warning: unhandled dyld version (15)
0x00007fffc4d83f4e in ?? ()
(gdb)
</code></pre>

<p>When I set the breakpoint:</p>

<pre><code>(gdb) break TF_NewSession
Function "TF_NewSession" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (TF_NewSession) pending.
</code></pre>

<p>Then even I run <code>sess = tf.Session()</code> as the post says. GDB will never enter into breakpoint.</p>

<p>Well, after I change to use <code>lldb</code> on macOS, everything works fine. So I guess the solution to this problem is "USING LLDB INSTEAD OF GDB".</p>

python debugging gdb tensorflow