tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Static Analysis


From: Peter \"Firefly\" Lund
Subject: Re: [Tinycc-devel] Static Analysis
Date: Sat, 3 May 2003 11:19:30 +0200 (MEST)

On Sat, 3 May 2003, Paul Miseiko wrote:

> I am currently looking to do a static analysis of a decent size code base
> to determining the peak stack utilization.  The code is to be run on

You realise that it will depend on the compiler you use?

> embedded hardware and as such available memory is low.  Would it be
> possible to modify TCC to produce such an output?  Does anybody on this

Yes, if you are willing to accept the quality you will get.

You can probably live just fine with a much simpler solution than what
Basile Starynkevich suggests.  I know I could when I programmed embedded
computers.

Let's just say that you want to use a 386+ (you probably don't but you
didn't say so don't complain).  Let's also say that you can live with the
quality of code you get with tcc (you probably can't do that either).
Then you need two things: a list of stack usage and a call graph.  Yes,
you can modify tcc to spit raw data for those out (it's not even all that
hard).  Then you will need to massage them a bit and generate a nice
listing and/or a graph.  Perl is nice for that.  Something like VCG will
give you the graph.

As long as your program doesn't call through function pointers it is easy
to get the static call graph.  Ok, you don't know for sure whether a
function will be called or not (if it's in an if-branch for example) but
you can live with that.  As long as there are no cycles in the static call
graph (no recursion, neither direct or indirect) you are home free.

A weekend hack, in other words, if you know just a little bit about what
you are doing.

> mailing list know of an application that would provide the peak stack
> usage of a standard C code base?

Can't remember any names off the top of my head but I did see several
programs like that a decade ago for Z80 and other small chips.

-Peter

PS: Basile is right in that it is unsolvable in the general case and that
you can approach a full solution with abstract interpretation.  So what.
You can get a 95% solution right now which should be more than good enough
to help you.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]