The following is contained in the header file as well as what is passed to CFFI in the py file.
struct token* add_number_expr_after(struct token* where, int num, struct expression** ret);
struct token* add_addr_space_attr_begin(struct token* tok); //problem function
struct token* add_addr_space_attr_end(struct token* tok);
I have a C function below that I am wrapping. I added some printfs to make sure i see what porinters are being passed/returned by the C function
struct token* add_addr_space_attr_begin(struct token* tok)
{
struct token* ret = create_built_in_token_before(tok, "__attribute__");
printf("\nadd_addr_space_attr_begin: %p",ret);
ret = create_char_token_after(ret, '(');
printf("\nadd_addr_space_attr_begin: %p",ret);
return ret;
}
I then stepped into the python debugger to step the piece of code that invokes it
> /nobackup/sarvi/spark1/rules.py(29)fixit()
-> tok = warn_info.symbol1.start_tok
(Pdb) n
> /nobackup/sarvi/spark1/rules.py(30)fixit()
-> if api_mod.check_addr_space(warn_info.symbol1, 1):
(Pdb) n
> /nobackup/sarvi/spark1/rules.py(32)fixit()
-> tok = api_mod.add_addr_space_attr_begin(tok)
(Pdb) n
add_addr_space_attr_begin: 0x2a9a81bfd0
add_addr_space_attr_begin: 0x2a9a81c010> /nobackup/sarvi/spark1/rules.py(33)fixit()
-> tok = api_mod.add_number_expr_after(tok, 1, exprptr)
(Pdb) print tok
<cdata 'struct token *' 0xffffffff9a81c010>
The value I see being returned seems like a valid pointer right to the end where it does
return ret
But the tok that I print from the python debugger seems off on the top.
<cdata 'struct token *' 0xffffffff9a81c010>
CFFI version
>>> import cffi
>>> cffi.__version__
'0.7.2'
>>>
I can't seem to figure what is going wrong. From the looks of it looks like the function is returning a valid pointer
but the cdata object returned by CFFI has the pointer address wrong.
Has anyone seen this before? How did you resolve it?
Sarvi