title: How to do basic parameter passing in gdb
body: <p>I have the following defined in my <code>.gdbinit</code>  to make it easier to print &quot;the stack&quot; when I want to see it in decimal format:</p>
  <pre><code>define s
     x/5gd $rsp
  end
  </code></pre>
  <p>Now I can type in something like:</p>
  <pre><code>&gt;&gt;&gt; s
  0x7fffffffe408: 10  8
  0x7fffffffe418: 6   4
  0x7fffffffe428: 2
  </code></pre>
  <p>By default it will print 5 8-byte values. How can I use an input parameter to use the number I pass instead of 5? For example, something like:</p>
  <pre><code>define s(d=5)
     x/%sgd $rsp % d
  end
  </code></pre>
  <p>Also, I'm familiar with python, so as long as I can access the input param, I could use that as well, i.e:</p>
  <pre><code>def stack():
      return &quot;x/%sgd&quot; % ('5' if not argv[1].isdigit() else argv[1])
  </code></pre>