Skip to content

Commit 6827fbe

Browse files
rovarmaUnityAlex
authored andcommitted
Added accessors for the data needed for PDB lookup
- The existing `get_pe_debug_guid` function has been updated to optionally output the path to the PDB as extracted from the PE header. The existing user of this function (`mono_ppdb_load_file`) passes NULL as argument for the new path argument. These are all the fields that are needed for PDB lookup in symbol servers and such. - Added `mono_ppdb_get_signature`, which internally just calls `get_pe_debug_guid`, but is exported - Exported the existing `mono_unity_method_get_token` function so that it can be used from profiler modules. The method token is needed for lookup of method data inside a PDB. removing whitespace change
1 parent 7b9c609 commit 6827fbe

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

mono/metadata/debug-mono-ppdb.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef struct {
5454
gint32 signature;
5555
guint8 guid [16];
5656
gint32 age;
57+
char path [];
5758
} CodeviewDebugDirectory;
5859

5960
typedef struct {
@@ -63,7 +64,7 @@ typedef struct {
6364
} PdbStreamHeader;
6465

6566
static gboolean
66-
get_pe_debug_guid (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp)
67+
get_pe_debug_guid (MonoImage *image, const char** out_path, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp)
6768
{
6869
MonoPEDirEntry *debug_dir_entry;
6970
ImageDebugDirectory *debug_dir;
@@ -82,6 +83,11 @@ get_pe_debug_guid (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *
8283
memcpy (out_guid, dir->guid, 16);
8384
*out_age = dir->age;
8485
*out_timestamp = debug_dir->time_date_stamp;
86+
87+
if (out_path != NULL) {
88+
*out_path = g_strdup (dir->path);
89+
}
90+
8591
return TRUE;
8692
}
8793
}
@@ -109,6 +115,12 @@ create_ppdb_file (MonoImage *ppdb_image)
109115
return ppdb;
110116
}
111117

118+
gboolean
119+
mono_ppdb_get_signature(MonoImage *image, const char** out_path, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp)
120+
{
121+
return get_pe_debug_guid (image, out_path, out_guid, out_age, out_timestamp);
122+
}
123+
112124
MonoPPDBFile*
113125
mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size)
114126
{
@@ -126,7 +138,7 @@ mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size)
126138
return create_ppdb_file (image);
127139
}
128140

129-
if (!get_pe_debug_guid (image, pe_guid, &pe_age, &pe_timestamp)) {
141+
if (!get_pe_debug_guid (image, NULL, pe_guid, &pe_age, &pe_timestamp)) {
130142
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Image '%s' has no debug directory.", image->name);
131143
return NULL;
132144
}

mono/metadata/debug-mono-ppdb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <mono/metadata/metadata-internals.h>
1818
#include <mono/metadata/mono-debug.h>
1919

20+
MONO_API gboolean
21+
mono_ppdb_get_signature (MonoImage *image, const char** out_path, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp);
22+
2023
MonoPPDBFile*
2124
mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size);
2225

mono/metadata/unity-utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ guint64 mono_unity_method_get_hash(MonoMethod *method, gboolean inflate);
9696
MonoMethod* mono_unity_method_get_aot_array_helper_from_wrapper(MonoMethod *method);
9797
MonoObject* mono_unity_method_convert_return_type_if_needed(MonoMethod *method, void *value);
9898
MONO_API gboolean unity_mono_method_is_inflated(MonoMethod* method);
99-
guint32 mono_unity_method_get_token(MonoMethod *method);
99+
MONO_API guint32 mono_unity_method_get_token(MonoMethod *method);
100100

101101
//domain
102102
void mono_unity_domain_install_finalize_runtime_invoke(MonoDomain* domain, RuntimeInvokeFunction callback);

0 commit comments

Comments
 (0)