[lldb-dev] Calling const char* functions from within lldb

Carlo Kok ck at remobjects.com
Tue Mar 5 08:48:33 PST 2013


I want to do a msgSend so first I need a selector (Which needs an 
NSString/CFString) so my first step was:


FindSymbolsWithNameAndType(... "__CFStringMakeConstantString")

to get the pointer to the function (that goes fine)

ValueList args;
Value strname((uint8_t*)value.c_str(), value.length() + 1);
strname.SetContext(Value::eContextTypeClangType, 
ast_context->GetCStringType(true));
args.PushValue(strname);

auto rettype = ast_context->CreatePointerType 
(ast_context->GetBuiltInType_void());

Value ret;
ret.SetContext(Value::eContextTypeClangType, rettype);

ClangFunction func (*GetBestExecutionContextScope(),
                     ast,
                     rettype,
                     *fn,
                     args);

     func.InsertFunction(m_process, wrapper_struct_addr, error_stream);



     ExecutionResults results = func.ExecuteFunction (m_process,
       &wrapper_struct_addr,
       error_stream,
       true,
       0 /* no timeout */,
       true,
       true,
       true,
       ret);




However this fails with a stop_reason exception, so I think I'm doing 
something wrong. Is this the right way to pass a char* to the process on 
the other side? If so, what could I be missing, if not, what is?

Thanks,

Carlo Kok



More information about the lldb-dev mailing list