(section, outputCount=0)
| 792 | return script |
| 793 | |
| 794 | def 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''' |
| 800 | struct 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 | |
| 809 | struct 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''' |
| 817 | memset(&classNames, 0, sizeof(classNames)); |
| 818 | for (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 | } |
| 822 | classNames''' |
| 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 | |
| 839 | def getLazyPointersFromData(data, section, outputCount=0): |
| 840 | script = generateLazyPointerScriptWithOptions(section) |
no test coverage detected
searching dependent graphs…