summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-10-27 00:02:05 +0000
committerSean Callanan <scallanan@apple.com>2011-10-27 00:02:05 +0000
commit7ba9636f0a04822812183fdc3c087bd4b7f72ca5 (patch)
treeba44dc6fe29ad72faf20fee22621db94f7929ea0
parent3249a1e8626fb73fba5fc840d2656b77ec27bf20 (diff)
downloadbcm5719-llvm-7ba9636f0a04822812183fdc3c087bd4b7f72ca5.tar.gz
bcm5719-llvm-7ba9636f0a04822812183fdc3c087bd4b7f72ca5.zip
Added an extra parameter to the object-checker
functions in the Objective-C language runtime that is set to the selector that is being passed to the object. llvm-svn: 143083
-rw-r--r--lldb/source/Expression/IRDynamicChecks.cpp40
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp36
3 files changed, 53 insertions, 25 deletions
diff --git a/lldb/source/Expression/IRDynamicChecks.cpp b/lldb/source/Expression/IRDynamicChecks.cpp
index 2af5e5ebedd..76b7ea30e26 100644
--- a/lldb/source/Expression/IRDynamicChecks.cpp
+++ b/lldb/source/Expression/IRDynamicChecks.cpp
@@ -275,6 +275,34 @@ protected:
return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
}
+ //------------------------------------------------------------------
+ /// Build a function pointer for a function with signature
+ /// void (*)(uint8_t*, uint8_t*) with a given address
+ ///
+ /// @param[in] start_address
+ /// The address of the function.
+ ///
+ /// @return
+ /// The function pointer, for use in a CallInst.
+ //------------------------------------------------------------------
+ llvm::Value *BuildObjectCheckerFunc(lldb::addr_t start_address)
+ {
+ IntegerType *intptr_ty = llvm::Type::getIntNTy(m_module.getContext(),
+ (m_module.getPointerSize() == llvm::Module::Pointer64) ? 64 : 32);
+
+ llvm::Type *param_array[2];
+
+ param_array[0] = const_cast<llvm::PointerType*>(GetI8PtrTy());
+ param_array[1] = const_cast<llvm::PointerType*>(GetI8PtrTy());
+
+ ArrayRef<llvm::Type*> params(param_array, 2);
+
+ FunctionType *fun_ty = FunctionType::get(llvm::Type::getVoidTy(m_module.getContext()), params, true);
+ PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
+ Constant *fun_addr_int = ConstantInt::get(intptr_ty, start_address, false);
+ return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
+ }
+
PointerType *GetI8PtrTy()
{
if (!m_i8ptr_ty)
@@ -386,14 +414,13 @@ private:
return false; // call_inst really shouldn't be NULL, because otherwise InspectInstruction wouldn't have registered it
if (!m_objc_object_check_func)
- m_objc_object_check_func = BuildPointerValidatorFunc(m_checker_functions.m_objc_object_check->StartAddress());
-
- llvm::Value *target_object = NULL;
+ m_objc_object_check_func = BuildObjectCheckerFunc(m_checker_functions.m_objc_object_check->StartAddress());
// id objc_msgSend(id theReceiver, SEL theSelector, ...)
- target_object = call_inst->getArgOperand(0);
-
+ llvm::Value *target_object = call_inst->getArgOperand(0);;
+ llvm::Value *selector = call_inst->getArgOperand(1);
+
// Insert an instruction to cast the receiver id to int8_t*
BitCastInst *bit_cast = new BitCastInst(target_object,
@@ -403,9 +430,10 @@ private:
// Insert an instruction to call the helper with the result
- llvm::Value *arg_array[1];
+ llvm::Value *arg_array[2];
arg_array[0] = bit_cast;
+ arg_array[1] = selector;
ArrayRef<llvm::Value*> args(arg_array, 1);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 6af8f2294d0..550272aa3a9 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -147,7 +147,7 @@ AppleObjCRuntimeV1::CreateObjectChecker(const char *name)
"}; \n"
" \n"
"extern \"C\" void \n"
- "%s(void *$__lldb_arg_obj) \n"
+ "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) \n"
"{ \n"
" struct __objc_object *obj = (struct __objc_object*)$__lldb_arg_obj; \n"
" (int)strlen(obj->isa->name); \n"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 818306054e5..9d774d0dd52 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -499,31 +499,31 @@ AppleObjCRuntimeV2::CreateObjectChecker(const char *name)
{
len = ::snprintf (check_function_code,
sizeof(check_function_code),
- "extern \"C\" void *gdb_object_getClass(void *); \n"
- "extern \"C\" void \n"
- "%s(void *$__lldb_arg_obj) \n"
- "{ \n"
- " if ($__lldb_arg_obj == (void *)0) \n"
- " return; // nil is ok \n"
- " if (!gdb_object_getClass($__lldb_arg_obj)) \n"
- " *((volatile int *)0) = 'ocgc'; \n"
- "} \n",
+ "extern \"C\" void *gdb_object_getClass(void *); \n"
+ "extern \"C\" void \n"
+ "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) \n"
+ "{ \n"
+ " if ($__lldb_arg_obj == (void *)0) \n"
+ " return; // nil is ok \n"
+ " if (!gdb_object_getClass($__lldb_arg_obj)) \n"
+ " *((volatile int *)0) = 'ocgc'; \n"
+ "} \n",
name);
}
else
{
len = ::snprintf (check_function_code,
sizeof(check_function_code),
- "extern \"C\" void *gdb_class_getClass(void *); \n"
- "extern \"C\" void \n"
- "%s(void *$__lldb_arg_obj) \n"
- "{ \n"
- " if ($__lldb_arg_obj == (void *)0) \n"
- " return; // nil is ok \n"
- " void **$isa_ptr = (void **)$__lldb_arg_obj; \n"
+ "extern \"C\" void *gdb_class_getClass(void *); \n"
+ "extern \"C\" void \n"
+ "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) \n"
+ "{ \n"
+ " if ($__lldb_arg_obj == (void *)0) \n"
+ " return; // nil is ok \n"
+ " void **$isa_ptr = (void **)$__lldb_arg_obj; \n"
" if (*$isa_ptr == (void *)0 || !gdb_class_getClass(*$isa_ptr)) \n"
- " *((volatile int *)0) = 'ocgc'; \n"
- "} \n",
+ " *((volatile int *)0) = 'ocgc'; \n"
+ "} \n",
name);
}
OpenPOWER on IntegriCloud