title: How to debug C++11 code with unique_ptr in DDD (or gdb)?
body: <p><code>std::unique_ptr</code> are nice, but I find them less comfortable when debugging in <a href="https://www.gnu.org/software/ddd/">DDD</a> or <a href="https://www.gnu.org/software/gdb/">gdb</a>.</p>
  
  <p>I'm using the gdb pretty printers that are part of gcc (e.g., <code>/usr/share/gcc-4.8.2/python/libstdcxx/v6/printers.py</code>). That is a big win for readability, for example:</p>
  
  <pre><code>$ print pTest
  std::unique_ptr&lt;MyType&gt; containing 0x2cef0a0
  </code></pre>
  
  <p>However, dereferencing the pointer does not work:</p>
  
  <pre><code>$ print *pTest
  Could not find operator*.
  </code></pre>
  
  <p>When I need to access the value, I have to manually copy the pointer and cast it to the correct type, for example:</p>
  
  <pre><code>print *((MyType*) 0x2cef0a0)
  </code></pre>
  
  <p>If the process is still running, this version works (still ugly but better):</p>
  
  <pre><code>print *pTest.get() // will not work if analyzing a core dump
  </code></pre>
  
  <p>The straightforward approach to <code>Display *pTest</code> in DDD does not work either. It only results in the following error:</p>
  
  <pre><code>&lt;error: Could not find operator*.&gt;
  </code></pre>
  
  <p><strong>Is there a way to debug C++11 code with unique_ptr in DDD</strong> (without breaking the workflow like I do with my cumbersome workarounds)?</p>
  
  <hr>
  
  <p>I'm not afraid to use gdb commands, but DDD integration would be a plus. For example, following pointers in data structures by just double-clicking on them is often faster than typing.</p>
  
  <p>I already tried to drop the pretty printer, but it is also not optimal. The best that I could come up with is the following:</p>
  
  <pre><code> print pTest._M_t-&gt;_M_head_impl
  </code></pre>