MCPcopy
hub / github.com/DerekSelander/LLDB / getObjcCategoriesFromData

Function getObjcCategoriesFromData

lldb_commands/ds.py:794–837  ·  view source on GitHub ↗
(section, outputCount=0)

Source from the content-addressed store, hash-verified

792 return script
793
794def getObjcCategoriesFromData(section, outputCount=0):
795 target = getTarget()
796 ptrsize = getType("void*").GetByteSize()
797 sz = section.GetByteSize() / ptrsize
798 addr = section.GetLoadAddress(target)
799 script = r'''
800struct ds_category_t {
801 const char *name;
802 Class /* classref_t */ cls;
803 void */* struct method_list_t */ *instanceMethods;
804 void */* struct method_list_t */ *classMethods;
805 void */* struct protocol_list_t */ *protocols;
806 void */* struct property_list_t */ *instanceProperties;
807};
808
809struct ds_ret_category {
810 char *name;
811 char *className;
812};
813'''
814
815 script += "int dssize = {};\nstruct ds_ret_category classNames[{}];\nstruct ds_category_t **categoryPointer = (struct ds_category_t**){};".format(sz, sz, addr)
816 script += r'''
817memset(&classNames, 0, sizeof(classNames));
818for (int i = 0; i < dssize; i++) {
819 classNames[i].name = (char*)(categoryPointer[i]->name);
820 classNames[i].className = (char*)(class_getName(categoryPointer[i]->cls));
821}
822classNames''&#x27;
823 indeces = []
824 stringList = []
825 descriptions = []
826 # lldb.debugger.HandleCommand('exp -l objc++ -O -g -- ' + script)
827 # return (indeces, stringList)
828 val = target.EvaluateExpression(script, genExpressionOptions(False, True, True))
829 for i in range(val.GetNumChildren()):
830 x = val.GetChildAtIndex(i)
831 # x.GetChildAtIndex(0) # category name
832 # x.GetChildAtIndex(1) # class name
833 indeces.append(i * ptrsize)
834 stringList.append(x.GetChildAtIndex(1).summary.strip('\"'))
835 descriptions.append("(" + x.GetChildAtIndex(0).summary.strip('\"') + ")")
836
837 return (indeces, stringList, descriptions)
838
839def getLazyPointersFromData(data, section, outputCount=0):
840 script = generateLazyPointerScriptWithOptions(section)

Callers 1

formatFromDataFunction · 0.85

Calls 3

getTargetFunction · 0.85
getTypeFunction · 0.85
genExpressionOptionsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…