symfile->raw_contents = p = g_malloc (size);
memcpy (p, raw_contents, size);
symfile->filename = g_strdup_printf ("LoadedFromMemory");
+ symfile->was_loaded_from_memory = TRUE;
} else {
MonoFileMap *f;
symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
-
+ symfile->was_loaded_from_memory = FALSE;
if ((f = mono_file_map_open (symfile->filename))) {
symfile->raw_contents_size = mono_file_map_size (f);
if (symfile->raw_contents_size == 0) {
if (symfile->method_hash)
g_hash_table_destroy (symfile->method_hash);
- if (symfile->raw_contents)
- mono_file_unmap ((gpointer) symfile->raw_contents, symfile->raw_contents_handle);
+ if (symfile->raw_contents) {
+ if (symfile->was_loaded_from_memory)
+ g_free ((gpointer)symfile->raw_contents);
+ else
+ mono_file_unmap ((gpointer) symfile->raw_contents, symfile->raw_contents_handle);
+ }
if (symfile->filename)
g_free (symfile->filename);
int line_base, line_range, max_address_incr;
guint8 opcode_base;
guint32 last_line, last_file, last_offset;
+ guint32 first_file;
int line, file, offset;
+ gboolean is_hidden;
} StatementMachine;
static gboolean
stm.offset = stm.last_offset = 0;
stm.last_file = 0;
stm.last_line = 0;
+ stm.first_file = 0;
stm.file = 1;
stm.line = 1;
+ stm.is_hidden = FALSE;
while (TRUE) {
guint8 opcode = *ptr++;
goto out_success;
break;
} else if (opcode == DW_LNE_MONO_negate_is_hidden) {
- ;
+ stm.is_hidden = !stm.is_hidden;
} else if ((opcode >= DW_LNE_MONO__extensions_start) &&
(opcode <= DW_LNE_MONO__extensions_end)) {
; // reserved for future extensions
g_ptr_array_add (il_offset_array, GUINT_TO_POINTER (stm->offset));
g_ptr_array_add (line_number_array, GUINT_TO_POINTER (stm->line));
}
+
+ if (!stm->is_hidden && !stm->first_file)
+ stm->first_file = stm->file;
+}
+
+/*
+ * mono_debug_symfile_free_location:
+ *
+ * Free a MonoDebugSourceLocation returned by
+ * mono_debug_symfile_lookup_location
+ */
+void
+mono_debug_symfile_free_location (MonoDebugSourceLocation *location)
+{
+ g_free (location->source_file);
+ g_free (location);
}
/*
stm.offset = stm.last_offset = 0;
stm.last_file = 0;
stm.last_line = 0;
+ stm.first_file = 0;
stm.file = 1;
stm.line = 1;
+ stm.is_hidden = FALSE;
while (TRUE) {
guint8 opcode = *ptr++;
add_line (&stm, il_offset_array, line_number_array);
break;
} else if (opcode == DW_LNE_MONO_negate_is_hidden) {
- ;
+ stm.is_hidden = !stm.is_hidden;
} else if ((opcode >= DW_LNE_MONO__extensions_start) &&
(opcode <= DW_LNE_MONO__extensions_end)) {
; // reserved for future extensions
}
}
+ if (!stm.file && stm.first_file)
+ stm.file = stm.first_file;
+
if (stm.file) {
int offset = read32(&(stm.symfile->offset_table->_source_table_offset)) +
(stm.file - 1) * sizeof (MonoSymbolFileSourceEntry);