public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE
@ 2012-04-25  5:38 Brett Foster
  2012-04-25 11:26 ` Diego Novillo
  0 siblings, 1 reply; 6+ messages in thread
From: Brett Foster @ 2012-04-25  5:38 UTC (permalink / raw)
  To: gcc

Hi all,

I've been working on a plugin that processes some data. My plugin
grabs some data from the tree. I'm trying to understand a certain
"weird" behaviour I am seeing. And yeah, I'm new to the mailing list
and gcc's innards! Be forgiving! :) I appreciate the help!

When I add:

	register_callback (BaseName, PLUGIN_FINISH_TYPE, CinsGcc_CB_Type, NULL);

The plugin appears to be loaded by a 2nd process, initialized, and
provided with what appears to be much the same data (at least from my
view). Other plugin events do not appear to cause this behaviour.

The command line is..,

gcc -fplugin=./out/cins.so -c -o ./out/tests/test_0.o test/test_0.c \
		 -fplugin-arg-cins-error=./out/tests/test_0.o_err.txt \
		 -fplugin-arg-cins-output=./out/tests/test_0.o_out.txt

The extended log file written to disk says:
(0000001E:000031D1)             INFO
src/plugin/gcc_core.c:00000092                      plugin_init CINS
silencing console now.

The console says:
<CINS     INFO:0000001E:000031CD> CINS silencing console now.

000031D1 and 000031CD are different PIDs.
0000001E is the identifier indicating the log count (i.e. there were
0x1E prints that came before)

As well, __progname == 'cc1'.

gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6.1/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.1-9ubuntu3'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-objc-gc --enable-targets=all --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-checking=release
--build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE
  2012-04-25  5:38 GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE Brett Foster
@ 2012-04-25 11:26 ` Diego Novillo
  2012-04-25 14:17   ` fosterb
  0 siblings, 1 reply; 6+ messages in thread
From: Diego Novillo @ 2012-04-25 11:26 UTC (permalink / raw)
  To: Brett Foster; +Cc: gcc

On 4/25/12 1:37 AM, Brett Foster wrote:

> When I add:
>
> 	register_callback (BaseName, PLUGIN_FINISH_TYPE, CinsGcc_CB_Type, NULL);
>
> The plugin appears to be loaded by a 2nd process, initialized, and
> provided with what appears to be much the same data (at least from my
> view).

That's correct.  All plugin events are emitted from 
cc1/cc1plus/f951/jc1/lto1.  These binaries are the actual compiler. 
'gcc' is a driver process that calls the compiler, the assembler, the 
linker, etc.

> Other plugin events do not appear to cause this behaviour.

They should.  All events are generated from the compiler, not the driver.


Diego.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE
  2012-04-25 11:26 ` Diego Novillo
@ 2012-04-25 14:17   ` fosterb
  2012-04-25 14:23     ` Diego Novillo
  0 siblings, 1 reply; 6+ messages in thread
From: fosterb @ 2012-04-25 14:17 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc

That much I understand. But it's cc1 that is in two processes, and gcc -v only shows it being invoked once. Finally the output on stderr is only from one of the two processes.

Remove the finish type register and suddenly cc1 runs (as expected) and the logfiles PID and the console PID match once again.

