|Instrumenting code for profiling. firstname.lastname@example.org (2004-11-14)|
|Re: Instrumenting code for profiling. email@example.com (glen herrmannsfeldt) (2004-11-17)|
|Re: Instrumenting code for profiling. firstname.lastname@example.org (2004-11-17)|
|Re: Instrumenting code for profiling. email@example.com (2004-11-19)|
|Re: Instrumenting code for profiling. firstname.lastname@example.org (2004-11-20)|
|Re: Instrumenting code for profiling. email@example.com (Ira Baxter) (2004-11-20)|
|Re: Instrumenting code for profiling. firstname.lastname@example.org (2004-11-20)|
|Re: Instrumenting code for profiling. email@example.com (2004-11-26)|
|From:||firstname.lastname@example.org (Michael Tiomkin)|
|Date:||20 Nov 2004 21:30:26 -0500|
|References:||04-11-043 04-11-051 04-11-065|
|Posted-Date:||20 Nov 2004 21:30:26 EST|
email@example.com (Nick Maclaren) wrote
> glen herrmannsfeldt <firstname.lastname@example.org> writes:
> |> FETE would read in a Fortran 66 program and then write out a new
> |> Fortran program that would count the number of times each statement
> |> was executed. ...
> Yes. There were other, similar ones, too.
> |> Presumably a similar system could be done for other languages.
> If you can't, it would be pretty hard to compile! With Fortran or
> BCPL, you could take short cuts and not do a full parsing job; with C
> or Algol 68, you would have to do a full parse, and would find it
> easiest to hack a compiler.
Well, with some natural assumptions, you don't need to do full
parsing for C profiling. You can use the line info in the executable
to find the images of the "statements" (BTW, the line num/file name
can be used as an ID for a statement). In C, the only problem can be
jump tables in switch statements, but you can find the pattern that
your compiler uses and update the jump tables as well.
For a function with one entry (the case of C), it's not very
complicated to make a copy of the function extended with
instrumentation. You even don't neeed to analyze the executable: a
good disassembler can help in this task, and then you can easily
insert profiling instructions.
The question is if you really need to do profiling by yourself. Most
compilers would happily do this for you, and there are other tools
that do profiling for executables, like Vtune of Intel did for Win/x86
Return to the
Search the comp.compilers archives again.