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

Function getStringsFromData

lldb_commands/ds.py:881–915  ·  view source on GitHub ↗
(_data, outputCount=0)

Source from the content-addressed store, hash-verified

879 return (indeces, stringList, descriptions)
880
881def getStringsFromData(_data, outputCount=0):
882 indeces = []
883 stringList = []
884 target = getTarget()
885
886 # Hack, f it
887 if outputCount == 1:
888 err = lldb.SBError()
889 val = target.EvaluateExpression('(char *){}'.format(_data.GetAddress(err, 0)), genExpressionOptions())
890 print(val)
891
892 # Force conversion of "unknown" data to known of char**
893 t = target.GetBasicType(lldb.eBasicTypeChar).GetPointerType()
894 data = _data
895
896 vl = target.CreateValueFromData("__ds_unused", _data, t)
897 if not vl.IsValid():
898 print("SBValue not valid")
899 return (indeces, stringList)
900
901 dataArray = data.sint8
902 marker = 0
903
904 for index, x in enumerate(dataArray):
905 if outputCount != 0 and len(stringList) > outputCount:
906 break
907 if x == 0:
908 indeces.append(marker)
909 stringList.append(''.join([chr(i) for i in dataArray[marker:index]]))
910 marker = index + 1
911 if len(stringList) == 0:
912 stringList.append(''.join([chr(i) for i in data.sint8]))
913 indeces.append(0)
914
915 return (indeces, stringList)
916
917
918

Callers 1

formatFromDataFunction · 0.85

Calls 2

getTargetFunction · 0.85
genExpressionOptionsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…