@@ -5588,6 +5588,7 @@ void MONO_NOINLINE __jit_debug_register_code(void) { };
55885588 debugger may check the version before we can set it. */
55895589struct jit_descriptor __jit_debug_descriptor = { 1 , 0 , 0 , 0 };
55905590
5591+ static MonoImageWriter * xdebug_w ;
55915592static MonoDwarfWriter * xdebug_writer ;
55925593static FILE * xdebug_fp , * il_file ;
55935594static gboolean use_gdb_interface , save_symfiles ;
@@ -5670,7 +5671,7 @@ xdebug_end_emit (MonoImageWriter *w, MonoDwarfWriter *dw, MonoMethod *method)
56705671
56715672 img_writer_destroy (w );
56725673
5673- if (save_symfiles && method ) {
5674+ if (TRUE ) {
56745675 /* Save the symbol files to help debugging */
56755676 FILE * fp ;
56765677 char * file_name ;
@@ -5704,6 +5705,23 @@ xdebug_end_emit (MonoImageWriter *w, MonoDwarfWriter *dw, MonoMethod *method)
57045705 __jit_debug_register_code ();
57055706}
57065707
5708+ /*
5709+ * mono_xdebug_flush:
5710+ *
5711+ * This could be called from inside gdb to flush the debugging information not yet
5712+ * registered with gdb.
5713+ */
5714+ static void
5715+ mono_xdebug_flush (void )
5716+ {
5717+ if (xdebug_w )
5718+ xdebug_end_emit (xdebug_w , xdebug_writer , NULL );
5719+
5720+ xdebug_begin_emit (& xdebug_w , & xdebug_writer );
5721+ }
5722+
5723+ static int xdebug_method_count ;
5724+
57075725/*
57085726 * mono_save_xdebug_info:
57095727 *
@@ -5715,33 +5733,40 @@ void
57155733mono_save_xdebug_info (MonoCompile * cfg )
57165734{
57175735 if (use_gdb_interface ) {
5718- MonoImageWriter * w ;
5719- MonoDwarfWriter * dw ;
5720- char * sym ;
5721-
57225736 mono_loader_lock ();
57235737
57245738 if (!xdebug_syms )
57255739 xdebug_syms = g_hash_table_new_full (g_str_hash , g_str_equal , g_free , NULL );
57265740
5727- xdebug_begin_emit (& w , & dw );
5741+ /*
5742+ * gdb is not designed to handle 1000s of symbol files (one per method). So we
5743+ * group them into groups of 10.
5744+ */
5745+ if ((xdebug_method_count % 10 ) == 0 )
5746+ mono_xdebug_flush ();
5747+
5748+ xdebug_method_count ++ ;
57285749
5729- mono_dwarf_writer_emit_method (dw , cfg , cfg -> jit_info -> method , NULL , NULL , cfg -> jit_info -> code_start , cfg -> jit_info -> code_size , cfg -> args , cfg -> locals , cfg -> unwind_ops , mono_debug_find_method (cfg -> jit_info -> method , mono_domain_get ()));
5750+ mono_dwarf_writer_emit_method (xdebug_writer , cfg , cfg -> jit_info -> method , NULL , NULL , cfg -> jit_info -> code_start , cfg -> jit_info -> code_size , cfg -> args , cfg -> locals , cfg -> unwind_ops , mono_debug_find_method (cfg -> jit_info -> method , mono_domain_get ()));
57305751
5752+ #if 0
57315753 /*
57325754 * Emit a symbol for the code by emitting it at the beginning of the text
57335755 * segment, and setting the text segment to have an absolute address.
57345756 * This symbol can be used to set breakpoints in gdb.
5757+ * FIXME: This doesn't work when multiple methods are emitted into the same file.
57355758 */
57365759 sym = get_debug_sym (cfg -> jit_info -> method , "" , xdebug_syms );
57375760 img_writer_emit_section_change (w , ".text" , 0 );
5738- img_writer_set_section_addr (w , (gssize )cfg -> jit_info -> code_start );
5739- img_writer_emit_global (w , sym , TRUE);
5761+ if (!xdebug_text_addr ) {
5762+ xdebug_text_addr = cfg -> jit_info -> code_start ;
5763+ img_writer_set_section_addr (w , (gssize )xdebug_text_addr );
5764+ }
5765+ img_writer_emit_global_with_size (w , sym , cfg -> jit_info -> code_size , TRUE);
57405766 img_writer_emit_label (w , sym );
57415767 img_writer_emit_bytes (w , cfg -> jit_info -> code_start , cfg -> jit_info -> code_size );
57425768 g_free (sym );
5743-
5744- xdebug_end_emit (w , dw , cfg -> jit_info -> method );
5769+ #endif
57455770
57465771 mono_loader_unlock ();
57475772 } else {
0 commit comments