NationalSecurityAgency/ghidra · warning · ValueError
Conversion of string arrays unimplemented
Error message
Conversion of string arrays unimplemented
What it means
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.
Source
Thrown at Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py:845
return to_string(val, type, 'utf-16', full=False), sch.STRING
schema = sch.SHORT_ARR
elif schema == sch.CHAR_ARR:
return to_string(val, type, 'utf-16', full=True), schema
return to_int_list(val, type), schema
elif etype.sizeof == 4:
if schema is None:
if etype.name == 'wchar_t':
return to_string(val, type, 'utf-32', full=False), sch.STRING
schema = sch.INT_ARR
elif schema == sch.CHAR_ARR:
return to_string(val, type, 'utf-32', full=True), schema
return to_int_list(val, type), schema
elif schema is not None:
return to_int_list(val, type), schema
elif etype.sizeof == 8:
return to_int_list(val, type), sch.LONG_ARR
elif etype.code == gdb.TYPE_CODE_STRING:
raise ValueError("Conversion of string arrays unimplemented")
# TODO: Array of C strings?
elif type.code == gdb.TYPE_CODE_STRING:
return val.string(), sch.STRING
elif type.code == gdb.TYPE_CODE_PTR:
offset = int(val)
inf = gdb.selected_inferior()
base, addr = STATE.require_trace().extra.require_mm().map(inf, offset)
return (base, addr), sch.ADDRESS
raise ValueError(f"Cannot convert ({schema}): '{value}', value='{val}'")
@cmd('ghidra trace set-value', '-ghidra-trace-set-value', gdb.COMMAND_DATA, True)
def ghidra_trace_set_value(path: str, key: str, value: str,
schema: Optional[str] = None, *, is_mi: bool,
**kwargs) -> None:
"""Set a value (attribute or element) in the Ghidra trace's object tree.
A void value implies removal. NOTE: The type of an expression may beView on GitHub (pinned to d5f144c24d)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
def is_string_array_value(val: gdb.Value) -> bool:
try:
t = val.type.strip_typedefs()
if t.code == gdb.TYPE_CODE_ARRAY:
etype = t.target()
if etype.code == gdb.TYPE_CODE_STRING:
return True
except Exception:
pass
return False Type guard
def is_convertible_value(val: gdb.Value) -> bool:
try:
t = val.type.strip_typedefs()
if t.code == gdb.TYPE_CODE_ARRAY:
etype = t.target()
if etype.code == gdb.TYPE_CODE_STRING:
return False
return True
except Exception:
return False Try / catch
try:
result = convert_value(val, type, schema)
except ValueError as e:
if 'string arrays unimplemented' in str(e):
print('TYPE_CODE_STRING array conversion is not supported. Skipping this value.')
result = None
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot convert ({schema}): '{value}', value='{val}'
- TODO: Unoptimized byte diff
- Cannot convert {}'s value: '{}', type: '{}'
- Cannot convert '{}' to length
- Address {address} is not in inferior {inf.num}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/840fa2dba3ec6308.
Report an issue: GitHub.