Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
adapt to changes in runtime, specifically new load version and differ…
Browse files Browse the repository at this point in the history
…ent call function names
  • Loading branch information
codeon-nat authored and mulle-nat committed Nov 11, 2018
1 parent e7e06d4 commit cb30cf6
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion include/lldb/Target/ObjCLanguageRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ObjCLanguageRuntime : public LanguageRuntime {
eAppleObjC_V1 = 1,
eAppleObjC_V2 = 2
// @mulle-lldb@ add runtime enum >
, eMulleObjC_V1 = 1848
, eMulleObjC_V1 = 48
// @mulle-lldb@ add runtime enum <
};

Expand Down
2 changes: 1 addition & 1 deletion source/Expression/ExpressionSourceCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static const struct mulle_clang_objccompilerinfo\n\
unsigned int runtime_version;\n\
} __mulle_objc_objccompilerinfo =\n\
{\n\
12, // load version must match \n\
14, // load version must match \n\
0 // 0 to not emit __load_mulle_objc\n\
};\n\
");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,12 @@ static bool _IsSymbolARuntimeThunk(const Symbol &symbol) {
// *** object calls ***

static ConstString g_c_01 = ConstString( "mulle_objc_object_call");
static ConstString g_c_02 = ConstString( "mulle_objc_object_inlinecall_constantmethodid");
static ConstString g_c_03 = ConstString( "mulle_objc_object_call_constantmethodid");
static ConstString g_c_02 = ConstString( "mulle_objc_object_inlinecall");
static ConstString g_c_03 = ConstString( "mulle_objc_object_partialinlinecall");
static ConstString g_c_04 = ConstString( "mulle_objc_object_inlinecall_variablemethodid");

// *** objects calls ***

static ConstString g_c_05 = ConstString( "mulle_objc_objects_call");

