Bug 172205 - CDT does not work when natively compiled
CDT does not work when natively compiled
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: eclipse-cdt (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Andrew Overholt
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-11-01 10:51 EST by Adam Jocksch
Modified: 2007-11-30 17:11 EST (History)
4 users (show)

See Also:
Fixed In Version: gcc-4.0.2-8.fc4
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-01-24 17:10:15 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
stack trace (1.62 KB, text/plain)
2005-11-15 14:38 EST, Andrew Overholt
no flags Details
Program to test the cdtparser (6.78 KB, text/plain)
2005-11-15 15:37 EST, Adam Jocksch
no flags Details
test input file for CDTParserTest (28 bytes, text/plain)
2005-11-15 15:50 EST, Adam Jocksch
no flags Details

  None (edit)
Description Adam Jocksch 2005-11-01 10:51:20 EST
Description of problem:
ssia
Comment 1 Andrew Overholt 2005-11-15 14:38:44 EST
Created attachment 121084 [details]
stack trace

This is what appeared in my terminal after a failed session where I tried to
debug but got an error at each debug step.  The variables view never populated
but the console did show the output of my program as I stepped.
Comment 2 Andrew Overholt 2005-11-15 14:46:53 EST
This is with rawhide.  gcc 4.0.2-3
Comment 3 Andrew Overholt 2005-11-15 14:51:15 EST
Relevant version #s:

java-1.4.2-gcj-compat-1.4.2.0-40jpp_51rh.i386
libgcj-4.0.2-3.i386
libgcj-devel-4.0.2-3.i386
java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp_51rh.i386

eclipse-*-3.1.1-1jpp_6fc.i386

eclipse-cdt-3.0*
Comment 4 Andrew Overholt 2005-11-15 15:26:10 EST
This is how I *was* reproducing but it appears to not happen every time:

File->New Project->C->Managed Make C Project->Next
Give a project name (say, "blahblah")
Finish
"Do you want to switch to ..." -> Yes
Expand project blahblah (little arrow on the left-hand side)
Right-click on blahblah -> New -> (c) Source File
Give a name (say, "main.c"), press enter
Enter this program:

#include <stdio.h>

int main(int argc, char **argv) {
	int i = 0;
	for (i = 0; i < 3; ++i) {
		printf("%d\n", i);
	}
	return 0;
}

File->Save
Notice the new entry under project blahblah:  Binaries
Expand Binaries, right-click on "blahblah - [x86le]"
Debug As -> Debug Local C/C++ Application
Hit OK
"Do you want to switch ..." -> Yes
Use Run->Step Over to step over each line in the program and watch the output in
the console
I was getting errors at each step request
Comment 5 Adam Jocksch 2005-11-15 15:37:48 EST
Created attachment 121092 [details]
Program to test the cdtparser

This is a program I've been using to test the cdtparser when natively compiled.
All it does it takes a C++ source file as an argument, then prints out the
functions it finds. When it works properly, everything is as it should be, but
when I compiled the cdtparser jar with find-and-aot-compile (which uses the
options '-findirectdispatch -shared -Wl,-Bsymbolic') it produces very strange
output. I will attach a test file I have been using as input shortly
Comment 6 Adam Jocksch 2005-11-15 15:50:50 EST
Created attachment 121093 [details]
test input file for CDTParserTest

This is the sample input file that I have been using for CDTParserTest. When
working properly, it should say that function c starts at offset 4 and goes
until offset 5 on line 1. When working incorrectly, it says that function c
starts at character 4, but ends on an extremely large offset (> 20000) .

To get these results I've compiled everything as follows:
gcj -shared -fPIC -fjni -o libcdtparser.jar.so cdtparser.jar
gcj -fPIC -fjni -classpath ./cdtparser.jar -L. -lcdtparser.jar 
	--main=CDTParserTest CDTParserTest.java
LD_LIBRARY_PATH=. ./a.out main.cpp
Comment 7 Andrew Overholt 2005-11-15 16:16:11 EST
I was able to reproduce with gcc-4.0.2-3.i386:

wget https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=121092
mv attachment.cgi\?id\=121092 CDTParserTest.java
wget https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=121093
mv attachment.cgi\?id\=121093 main.cpp

(with eclipse-cdt-3.0.1 (rawhide as of 2005-11-16) installed)
Correct behaviour (no BC ABI):
=============================
gcj -shared -fPIC -fjni -o libcdtparser.jar.so \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.1/cdtparser.jar
gcj -fPIC -fjni -classpath \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.1/cdtparser.jar \
  -L. -lcdtparser.jar --main=CDTParserTest CDTParserTest.java
LD_LIBRARY_PATH=. ./a.out main.cpp
Function found
Name: c
Starting at: 0
Ending at: 0
Name starts at: 4
Name ends at: 5

INcorrect behaviour (BC ABI):
=============================
gcj -shared -findirect-dispatch -Wl,-Bsymbolic -fPIC -fjni -o \
  libcdtparser.jar.so \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.1/cdtparser.jar
gcj -fPIC -fjni -classpath \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.1/cdtparser.jar \
  -L. -lcdtparser.jar --main=CDTParserTest CDTParserTest.java
LD_LIBRARY_PATH=. ./a.out main.cpp
Function found
Name: c
Starting at: 17409568
Ending at: 5
Aborted

(with eclipse-cdt-3.0.0 (FC4 or older than 2005-11-16's rawhide) installed)
Correct behaviour (no BC ABI):
=============================
gcj -shared -fPIC -fjni -o libcdtparser.jar.so \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.0/cdtparser.jar
gcj -fPIC -fjni -classpath \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.0/cdtparser.jar \
  -L. -lcdtparser.jar --main=CDTParserTest CDTParserTest.java
LD_LIBRARY_PATH=. ./a.out main.cpp
Function found
Name: c
Starting at: 0
Ending at: 0
Name starts at: 4
Name ends at: 5

INcorrect behaviour (BC ABI):
=============================
gcj -shared -findirect-dispatch -Wl,-Bsymbolic -fPIC -fjni -o \
  libcdtparser.jar.so \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.0/cdtparser.jar
gcj -fPIC -fjni -classpath \
  /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.0/cdtparser.jar \
  -L. -lcdtparser.jar --main=CDTParserTest CDTParserTest.java
LD_LIBRARY_PATH=. ./a.out main.cpp
Function found
Name: c
Starting at: 17409568
Ending at: 5
Aborted
Comment 8 Tom Tromey 2006-01-19 19:04:41 EST
I tried this with the 3.0 CDT RPM installed.

With my FC4 system gcj (4.0.something), it failed when BC-compiled.

With gcc 4.1 and gcc svn head, it worked.
Comment 9 Andrew Haley 2006-01-24 05:29:26 EST
I can confirm this is OK with current rawhide gcc version 4.1.0 20060121 (Red
Hat 4.1.0-0.16)

Target: x86_64
Comment 10 Andrew Haley 2006-01-24 06:27:59 EST
Works for me with 4.0.0-6.

aph@zorro ~]$ gcj -shared -findirect-dispatch -Wl,-Bsymbolic -fPIC -fjni -o \
>   libcdtparser.jar.so \
>   /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.0/cdtparser.jar
[aph@zorro ~]$ gcj -fPIC -fjni -classpath \
>   /usr/share/eclipse/plugins/org.eclipse.cdt.core_3.0.0/cdtparser.jar \
>   -L. -lcdtparser.jar --main=CDTParserTest CDTParserTest.java
[aph@zorro ~]$ LD_LIBRARY_PATH=. ./a.out main.cpp
Function found
Name: c
Starting at: 0
Ending at: 0
Name starts at: 4
Name ends at: 5
[aph@zorro ~]$ gcj -v
Using built-in specs.
Reading specs from /usr/lib/gcc/i386-redhat-linux/4.0.2/libgcj.spec
rename spec lib to liborig
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.2 20051109 (Red Hat 4.0.2-6)

But fails with 4.0.0-8:

[aph@zorro ~]$ LD_LIBRARY_PATH=. ./a.out main.cpp
Function found
Name: c
Starting at: 18582304
Ending at: 5
Aborted

So this is a regression.  Ths differences between these two gcj versions are
fairly small, so this should be easy to find.
Comment 11 Andrew Haley 2006-01-24 09:39:09 EST
OK, found it.  This is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24251.

The Red Hat 4.0 package needs to be updated with this patch from gcc-4_0-branch.
Comment 12 Jakub Jelinek 2006-01-24 09:52:54 EST
It is updated from gcc-4_0-branch, RHEL4 U3 contains 20051130 snapshot
in gcc4-java-4.0.2-9.EL4 and above.  You just need to use gcj4 and gij4
instead of gcj and gij.
Comment 13 Andrew Haley 2006-01-24 10:00:22 EST
I'm testing on FC4.  This patch is not in gcc-4.0.0-8.

It is needed.
Comment 14 Jakub Jelinek 2006-01-24 10:13:10 EST
FC4 has gcc-4.0.2-8.fc4, which is a 20051126 snapshot.
sudo yum update
Comment 15 Andrew Haley 2006-01-24 10:43:46 EST
Confirmed.  

Andrew O, please close.
Comment 16 Andrew Overholt 2006-01-24 17:10:15 EST
I have verified that things do indeed work as expected with an updated FC4
system and also with current rawhide.  Closing.

Note You need to log in before you can comment on or make changes to this bug.