NationalSecurityAgency/ghidra · error · ValueError

Unrecognized order: {order}

Error message

Unrecognized order: {order}

What it means

ValueError raised by get_byte_order() when SBData.byte_order is not one of big, little, or PDP. This is a defensive fallthrough for an unrecognized lldb byte-order enum value, indicating either a new LLDB API addition or corrupt/unexpected data.

Source

Thrown at Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py:1088

    return [int(value.GetChildAtIndex(i).GetValueAsUnsigned())
            for i in range(0, n)]


def to_short_list(value: lldb.SBValue) -> List[int]:
    n = value.GetNumChildren()
    return [int(value.GetChildAtIndex(i).GetValueAsUnsigned())
            for i in range(0, n)]


def get_byte_order(order: int) -> Literal['big', 'little']:
    if order == lldb.eByteOrderBig:
        return 'big'
    elif order == lldb.eByteOrderLittle:
        return 'little'
    elif order == lldb.eByteOrderPDP:
        raise ValueError("PDP byte order unsupported")
    else:
        raise ValueError(f"Unrecognized order: {order}")


def data_to_int(data: lldb.SBData) -> int:
    order = get_byte_order(data.byte_order)
    return int.from_bytes(data.uint8s, order)


def data_to_reg_bytes(data: lldb.SBData) -> bytes:
    order = get_byte_order(data.byte_order)
    if order == 'little':
        return bytes(reversed(data.uint8s))
    return bytes(data.uint8s)


def eval_value(expr: str, schema: Optional[sch.Schema] = None) -> Tuple[Union[
        bool, int, float, bytes, Tuple[str, Address], List[bool], List[int],
        str, None], Optional[sch.Schema]]:
    return convert_value(expr, util.get_eval(expr), schema)

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure a valid target/process/frame is selected before calling commands that read byte_order.
  2. Check the LLDB version changelog for new eByteOrder constants and extend get_byte_order if needed.
  3. Downgrade or pin LLDB to a version whose byte-order enum this agent was written against.
Defensive patterns

Strategy: validation

Validate before calling

import lldb

KNOWN_ORDERS = {lldb.eByteOrderBig, lldb.eByteOrderLittle, lldb.eByteOrderPDP}

def order_recognized(order: int) -> bool:
    return order in KNOWN_ORDERS

Type guard

def is_known_order(order: int) -> bool:
    import lldb
    return order in {lldb.eByteOrderBig, lldb.eByteOrderLittle, lldb.eByteOrderPDP}

Try / catch

try:
    order = get_byte_order(data.byte_order)
except ValueError as e:
    if 'Unrecognized' in str(e):
        # log and skip; new/unknown LLDB byte order
        return None
    raise

Prevention

When it happens

Trigger: A newer LLDB version introduces a new eByteOrder* enum that this code does not handle; byte_order returns an out-of-range integer due to API misuse or an unloaded target.

Common situations: Upgrading LLDB to a version that adds endianness variants; querying byte_order before a target/process is properly selected so the field is uninitialized.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/58b6b6f504199a7a. Report an issue: GitHub.