<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - The _Unwind_Backtrace code for arm based systems is non-functional."
   href="http://llvm.org/bugs/show_bug.cgi?id=20779">20779</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The _Unwind_Backtrace code for arm based systems is non-functional.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++abi
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cferris@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12943" name="attach_12943" title="Example of failing test.">attachment 12943</a> <a href="attachment.cgi?id=12943&action=edit" title="Example of failing test.">[details]</a></span>
Example of failing test.

src/Unwind/UnwindLevel1-gcc-ext.c implements the _Unwind_Backtrace function.
Arm has it's own unwind format that is special, and on this platform, the IP is
never modified. Calling this function results in an infinite loop calling the
trace function without ever terminating.

Attached is a simple example that will run infinitely.

I implemented a hack to allow this to work. Adding this to the end of
_Unwind_Backtrace

#if LIBCXXABI_ARM_EHABI
    // Get the information for this frame.
    unw_proc_info_t frameInfo;
    if (unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {
      return _URC_END_OF_STACK;
    }

    uint32_t* unwindInfo = (uint32_t *) frameInfo.unwind_info;
    uint32_t format = ((*unwindInfo & 0x0f000000) >> 24);
    size_t len, startOffset;
    switch (format) {
      case 0:  // Short descriptor, 16-bit entries
        len = 4;
        startOffset = 1;
        break;
      case 1:  // Long descriptor, 16-bit entries
      case 3:  // Long descriptor, 32-bit entries
        len = 4 + 4 * ((*unwindInfo & 0x00ff0000) >> 16);
        startOffset = 2;
        break;
      default:
        startOffset = 0;
        break;
    }
    // Update the IP address.
    result = _Unwind_VRS_Interpret((struct _Unwind_Context *)(&cursor),
        unwindInfo, startOffset, len);
    if (result != _URC_CONTINUE_UNWIND) {
      return _URC_END_OF_STACK;
    }
#endif  // LIBCXXABI_ARM_EHABI

This is just a kludge to allow this code to work to mostly work. It also has a
problem since the backtrace will stop at the first catch it finds even with
this code.

This can be tested on an Android aosp tree if necessary.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>