You may not have set out wanting to --- by you definitely appear to be
doing exactly that.
> But I cannot imagine that it is possible to get a real picture of an
> embedded software with asynchronous interrupts from the outside
> world with these tools.
The timer used by -pg is inside the target system, i.e. it'd be a
timer of your embedded system. The builtin featur you're looking at
*is* -pg, and more to the point, the mcount() function used by it.
Your best by far is going to be to change mcount() and/or the
-fprofile-arcs support machinery for your purpose. The tricky part
will be to get the generated data off the embedded system and
presentable for gprof, of course.
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply by Vadim Borshchev●March 17, 20062006-03-17
Karl-Heinz Rossmann wrote:
> Hi,
> I am looking for a builtin functionality of the GCC.
> Is there a way get an unambiguous number of each compiled/linked
> c-function? I want to use it as an index into a table for all functions
> of an embedded (cross GCC, M68k) executable. With the help of this
> index I would be able to define a table where I can store profiling
> information of my code e.g. by using timer values of a hardware timer,
> the function name (__func__) and so on.
Look for -finstrument-functions option. GCC will generate calls to the entry and exit profiling functions which you can implement as you wish.
Vadim
Reply by Karl-Heinz Rossmann●March 17, 20062006-03-17
Hans-Bernhard Broeker schrieb:
> Karl-Heinz Rossmann <karl-heinz.rossmann@liebherr.com> wrote:
>
> > Is there a way get an unambiguous number of each compiled/linked
> > c-function?
>
> Its address.
>
> > I want to use it as an index into a table for all functions
> > of an embedded (cross GCC, M68k) executable. With the help of this
> > index I would be able to define a table where I can store profiling
> > information of my code e.g. by using timer values of a hardware timer,
> > the function name (__func__) and so on.
>
> Why? Do you want to re-invent the -pg option and gprof? And/or
> -fprofile-arcs and gcov?
No, I don't want to reinvent any GNU tools. But I cannot imagine that
it is possible to get a real picture of an embedded software with
asynchronous interrupts from the outside world with these tools. So I
decided to follow the way I described.
>
> --
> Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
> Even if all the snow were burnt, ashes would remain.
Reply by Hans-Bernhard Broeker●March 17, 20062006-03-17
> Is there a way get an unambiguous number of each compiled/linked
> c-function?
Its address.
> I want to use it as an index into a table for all functions
> of an embedded (cross GCC, M68k) executable. With the help of this
> index I would be able to define a table where I can store profiling
> information of my code e.g. by using timer values of a hardware timer,
> the function name (__func__) and so on.
Why? Do you want to re-invent the -pg option and gprof? And/or
-fprofile-arcs and gcov?
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply by Bob White●March 17, 20062006-03-17
Karl-Heinz Rossmann wrote:
> Good idea, but the problem is I have to implement a search algorithm to
> find out if the currently processed function is already present in the
> table or not. I wanted to avoid to do this way because of timing
> issues.
>
> Here is a small code snippet to give a rough idea of what I intend:
>
> void FunctionName(void)
> {
> # ifdef __PROF__
> Prof_g[FunctionIndex].sFuncName = __func__;
> Prof_g[FunctionIndex].nNCalls++;
> Prof_g[FunctionIndex].nStartTime = CTM4_g.nMCSM11Counter;
> # endif /* __PROF__ */
> ...
> FunctionBody
> ...
> # ifdef __PROF__
> Prof_g[FunctionIndex].nStopTime = CTM4_g.nMCSM11Counter;
> Prof_g[FunctionIndex].nCurExecTime = Prof_g.nStopTime -
> Prof_g.nStartTime;
> # endif /* __PROF__ */
> }
Instead of adding explicit profiling code to the source, have you
considered Monte Carlo profiling ? For counting function calls, you
could use the gcc -p or -pg flag.
>> On 16 Mar 2006 23:53:02 -0800, "Karl-Heinz Rossmann"
>> <karl-heinz.rossmann@liebherr.com> wrote:
>>
>> >Hi,
>> >I am looking for a builtin functionality of the GCC.
>> >Is there a way get an unambiguous number of each compiled/linked
>> >c-function? I want to use it as an index into a table for all functions
>> >of an embedded (cross GCC, M68k) executable. With the help of this
>> >index I would be able to define a table where I can store profiling
>> >information of my code e.g. by using timer values of a hardware timer,
>> >the function name (__func__) and so on.
>> >I didn't find something suitable in the GCC manual.
>
> Here is a small code snippet to give a rough idea of what I intend:
>
> void FunctionName(void)
> {
> # ifdef __PROF__
> Prof_g[FunctionIndex].sFuncName = __func__;
> Prof_g[FunctionIndex].nNCalls++;
> Prof_g[FunctionIndex].nStartTime = CTM4_g.nMCSM11Counter;
> # endif /* __PROF__ */
> ...
> FunctionBody
> ...
> # ifdef __PROF__
> Prof_g[FunctionIndex].nStopTime = CTM4_g.nMCSM11Counter;
> Prof_g[FunctionIndex].nCurExecTime = Prof_g.nStopTime -
> Prof_g.nStartTime;
> # endif /* __PROF__ */
> }
I suppose you could do something like:
int global_function_number;
...
void FunctionName(void)
{
#ifdef __PROF__
static int FunctionIndex;
extern int global_function_number;
if(!FunctionIndex)
{
FunctionIndex = global_function_number++;
}
Prof_g[FunctionIndex].sFuncName = __func__;
Prof_g[FunctionIndex].nNCalls++;
Prof_g[FunctionIndex].nStartTime = CTM4_g.nMCSM11Counter;
...
--
John Devereux
Reply by Meindert Sprang●March 17, 20062006-03-17
"Karl-Heinz Rossmann" <karl-heinz.rossmann@liebherr.com> wrote in message
news:1142584782.975258.25780@u72g2000cwu.googlegroups.com...
> Zara schrieb:
> > What about the address of the function? It should be unique, and it is
> > perfect for building function tables!
> >
> > Regards,
> >
> > Zara
>
> Good idea, but the problem is I have to implement a search algorithm to
> find out if the currently processed function is already present in the
> table or not. I wanted to avoid to do this way because of timing
> issues.
Binary search? Just 2log(N) iterations for N functions. 10000 functions take
14 iterations.
Meindert
Reply by Karl-Heinz Rossmann●March 17, 20062006-03-17
Zara schrieb:
> On 16 Mar 2006 23:53:02 -0800, "Karl-Heinz Rossmann"
> <karl-heinz.rossmann@liebherr.com> wrote:
>
> >Hi,
> >I am looking for a builtin functionality of the GCC.
> >Is there a way get an unambiguous number of each compiled/linked
> >c-function? I want to use it as an index into a table for all functions
> >of an embedded (cross GCC, M68k) executable. With the help of this
> >index I would be able to define a table where I can store profiling
> >information of my code e.g. by using timer values of a hardware timer,
> >the function name (__func__) and so on.
> >I didn't find something suitable in the GCC manual.
> >
> >Thanks for you help.
>
> What about the address of the function? It should be unique, and it is
> perfect for building function tables!
>
> Regards,
>
> Zara
Good idea, but the problem is I have to implement a search algorithm to
find out if the currently processed function is already present in the
table or not. I wanted to avoid to do this way because of timing
issues.
Here is a small code snippet to give a rough idea of what I intend:
void FunctionName(void)
{
# ifdef __PROF__
Prof_g[FunctionIndex].sFuncName = __func__;
Prof_g[FunctionIndex].nNCalls++;
Prof_g[FunctionIndex].nStartTime = CTM4_g.nMCSM11Counter;
# endif /* __PROF__ */
...
FunctionBody
...
# ifdef __PROF__
Prof_g[FunctionIndex].nStopTime = CTM4_g.nMCSM11Counter;
Prof_g[FunctionIndex].nCurExecTime = Prof_g.nStopTime -
Prof_g.nStartTime;
# endif /* __PROF__ */
}
Reply by Zara●March 17, 20062006-03-17
On 16 Mar 2006 23:53:02 -0800, "Karl-Heinz Rossmann"
<karl-heinz.rossmann@liebherr.com> wrote:
>Hi,
>I am looking for a builtin functionality of the GCC.
>Is there a way get an unambiguous number of each compiled/linked
>c-function? I want to use it as an index into a table for all functions
>of an embedded (cross GCC, M68k) executable. With the help of this
>index I would be able to define a table where I can store profiling
>information of my code e.g. by using timer values of a hardware timer,
>the function name (__func__) and so on.
>I didn't find something suitable in the GCC manual.
>
>Thanks for you help.
What about the address of the function? It should be unique, and it is
perfect for building function tables!
Regards,
Zara
Reply by Karl-Heinz Rossmann●March 17, 20062006-03-17
Hi,
I am looking for a builtin functionality of the GCC.
Is there a way get an unambiguous number of each compiled/linked
c-function? I want to use it as an index into a table for all functions
of an embedded (cross GCC, M68k) executable. With the help of this
index I would be able to define a table where I can store profiling
information of my code e.g. by using timer values of a hardware timer,
the function name (__func__) and so on.
I didn't find something suitable in the GCC manual.
Thanks for you help.