def copy_value(obj):
    """
    Copy SBValue object and preserve dynamic type.

    Useful when `SetPreferDynamicValue()` cannot be used on original object.

    :param lldb.SBValue obj: LLDB object.
    :return: Copy of obj.
    :rtype: lldb.SBValue
    """
    c = obj.GetDynamicValue(obj.GetPreferDynamicValue())
    return c
