diff --git a/src/mono/mono/component/hot_reload.c b/src/mono/mono/component/hot_reload.c index d76fc8c5ad267..575ffa36981db 100644 --- a/src/mono/mono/component/hot_reload.c +++ b/src/mono/mono/component/hot_reload.c @@ -19,7 +19,9 @@ #include "mono/utils/mono-lazy-init.h" #include "mono/utils/mono-logger-internals.h" #include "mono/utils/mono-path.h" +#include "mono/metadata/debug-internals.h" #include "mono/metadata/mono-debug.h" +#include "mono/metadata/debug-mono-ppdb.h" #include @@ -325,6 +327,8 @@ delta_info_init (MonoImage *image_dmeta, MonoImage *image_base, BaselineInfo *ba static void free_ppdb_entry (gpointer key, gpointer val, gpointer user_data) { + MonoDebugInformationEnc *value = (MonoDebugInformationEnc *) val; + mono_ppdb_close (value->ppdb_file); g_free (val); } @@ -1217,8 +1221,8 @@ hot_reload_get_method_debug_information (MonoImage *image_dppdb, int idx) int token_index = mono_metadata_token_index (map_token); if (token_index == idx) { MonoDebugInformationEnc *encDebugInfo = g_new0 (MonoDebugInformationEnc, 1); - encDebugInfo->idx = i; - encDebugInfo->image = image_dppdb; + encDebugInfo->idx = i + 1; + encDebugInfo->ppdb_file = mono_create_ppdb_file (image_dppdb, FALSE); return encDebugInfo; } } diff --git a/src/mono/mono/metadata/debug-mono-ppdb.c b/src/mono/mono/metadata/debug-mono-ppdb.c index 093f47b7a0f7e..934ab484a8280 100644 --- a/src/mono/mono/metadata/debug-mono-ppdb.c +++ b/src/mono/mono/metadata/debug-mono-ppdb.c @@ -37,13 +37,6 @@ #include "debug-mono-ppdb.h" -struct _MonoPPDBFile { - MonoImage *image; - GHashTable *doc_hash; - GHashTable *method_hash; - gboolean is_embedded; -}; - typedef struct { gint32 signature; guint8 guid [16]; @@ -130,8 +123,8 @@ doc_free (gpointer key) g_free (info); } -static MonoPPDBFile* -create_ppdb_file (MonoImage *ppdb_image, gboolean is_embedded_ppdb) +MonoPPDBFile* +mono_create_ppdb_file (MonoImage *ppdb_image, gboolean is_embedded_ppdb) { MonoPPDBFile *ppdb; @@ -161,7 +154,7 @@ mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size) if (table_info_get_rows (&image->tables [MONO_TABLE_DOCUMENT])) { /* Embedded ppdb */ mono_image_addref (image); - return create_ppdb_file (image, TRUE); + return mono_create_ppdb_file (image, TRUE); } if (!get_pe_debug_info (image, pe_guid, &pe_age, &pe_timestamp, &ppdb_data, &ppdb_size, &ppdb_compressed_size)) { @@ -236,14 +229,12 @@ mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size) return NULL; } - return create_ppdb_file (ppdb_image, is_embedded_ppdb); + return mono_create_ppdb_file (ppdb_image, is_embedded_ppdb); } void -mono_ppdb_close (MonoDebugHandle *handle) +mono_ppdb_close (MonoPPDBFile *ppdb) { - MonoPPDBFile *ppdb = handle->ppdb; - mono_image_close (ppdb->image); g_hash_table_destroy (ppdb->doc_hash); g_hash_table_destroy (ppdb->method_hash); @@ -332,15 +323,12 @@ get_docinfo (MonoPPDBFile *ppdb, MonoImage *image, int docidx) res->hash = (guint8*)mono_metadata_blob_heap (image, cols [MONO_DOCUMENT_HASH]); mono_debugger_lock (); - if (ppdb) - { - cached = (MonoDebugSourceInfo *)g_hash_table_lookup (ppdb->doc_hash, GUINT_TO_POINTER (docidx)); - if (!cached) { - g_hash_table_insert (ppdb->doc_hash, GUINT_TO_POINTER (docidx), res); - } else { - doc_free (res); - res = cached; - } + cached = (MonoDebugSourceInfo *)g_hash_table_lookup (ppdb->doc_hash, GUINT_TO_POINTER (docidx)); + if (!cached) { + g_hash_table_insert (ppdb->doc_hash, GUINT_TO_POINTER (docidx), res); + } else { + doc_free (res); + res = cached; } mono_debugger_unlock (); return res; @@ -453,7 +441,7 @@ mono_ppdb_lookup_location (MonoDebugMethodInfo *minfo, uint32_t offset) MonoDebugSourceLocation * mono_ppdb_lookup_location_enc (MonoImage *image, int idx, uint32_t offset) { - return mono_ppdb_lookup_location_internal (image, idx+1, offset, NULL); + return mono_ppdb_lookup_location_internal (image, idx, offset, NULL); } MonoImage * @@ -606,10 +594,10 @@ mono_ppdb_get_seq_points_internal (MonoImage *image, MonoPPDBFile *ppdb, MonoMet } gboolean -mono_ppdb_get_seq_points_enc (MonoDebugMethodInfo *minfo, MonoImage *image, int idx, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points) +mono_ppdb_get_seq_points_enc (MonoDebugMethodInfo *minfo, MonoPPDBFile *ppdb_file, int idx, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points) { MonoMethod *method = minfo->method; - if (mono_ppdb_get_seq_points_internal (image, NULL, method, idx+1, source_file, source_file_list, source_files, seq_points, n_seq_points) > 0) + if (mono_ppdb_get_seq_points_internal (ppdb_file->image, ppdb_file, method, idx, source_file, source_file_list, source_files, seq_points, n_seq_points) > 0) return TRUE; return FALSE; } @@ -724,7 +712,7 @@ mono_ppdb_lookup_locals_internal (MonoImage *image, int method_idx) MonoDebugLocalsInfo* mono_ppdb_lookup_locals_enc (MonoImage *image, int method_idx) { - return mono_ppdb_lookup_locals_internal (image, method_idx + 1); + return mono_ppdb_lookup_locals_internal (image, method_idx); } MonoDebugLocalsInfo* diff --git a/src/mono/mono/metadata/debug-mono-ppdb.h b/src/mono/mono/metadata/debug-mono-ppdb.h index 990e178ba4847..000430d4bec72 100644 --- a/src/mono/mono/metadata/debug-mono-ppdb.h +++ b/src/mono/mono/metadata/debug-mono-ppdb.h @@ -21,7 +21,7 @@ MonoPPDBFile* mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size); void -mono_ppdb_close (MonoDebugHandle *handle); +mono_ppdb_close (MonoPPDBFile *ppdb_file); MonoDebugMethodInfo * mono_ppdb_lookup_method (MonoDebugHandle *handle, MonoMethod *method); @@ -36,7 +36,7 @@ void mono_ppdb_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points); gboolean -mono_ppdb_get_seq_points_enc (MonoDebugMethodInfo *minfo, MonoImage *image, int idx, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points); +mono_ppdb_get_seq_points_enc (MonoDebugMethodInfo *minfo, MonoPPDBFile *ppdb_file, int idx, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points); MonoDebugLocalsInfo* mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo); @@ -56,4 +56,7 @@ mono_ppdb_get_sourcelink (MonoDebugHandle *handle); gboolean mono_ppdb_is_embedded (MonoPPDBFile *ppdb); +MonoPPDBFile* +mono_create_ppdb_file (MonoImage *ppdb_image, gboolean is_embedded_ppdb); + #endif diff --git a/src/mono/mono/metadata/mono-debug.c b/src/mono/mono/metadata/mono-debug.c index 81b5d4f25156f..0d88f1d329fe7 100644 --- a/src/mono/mono/metadata/mono-debug.c +++ b/src/mono/mono/metadata/mono-debug.c @@ -124,7 +124,7 @@ static void free_debug_handle (MonoDebugHandle *handle) { if (handle->ppdb) - mono_ppdb_close (handle); + mono_ppdb_close (handle->ppdb); if (handle->symfile) mono_debug_close_mono_symbol_file (handle->symfile); /* decrease the refcount added with mono_image_addref () */ @@ -843,7 +843,7 @@ mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset) int idx = mono_metadata_token_index (minfo->method->token); MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx); if (mdie != NULL) { - MonoDebugSourceLocation * ret = mono_ppdb_lookup_location_enc (mdie->image, mdie->idx, il_offset); + MonoDebugSourceLocation * ret = mono_ppdb_lookup_location_enc (mdie->ppdb_file->image, mdie->idx, il_offset); if (ret) return ret; } @@ -877,7 +877,7 @@ mono_debug_lookup_locals (MonoMethod *method, mono_bool ignore_pdb) int idx = mono_metadata_token_index (method->token); MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx); if (mdie != NULL) { - res = mono_ppdb_lookup_locals_enc (mdie->image, mdie->idx); + res = mono_ppdb_lookup_locals_enc (mdie->ppdb_file->image, mdie->idx); if (res != NULL) return res; } @@ -1143,7 +1143,7 @@ mono_debug_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrA int idx = mono_metadata_token_index (minfo->method->token); MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx); if (mdie != NULL) { - if (mono_ppdb_get_seq_points_enc (minfo, mdie->image, mdie->idx, source_file, source_file_list, source_files, seq_points, n_seq_points)) + if (mono_ppdb_get_seq_points_enc (minfo, mdie->ppdb_file, mdie->idx, source_file, source_file_list, source_files, seq_points, n_seq_points)) return; } } diff --git a/src/mono/mono/metadata/mono-debug.h b/src/mono/mono/metadata/mono-debug.h index ccc9d3a005434..5f73fc50a7431 100644 --- a/src/mono/mono/metadata/mono-debug.h +++ b/src/mono/mono/metadata/mono-debug.h @@ -10,6 +10,7 @@ #include #include #include +#include MONO_BEGIN_DECLS @@ -113,10 +114,17 @@ struct _MonoDebugSourceLocation { struct _MonoDebugInformationEnc { - MonoImage *image; + MonoPPDBFile *ppdb_file; int idx; }; +struct _MonoPPDBFile { + MonoImage *image; + GHashTable *doc_hash; + GHashTable *method_hash; + gboolean is_embedded; +}; + MONO_API mono_bool mono_debug_enabled (void); /*