[lldb-dev] lldb test failures on 32bit

Michael Sartain mikesart at gmail.com
Thu Aug 15 10:39:14 PDT 2013

On Tue, Aug 13, 2013 at 6:22 PM, Michael Sartain <mikesart at gmail.com> wrote:

> Unwind info does exist for addresses in main(), and all of this works as
> expected in x64.
> I'll start debugging where this is failing...

For x86 elf files, the plt_entsize wasn't being rounded to the proper
alignment - this was causing the .plt symbols to be incorrect, along with
unwind info, etc. This patch fixes that:


The next problem is we're using the x64 register set, but then calling into
the i386 ABI. Ie, this call:

 246|     addr_t pc;
 247+>    if (!ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC,
 248|     {

Winds up here:

1092|     ExecutionContext exe_ctx(m_thread.shared_from_this());
1093|     Process *process = exe_ctx.GetProcessPtr();
1094|     if (have_unwindplan_regloc == false)
1095|     {
1096|         // If a volatile register is being requested, we don't want
to forward the next frame's register contents
1097|         // up the stack -- the register is not retrievable at this
1098|         ABI *abi = process ? process->GetABI().get() : NULL;
1099|         if (abi)
1100|         {
1101+>            const RegisterInfo *reg_info =
1102|             if (reg_info && abi->RegisterIsVolatile (reg_info))
1103|             {
1104|                 UnwindLogMsg ("did not supply reg location for %d
(%s) because it is volatile",
1105|                     lldb_regnum, reg_info->name ? reg_info->name :
1106|                 return
1107|             }
1108|         }

Which calls into this function:

902| bool
903| ABIMacOSX_i386::RegisterIsCalleeSaved (const RegisterInfo *reg_info)
904| {
905|     if (reg_info)
906|     {
907|         // Saved registers are ebx, ebp, esi, edi, esp, eip
908|         const char *name = reg_info->name;
909|         if (name[0] == 'e')
910|         {

reg_info->name is "rip", and so ABIMacOSX_i386::RegisterIsCalleeSaved() is
returning false.

ABIMacOSX_i386.cpp looks like it does several things using register names.

> Actually, RegisterContext_i386 doesn't get used in the case of a 32-bit
inferior on a 64-bit host.  In that scenario we use RegisterContext_x86_64
and do some mapping under the covers for 32-bit targets.

Does this mean this is an issue with RegisterContext_x86_64 returning "rip"
and not "eip"?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130815/938f5b2d/attachment.html>

More information about the lldb-dev mailing list