// *** internal calls ***
Expand All @@ -321,7 +324,7 @@ static bool _IsSymbolARuntimeThunk(const Symbol &symbol) {
static ConstString g_c_08 = ConstString( "_mulle_objc_object_call2_needcache");
static ConstString g_c_09 = ConstString( "_mulle_objc_object_call_class");
static ConstString g_c_10 = ConstString( "_mulle_objc_object_call_class_needcache");
static ConstString g_c_11 = ConstString( "_mulle_objc_object_call_methodid_nofail");
static ConstString g_c_11 = ConstString( "_mulle_objc_object_call_class_nofail");
static ConstString g_c_12 = ConstString( "_mulle_objc_object_call_class_nocache");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace lldb_private;
static const char *g_dangerous_function_name =
"__lldb_objc_get_dangerous_class_storage";

static const char *g_dangerous_function_code =
static const char *g_dangerous_function_code =

#include "mulle-objc-dangerous-class-storage.inc"

Expand Down Expand Up @@ -132,11 +132,13 @@ struct BufStruct {
char contents[2048];
};

static char object_checker_c[] =
#ifndef NDEBUG
static char object_checker_c[] =

#include "mulle-objc-object-checker.inc"

;
#endif


UtilityFunction *MulleObjCRuntimeV1::CreateObjectChecker(const char *name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ using namespace lldb_private;
static const char *g_lookup_implementation_function_name =
"__lldb_objc_find_implementation_for_selector";

static const char *g_lookup_implementation_function_code =
static const char *g_lookup_implementation_function_code =

#include "mulle-objc-lookup-imp.inc"
;
Expand All @@ -70,7 +70,7 @@ MulleObjCTrampolineHandler::~MulleObjCTrampolineHandler() {}
//
// We should also step through
// mulle_objc_fastlookup_infraclass_nofail
// but we can't for now.
// but we can't for now. (Why not ?)
//
const MulleObjCTrampolineHandler::DispatchFunction
MulleObjCTrampolineHandler::g_dispatch_functions[] = {
Expand Down Expand Up @@ -183,8 +183,14 @@ MulleObjCTrampolineHandler::MulleObjCTrampolineHandler(
m_msgSend_map.insert(std::pair<lldb::addr_t, int>(sym_addr, i));
}

m_classlookup_addr = LookupFunctionSymbol( process_sp,
"mulle_objc_fastlookup_infraclass_nofail");
m_classlookup_addr[ 0] = LookupFunctionSymbol( process_sp,
"mulle_objc_global_lookup_infraclass_nofail");
m_classlookup_addr[ 1] = LookupFunctionSymbol( process_sp,
"mulle_objc_global_lookup_infraclass_nofail_nofast");
m_classlookup_addr[ 2] = LookupFunctionSymbol( process_sp,
"mulle_objc_object_lookup_infraclass_nofail");
m_classlookup_addr[ 3] = LookupFunctionSymbol( process_sp,
"mulle_objc_object_lookup_infraclass_nofail_nofast");
}


Expand Down Expand Up @@ -406,19 +412,22 @@ MulleObjCTrampolineHandler::GetStepThroughDispatchPlan( Thread &thread,

if( CanStepOver())
{
if( curr_pc == m_classlookup_addr)
{
if (log)
log->Printf( "Mulle: Return with \"step out of class-lookup\" plan.");

ret_plan_sp.reset( new ThreadPlanStepOut(
thread,
nullptr,
false, stop_others, eVoteYes,
eVoteNoOpinion, thread.GetSelectedFrameIndex(),
eLazyBoolNo));
return( ret_plan_sp);
}
int i;

for( i = 0; i < 4; i++)
if( curr_pc == m_classlookup_addr[ i])
{
if (log)
log->Printf( "Mulle: Return with \"step out of class-lookup\" plan.");

ret_plan_sp.reset( new ThreadPlanStepOut(
thread,
nullptr,
false, stop_others, eVoteYes,
eVoteNoOpinion, thread.GetSelectedFrameIndex(),
eLazyBoolNo));
return( ret_plan_sp);
}
}

// First step is to look and see if we are in one of the known ObjC dispatch functions. We've already compiled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MulleObjCTrampolineHandler {
bool stop_others);
lldb::ThreadPlanSP GetStepOutDispatchPlan(Thread &thread,
bool stop_others);


FunctionCaller *GetLookupImplementationFunctionCaller();

Expand All @@ -62,7 +62,7 @@ class MulleObjCTrampolineHandler {
private:
lldb::addr_t LookupFunctionSymbol( const lldb::ProcessSP &process_sp,
const char *name);

static const DispatchFunction g_dispatch_functions[];

typedef std::map<lldb::addr_t, int> MsgsendMap; // This table maps an dispatch
Expand All @@ -75,18 +75,18 @@ class MulleObjCTrampolineHandler {
const char *m_lookup_implementation_function_code;
std::unique_ptr<UtilityFunction> m_impl_code;
std::mutex m_impl_function_mutex;
lldb::addr_t m_classlookup_addr;
lldb::addr_t m_classlookup_addr[ 4];
lldb::addr_t m_impl_fn_addr;
lldb::addr_t m_msg_forward_addr; // this is the function to "get" the forward method from the class

public:
bool CanStepThrough()
{
return( m_impl_fn_addr != LLDB_INVALID_ADDRESS);
}
bool CanStepOver()
{
return( m_classlookup_addr != LLDB_INVALID_ADDRESS);
return( m_classlookup_addr[ 0] != LLDB_INVALID_ADDRESS);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"unsigned int runtime_version;\n"
"} __mulle_objc_objccompilerinfo =\n"
"{\n"
"12, \n"
"14, \n"
"0 \n"
"};\n"
"void *__lldb_objc_get_dangerous_class_storage( void)\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
extern "C"
{
static const
static const
struct mulle_clang_objccompilerinfo
{
unsigned int load_version;
unsigned int runtime_version;
} __mulle_objc_objccompilerinfo =
{
12, // load version must match
14, // load version must match
0 // 0 to not emit __load_mulle_objc
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"unsigned int runtime_version;\n"
"} __mulle_objc_objccompilerinfo =\n"
"{\n"
"12, \n"
"14, \n"
"0 \n"
"};\n"
"void *__lldb_objc_find_implementation_for_selector( void *object,\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
extern "C"
{
static const
static const
struct mulle_clang_objccompilerinfo
{
unsigned int load_version;
unsigned int runtime_version;
} __mulle_objc_objccompilerinfo =
{
12, // load version must match
14, // load version must match
0 // 0 to not emit __load_mulle_objc
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"unsigned int runtime_version;\n"
"} __mulle_objc_objccompilerinfo =\n"
"{\n"
"12, \n"
"14, \n"
"0 \n"
"};\n"
"void %s( void *$__lldb_obj, unsigned int $__lldb_sel)\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
extern "C"
{
static const
static const
struct mulle_clang_objccompilerinfo
{
unsigned int load_version;
unsigned int runtime_version;
} __mulle_objc_objccompilerinfo =
{
12, // load version must match
14, // load version must match
0 // 0 to not emit __load_mulle_objc
};

Expand Down

0 comments on commit cb30cf6

Please sign in to comment.