[lldb-dev] Trying to understand AppleObjCRuntimeV1::CreateObjectChecker
Nat! via lldb-dev
lldb-dev at lists.llvm.org
Fri Jul 1 02:38:41 PDT 2016
Hi
is this funny function AppleObjCRuntimeV1::CreateObjectChecker actually
used ?
First of all the snprintf is wrapped in an assert (!?). If the code gets
compiled with -DNDEBUG, the function would pretty much do nothing.
Second, I guess, that this is some C-code that gets compiled on the fly,
It seems to do nothing. I guess the code has a chance of crashing, if
the parameter is not really an object. The debugger could notice that
and figure out, that it's not an object. But guessing is not knowing... :)
Ciao
Nat!
```
struct BufStruct {
char contents[2048];
};
UtilityFunction *
AppleObjCRuntimeV1::CreateObjectChecker(const char *name)
{
std::unique_ptr<BufStruct> buf(new BufStruct);
assert(snprintf(&buf->contents[0], sizeof(buf->contents),
"struct __objc_class
\n"
"{
\n"
" struct __objc_class *isa;
\n"
" struct __objc_class *super_class;
\n"
" const char *name;
\n"
" // rest of struct elided because unused
\n"
"};
\n"
"
\n"
"struct __objc_object
\n"
"{
\n"
" struct __objc_class *isa;
\n"
"};
\n"
"
\n"
"extern \"C\" void
\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"
"}
\n",
name) < (int)sizeof(buf->contents));
Error error;
return GetTargetRef().GetUtilityFunctionForLanguage(buf->contents,
eLanguageTypeObjC, name, error);
}
```
More information about the lldb-dev
mailing list