Skip to content

Commit f335c0b

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 9f4bc33 commit f335c0b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

mono/metadata/debug-mono-ppdb.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ typedef struct {
4848
gint32 signature;
4949
guint8 guid [16];
5050
gint32 age;
51+
char path [];
5152
} CodeviewDebugDirectory;
5253

5354
typedef struct {
@@ -66,7 +67,7 @@ enum {
6667
};
6768

6869
static gboolean
69-
get_pe_debug_info (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp, guint8 **ppdb_data,
70+
get_pe_debug_info (MonoImage *image, const char** out_path, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp, guint8 **ppdb_data,
7071
int *ppdb_uncompressed_size, int *ppdb_compressed_size)
7172
{
7273
MonoPEDirEntry *debug_dir_entry;
@@ -104,6 +105,10 @@ get_pe_debug_info (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *
104105
*out_age = read32(data + 20);
105106
*out_timestamp = debug_dir.time_date_stamp;
106107
guid_found = TRUE;
108+
109+
if (out_path != NULL) {
110+
*out_path = g_strdup (dir.path);
111+
}
107112
}
108113
}
109114
if (debug_dir.type == DEBUG_DIR_ENTRY_PPDB && debug_dir.major_version >= 0x100 && debug_dir.minor_version == 0x100) {
@@ -143,6 +148,14 @@ create_ppdb_file (MonoImage *ppdb_image, gboolean is_embedded_ppdb)
143148
return ppdb;
144149
}
145150

151+
gboolean
152+
mono_ppdb_get_signature(MonoImage *image, const char** out_path, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp)
153+
{
154+
guint8 *ppdb_data = NULL;
155+
int ppdb_size, ppdb_compressed_size;
156+
return get_pe_debug_info (image, out_path, out_guid, out_age, out_timestamp, &ppdb_data, &ppdb_size, &ppdb_compressed_size);
157+
}
158+
146159
MonoPPDBFile*
147160
mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size)
148161
{
@@ -164,7 +177,7 @@ mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size)
164177
return create_ppdb_file (image, TRUE);
165178
}
166179

167-
if (!get_pe_debug_info (image, pe_guid, &pe_age, &pe_timestamp, &ppdb_data, &ppdb_size, &ppdb_compressed_size)) {
180+
if (!get_pe_debug_info (image, NULL, pe_guid, &pe_age, &pe_timestamp, &ppdb_data, &ppdb_size, &ppdb_compressed_size)) {
168181
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Image '%s' has no debug directory.", image->name);
169182
return NULL;
170183
}

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)