Community Wiki

Developing Ingres With Eclipse CDT

From Ingres Community Wiki

Jump to: navigation, search

Contents

Eclipse can talk C too!

Eclipse is a great tool for developing Java, but with the language edition or CDT plug-in you can use it to develop in C too. Eclipse is a very good tool for debugging C code and once you've mastered "hello world" in C, you might want something slightly more challenging. May we suggest Ingres?

Before you begin please take a look at the topics in Getting Started they will save you a lot of time. Some links are repeated here for your convenience.

Getting the code:

Add a subversion plug-in to Eclipse and you can then use the Ingres subversion repository to download the code. Instructions are at Getting the Code.

Please be sure to read the rest of this topic while the code is downloading.

Both the Subclipse and Subversive plug-ins work with Ingres but note that as of writing, you will need to use Eclipse Europa for both since they have not yet been ported to Ganymede.

General Ingres Build Instructions:

General build instructions for Ingres may be found at Build Ingres

Browsing the Call Hierarchy:

One thing that is especially useful is the call hierarchy window; it doesn't draw a complete call graph, but it will show you all callers and callees of a function and you can click through to drill up or drill down the virtual stack.

CDT doesn't need the program running, but it does require that the source tree is indexed by Eclipse. When you first import the Ingres source tree into a new project let Eclipse spend the 5 or 10 minutes it needs to index the code.

The easiest way to open the call hierarchy windows is to highlight a function name in the editor, then right-click and choose "Open Call Hierarchy".

Automatic re-compile:

Eclipse will normally try to automatically re-build every dependency when you debug. This really doesn't work well with something as big as Ingres, especially when it doesn't know the dependencies properly. It is better to turn off the re-build feature.

To turn off the re-build go to:

   Window | Preferences

then

   Run/debug | Launching

In the "General Options" area

  • uncheck "Build (if required) before launching"

In the "General" section, click on "Workspace"

  • uncheck "Build Automatically"


Using the Ingres builder with Eclipse

Ingres uses a different builder from the Eclipse one. Ingres uses "jam" (Just Another Make).

If you want to tell Eclipse to use jam go to

  Project | Properties

in the properties window go to

  C/C++ Build | builder settings

and

  • uncheck "Use default build command"
  • replace the build command with "jam"
  • uncheck generate makefiles automatically
  • replace the text in the "Build directory" field with "${resource_loc}"

You will need to set up two profiles

  • debug
  • production

and in the debug profile the command is

   jam -sIIOPTIM=-g

Tips:

  • Make sure your environment is set correctly in Eclipse, to do this run the environment setup scrip in a terminal before launching Eclipse.
  • The DBMS will fail to launch if the rest of the servers are not running; to debug the DBMS
    • start Ingres first in a terminal with ingstart
    • shut just the DBMS down with iimonitor
    • run the DBMS under debug in Eclipse
  • In case of failure: review the messages in errlog.log
  • Debugging a section of the DBMS is easiest by attaching to an already running DBMS from inside Eclipse
    • build all the code in debug and run up the server
    • in the debug perspective open the debug dialog
    • in the debug window choose "C/C++ Attach to local Application"
    • choose "New"
    • enter the profile of your debug DBMS
    • debug it and attach to the right process

Gotchas:

Linux only: Windows Gurus please share your knowlege!

Debug Libraries:

The DBMS uses several libraries, to make it debug-able you re-build the relevant library in debug (using jam -sIIOPTIM=-g), then run "mksvrearlibs" to re-make iimerge.o from the archive libraries, and then re-build the iimerge executable using iilink.

You can build targets set up for all these steps in Eclipse.

Shared Libaries:

Other binaries may also link with the shared library versions of the CL and other things, to make other things debug-able you may additionally need to run "mkshlibs" after re-building the library and before re-linking the executable

Rebuild All:

Use the "jam" "-a" flag to force a re-build. If not you may not get all of the code in debug.

Reducing Debug Resource Requirements:

The DBMS server is gigantic and will take a very long time to start if everything is compiled with debug turned on. Also it is unlikely that you will need to debug everything all at once. Therefore as a rule of thumb don't build more than 2 back-end facility libraries in debug at the same time. Typically this alone will need at least 4 gig of memory to run it... an enterprise quality DBMS is a big thing so be sparing about what you build in debug and if you missed something that you need to step into it is still likely quicker to start all over again.

And Finally...

Welcome to the Ingres Eclipse CDT club. Enjoy it, we do!

Personal tools