Need help debugging plugin

Emílio Wuerges wuerges at gmail.com
Tue Apr 17 19:43:08 UTC 2012


Hello,

More news on the debugging:

See, the problem was really in the first lines of plugin_init.
Gcc checks the configuration arguments.
They need to match exacly with a strcmp.

But is that really the case?
This comparison is done inside gcc by a call to
"check_default_plugin_version", but wich argments it is really needed
to check?
I'll disable it and do some testing. Stay tunned.

---------------------------------------------------------------------
Configuration argumetns from arm gcc:
{basever = 0x100a00c "4.6.1",
datestamp = 0x100a012 "20110903",
devphase = 0x102e1d8 "",
revision = 0x102e1d9 "",
  configuration_arguments = 0xbb2100
"../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++
--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/arm-linux-gnueabi/include/c++/4.6.1
--libdir=/usr/lib
--enable-nls
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc
--enable-multilib
--disable-sjlj-exceptions
--with-arch=armv7-a
--with-float=softfp
--with-fpu=vfpv3-d16
--with-mode=thumb
--disable-werror
--enable-checking=release
--build=x86_64-linux-gnu
--host=x86_64-linux-gnu
--target=arm-linux-gnueabi
--program-prefix=arm-linux-gnueabi-
--includedir=/usr/arm-linux-gnueabi/include
--with-headers=/usr/arm-linux-gnueabi/include
--with-libs=/usr/arm-linux-gnueabi/lib"}
--------------------------------------------------
Configuration arms from x86_64 gcc:

{basever = 0x7ffff5645488 "4.6.1",
datestamp = 0x7ffff564548e "20110903",
devphase = 0x7ffff56b8a08 "",
revision = 0x7ffff56b8a09 "",
  configuration_arguments = 0x7ffff5438e80
"../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
--disable-werror
--with-arch-32=i686
--with-tune=generic
--enable-checking=release
--build=x86_64-linux-gnu
--host=x86_64-linux-gnu
--target=x86_64-linux-gnu"}


On Mon, Apr 16, 2012 at 7:18 PM, David Malcolm <dmalcolm at redhat.com> wrote:
> On Mon, 2012-04-16 at 19:02 -0300, Emílio Wuerges wrote:
>> Thanks Dave,
>>
>> I can do it by myself now.
> Excellent.
>
>> Btw, I'll never use the plugin with the same gcc I'm building the
>> plugin. I want to cross-compile to arm.
> I think my wording below was wrong; I meant that you have to build the
> plugin against the headers for the exact version of gcc that you intend
> the plugin to run inside.  Sorry about that.
>
> FWIW I've haven't yet tried to use it with a cross-compiler (hence my
> sloppiness below), but it ought to work.
>
>
>> []'s
>>
>>
>> On Mon, Apr 16, 2012 at 6:51 PM, David Malcolm <dmalcolm at redhat.com> wrote:
>> > On Mon, 2012-04-16 at 18:37 -0300, Emílio Wuerges wrote:
>> >> Hi,
>> >>
>> >>
>> >> I'm using gcc-python-plugin in my pass for x86_64 happily until now.
>> >> But now I'm trying it to use it for arm and I get this error message:
>> >>
>> >> ew at arrakis:~/work/mibench/security/sha$
>> >> /home/ew/work/sca-python/bin/gcc-with-ipet -Wall -c  sha_driver.c
>> >> cc1: error: fail to initialize plugin
>> >> /home/ew/gcc-python-plugin/gcc-python-plugin/python.so
>> >>
>> >> Can someone tell me what should I do to debug this error? I have no
>> >> idea how to start.
>> > IIRC this error message happens if the plugin's plugin_init() returns a
>> > non-zero result, which can happen for various reasons.  One of them is
>> > if there's a mismatch between the exact version of gcc that the plugin
>> > was built with vs the exact version of gcc that's trying to load the
>> > plugin - there needs to be an exact match.
>> >
>> > Debugging the plugin with gdb is a little fiddly, so I've written some
>> > notes on how to do it within docs/getting-involved.rst, which you can
>> > see in HTML form here:
>> > http://gcc-python-plugin.readthedocs.org/en/latest/getting-involved.html#debugging-the-plugin-s-c-code
>> >
>> > Hopefully that will enable you to run the plugin under gdb, set a
>> > breakpoint on the plugin's "plugin_init", and step through it, which
>> > should (I hope) shed light on why it's failing.  Caveat: I wrote the
>> > notes based on my experiences on Fedora; I've not tried it on Ubuntu -
>> > does it work?
>> >
>> >> If you are curious this is how I'm using gcc-python-plugin
>> >>
>> >>
>> >> All I did in my script was to change the gcc to arm-linux-gnueabi-gcc
>> >> wich comes with ubuntu:
>> > [...snip...]
>> >> export LD_PRELOAD=libpython2.7.so
>> > FWIW, I don't know why this is needed, but for some reason the above
>> > does seem to be needed on Ubuntu.
>> >
>> >
>> > Hope this is helpful - good luck!
>> > Dave
>> >
>> > _______________________________________________
>> > gcc-python-plugin mailing list
>> > gcc-python-plugin at lists.fedorahosted.org
>> > https://fedorahosted.org/mailman/listinfo/gcc-python-plugin
>>
>>
>>
>
>
> _______________________________________________
> gcc-python-plugin mailing list
> gcc-python-plugin at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/gcc-python-plugin



-- 
Emilio Wuerges
ECL - Embedded Computing Lab
UFSC - Universidade Federal de Santa Catarina
Brasil


More information about the gcc-python-plugin mailing list