On Thu, 9 Feb 2012, Michael Stefaniuc wrote:

Julia Lawall wrote:
On Thu, 9 Feb 2012, Michael Stefaniuc wrote:

Hello,

the type of an expression metavariable when passed to python is
 <type 'instance'>
but an expression list gets flattened to a string aka
 <type 'str'>

Perhaps.  I was hoping to get rid of the instance idea, as I don't see
the point of having anything other than string, ast least if itis not
going to contain any useful information.
Well, yeah it is just a wrapper object around a string. An array of
strings would be fine too for the expression list. I was thinking to do
simple regexp matches against the expression thus avoiding any parsing
of the expression. With a flat string for the whole expression I cannot
do that any longer.

OK, I can look into this.

Can the expression list be passed instead as a list/array of 'instance'?
That way one could get to the expressions without having to write a
(simplified) C parser in python.

What I'm trying to do is to add additional checks to the Wine debug
functions ERR/FIXME/TRACE/WARN. Those are printf style functions with
varargs. While they do use __attribute__(format) there are stricter
checks that can be done for those. But those require the parsing of the
format string and thus the need to go through python.

Could another option be to process the arguments individually?  I'm not
sure to understand how the __attribute__(format) fits in, but if one
considers the normal printf, then one could write

@@
expression str,e;
expression list[n] es;
@@

printf(str,es,e,...)

Then afterwards one could inherit n, and use that to check that the
corresponding ยค directive in str is compatible with e.
Yes, I had that initially but then I'll hit the python rule a lot more
often which from past experience can be a severe performance penalty.
Though I need to measure this to see how big the impact is.

I don't know if it is the fact of calling the python code, or the maintenance of many environments.

If you find any evidence of a memory leak, please let me know.

julia

Also I'll need to cache the parsed format string to not have to re-parse
it over and over. But that is trivial to do and I planned to do it
anyway as some format strings are very common.

thanks
bye
        michael
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to