#include <mono/metadata/mono-endian.h>
#include <mono/metadata/debug-mono-symfile.h>
+#include <mono/metadata/mono-debug-debugger.h>
#include <mono/utils/mono-compiler.h>
#ifndef HOST_WIN32
w->appending = appending;
if (appending)
- g_assert (img_writer_subsections_supported (w->w));
+ g_assert (mono_img_writer_subsections_supported (w->w));
w->emit_line = TRUE;
if (appending) {
- if (!img_writer_subsections_supported (w->w))
+ if (!mono_img_writer_subsections_supported (w->w))
/* Can't emit line number info without subsections */
w->emit_line = FALSE;
} else {
w->collect_line_info = FALSE;
}
- w->fp = img_writer_get_fp (w->w);
- w->temp_prefix = img_writer_get_temp_label_prefix (w->w);
+ w->fp = mono_img_writer_get_fp (w->w);
+ w->temp_prefix = mono_img_writer_get_temp_label_prefix (w->w);
w->class_to_die = g_hash_table_new (NULL, NULL);
w->class_to_vtype_die = g_hash_table_new (NULL, NULL);
static inline void
emit_section_change (MonoDwarfWriter *w, const char *section_name, int subsection_index)
{
- img_writer_emit_section_change (w->w, section_name, subsection_index);
+ mono_img_writer_emit_section_change (w->w, section_name, subsection_index);
}
static inline void
emit_push_section (MonoDwarfWriter *w, const char *section_name, int subsection)
{
- img_writer_emit_push_section (w->w, section_name, subsection);
+ mono_img_writer_emit_push_section (w->w, section_name, subsection);
}
static inline void
emit_pop_section (MonoDwarfWriter *w)
{
- img_writer_emit_pop_section (w->w);
+ mono_img_writer_emit_pop_section (w->w);
}
static inline void
emit_label (MonoDwarfWriter *w, const char *name)
{
- img_writer_emit_label (w->w, name);
+ mono_img_writer_emit_label (w->w, name);
}
static inline void
emit_bytes (MonoDwarfWriter *w, const guint8* buf, int size)
{
- img_writer_emit_bytes (w->w, buf, size);
+ mono_img_writer_emit_bytes (w->w, buf, size);
}
static inline void
emit_string (MonoDwarfWriter *w, const char *value)
{
- img_writer_emit_string (w->w, value);
+ mono_img_writer_emit_string (w->w, value);
}
static inline void
emit_line (MonoDwarfWriter *w)
{
- img_writer_emit_line (w->w);
+ mono_img_writer_emit_line (w->w);
}
static inline void
emit_alignment (MonoDwarfWriter *w, int size)
{
- img_writer_emit_alignment (w->w, size);
+ mono_img_writer_emit_alignment (w->w, size);
}
static inline void
emit_pointer_unaligned (MonoDwarfWriter *w, const char *target)
{
- img_writer_emit_pointer_unaligned (w->w, target);
+ mono_img_writer_emit_pointer_unaligned (w->w, target);
}
static inline void
emit_pointer (MonoDwarfWriter *w, const char *target)
{
- img_writer_emit_pointer (w->w, target);
+ mono_img_writer_emit_pointer (w->w, target);
}
static inline void
emit_int16 (MonoDwarfWriter *w, int value)
{
- img_writer_emit_int16 (w->w, value);
+ mono_img_writer_emit_int16 (w->w, value);
}
static inline void
emit_int32 (MonoDwarfWriter *w, int value)
{
- img_writer_emit_int32 (w->w, value);
+ mono_img_writer_emit_int32 (w->w, value);
}
static inline void
emit_symbol_diff (MonoDwarfWriter *w, const char *end, const char* start, int offset)
{
- img_writer_emit_symbol_diff (w->w, end, start, offset);
+ mono_img_writer_emit_symbol_diff (w->w, end, start, offset);
}
static inline void
emit_byte (MonoDwarfWriter *w, guint8 val)
{
- img_writer_emit_byte (w->w, val);
+ mono_img_writer_emit_byte (w->w, val);
+}
+
+static void
+emit_escaped_string (MonoDwarfWriter *w, char *value)
+{
+ int i, len;
+
+ len = strlen (value);
+ for (i = 0; i < len; ++i) {
+ char c = value [i];
+ if (!(isalnum (c))) {
+ switch (c) {
+ case '_':
+ case '-':
+ case ':':
+ case '.':
+ case ',':
+ case '/':
+ case '<':
+ case '>':
+ case '`':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
+ break;
+ default:
+ value [i] = '_';
+ break;
+ }
+ }
+ }
+ mono_img_writer_emit_string (w->w, value);
}
static G_GNUC_UNUSED void
}
/* Convert the list of MonoUnwindOps to the format used by DWARF */
- uw_info = mono_unwind_ops_encode (l, &uw_info_len);
+ uw_info = mono_unwind_ops_encode_full (l, &uw_info_len, FALSE);
emit_bytes (w, uw_info, uw_info_len);
g_free (uw_info);
int len, i, j;
len = strlen (name);
- s = g_malloc0 ((len + 1) * 2);
+ s = (char *)g_malloc0 ((len + 1) * 2);
j = 0;
for (i = 0; i < len; ++i) {
if (name [i] == '\\') {
/* Collect files */
info_list = g_slist_reverse (w->line_info);
for (l = info_list; l; l = l->next) {
- MethodLineNumberInfo *info = l->data;
+ MethodLineNumberInfo *info = (MethodLineNumberInfo *)l->data;
MonoDebugMethodInfo *minfo;
- char *source_file;
GPtrArray *source_file_list;
// FIXME: Free stuff
if (!minfo)
continue;
- mono_debug_symfile_get_line_numbers_full (minfo, &source_file, &source_file_list, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ mono_debug_get_seq_points (minfo, NULL, &source_file_list, NULL, NULL, NULL);
for (i = 0; i < source_file_list->len; ++i) {
- MonoDebugSourceInfo *sinfo = g_ptr_array_index (source_file_list, i);
+ MonoDebugSourceInfo *sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i);
add_line_number_file_name (w, sinfo->source_file, 0, 0);
}
}
dir_to_index = g_hash_table_new (g_str_hash, g_str_equal);
index_to_dir = g_hash_table_new (NULL, NULL);
for (i = 0; i < w->line_number_file_index; ++i) {
- char *name = g_hash_table_lookup (w->index_to_file, GUINT_TO_POINTER (i + 1));
+ char *name = (char *)g_hash_table_lookup (w->index_to_file, GUINT_TO_POINTER (i + 1));
char *copy;
int dir_index = 0;
/* Includes */
emit_section_change (w, ".debug_line", 0);
for (i = 0; i < w->line_number_dir_index; ++i) {
- char *dir = g_hash_table_lookup (index_to_dir, GUINT_TO_POINTER (i + 1));
+ char *dir = (char *)g_hash_table_lookup (index_to_dir, GUINT_TO_POINTER (i + 1));
emit_string (w, mono_dwarf_escape_path (dir));
}
/* Files */
for (i = 0; i < w->line_number_file_index; ++i) {
- char *name = g_hash_table_lookup (w->index_to_file, GUINT_TO_POINTER (i + 1));
+ char *name = (char *)g_hash_table_lookup (w->index_to_file, GUINT_TO_POINTER (i + 1));
char *basename = NULL, *dir;
int dir_index = 0;
/* Emit line number table */
for (l = info_list; l; l = l->next) {
- MethodLineNumberInfo *info = l->data;
+ MethodLineNumberInfo *info = (MethodLineNumberInfo *)l->data;
MonoDebugMethodJitInfo *dmji;
- dmji = mono_debug_find_method (info->method, mono_domain_get ());;
+ dmji = mono_debug_find_method (info->method, mono_domain_get ());
+ if (!dmji)
+ continue;
emit_line_number_info (w, info->method, info->start_symbol, info->end_symbol, info->code, info->code_size, dmji);
mono_debug_free_method_jit_info (dmji);
}
{
/* This doesn't seem to work/required with recent iphone sdk versions */
#if 0
- if (!img_writer_subsections_supported (w->w))
+ if (!mono_img_writer_subsections_supported (w->w))
fprintf (w->fp, "\n.set %sdebug_info_end,.\n", w->temp_prefix);
#endif
}
emit_int32 (w, 0); /* .debug_abbrev offset */
emit_byte (w, sizeof (gpointer)); /* address size */
- if (img_writer_subsections_supported (w->w) && w->appending) {
+ if (mono_img_writer_subsections_supported (w->w) && w->appending) {
/* Emit this into a separate section so it gets placed at the end */
emit_section_change (w, ".debug_info", 1);
emit_byte (w, 0); /* close COMPILE_UNIT */
else
cache = w->class_to_die;
- return g_hash_table_lookup (cache, klass);
+ return (const char *)g_hash_table_lookup (cache, klass);
}
/* Returns the local symbol pointing to the emitted debug info */
else
cache = w->class_to_die;
- die = g_hash_table_lookup (cache, klass);
+ die = (char *)g_hash_table_lookup (cache, klass);
if (die)
return die;
const char *p;
MonoTypeEnum def_type;
- if (strcmp ("value__", mono_field_get_name (field)) == 0)
+ if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
if (mono_field_is_deleted (field))
continue;
if (t->byref) {
if (t->type == MONO_TYPE_VALUETYPE) {
- tdie = g_hash_table_lookup (w->class_to_pointer_die, klass);
+ tdie = (const char *)g_hash_table_lookup (w->class_to_pointer_die, klass);
}
else {
tdie = get_class_die (w, klass, FALSE);
} else {
switch (t->type) {
case MONO_TYPE_CLASS:
- tdie = g_hash_table_lookup (w->class_to_reference_die, klass);
+ tdie = (const char *)g_hash_table_lookup (w->class_to_reference_die, klass);
//tdie = ".LDIE_OBJECT";
break;
case MONO_TYPE_ARRAY:
break;
case MONO_TYPE_GENERICINST:
if (!MONO_TYPE_ISSTRUCT (t)) {
- tdie = g_hash_table_lookup (w->class_to_reference_die, klass);
+ tdie = (const char *)g_hash_table_lookup (w->class_to_reference_die, klass);
} else {
tdie = ".LDIE_I4";
}
case CEE_CASTCLASS:
case CEE_LDELEMA:
if (method->wrapper_type) {
- klass = data;
+ klass = (MonoClass *)data;
} else {
klass = mono_class_get_checked (method->klass->image, token, &error);
g_assert (mono_error_ok (&error)); /* FIXME error handling */
case CEE_CALL:
case CEE_CALLVIRT:
if (method->wrapper_type)
- cmethod = data;
+ cmethod = (MonoMethod *)data;
else
cmethod = mono_get_method_full (method->klass->image, token, NULL, NULL);
desc = mono_method_full_name (cmethod, TRUE);
break;
case CEE_CALLI:
if (method->wrapper_type) {
- desc = mono_signature_get_desc (data, FALSE);
+ desc = mono_signature_get_desc ((MonoMethodSignature *)data, FALSE);
res = g_strdup_printf ("<%s>", desc);
g_free (desc);
} else {
case CEE_STFLD:
case CEE_STSFLD:
if (method->wrapper_type) {
- field = data;
+ field = (MonoClassField *)data;
} else {
field = mono_field_from_token_checked (method->klass->image, token, &klass, NULL, &error);
g_assert (mono_error_ok (&error)); /* FIXME error handling */
ln_array = g_new0 (MonoDebugLineNumberEntry, debug_info->num_line_numbers);
memcpy (ln_array, debug_info->line_numbers, debug_info->num_line_numbers * sizeof (MonoDebugLineNumberEntry));
- qsort (ln_array, debug_info->num_line_numbers, sizeof (MonoDebugLineNumberEntry), (gpointer)compare_lne);
+ qsort (ln_array, debug_info->num_line_numbers, sizeof (MonoDebugLineNumberEntry), (int (*)(const void *, const void *))compare_lne);
native_to_il_offset = g_new0 (int, code_size + 1);
prev_il_offset = il_offset;
loc = mono_debug_symfile_lookup_location (minfo, il_offset);
- if (!(loc && loc->source_file))
+ if (!loc)
+ continue;
+ if (!loc->source_file) {
+ mono_debug_symfile_free_location (loc);
continue;
+ }
line_diff = (gint32)loc->row - (gint32)prev_line;
addr_diff = i - prev_native_offset;
emit_uleb128 (w, ABBREV_SUBPROGRAM);
/* DW_AT_name */
name = mono_method_full_name (method, FALSE);
- emit_string (w, name);
+ emit_escaped_string (w, name);
/* DW_AT_MIPS_linkage_name */
if (linkage_name)
emit_string (w, linkage_name);
int file_index = add_line_number_file_name (w, loc->source_file, 0, 0);
emit_uleb128 (w, file_index + 1);
emit_uleb128 (w, loc->row);
+
+ mono_debug_symfile_free_location (loc);
+ loc = NULL;
} else {
emit_uleb128 (w, 0);
emit_uleb128 (w, 0);
}
if (locals_info)
- mono_debug_symfile_free_locals (locals_info);
+ mono_debug_free_locals (locals_info);
/* Subprogram end */
emit_uleb128 (w, 0x0);