title: How do I determine detailed call-stack information in C++?
body: <p><strong><em>I’d like to understand the call-stack a bit better, and in an effort to do so, I’d like to work with it some more.</em></strong></p>
  
  <p>What will I do with this information? I have no idea! It’s fun to learn new things though, and this is my new thing for today.</p>
  
  <p>I don’t like the call-stack in my programs being this mystical entity that I know nothing about. How big is it? How much memory is available on my current call-stack? <em>Where is it?</em> I don't know! And, I would like to know.</p>
  
  <p>My current way to deal with the call-stack is to be aware of it, but to not knowingly interact with it until I hit a stack overflow error. <em>That's just not good enough!</em></p>
  
  <p>So in my quest, I’d like to figure out how to do the following:</p>
  
  <ol>
  <li><p><em>I'd like to know the total size of the current call-stack that I'm operating on.</em></p></li>
  <li><p><em>I'd like to calculate the total available memory available on my current call-stack.</em></p></li>
  <li><p><em>I’d like to be able to find the address of where my call-stack starts.</em></p></li>
  </ol>
  
  <p>The declaration could look like this, and be filled in for various platforms:</p>
  
  <pre><code>class call_stack
  {
      inline static void* base_address();
      inline static void* end_address();
      inline static std::size_t size();
      inline static std::size_t remaining();
  };
  </code></pre>
  
  <p><strong><em>How is stack information defined on current desktop and mobile platforms, and how can I access it? How can I code this at compile time, or determine it at runtime?</em></strong></p>
  
  <p>Looking into this reminds me of a talk that Herb Sutter gave about atomics. He said something along the lines of “as C++ programmers, we like to push the big red buttons that say don’t touch.”</p>
  
  <p>I realize there are many questions about the call-stack, and I believe that mine is both meaningful and unique. </p>
  
  <p><em>Other questions on the call-stack topic don't ask about the call-stack in a similarly broad manner to what I'm asking here.</em></p>