diff options
Diffstat (limited to 'source/Plugins/ABI')
| -rw-r--r-- | source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 76 | ||||
| -rw-r--r-- | source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h | 7 | ||||
| -rw-r--r-- | source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 116 | ||||
| -rw-r--r-- | source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h | 7 | ||||
| -rw-r--r-- | source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 90 | ||||
| -rw-r--r-- | source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h | 7 | 
6 files changed, 58 insertions, 245 deletions
| diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index f27c294a4abd..abf873ff3dd1 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -198,12 +198,7 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread,                                     addr_t sp,                                      addr_t function_addr,                                      addr_t return_addr,  -                                   addr_t *arg1_ptr, -                                   addr_t *arg2_ptr, -                                   addr_t *arg3_ptr, -                                   addr_t *arg4_ptr, -                                   addr_t *arg5_ptr, -                                   addr_t *arg6_ptr) const +                                   llvm::ArrayRef<addr_t> args) const  {      RegisterContext *reg_ctx = thread.GetRegisterContext().get();      if (!reg_ctx) @@ -215,50 +210,45 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread,      RegisterValue reg_value; -    if (arg1_ptr) +    const char *reg_names[] = { "r0", "r1", "r2", "r3" }; +     +    llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); +     +    for (size_t i = 0; i < (sizeof(reg_names) / sizeof(reg_names[0])); ++i)      { -        reg_value.SetUInt32(*arg1_ptr); -        if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r0"), reg_value)) +        if (ai == ae) +            break; +         +        reg_value.SetUInt32(*ai); +        if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName(reg_names[i]), reg_value))              return false; - -        if (arg2_ptr) +         +        ++ai; +    } +     +    if (ai != ae) +    { +        // Spill onto the stack +        size_t num_stack_regs = ae - ai; +         +        sp -= (num_stack_regs * 4); +        // Keep the stack 8 byte aligned, not that we need to +        sp &= ~(8ull-1ull); +         +        // just using arg1 to get the right size +        const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); +         +        addr_t arg_pos = sp; +         +        for (; ai != ae; ++ai)          { -            reg_value.SetUInt32(*arg2_ptr); -            if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r1"), reg_value)) +            reg_value.SetUInt32(*ai); +            if (reg_ctx->WriteRegisterValueToMemory(reg_info, arg_pos, reg_info->byte_size, reg_value).Fail())                  return false; - -            if (arg3_ptr) -            { -                reg_value.SetUInt32(*arg3_ptr); -                if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r2"), reg_value)) -                    return false; -                if (arg4_ptr) -                { -                    reg_value.SetUInt32(*arg4_ptr); -                    const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3"); -                    if (!reg_ctx->WriteRegister (reg_info, reg_value)) -                        return false; -                    if (arg5_ptr) -                    { -                        // Keep the stack 8 byte aligned, not that we need to -                        sp -= 8; -                        sp &= ~(8ull-1ull); -                        reg_value.SetUInt32(*arg5_ptr); -                        if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp, reg_info->byte_size, reg_value).Fail()) -                            return false; -                        if (arg6_ptr) -                        { -                            reg_value.SetUInt32(*arg6_ptr); -                            if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp + 4, reg_info->byte_size, reg_value).Fail()) -                                return false; -                        } -                    } -                } -            }             +            arg_pos += reg_info->byte_size;          }      } -      TargetSP target_sp (thread.CalculateTarget());      Address so_addr; diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h index 27cea85aaf6f..6f7b339e28a2 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -30,12 +30,7 @@ public:                          lldb::addr_t sp,                          lldb::addr_t func_addr,                          lldb::addr_t returnAddress,  -                        lldb::addr_t *arg1_ptr = NULL, -                        lldb::addr_t *arg2_ptr = NULL, -                        lldb::addr_t *arg3_ptr = NULL, -                        lldb::addr_t *arg4_ptr = NULL, -                        lldb::addr_t *arg5_ptr = NULL, -                        lldb::addr_t *arg6_ptr = NULL) const; +                        llvm::ArrayRef<lldb::addr_t> args) const;      virtual bool      GetArgumentValues (lldb_private::Thread &thread, diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index ecf44b9c4f73..f360a182e065 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -260,12 +260,7 @@ ABIMacOSX_i386::PrepareTrivialCall (Thread &thread,                                      addr_t sp,                                       addr_t func_addr,                                       addr_t return_addr,  -                                    addr_t *arg1_ptr, -                                    addr_t *arg2_ptr, -                                    addr_t *arg3_ptr, -                                    addr_t *arg4_ptr, -                                    addr_t *arg5_ptr, -                                    addr_t *arg6_ptr) const +                                    llvm::ArrayRef<addr_t> args) const  {      RegisterContext *reg_ctx = thread.GetRegisterContext().get();      if (!reg_ctx) @@ -287,114 +282,25 @@ ABIMacOSX_i386::PrepareTrivialCall (Thread &thread,      RegisterValue reg_value;      // Write any arguments onto the stack -    if (arg1_ptr) -    { -        sp -= 4; -        if (arg2_ptr) -        { -            sp -= 4; -            if (arg3_ptr) -            { -                sp -= 4; -                if (arg4_ptr) -                { -                    sp -= 4; -                    if (arg5_ptr) -                    { -                        sp -= 4; -                        if (arg6_ptr) -                        { -                            sp -= 4; -                        } -                    } -                } -            } -        } -    } - +    sp -= 4 * args.size(); +          // Align the SP          sp &= ~(16ull-1ull); // 16-byte alignment -    if (arg1_ptr) +    addr_t arg_pos = sp; +     +    for (addr_t arg : args)      { -        reg_value.SetUInt32(*arg1_ptr); -        error = reg_ctx->WriteRegisterValueToMemory (reg_info_32,  -                                                     sp,  -                                                     reg_info_32->byte_size,  +        reg_value.SetUInt32(arg); +        error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, +                                                     arg_pos, +                                                     reg_info_32->byte_size,                                                       reg_value);          if (error.Fail())              return false; - -        if (arg2_ptr) -        { -            reg_value.SetUInt32(*arg2_ptr); -            // The register info used to write memory just needs to have the correct -            // size of a 32 bit register, the actual register it pertains to is not -            // important, just the size needs to be correct. Here we use "eax"... -            error = reg_ctx->WriteRegisterValueToMemory (reg_info_32,  -                                                         sp + 4,  -                                                         reg_info_32->byte_size,  -                                                         reg_value); -            if (error.Fail()) -                return false; -             -            if (arg3_ptr) -            { -                reg_value.SetUInt32(*arg3_ptr); -                // The register info used to write memory just needs to have the correct -                // size of a 32 bit register, the actual register it pertains to is not -                // important, just the size needs to be correct. Here we use "eax"... -                error = reg_ctx->WriteRegisterValueToMemory (reg_info_32,  -                                                             sp + 8,  -                                                             reg_info_32->byte_size,  -                                                             reg_value); -                if (error.Fail()) -                    return false; - -                if (arg4_ptr) -                { -                    reg_value.SetUInt32(*arg4_ptr); -                    // The register info used to write memory just needs to have the correct -                    // size of a 32 bit register, the actual register it pertains to is not -                    // important, just the size needs to be correct. Here we use "eax"... -                    error = reg_ctx->WriteRegisterValueToMemory (reg_info_32,  -                                                                 sp + 12,  -                                                                 reg_info_32->byte_size,  -                                                                 reg_value); -                    if (error.Fail()) -                        return false; -                    if (arg5_ptr) -                    { -                        reg_value.SetUInt32(*arg5_ptr); -                        // The register info used to write memory just needs to have the correct -                        // size of a 32 bit register, the actual register it pertains to is not -                        // important, just the size needs to be correct. Here we use "eax"... -                        error = reg_ctx->WriteRegisterValueToMemory (reg_info_32,  -                                                                     sp + 16,  -                                                                     reg_info_32->byte_size,  -                                                                     reg_value); -                        if (error.Fail()) -                            return false; -                        if (arg6_ptr) -                        { -                            reg_value.SetUInt32(*arg6_ptr); -                            // The register info used to write memory just needs to have the correct -                            // size of a 32 bit register, the actual register it pertains to is not -                            // important, just the size needs to be correct. Here we use "eax"... -                            error = reg_ctx->WriteRegisterValueToMemory (reg_info_32,  -                                                                         sp + 20,  -                                                                         reg_info_32->byte_size,  -                                                                         reg_value); -                            if (error.Fail()) -                                return false; -                        } -                    } -                } -            } -        } +        arg_pos += 4;      } -          // The return address is pushed onto the stack (yes after we just set the      // alignment above!).      sp -= 4; diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h index 5428d0c1e44e..a2eee280fa38 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -33,12 +33,7 @@ public:                          lldb::addr_t sp,                          lldb::addr_t func_addr,                          lldb::addr_t return_addr,  -                        lldb::addr_t *arg1_ptr = NULL, -                        lldb::addr_t *arg2_ptr = NULL, -                        lldb::addr_t *arg3_ptr = NULL, -                        lldb::addr_t *arg4_ptr = NULL, -                        lldb::addr_t *arg5_ptr = NULL, -                        lldb::addr_t *arg6_ptr = NULL) const; +                        llvm::ArrayRef<lldb::addr_t> args) const;      virtual bool      PrepareNormalCall (lldb_private::Thread &thread, diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index a8cf714a13b3..a8ef6a51399c 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -303,12 +303,7 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,                                      addr_t sp,                                       addr_t func_addr,                                       addr_t return_addr,  -                                    addr_t *arg1_ptr, -                                    addr_t *arg2_ptr, -                                    addr_t *arg3_ptr, -                                    addr_t *arg4_ptr, -                                    addr_t *arg5_ptr, -                                    addr_t *arg6_ptr) const +                                    llvm::ArrayRef<addr_t> args) const  {      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -321,28 +316,8 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,                      (uint64_t)func_addr,                      (uint64_t)return_addr); -        if (arg1_ptr) -        { -            s.Printf (", arg1 = 0x%" PRIx64, (uint64_t)*arg1_ptr); -            if (arg2_ptr) -            { -                s.Printf (", arg2 = 0x%" PRIx64, (uint64_t)*arg2_ptr); -                if (arg3_ptr) -                { -                    s.Printf (", arg3 = 0x%" PRIx64, (uint64_t)*arg3_ptr); -                    if (arg4_ptr) -                    { -                        s.Printf (", arg4 = 0x%" PRIx64, (uint64_t)*arg4_ptr); -                        if (arg5_ptr) -                        { -                            s.Printf (", arg5 = 0x%" PRIx64, (uint64_t)*arg5_ptr); -                            if (arg6_ptr) -                                s.Printf (", arg6 = 0x%" PRIx64, (uint64_t)*arg6_ptr); -                        } -                    } -                } -            } -        } +        for (int i = 0; i < args.size(); ++i) +            s.Printf (", arg%d = 0x%" PRIx64, i + 1, args[i]);          s.PutCString (")");          log->PutCString(s.GetString().c_str());      } @@ -352,62 +327,19 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,          return false;      const RegisterInfo *reg_info = NULL; -    if (arg1_ptr) +     +    if (args.size() > 6) // TODO handle more than 6 arguments +        return false; +     +    for (int i = 0; i < args.size(); ++i)      { -        reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); +        reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);          if (log) -            log->Printf("About to write arg1 (0x%" PRIx64 ") into %s", (uint64_t)*arg1_ptr, reg_info->name); - -        if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg1_ptr)) +            log->Printf("About to write arg%d (0x%" PRIx64 ") into %s", i + 1, args[i], reg_info->name); +        if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i]))              return false; - -        if (arg2_ptr) -        { -            reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); -            if (log) -                log->Printf("About to write arg2 (0x%" PRIx64 ") into %s", (uint64_t)*arg2_ptr, reg_info->name); -            if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg2_ptr)) -                return false; - -            if (arg3_ptr) -            { -                reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3); -                if (log) -                    log->Printf("About to write arg3 (0x%" PRIx64 ") into %s", (uint64_t)*arg3_ptr, reg_info->name); -                if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg3_ptr)) -                    return false; - -                if (arg4_ptr) -                { -                    reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4); -                    if (log) -                        log->Printf("About to write arg4 (0x%" PRIx64 ") into %s", (uint64_t)*arg4_ptr, reg_info->name); -                    if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg4_ptr)) -                        return false; - -                    if (arg5_ptr) -                    { -                        reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5); -                        if (log) -                            log->Printf("About to write arg5 (0x%" PRIx64 ") into %s", (uint64_t)*arg5_ptr, reg_info->name); -                        if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg5_ptr)) -                            return false; - -                        if (arg6_ptr) -                        { -                            reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6); -                            if (log) -                                log->Printf("About to write arg6 (0x%" PRIx64 ") into %s", (uint64_t)*arg6_ptr, reg_info->name); -                            if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg6_ptr)) -                                return false; -                        } -                    } -                } -            } -        }      } -      // First, align the SP      if (log) diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h index d9d6fd7af79a..5ccb6e5fa744 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -34,12 +34,7 @@ public:                          lldb::addr_t sp,                          lldb::addr_t functionAddress,                          lldb::addr_t returnAddress,  -                        lldb::addr_t *arg1_ptr = NULL, -                        lldb::addr_t *arg2_ptr = NULL, -                        lldb::addr_t *arg3_ptr = NULL, -                        lldb::addr_t *arg4_ptr = NULL, -                        lldb::addr_t *arg5_ptr = NULL, -                        lldb::addr_t *arg6_ptr = NULL) const; +                        llvm::ArrayRef<lldb::addr_t> args) const;      virtual bool      GetArgumentValues (lldb_private::Thread &thread, | 
