title: Can we define a new data type in a GDB session
body: <p>Is there a way to define a new data type (C structure or union) in gdb. The idea is to define a structure and then make gdb print data from an address interpreted as the newly defined structure.</p>
  
  <p>For example, lets say we have a sample structure.</p>
  
  <pre><code>struct sample {
    int i;
    struct sample *less;
    struct sample *more;
  }
  </code></pre>
  
  <p>And if 0x804b320 is the address of an array of <code>struct sample</code>. The binary doesn't have debugging information so that gdb understands <code>struct sample</code>. Is there any way to define <code>struct sample</code> in a gdb session? So that we can print <code>p *(struct sample *)0x804b320</code></p>