[lldb-dev] [Bug 36870] New: x86_64 ABI only takes doesn't consult C++ info in computing return types

via lldb-dev lldb-dev at lists.llvm.org
Thu Mar 22 17:46:37 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=36870

            Bug ID: 36870
           Summary: x86_64 ABI only takes doesn't consult C++ info in
                    computing return types
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: jingham at apple.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20105
  --> https://bugs.llvm.org/attachment.cgi?id=20105&action=edit
Example file showing a case where we get the return wrong.

Build the attached notright.cpp and do:

 > lldb notright
(lldb) b s -p "Set a breakpoint here"
Breakpoint 1: where = notright`takeS(S) + 25 at notright.cpp:10, address =
0x0000000100000e19
(lldb) run
Process 35604 launched: '/tmp/notright' (x86_64)
Process 35604 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000e19 notright`takeS(S) at notright.cpp:10
   7    {
   8      S ret_val = inVal;
   9      ret_val.ivar = 30;
-> 10     return ret_val;   // Set a breakpoint here
          ^
   11   }
   12   
   13   int
Target 0: (notright) stopped.
(lldb) fin
Process 35604 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step out
Return value: (S) $0 = {
  ivar = -272632024
}

    frame #0: 0x0000000100000ea4 notright`main at notright.cpp:17
   14   main()
   15   {
   16     S inVal, outVal;
-> 17     outVal = takeS(inVal);
                   ^
   18   
   19     return 0;
   20   }
Target 0: (notright) stopped.

Note that the return value was not calculated correctly.  The struct is in fact
small enough and correctly aligned so by the simple Itanium ABI it should have
gotten passed in registers, but C++ for its own reasons decided to pass it in
memory instead.  We have to dig more information out of the C++ type to figure
out these cases.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20180323/066d557c/attachment.html>


More information about the lldb-dev mailing list