Skip to content

Commit

Permalink
Addressing Aleksey comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
thaystg committed Jul 28, 2021
1 parent c78b01a commit 0a734ac
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
8 changes: 6 additions & 2 deletions src/mono/mono/component/hot_reload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mono/component/hot_reload.h>
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
42 changes: 15 additions & 27 deletions src/mono/mono/metadata/debug-mono-ppdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 *
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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*
Expand Down
7 changes: 5 additions & 2 deletions src/mono/mono/metadata/debug-mono-ppdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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
8 changes: 4 additions & 4 deletions src/mono/mono/metadata/mono-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 () */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/mono/mono/metadata/mono-debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <mono/utils/mono-publib.h>
#include <mono/metadata/image.h>
#include <mono/metadata/appdomain.h>
#include <glib.h>

MONO_BEGIN_DECLS

Expand Down Expand Up @@ -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);

/*
Expand Down

0 comments on commit 0a734ac

Please sign in to comment.