{"record":{"id":"840fa2dba3ec6308","repo":"NationalSecurityAgency/ghidra","slug":"conversion-of-string-arrays-unimplemented","errorCode":null,"errorMessage":"Conversion of string arrays unimplemented","messagePattern":"Conversion of string arrays unimplemented","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py","lineNumber":845,"sourceCode":"                        return to_string(val, type, 'utf-16', full=False), sch.STRING\n                    schema = sch.SHORT_ARR\n                elif schema == sch.CHAR_ARR:\n                    return to_string(val, type, 'utf-16', full=True), schema\n                return to_int_list(val, type), schema\n            elif etype.sizeof == 4:\n                if schema is None:\n                    if etype.name == 'wchar_t':\n                        return to_string(val, type, 'utf-32', full=False), sch.STRING\n                    schema = sch.INT_ARR\n                elif schema == sch.CHAR_ARR:\n                    return to_string(val, type, 'utf-32', full=True), schema\n                return to_int_list(val, type), schema\n            elif schema is not None:\n                return to_int_list(val, type), schema\n            elif etype.sizeof == 8:\n                return to_int_list(val, type), sch.LONG_ARR\n        elif etype.code == gdb.TYPE_CODE_STRING:\n            raise ValueError(\"Conversion of string arrays unimplemented\")\n        # TODO: Array of C strings?\n    elif type.code == gdb.TYPE_CODE_STRING:\n        return val.string(), sch.STRING\n    elif type.code == gdb.TYPE_CODE_PTR:\n        offset = int(val)\n        inf = gdb.selected_inferior()\n        base, addr = STATE.require_trace().extra.require_mm().map(inf, offset)\n        return (base, addr), sch.ADDRESS\n    raise ValueError(f\"Cannot convert ({schema}): '{value}', value='{val}'\")\n\n\n@cmd('ghidra trace set-value', '-ghidra-trace-set-value', gdb.COMMAND_DATA, True)\ndef ghidra_trace_set_value(path: str, key: str, value: str,\n                           schema: Optional[str] = None, *, is_mi: bool,\n                           **kwargs) -> None:\n    \"\"\"Set a value (attribute or element) in the Ghidra trace's object tree.\n\n    A void value implies removal. NOTE: The type of an expression may be","sourceCodeStart":827,"sourceCodeEnd":863,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py#L827-L863","documentation":"Thrown as a ValueError during type conversion in the gdb agent when a gdb.Value has type code gdb.TYPE_CODE_STRING inside an array context. The code explicitly raises this because conversion of Pascal-style string arrays (common in Fortran/Ada) to Ghidra trace values has not been implemented yet. The TODO comment confirms this is a known gap.","triggerScenarios":"Calling ghidra_trace_set_value or any value-conversion path with a gdb.Value whose dynamic type has code gdb.TYPE_CODE_STRING within an array. This occurs primarily when debugging Fortran or Ada programs that use fixed-length string arrays, or when evaluating expressions that yield such types.","commonSituations":"Debugging Fortran CHARACTER arrays, Ada string types, or Pascal STRING arrays; setting a value on a variable whose type resolves to TYPE_CODE_STRING in an array context; evaluating an expression in a mixed-language session.","solutions":["Avoid setting trace values for string-array typed variables — this conversion is unimplemented.","If the value is a simple string (not an array), access it via val.string() outside the array branch.","Convert the value to a byte array or int list manually before passing to the trace API.","File a feature request with the Ghidra project for TYPE_CODE_STRING array support."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def is_string_array_value(val: gdb.Value) -> bool:\n    try:\n        t = val.type.strip_typedefs()\n        if t.code == gdb.TYPE_CODE_ARRAY:\n            etype = t.target()\n            if etype.code == gdb.TYPE_CODE_STRING:\n                return True\n    except Exception:\n        pass\n    return False","typeGuard":"def is_convertible_value(val: gdb.Value) -> bool:\n    try:\n        t = val.type.strip_typedefs()\n        if t.code == gdb.TYPE_CODE_ARRAY:\n            etype = t.target()\n            if etype.code == gdb.TYPE_CODE_STRING:\n                return False\n        return True\n    except Exception:\n        return False","tryCatchPattern":"try:\n    result = convert_value(val, type, schema)\nexcept ValueError as e:\n    if 'string arrays unimplemented' in str(e):\n        print('TYPE_CODE_STRING array conversion is not supported. Skipping this value.')\n        result = None\n    else:\n        raise","preventionTips":["Check gdb.Value type codes before passing to the trace conversion API.","Avoid tracing Fortran/Ada string arrays — this path is unimplemented.","Convert string arrays to byte sequences or int lists manually before tracing."],"tags":["gdb","type-conversion","unimplemented","fortran","ada"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}