title: Finding Numpy array content with gdb
body: <p>I am trying to debug a python script with a c++ extension that takes a numpy array as argument. The numpy array is called times</p>
  
  <pre><code>times = np.arange(0.0,5.0)
  result = f(times)
  </code></pre>
  
  <p>This is an input in a C++ function that takes a PyObject*</p>
  
  <pre><code>f(PyObject* times)
  </code></pre>
  
  <p>is a C++ function (it goes via Boost.Python)</p>
  
  <p>I am trying to debug into this using gdb, but I can't seem to find the data of times. See my output below. I suspect it gets an empty array (as ob_size =0), but I am not sure as I am not very experienced with the C++ underlyings of numpy arrays.</p>
  
  <p>Any thoughts,
  Mike</p>
  
  <p>GDB debugging session</p>
  
  <pre><code>(gdb) p times
  $21 = (PyObject *) 0x7ffff2c9b620
  (gdb) p *$21
  $22 = {ob_refcnt = 2, ob_type = 0x7ffff5518a80 &lt;PyArray_Type&gt;}
  (gdb) p *$22.ob_type
  $23 = {ob_refcnt = 190, ob_type = 0x91f8e0 &lt;PyType_Type&gt;, ob_size = 0, 
  tp_name = 0x7ffff52d5566 "numpy.ndarray", tp_basicsize = 80, tp_itemsize = 0, 
  tp_dealloc = 0x7ffff51d35b0 &lt;array_dealloc&gt;, tp_print = 0x0, tp_getattr = 0x0, tp_setattr = 0x0, 
  tp_compare = 0x0, tp_repr = 0x7ffff51d3810 &lt;array_repr&gt;, 
  tp_as_number = 0x7ffff551fc40 &lt;array_as_number&gt;, tp_as_sequence = 0x7ffff551fd80    &lt;array_as_sequence&gt;, 
  tp_as_mapping = 0x7ffff551d570 &lt;array_as_mapping&gt;, tp_hash = 0x0, tp_call = 0x0, 
  tp_str = 0x7ffff51d37a0 &lt;array_str&gt;, tp_getattro = 0x442fef &lt;PyObject_GenericGetAttr&gt;, 
  tp_setattro = 0x4272ff &lt;PyObject_GenericSetAttr&gt;, tp_as_buffer = 0x7ffff551b920 &lt;array_as_buffer&gt;, 
  tp_flags = 2233851, 
  tp_doc = 0xbf2814 "ndarray(shape, dtype=float, buffer=None, offset=0,\n", ' ' &lt;repeats 12 times&gt;, "strides=None, order=None)\n\n    An array object represents a multidimensional, homogeneous array\n    of fixed-size items.  An associated d"..., tp_traverse = 0x0, tp_clear = 0x0, 
  tp_richcompare = 0x7ffff51d4750 &lt;array_richcompare&gt;, tp_weaklistoffset = 72, 
  tp_iter = 0x7ffff51d3760 &lt;array_iter&gt;, tp_iternext = 0x0, tp_methods = 0x7ffff551da00 &lt;array_methods&gt;, 
  tp_members = 0x0, tp_getset = 0x7ffff551c8e0 &lt;array_getsetlist&gt;, 
  tp_base = 0x9175e0 &lt;PyBaseObject_Type&gt;, tp_dict = 0x7ffff7e83a28, tp_descr_get = 0x0, 
  tp_descr_set = 0x0, tp_dictoffset = 0, tp_init = 0x5112d0, tp_alloc = 0x7ffff51d3050 &lt;array_alloc&gt;, 
  tp_new = 0x7ffff51d4d50 &lt;array_new&gt;, tp_free = 0x7ffff51d3040 &lt;array_free&gt;, tp_is_gc = 0x0, 
  tp_bases = 0x7ffff7e82a10, tp_mro = 0x7ffff7e8bab8, tp_cache = 0x0, tp_subclasses = 0x7ffff4cc2cf8, 
  tp_weaklist = 0x7ffff7e89100, tp_del = 0x0, tp_version_tag = 0}
  </code></pre>