Difference between revisions of "Debug generated C code"

(Mac OS X)
(Added runtime debug compilation.)
Line 1: Line 1:
 
[[Category:Runtime]]
 
[[Category:Runtime]]
Sometimes you need debug Eiffel generated C code, this is how to.
+
Sometimes you need debug Eiffel generated C code, this page will show you how to achieve this. In addition you may also want to compile the runtime in debug mode as well and the instructions after the one about the generated C code.
  
 
== Unix ==
 
== Unix ==
Line 44: Line 44:
 
sed -i -e 's/$(RM) $(OBJECTS)//g' `find -d . | grep "Makefile.SH"`
 
sed -i -e 's/$(RM) $(OBJECTS)//g' `find -d . | grep "Makefile.SH"`
 
</pre>
 
</pre>
 +
 +
 +
== Runtime ==
 +
Edit $EIFFEL_SRC/C/CONFIGS/$ISE_PLATFORM and perform the same substitution as above for Unix. Then type '''./quick_configure''' in the $EIFFEL_SRC/C directory for Unix, and '''configure win64 m''' (Windows 64-bit) or '''configure win32 m''' (Windows 32-bit).

Revision as of 07:38, 21 August 2009

Sometimes you need debug Eiffel generated C code, this page will show you how to achieve this. In addition you may also want to compile the runtime in debug mode as well and the instructions after the one about the generated C code.

Unix

Edit $ISE_EIFFEL/studio/spec/$ISE_PLATFORM/include/config.sh and

  1. To the value of wkoptimize add the -g option.
  2. Replace the value of optimize to disable the C optimization (usually -O0) and add -g.

Once you have done that, do in your W_code or F_code directory:

  1. make clobber
  2. finish_freezing

Windows

After doing the changes below (depending on your C compiler), you can recompile your project from scratch and the debug information will be present.

MinGW

Edit $ISE_EIFFEL\studio\config\$ISE_PLATFORM\$ISE_C_COMPILER\config.eif and perform the following edits:

  1. Replace the content of optimize by -O0 -g.
  2. Replace the content of wkoptimize by -O0 -g.

Visual C++

Edit $ISE_EIFFEL\studio\config\$ISE_PLATFORM\$ISE_C_COMPILER\config.eif and perform the following edits:

  1. Replace the content of optimize' by -Od -Zi -MT.
  2. Search and replace all occurrences of -NODEFAULTLIB:libc by -NODEFAULTLIB:libc -DEBUG.

With Visual C++, you can have access to the Visual Studio C debugger which will let you attach Eiffel running processes. We certainly recommend that you catch all exceptions (Ctrl + Alt + E to get to the dialog).

If you have issues with Visual Studio not finding some debugging information, it might be necessary to tell Visual Studio where to find the associated PDB of your Eiffel executable or DLL.

Mac OS X

Hint: Eclipse works well to graphically debug your application, Xcode can be set up as well (more).

  1. Replace the content of optimize by -O0 -g.
  2. Replace the content of wkoptimize by -O0 -g.

Once you have done that, do in your W_code or F_code directory:

  1. make clobber
  2. finish_freezing
Now that's not enough. You need to modify the Makefile.SH manually for all Cx directories and remove the line
$(RM) $(OBJECTS)

The following shell script will do the magic for you:

sed -i -e 's/$(RM) $(OBJECTS)//g' `find -d . | grep "Makefile.SH"`


Runtime

Edit $EIFFEL_SRC/C/CONFIGS/$ISE_PLATFORM and perform the same substitution as above for Unix. Then type ./quick_configure in the $EIFFEL_SRC/C directory for Unix, and configure win64 m (Windows 64-bit) or configure win32 m (Windows 32-bit).