[Mono-list] Mono now supports the DWARF 2 debugging format

Martin Baulig martin@gnome.org
14 Mar 2002 00:43:54 +0100


Hi guys,

in addition to the stabs debugging format, our JIT engine (mono) can now
also write DWARF 2 debugging files.

This is done by the new --dwarf command line argument:

====[from mono/docs/jit-debug]=====
You need to run mono inside gdb. The following command line swicthes 
are available:

	--stabs
	--dwarf
	--debug className:methodName

--stabs will create an assemblyname-stabs.s file for each assembly the
CLR program uses.  Note that to properly display source code lines,
you need to disassemble the CLR executables with monodis before running
mono. Each IL assembly file needs to have the name <assemblyname>.il.

--dwarf will create an assemblyname-dwarf.s file for each assembly the
CLR program uses.  Note that to properly display source code lines,
you need to disassemble the CLR executables with monodis before running
mono. Each IL assembly file needs to have the name <assemblyname>.il.

--debug className:methodName will insert a breakpoin at the beginning of
methodName's code, so that control is trasnfered to the debugger as soon
as it is entered. You may use this switch multiple times.

So, suppose you use the --debug switch, or hit a segfault inside a
jitted method.  In a shell you need to compile the stab/dwarf information
created with the --stabs or --dwarf option with the assembler:

	as assemblyname-stabs.s -o assemblyname-stabs.o

or

	as assemblyname-dwarf.s -o assemblyname-dwarf.o

Now, inside gdb, you can load the debug information with:

	add-symbol-file assemblyname-stabs.o 0

or

	add-symbol-file assemblyname-dwarf.o 0

And at this point the debugger should be able to print a correct
backtrace, you should be able to inspect method parameters and local
variables, disassemble methods and step through the code.

Using the DWARF 2 debugging format (with the --dwarf) argument is the
recommended one since it supports source files with more than 65.536
lines (for instance corlib.il) and you'll also get much better type
support with it. [FIXME: I'm still working on this, but it's already
making good progress. Martin].

However, some systems or debuggers may not support the DWARF 2 format,
in this case just use stabs.
=====

Note that the DWARF 2 format is an addition to STABS - some systems
and debuggers only support STABS so this format is still supported and
will not go away.

You may need GDB 5.1.1 to read the dwarf file though it should also
work with GDB 5.0 (I tried hard not to use any features which aren't
supported by GDB 5.0, but unfortunately I didn't backup my old gdb
binary before upgrading my system, so I cannot test it with the old
GDB. The only older GDB I have is GDB 19990928 and this doesn't work).

So if your GDB is too old, either upgrade or use --stabs as you did
before ....

-- 
Martin Baulig
martin@gnome.org