def argumentAsString()

in commands/FBInvocationCommands.py [0:0]


def argumentAsString(frame, address, encoding):  # noqa C901
    if encoding[0] == "{":
        encoding = encoding[1:]

    encodingMap = {
        "c": "char",
        "i": "int",
        "s": "short",
        "l": "long",
        "q": "long long",
        "C": "unsigned char",
        "I": "unsigned int",
        "S": "unsigned short",
        "L": "unsigned long",
        "Q": "unsigned long long",
        "f": "float",
        "d": "double",
        "B": "bool",
        "v": "void",
        "*": "char *",
        "@": "id",
        "#": "Class",
        ":": "SEL",
    }

    pointers = ""
    while encoding[0] == "^":
        pointers += "*"
        encoding = encoding[1:]

    type = None
    if encoding in encodingMap:
        type = encodingMap[encoding]

    if type and pointers:
        type = type + " " + pointers

    if not type:
        # Handle simple structs: {CGPoint=ff}, {CGSize=ff},
        # {CGRect={CGPoint=ff}{CGSize=ff}}
        if encoding[0] == "{":
            encoding = encoding[1:]

        type = re.sub(r"=.*", "", encoding)
        if pointers:
            type += " " + pointers

    if type:
        value = frame.EvaluateExpression("*(" + type + " *)" + str(address))

        if value.GetError() is None or str(value.GetError()) == "success":
            description = None

            if encoding == "@":
                description = value.GetObjectDescription()

            if not description:
                description = value.GetValue()
            if not description:
                description = value.GetSummary()
            if description:
                return type + ": " + description

    return None