How do I assign something to a gdb convenience variable from its built-in python? I thought it should be simple, because it naturally arises while trying to implement a user-defined function. However I couldn't find anything.
UPD: Added a simplified example. My real function is more complex though. Anyway, a way to transfer a variable from python up to gdb would help greatly.
An example of usage (achtung! — it raises an error):
#accept a string, return it's lenght
define RetLenOfArg
py arg0 = gdb.parse_and_eval("$arg0")
set $Retrn = py len(arg0)
end
source <python_file>, and then use. In my real case I will need anyway create one more function that will use a python one. Cumbersome, but that's how it is done.