-/*
- * xdebug.c: Support for emitting gdb debug info for JITted code.
+/**
+ * \file
+ * Support for emitting gdb debug info for JITted code.
*
* Author:
* Zoltan Varga (vargaz@gmail.com)
#include <glib.h>
#include "mini.h"
-#if !defined(DISABLE_AOT) && !defined(DISABLE_JIT)
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <sys/stat.h>
#include "image-writer.h"
+
+#if !defined(DISABLE_AOT) && !defined(DISABLE_JIT) && USE_BIN_WRITER
+
#include "dwarfwriter.h"
#include "mono/utils/mono-compiler.h"
unlink ("xdb.s");
xdebug_fp = fopen ("xdb.s", "w");
- w = img_writer_create (xdebug_fp, FALSE);
+ w = mono_img_writer_create (xdebug_fp, FALSE);
- img_writer_emit_start (w);
+ mono_img_writer_emit_start (w);
- xdebug_writer = mono_dwarf_writer_create (w, il_file, 0, TRUE, TRUE);
+ xdebug_writer = mono_dwarf_writer_create (w, il_file, 0, TRUE);
/* Emit something so the file has a text segment */
- img_writer_emit_section_change (w, ".text", 0);
- img_writer_emit_string (w, "");
+ mono_img_writer_emit_section_change (w, ".text", 0);
+ mono_img_writer_emit_string (w, "");
mono_dwarf_writer_emit_base_info (xdebug_writer, "JITted code", mono_unwind_get_cie_program ());
}
MonoImageWriter *w;
MonoDwarfWriter *dw;
- w = img_writer_create (NULL, TRUE);
+ w = mono_img_writer_create (NULL, TRUE);
- img_writer_emit_start (w);
+ mono_img_writer_emit_start (w);
/* This file will contain the IL code for methods which don't have debug info */
if (!il_file)
il_file = fopen ("xdb.il", "w");
- dw = mono_dwarf_writer_create (w, il_file, il_file_line_index, FALSE, TRUE);
+ dw = mono_dwarf_writer_create (w, il_file, il_file_line_index, TRUE);
mono_dwarf_writer_emit_base_info (dw, "JITted code", mono_unwind_get_cie_program ());
il_file_line_index = mono_dwarf_writer_get_il_file_line_index (dw);
mono_dwarf_writer_close (dw);
- img_writer_emit_writeout (w);
+ mono_img_writer_emit_writeout (w);
- img = img_writer_get_output (w, &img_size);
+ img = mono_img_writer_get_output (w, &img_size);
- img_writer_destroy (w);
+ mono_img_writer_destroy (w);
if (FALSE) {
/* Save the symbol files to help debugging */
xdebug_method_count ++;
dmji = mono_debug_find_method (jinfo_get_method (cfg->jit_info), mono_domain_get ());;
- mono_dwarf_writer_emit_method (xdebug_writer, cfg, jinfo_get_method (cfg->jit_info), NULL, NULL, cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, dmji);
+ mono_dwarf_writer_emit_method (xdebug_writer, cfg, jinfo_get_method (cfg->jit_info), NULL, NULL, NULL,
+ cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, dmji);
mono_debug_free_method_jit_info (dmji);
#if 0
* FIXME: This doesn't work when multiple methods are emitted into the same file.
*/
sym = get_debug_sym (cfg->jit_info->method, "", xdebug_syms);
- img_writer_emit_section_change (w, ".text", 0);
+ mono_img_writer_emit_section_change (w, ".text", 0);
if (!xdebug_text_addr) {
xdebug_text_addr = cfg->jit_info->code_start;
- img_writer_set_section_addr (w, (gssize)xdebug_text_addr);
+ mono_img_writer_set_section_addr (w, (gssize)xdebug_text_addr);
}
- img_writer_emit_global_with_size (w, sym, cfg->jit_info->code_size, TRUE);
- img_writer_emit_label (w, sym);
- img_writer_emit_bytes (w, cfg->jit_info->code_start, cfg->jit_info->code_size);
+ mono_img_writer_emit_global_with_size (w, sym, cfg->jit_info->code_size, TRUE);
+ mono_img_writer_emit_label (w, sym);
+ mono_img_writer_emit_bytes (w, cfg->jit_info->code_start, cfg->jit_info->code_size);
g_free (sym);
#endif
mono_loader_lock ();
dmji = mono_debug_find_method (jinfo_get_method (cfg->jit_info), mono_domain_get ());
- mono_dwarf_writer_emit_method (xdebug_writer, cfg, jinfo_get_method (cfg->jit_info), NULL, NULL, cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, dmji);
+ mono_dwarf_writer_emit_method (xdebug_writer, cfg, jinfo_get_method (cfg->jit_info), NULL, NULL, NULL,
+ cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, dmji);
mono_debug_free_method_jit_info (dmji);
fflush (xdebug_fp);
mono_loader_unlock ();
void
mono_save_trampoline_xdebug_info (MonoTrampInfo *info)
{
+ const char *info_name = info->name;
+ if (info_name == NULL)
+ info_name = "";
+
if (use_gdb_interface) {
MonoImageWriter *w;
MonoDwarfWriter *dw;
xdebug_begin_emit (&w, &dw);
- mono_dwarf_writer_emit_trampoline (dw, info->name, NULL, NULL, info->code, info->code_size, info->unwind_ops);
+ mono_dwarf_writer_emit_trampoline (dw, info_name, NULL, NULL, info->code, info->code_size, info->unwind_ops);
xdebug_end_emit (w, dw, NULL);
return;
mono_loader_lock_if_inited ();
- mono_dwarf_writer_emit_trampoline (xdebug_writer, info->name, NULL, NULL, info->code, info->code_size, info->unwind_ops);
+ mono_dwarf_writer_emit_trampoline (xdebug_writer, info_name, NULL, NULL, info->code, info->code_size, info->unwind_ops);
fflush (xdebug_fp);
mono_loader_unlock_if_inited ();
}