[Lldb-commits] [lldb] r143083 - in /lldb/trunk/source: Expression/IRDynamicChecks.cpp Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Sean Callanan
scallanan at apple.com
Wed Oct 26 17:02:05 PDT 2011
Author: spyffe
Date: Wed Oct 26 19:02:05 2011
New Revision: 143083
URL: http://llvm.org/viewvc/llvm-project?rev=143083&view=rev
Log:
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.
Modified:
lldb/trunk/source/Expression/IRDynamicChecks.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=143083&r1=143082&r2=143083&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original)
+++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Oct 26 19:02:05 2011
@@ -275,6 +275,34 @@
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 @@
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 @@
// 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);
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=143083&r1=143082&r2=143083&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Wed Oct 26 19:02:05 2011
@@ -147,7 +147,7 @@
"}; \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"
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=143083&r1=143082&r2=143083&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Oct 26 19:02:05 2011
@@ -499,31 +499,31 @@
{
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);
}
More information about the lldb-commits
mailing list