[Mono-list] JIT patch for stabs debugging

Paolo Molaro lupus@ximian.com
Sun, 10 Mar 2002 10:06:49 +0100


On 03/10/02 Martin Baulig wrote:
> 1.) Puts a NOP instruction at the start of every method.
> 
>     If you use `mono --debug Something', this buts a breakpoint
>     instruction (INT 3) at the start of "Something" - which means
>     that the address of Something's first instruction changes, but
>     this address is already hard-coded into the stabs file.
> 
>     So without the NOP instructions you need to recreate your stabs
>     symbol files each time you want to run mono with different --debug
>     arguments.

No, this is wrong: if you restart mono, all the infos in the stab file
are wrong. It may have happened that in two runs the same method was
assigned the same address by malloc, but you can't rely on it:-)
I don't know if a recent gdb allows to unload a debug object, if it
still doesn't, you need to quit and restart gdb as well (and recompile
the stabs each time you start mono).

> 2.) Uses correct line numbers in the stabs file.
> 
>     In mono_debug_add_method(), `t->cli_add' is a bytecode offset, but
>     not a line number in the .il file.

Thanks for fixing this: I ran out of time to properly implement this
when I added support for debugging and since stabs format allows lines
up to 2^16 I planned to switch to the dwarf debug format anyway
(plus, there is an actual specification for dwarf, <grin>).

> @@ -201,14 +228,16 @@
>  mono_debug_add_method (MonoDebugHandle* debug, MonoFlowGraph *cfg)
>  {
>  	char *name;
> -	int line = 0;
> -	int i;
> +	int line = 0, line_index = 0;
> +	int i, print;
>  	MonoMethod *method = cfg->method;
>  	MonoClass *klass = method->klass;
>  	MonoMethodSignature *sig = method->signature;
>  	char **names = g_new (char*, sig->param_count);
>  	AssemblyDebugInfo* info = mono_debug_open_ass (debug, klass->image);
>  
> +	print = !strcmp (method->name, "Parse") || !strcmp (method->name, "Main");
> +
^^^^^^^^^^^^^^^^^^^^^^^
Leftover from debugging?

> --- x86.brg	2002/03/08 06:08:46	1.92
> +++ x86.brg	2002/03/09 21:48:16
> @@ -816,7 +816,7 @@
>  	if (tree->left->reg1 != X86_EAX)
>  		x86_mov_reg_reg (s->code, X86_EAX, tree->left->reg1, 4);
>  
> -	x86_cdq (s->code);
> +	x86_mov_reg_imm (s->code, X86_EDX, 0);
>  	x86_div_reg (s->code, tree->right->reg1, FALSE);
>  
>  	mono_assert (tree->reg1 == X86_EAX &&

Use xor %edx, %edx, there.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better