(To clarify terminology: gcc app being the driver here? I didn't think the plugins were loaded in the 'gcc' driver? Strictly from the compiler?)
Sent via BlackBerry by AT&T

-----Original Message-----
From: Diego Novillo <dnovillo@google.com>
Date: Wed, 25 Apr 2012 07:25:51 
To: Brett Foster<fosterb@edgeandvertex.org>
Cc: <gcc@gcc.gnu.org>
Subject: Re: GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE

On 4/25/12 1:37 AM, Brett Foster wrote:

> When I add:
>
> 	register_callback (BaseName, PLUGIN_FINISH_TYPE, CinsGcc_CB_Type, NULL);
>
> The plugin appears to be loaded by a 2nd process, initialized, and
> provided with what appears to be much the same data (at least from my
> view).

That's correct.  All plugin events are emitted from 
cc1/cc1plus/f951/jc1/lto1.  These binaries are the actual compiler. 
'gcc' is a driver process that calls the compiler, the assembler, the 
linker, etc.

> Other plugin events do not appear to cause this behaviour.

They should.  All events are generated from the compiler, not the driver.


Diego.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE
  2012-04-25 14:17   ` fosterb
@ 2012-04-25 14:23     ` Diego Novillo
  2012-04-25 14:24       ` Richard Guenther
  2012-04-25 14:39       ` Brett Foster
  0 siblings, 2 replies; 6+ messages in thread
From: Diego Novillo @ 2012-04-25 14:23 UTC (permalink / raw)
  To: fosterb; +Cc: gcc

[ Please do not send html mail.  It will be rejected by the list server. ]

On Wed, Apr 25, 2012 at 10:16, <fosterb@edgeandvertex.org> wrote:

> That much I understand. But it's cc1 that is in two processes, and gcc -v
> only shows it being invoked once. Finally the output on stderr is only from
> one of the two processes.

cc1 is just one process.  You will need to show us the output of 'gcc -v'.


> (To clarify terminology: gcc app being the driver here? I didn't think the
> plugins were loaded in the 'gcc' driver? Strictly from the compiler?)

They are not.  They are loaded by cc1.


Diego.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE
  2012-04-25 14:23     ` Diego Novillo
@ 2012-04-25 14:24       ` Richard Guenther
  2012-04-25 14:39       ` Brett Foster
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2012-04-25 14:24 UTC (permalink / raw)
  To: Diego Novillo; +Cc: fosterb, gcc

On Wed, Apr 25, 2012 at 4:23 PM, Diego Novillo <dnovillo@google.com> wrote:
> [ Please do not send html mail.  It will be rejected by the list server. ]
>
> On Wed, Apr 25, 2012 at 10:16, <fosterb@edgeandvertex.org> wrote:
>
>> That much I understand. But it's cc1 that is in two processes, and gcc -v
>> only shows it being invoked once. Finally the output on stderr is only from
>> one of the two processes.
>
> cc1 is just one process.  You will need to show us the output of 'gcc -v'.

If you use -save-temps cc1 is run twice, once for preprocessing and once
for compilation.  Maybe you are confused by this?

>
>> (To clarify terminology: gcc app being the driver here? I didn't think the
>> plugins were loaded in the 'gcc' driver? Strictly from the compiler?)
>
> They are not.  They are loaded by cc1.
>
>
> Diego.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE
  2012-04-25 14:23     ` Diego Novillo
  2012-04-25 14:24       ` Richard Guenther
@ 2012-04-25 14:39       ` Brett Foster
  1 sibling, 0 replies; 6+ messages in thread
From: Brett Foster @ 2012-04-25 14:39 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc

Ah! I see what might be happening. I was using assert(0) in the
callback to stop the program's execution (to examine the output at
that location). When I do this, I get the funky results.

(I was surprised it was seen as HTML seeing as it was sent from my
blackberry (no html e-mail editing). The content type claimed
text/plain.)

On Wed, Apr 25, 2012 at 7:23 AM, Diego Novillo <dnovillo@google.com> wrote:
> [ Please do not send html mail.  It will be rejected by the list server. ]
>
> On Wed, Apr 25, 2012 at 10:16, <fosterb@edgeandvertex.org> wrote:
>
>> That much I understand. But it's cc1 that is in two processes, and gcc -v
>> only shows it being invoked once. Finally the output on stderr is only from
>> one of the two processes.
>
> cc1 is just one process.  You will need to show us the output of 'gcc -v'.
>
>
>> (To clarify terminology: gcc app being the driver here? I didn't think the
>> plugins were loaded in the 'gcc' driver? Strictly from the compiler?)
>
> They are not.  They are loaded by cc1.
>
>
> Diego.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-25 14:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-25  5:38 GCC Plugins - CC1 - Multiple processes on PLUGIN_FINISH_TYPE Brett Foster
2012-04-25 11:26 ` Diego Novillo
2012-04-25 14:17   ` fosterb
2012-04-25 14:23     ` Diego Novillo
2012-04-25 14:24       ` Richard Guenther
2012-04-25 14:39       ` Brett Foster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).