This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: dynamic tracing problem
- From: Ian Lance Taylor <iant at google dot com>
- To: Joe Buehler <aspam at cox dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 07 Oct 2011 18:09:00 -0700
- Subject: Re: dynamic tracing problem
- References: <loom.20111007T204606-672@post.gmane.org>
Joe Buehler <aspam@cox.net> writes:
> I am attempting to use inline assembly to implement a tracing mechanism that
> results in code something like this (asm syntax not meant to be exact):
>
> "pre" C code...
>
> /* via inline asm */
> j trace
> .pushsubsection 1000
> trace:
>
> "trace" C code...
>
> /* via inline asm */
> j post
> .popsubsection
> post:
>
> "post" C code...
>
> The idea is that the trace code can be nullified by changing the "j trace"
> instruction to a NOP or activated by putting the jump back.
I don't see how this can work reliably in gcc when optimizing. gcc
freely rearranges blocks, and there is no way to prevent that. If there
are any blocks between "trace" and "post", they may get moved out of the
subsection. It's even possible that other blocks will get moved into
the subsection.
Ian