{"record":{"id":"13020bbd0fce30dd","repo":"NationalSecurityAgency/ghidra","slug":"could-not-evaluate-expr-or-convert-result-va","errorCode":null,"errorMessage":"Could not evaluate '{expr}' or convert result '{value}'","messagePattern":"Could not evaluate '(.+?)' or convert result '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/util.py","lineNumber":645,"sourceCode":"    if type == DbgEng.DEBUG_VALUE_INT8:\n        return value.u.I8\n    if type == DbgEng.DEBUG_VALUE_INT16:\n        return value.u.I16\n    if type == DbgEng.DEBUG_VALUE_INT32:\n        return value.u.I32\n    if type == DbgEng.DEBUG_VALUE_INT64:\n        return value.u.I64.I64\n    if type == DbgEng.DEBUG_VALUE_FLOAT32:\n        return value.u.F32\n    if type == DbgEng.DEBUG_VALUE_FLOAT64:\n        return value.u.F64\n    if type == DbgEng.DEBUG_VALUE_FLOAT80:\n        return value.u.F80Bytes\n    if type == DbgEng.DEBUG_VALUE_FLOAT82:\n        return value.u.F82Bytes\n    if type == DbgEng.DEBUG_VALUE_FLOAT128:\n        return value.u.F128Bytes\n    raise ValueError(\n        f\"Could not evaluate '{expr}' or convert result '{value}'\")\n\n\n@dbg.eng_thread\ndef get_pc() -> int:\n    return dbg._base.reg.get_pc()\n\n\n@dbg.eng_thread\ndef get_sp() -> int:\n    return dbg._base.reg.get_sp()\n\n\n@dbg.eng_thread\ndef GetProcessIdsByIndex(count: int = 0) -> Tuple[List[int], List[int]]:\n    # TODO: This could be contributed upstream?\n    if count == 0:\n        try:","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/util.py#L627-L663","documentation":"Raised as ValueError at the end of the DbgEng expression evaluator when Evaluate() succeeded (check_err passed) but the returned DEBUG_VALUE type did not match any known branch (INT8/16/32/64, FLOAT32/64/80/82/128). In practice this is a defensive/unreachable branch: it guards against an unexpected value-type enum from DbgEng.","triggerScenarios":"Calling the evaluator (util expr evaluation) with a DesiredType constant outside the handled set, or a DbgEng version that returns a value type enum the agent does not enumerate.","commonSituations":"Passing a custom DEBUG_VALUE_* constant; newer DbgEng exposing additional value types (e.g. vector) not yet handled by the agent.","solutions":["Restrict the DesiredType argument to one of the handled DEBUG_VALUE_* constants (default INT64 covers most cases).","If a new value type appears, extend the if-chain in the evaluator to handle it.","Catch ValueError and report the unhandled type/value so the gap can be patched upstream."],"exampleFix":"// before\nreturn evaluate(expr, type=some_custom_type)  # unhandled -> ValueError\n// after\nhandled = {DbgEng.DEBUG_VALUE_INT8, DbgEng.DEBUG_VALUE_INT16,\n            DbgEng.DEBUG_VALUE_INT32, DbgEng.DEBUG_VALUE_INT64,\n            DbgEng.DEBUG_VALUE_FLOAT32, DbgEng.DEBUG_VALUE_FLOAT64,\n            DbgEng.DEBUG_VALUE_FLOAT80, DbgEng.DEBUG_VALUE_FLOAT82,\n            DbgEng.DEBUG_VALUE_FLOAT128}\nassert type in handled, f\"unsupported DesiredType {type}\"\nreturn evaluate(expr, type=type)","handlingStrategy":"try-catch","validationCode":"handled = {DbgEng.DEBUG_VALUE_INT8, DbgEng.DEBUG_VALUE_INT16,\n           DbgEng.DEBUG_VALUE_INT32, DbgEng.DEBUG_VALUE_INT64,\n           DbgEng.DEBUG_VALUE_FLOAT32, DbgEng.DEBUG_VALUE_FLOAT64,\n           DbgEng.DEBUG_VALUE_FLOAT80, DbgEng.DEBUG_VALUE_FLOAT82,\n           DbgEng.DEBUG_VALUE_FLOAT128}\nassert type in handled, f'unhandled DesiredType {type}'","typeGuard":"def is_handled_value_type(t) -> bool:\n    return t in {DbgEng.DEBUG_VALUE_INT8, DbgEng.DEBUG_VALUE_INT16,\n                DbgEng.DEBUG_VALUE_INT32, DbgEng.DEBUG_VALUE_INT64,\n                DbgEng.DEBUG_VALUE_FLOAT32, DbgEng.DEBUG_VALUE_FLOAT64,\n                DbgEng.DEBUG_VALUE_FLOAT80, DbgEng.DEBUG_VALUE_FLOAT82,\n                DbgEng.DEBUG_VALUE_FLOAT128}","tryCatchPattern":"try:\n    val = evaluate(expr, type=desired)\nexcept ValueError as e:\n    log.warning('evaluator cannot handle type %s for %r: %s', desired, expr, e)\n    val = evaluate(expr, type=DbgEng.DEBUG_VALUE_INT64)  # safe fallback","preventionTips":["Default DesiredType to DEBUG_VALUE_INT64 for numeric expressions.","Restrict DesiredType to the handled DEBUG_VALUE_* set before calling the evaluator.","Extend the if-chain if a newer DbgEng exposes additional value types."],"tags":["dbgeng","evaluator","value-type","unreachable-branch"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}