Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] recursive calls in value analysis

> I use the -ignore-recursive-calls option as recommended but it doesn?t work.

This wouldn't do what you want anyway, unless what you want is to
assume that the inner call to cmd_help does nothing. And if this is
what you want, you can simply cut the unimportant recursive functions,
or just the unimportant recursive calls, out of the analyzed code.

> Does somebody know how I can fix it?

You are in a bit of a worst case. This is indirect recursion, going
through three intermediate functions.

A workaround that would only work if the recursion is very shallow
(and still require a lot of work) would be to duplicate function
cmd_help() in as many version as you need: cmd_help_0, cmd_help_1,
cmd_help_2, ..., list pointers to these functions in an array, and use
a macro to replace calls to cmd_help(...) by:

(cmd_help_array[cmd_help_counter++])(...); cmd_help_counter--;

This would effectively erase the recursion from the program while
preserving the meaning.

If cmd_help() calls other functions again (such as command_foreach()),
you may have to apply the same transformation to these other
functions, too. But the worst part is that you must force the analysis
to compute precise values for all the function_counter variables at
all times.

So, in short, it will probably never work and I can't recommend trying it.

The value analysis currently assumes that each local variable appears
only once in the call stack. This is what prevents recursion from
being handled. Removing this limitation for programs with obviously
bounded recursion (the value analysis has to be able to see that it is
bounded) could be CEA LIST's contribution to a scientific
collaboration, but meanwhile, it is not on the roadmap.

I have not thought much about non-obviously-bounded recursion, but
that would take us rather far from the value analysis' original
mission of being a general-purpose automatic analyzer for embedded C