cfg representation

2007-08-09 Thread Bob Rossi
Hi,

I've been looking at the cfg that gcc dumps to a file. I'm noticing that
the code is transformed in the cfg. Especially the short circuited
expressions and the ternary operator for C/C++. Is there a particular 
algorithm gcc uses to transform the original AST into the modified version 
in the CFG?

Does anyone know where the code is that does this transformation so I
can look for myself?

Thanks,
Bob Rossi


printing cfg

2007-08-01 Thread Bob Rossi
Hi,

I'm trying to print the cfg so that I can visualize it. I have a simple
file,
  $ cat foo.c 
  int
  foo (int param)
  {
param++;
if (param)
  param++;
return param;
  }

I run the command,
  $ gcc -fdump-tree-vcg-blocks -c foo.c
and then I run,
  xvcg *.vcg
which displays a picture of the cfg. It appears for some reason, that
the expressions in the basic blocks just show things like,
  modify_expr (4)
  cond_expr (5)

Is there a way to make it show the actual expressions in the code
instead? Also, is there a native way to display this information using
dot instead?

Thanks,
Bob Rossi


Re: Looking for specific pages from Muchnick's book

2007-03-08 Thread Bob Rossi
On Thu, Mar 08, 2007 at 10:05:11AM +0100, Steven Bosscher wrote:
 Hi,
 
 I found this old patch
 (http://gcc.gnu.org/ml/gcc-patches/2003-06/msg01669.html) that refers
 to pages 202-214 of Muchnick's Advanced Compiler Design and
 Implementation book. That book still is not in my own compiler books
 collection because of its price. I used to have access to a copy in a
 university library, but that copy has been removed from the collection
 and, apparently, it's been disposed off :-(
 
 Could someone scan those pages and send them to me, please?

Hi,

With a little hard work, you can make google show you the pages.
http://books.google.com/books?vid=ISBN1558603204id=Pq7pHwG1_OkCpg=PP1lpg=PP1ots=4VaZHsi8qTdq=Advanced+Compiler+Design+and+Implementationsig=w20IRwAK8s3z7gCUB1LSzmPqOf0#PRA1-PA202,M1

If you search for 'structural analysis', pages 202, 203, 204, 205, 210,
211, 212 and 214 come up. You only need to make it show you 5 more
pages.

Bob Rossi


compile time enforcement of exception specification

2007-01-13 Thread Bob Rossi
Hi,

Will g++ ever add a compile time enforcement of the exception
specification like the Java compiler does?

I find the exception specification almost useless with out this
functionality.

Thanks,
Bob Rossi


Re: compile time enforcement of exception specification

2007-01-13 Thread Bob Rossi
On Sun, Jan 14, 2007 at 12:16:32AM -0500, Andrew Pinski wrote:
  
  Hi,
  
  Will g++ ever add a compile time enforcement of the exception
  specification like the Java compiler does?
  
  I find the exception specification almost useless with out this
  functionality.
 
 The C++ standard  ( 15.4/10) is very specific that the implemantion should not
 reject code just because of exception specification and calling other
 functions.

Do you have a link to the standard some where?

Will g++ not implement compile time enforcement until a standard says
it's OK to do so? This feature is obviously an improvement over doing
nothing. Wouldn't an option to g++ be only helpful here?

Thanks,
Bob Rossi


mingw build error

2006-12-18 Thread Bob Rossi
Hi,

Every time I build a gcc for mingw, I get the same error as reported
here, 
  http://gcc.gnu.org/ml/gcc/2006-09/msg00044.html

Basically, I have to edit the Makefile in gcc/Makefile like this,
-ORIGINAL_LD_FOR_TARGET = 
./C:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/bin/ld.exe
+ORIGINAL_LD_FOR_TARGET = 
/C/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/bin/ld

This is still broken with the latest snapshot from 4.1. How would I go
about fixing this? Is this a problem with the way I'm configuring gcc?

Thanks,
Bob Rossi


relocatable gdb

2006-12-16 Thread Bob Rossi
Hi,

I've been responding to an old thread regarding building gcc in mingw so
that it can be relocatable.

I'm not sure if the discussion should be on gcc-patches, so I'm moving
it here.

This link has the script I'm running to automate the build,
http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01181.html

This link has the output of the commands 'gcc -v -o main main.c' and 
'g++ -v -o main main.cpp' which are both Hello World programs.
The gcc executable can find stdio.h but the g++ exe can not find the
iostream header. 
http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01182.html


I'm imagining the multiple messages
  ignoring nonexistent directory C:/msys/1.0/home/bobbybrasko/g++...
have something to do with this.

Thanks for any assistance I could get on this.

Bob Rossi


distributing g++

2006-12-15 Thread Bob Rossi
Hi,

I've compiled g++ for mingw with,

../gcc-4.1.1/configure --prefix=/home/bobbybrasko/g++/prefixdir --host=mingw32 \
  --target=mingw32 --program-prefix= \
  --program-suffix=-4.1 --with-gcc --with-gnu-ld --with-gnu-as 
--enable-threads --disable-nls \
  --enable-languages=c,c++ --disable-win32-registry --disable-shared 
--without-x \
  --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug

Since i've used a prefix, I'm assumming gcc wants to be installed where
I told it to be. I'm wondering 2 things.

What are the standard practices with installing multiple versions of gcc
on a system. I renamed this gcc to be gcc-4.1. However, it looks like it
will still overwrite some files when I do 'make install'. Is this true?
How do people put multiple version on the same machine?

Second, say I wanted to tar up a release of gcc that i've built for
others to use. When the other user downloads and untars the file on
there filesystem in an arbitrary point, I'm assumming it won't work
because it's not in the --prefix=.. directory. Is it possible to get
around this? I would like a user to be able to untar it anywhere, and
have it work just fine. If this is possible, please advise.

Thanks,
Bob Rossi


Re: distributing g++

2006-12-15 Thread Bob Rossi
On Fri, Dec 15, 2006 at 12:35:23PM -0800, Brian Dessent wrote:
 Bob Rossi wrote:
 
  Since i've used a prefix, I'm assumming gcc wants to be installed where
  I told it to be. I'm wondering 2 things.
 
 It's not supposed to be that way.  The toolchain is supposed to be
 relocatable for MinGW targets.  I don't know if it currently is, but
 read the past threads on the topic first:
 
 http://gcc.gnu.org/ml/gcc/2006-04/threads.html#00227
 http://gcc.gnu.org/ml/gcc/2006-04/threads.html#00441
 
 Ranjit Mathew also has a web page somewhere describing what steps and/or
 patches are necessary to get a relocatable toolchain.  But I think he
 does a crossed-native (canadian) build for speed reasons, so that may
 complicate the procedure.

OK, I followed this tutorial I believe.
http://rmathew.com/articles/gcj/bldgcj.html
the section Building a Native Compiler.

I ran this,

#!/bin/sh

tar -zxvf gcc-core-4.1.1.tar.gz
tar -zxvf gcc-g++-4.1.1.tar.gz

mkdir builddir
cd builddir
../gcc-4.1.1/configure --prefix=/mingw --host=mingw32 \
  --target=mingw32 --program-prefix= \
  --program-suffix=-4.1 --with-gcc --with-gnu-ld --with-gnu-as 
--enable-threads --disable-nls \
  --enable-languages=c,c++ --disable-win32-registry --disable-shared 
--without-x \
  --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug \
  21 | tee configure-out.txt
make bootstrap 21 | tee make-out.txt
make DESTDIR=/home/bobbybrasko/g++-4.1-relocatable install

$ ls /home/bobbybrasko/g++-4.1-relocatable  

mingw   


$ ls /home/bobbybrasko/g++-4.1-relocatable/mingw

bin  include  info  lib  libexec  man  share


Am I doing the correct thing here? Pretend this isn't mingw even, would
this be the correct way to do this for native linux?

Now, How would I tar this up so that it could be relocatable? 

Thanks,
Bob Rossi


Re: building gcc

2006-10-14 Thread Bob Rossi
On Sat, Oct 14, 2006 at 02:16:01PM +1000, Brendon Costa wrote:
 Bob Rossi wrote:
  Hi Ian,
 
  Basically, I want to use GCC with C,C++. I want to walk a tree that GCC
  creates for the translation units. I would like to know if for these two
  languages if I should use a language dependent tree, the generic tree or
  the gimple tree. In general, I would like to use the tree that most
 closely
  resembles the source language, and that is documented best.
 
  For starters, can you recommend which tree structure I should use in
  GCC? If so, would it be to much to ask to point me to the object in the
  source code that represents the tree after the tree has been populated?
 
  If I should be using gimple, I found this paper.
  ftp://gcc.gnu.org/pub/gcc/summit/2003/GENERIC%20and%20GIMPLE.pdf
  Is there any other good documentation on this?
 
 I cant help much as i have only been fumbling around in the GCC source
 for a short time now and still have no idea about a lot of stuff.
 However I did want to also look at the full tree for the C++ front end.
 I did this from the parser.c: cp_parser_translation_unit() function just
 after the call to: finish_translation_unit() and I was looking at the
 tree defined globally elsewhere in the variable: global_namespace

Thanks Brendon, that was really helpful. I'm very new at this, and may 
have some seemingly rather odd questions. I see that global_namespace is
of type 'union tree_node'. Is this the C++ language dependent AST?

I found the documentation doc/c-tree.info. Is this the documentation
representing the global_namespace tree? Is there any better
documentation that you know of?

Also, I noticed that converting it to html failed. Maybe this is a 
documentation error?

Thanks again,
Bob Rossi

$ makeinfo --html ../../../gcc/gcc/doc/c-tree.texi
../../../gcc/gcc/doc/c-tree.texi:10: `Trees' has no Up field (perhaps
incorrect sectioning?).
makeinfo: Removing output file
`/home/bob/rcs/svn/gcc/gcc/builddir/gcc/doc/c-tree/index.html' due to
errors; use --force to preserve.

$ makeinfo --version
makeinfo (GNU texinfo) 4.8



Re: building gcc

2006-10-13 Thread Bob Rossi
On Thu, Oct 12, 2006 at 07:45:52AM -0700, Ian Lance Taylor wrote:
 Bob Rossi [EMAIL PROTECTED] writes:
 
  Hopefully I'll be able to debug gcc nicely after this is built. Two
  more questions that could save me a lot of time. Do you know where the
  abstract syntax tree is stored in GCC after a file is parsed?
 
 I'm not sure what kind of answer you are looking for.  One place to
 look is in the cgraph code.
 
  Does GCC
  still create an AST for C/C++, or does it go directly to GIMPLE?
 
 gcc generates an AST, of sorts, for C++.  For C it goes directly to
 GIMPLE (really GENERIC, but they are pretty similar).

Hi Ian,

Basically, I want to use GCC with C,C++. I want to walk a tree that GCC
creates for the translation units. I would like to know if for these two
languages if I should use a language dependent tree, the generic tree or 
the gimple tree. In general, I would like to use the tree that most closely
resembles the source language, and that is documented best.

For starters, can you recommend which tree structure I should use in
GCC? If so, would it be to much to ask to point me to the object in the
source code that represents the tree after the tree has been populated?

If I should be using gimple, I found this paper.
ftp://gcc.gnu.org/pub/gcc/summit/2003/GENERIC%20and%20GIMPLE.pdf
Is there any other good documentation on this?

Thanks,
Bob Rossi




Re: building gcc

2006-10-12 Thread Bob Rossi
On Thu, Oct 12, 2006 at 09:48:13AM +0200, Paolo Bonzini wrote:
 
 In particular, I was just wondering how do compile GCC with debug. Not
 how to debug it. I tried CFLAGS=-g ./configure ..., but it still
 compiled with gcc -O2 -g. Anyways, if anyone knows a helpful configure
 trick that will help get me ready to debug gcc, please let me know.
 
 By default, GCC bootstraps itself, and after the first stage it always 
 compiles itself with optimization enabled.  So what you need is
 
 ./configure --enable-languages=c,c++ --disable-bootstrap
 make CFLAGS=-g
 
 (or equivalently, with CFLAGS=-g passed to configure).

Thanks Paolo,

Here's what I have so far.

../gcc/configure CFLAGS=-g --enable-languages=c,c++ --enable-checking
--disable-bootstrap --prefix=$PWD/../prefixdir

Hopefully I'll be able to debug gcc nicely after this is built. Two
more questions that could save me a lot of time. Do you know where the
abstract syntax tree is stored in GCC after a file is parsed? Does GCC
still create an AST for C/C++, or does it go directly to GIMPLE?

Thanks for the help,
Bob Rossi


Re: building gcc

2006-10-12 Thread Bob Rossi
On Thu, Oct 12, 2006 at 06:56:58AM -0400, Bob Rossi wrote:
 On Thu, Oct 12, 2006 at 09:48:13AM +0200, Paolo Bonzini wrote:
  
  In particular, I was just wondering how do compile GCC with debug. Not
  how to debug it. I tried CFLAGS=-g ./configure ..., but it still
  compiled with gcc -O2 -g. Anyways, if anyone knows a helpful configure
  trick that will help get me ready to debug gcc, please let me know.
  
  By default, GCC bootstraps itself, and after the first stage it always 
  compiles itself with optimization enabled.  So what you need is
  
  ./configure --enable-languages=c,c++ --disable-bootstrap
  make CFLAGS=-g
  
  (or equivalently, with CFLAGS=-g passed to configure).
 
 Thanks Paolo,
 
 Here's what I have so far.
 
 ../gcc/configure CFLAGS=-g --enable-languages=c,c++ --enable-checking
 --disable-bootstrap --prefix=$PWD/../prefixdir

Actually, the CFLAGS=-g caused a problem. OK, now, as I expected,
I configure with 

../gcc/configure --enable-languages=c,c++ --enable-checking
 --disable-bootstrap --prefix=$PWD/../prefixdir

and the gcc that is put into prefixdir is compiled with -O2 and -g,
which makes it hard to follow in the debugger. Anyone have a clue on how
to compile gcc so only -g is used, and not -O2? Typically, I use the
CFLAGS trick, but it doesn't seem to work for gcc.

Thanks, and sorry for all the noise.

Bob Rossi


Re: building gcc

2006-10-12 Thread Bob Rossi
On Thu, Oct 12, 2006 at 12:25:04PM -0400, Daniel Jacobowitz wrote:
 On Thu, Oct 12, 2006 at 12:22:57PM -0400, Bob Rossi wrote:
  and the gcc that is put into prefixdir is compiled with -O2 and -g,
  which makes it hard to follow in the debugger. Anyone have a clue on how
  to compile gcc so only -g is used, and not -O2? Typically, I use the
  CFLAGS trick, but it doesn't seem to work for gcc.
 
 Use CFLAGS=-g ../gcc-src/configure.  The top level file is still
 autoconf 2.13.

Thanks Daniel! It works now.

Bob Rossi


building gcc

2006-10-11 Thread Bob Rossi
Hi,

I'd like to build gcc with just the C/C++ front ends. Are there 
any configure options I could use to make only a minimum gcc
build to get those 2 languages working?

Also, I'd like to be able to debug gcc. Is there any special flags for
this?

Finally, once it's built, I'd like to manually traverse the AST. Any
pointers on where this would be?

Thanks,
Bob Rossi


Re: building gcc

2006-10-11 Thread Bob Rossi
On Wed, Oct 11, 2006 at 02:39:39PM -0700, David Daney wrote:
 Bob Rossi wrote:
 Hi,
 
 I'd like to build gcc with just the C/C++ front ends. Are there 
 any configure options I could use to make only a minimum gcc
 build to get those 2 languages working?
 
 Take a look at the Fine documentation that is available at 
 http://gcc.gnu.org

Yes, thanks.

 In particular looking at the installation documentation where it 
 describes the --enable-languages=c,c++ configure option would be useful.

Thank you, this is what I was looking for.

 The answers to your other questions can be found in the documents and 
 WIKI at gcc.gnu.org.

In particular, I was just wondering how do compile GCC with debug. Not
how to debug it. I tried CFLAGS=-g ./configure ..., but it still
compiled with gcc -O2 -g. Anyways, if anyone knows a helpful configure
trick that will help get me ready to debug gcc, please let me know.

Thanks,
Bob Rossi