Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs14
-rw-r--r--mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs15
-rw-r--r--mcs/class/Mono.Debugger.Soft/Test/dtest.cs5
-rw-r--r--mono/metadata/debug-internals.h6
-rw-r--r--mono/metadata/debug-mono-ppdb.c24
-rw-r--r--mono/metadata/metadata-internals.h3
-rw-r--r--mono/metadata/metadata.c32
-rw-r--r--mono/metadata/row-indexes.h6
-rw-r--r--mono/mini/debugger-agent.c10
9 files changed, 113 insertions, 2 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
index af3e1716ca4..6172b440f49 100644
--- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
+++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
@@ -119,6 +119,9 @@ namespace Mono.Debugger.Soft
public int[] live_range_end;
public int[] scopes_start;
public int[] scopes_end;
+ public int nhoisted;
+ public int[] hoisted_scopes_start;
+ public int[] hoisted_scopes_end;
}
struct PropInfo {
@@ -420,7 +423,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 45;
+ internal const int MINOR_VERSION = 46;
enum WPSuspendPolicy {
NONE = 0,
@@ -1927,6 +1930,15 @@ namespace Mono.Debugger.Soft
info.scopes_end [i] = info.scopes_start [i] + res.ReadInt ();
last_start = info.scopes_start [i];
}
+ if (Version.AtLeast (2, 46)) {
+ info.nhoisted = res.ReadInt ();
+ info.hoisted_scopes_start = new int [info.nhoisted];
+ info.hoisted_scopes_end = new int [info.nhoisted];
+ for (int i = 0; i < info.nhoisted; ++i) {
+ info.hoisted_scopes_start [i] = res.ReadInt ();
+ info.hoisted_scopes_end [i] = res.ReadInt ();
+ }
+ }
}
int nlocals = res.ReadInt ();
diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs
index fb10f7117c3..65e3abc54dc 100644
--- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs
+++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs
@@ -24,6 +24,7 @@ namespace Mono.Debugger.Soft
MethodBodyMirror body;
MethodMirror gmd;
TypeMirror[] type_args;
+ LocalScope[] hoisted_scopes;
internal MethodMirror (VirtualMachine vm, long id) : base (vm, id) {
}
@@ -246,6 +247,16 @@ namespace Mono.Debugger.Soft
return scopes;
}
+ //
+ // Return the contents of the State Machine Hoisted Locals Scope record:
+ // https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/specs/PortablePdb-Metadata.md#state-machine-hoisted-local-scopes-c--vb-compilers
+ //
+ public LocalScope [] GetHoistedScopes () {
+ vm.CheckProtocolVersion (2, 46);
+ GetLocals ();
+ return hoisted_scopes;
+ }
+
public LocalVariable[] GetLocals () {
if (locals == null) {
LocalsInfo li = new LocalsInfo ();
@@ -271,6 +282,10 @@ namespace Mono.Debugger.Soft
for (int i = 0; i < scopes.Length; ++i)
scopes [i] = new LocalScope (vm, this, li.scopes_start [i], li.scopes_end [i]);
}
+
+ hoisted_scopes = new LocalScope [li.nhoisted];
+ for (int i = 0; i < li.nhoisted; ++i)
+ hoisted_scopes [i] = new LocalScope (vm, this, li.hoisted_scopes_start [i], li.hoisted_scopes_end [i]);
}
return locals;
}
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
index 631b5985db1..2586a315eb4 100644
--- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
+++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
@@ -1050,6 +1050,11 @@ public class DebuggerTests
e = step_in_await ("ss_await", e);//ss_await_1_exc (true, false).Wait ();//out
e = step_in_await ("MoveNext", e);//{
+
+ // Check hoisted scope information
+ var hoisted = (e as StepEvent).Method.GetHoistedScopes ();
+ Assert.AreEqual (2, hoisted.Length);
+
e = step_out_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//out
}
diff --git a/mono/metadata/debug-internals.h b/mono/metadata/debug-internals.h
index 5ac4f103adf..98174b4b438 100644
--- a/mono/metadata/debug-internals.h
+++ b/mono/metadata/debug-internals.h
@@ -28,6 +28,10 @@ typedef struct {
MonoDebugCodeBlock *block;
} MonoDebugLocalVar;
+typedef struct {
+ int start_offset, end_offset;
+} MonoHoistedLocalScope;
+
/*
* Information about local variables retrieved from a symbol file.
*/
@@ -36,6 +40,8 @@ struct _MonoDebugLocalsInfo {
MonoDebugLocalVar *locals;
int num_blocks;
MonoDebugCodeBlock *code_blocks;
+ int num_hoisted;
+ MonoHoistedLocalScope *hoisted;
};
/*
diff --git a/mono/metadata/debug-mono-ppdb.c b/mono/metadata/debug-mono-ppdb.c
index 3ad5235610a..9a5b01a6b2b 100644
--- a/mono/metadata/debug-mono-ppdb.c
+++ b/mono/metadata/debug-mono-ppdb.c
@@ -61,6 +61,9 @@ typedef struct {
guint64 referenced_tables;
} PdbStreamHeader;
+static const char*
+lookup_custom_debug_information (MonoImage* image, guint32 token, uint8_t parent_type, guint8* guid);
+
static gboolean
get_pe_debug_guid (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *out_timestamp)
{
@@ -606,6 +609,27 @@ mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo)
}
}
+ /*
+ * Read scope information for hoisted variables, if it exists.
+ * Its stored in the CustomDebugInformation table.
+ */
+ guint8 hoisted_scopes_guid [16] = { 0x1E, 0xA6, 0xA9, 0x6D, 0xC7, 0xF8, 0x74, 0x48, 0xBE, 0x62, 0x68, 0xBC, 0x56, 0x30, 0xDF, 0x71 };
+ char const *blob = lookup_custom_debug_information (image, method->token, MONO_HASCUSTOMDEBUGINFO_METHODDEF, hoisted_scopes_guid);
+ if (blob) {
+ const char *ptr = blob;
+ int size = mono_metadata_decode_blob_size (ptr, &ptr);
+ g_assert (size % 4 == 0);
+ size /= 4;
+ res->num_hoisted = size;
+ res->hoisted = g_new0 (MonoHoistedLocalScope, res->num_hoisted);
+ for (int hindex = 0; hindex < size; ++hindex) {
+ res->hoisted [hindex].start_offset = read16 (ptr);
+ ptr += 4;
+ res->hoisted [hindex].end_offset = res->hoisted [hindex].start_offset + read16 (ptr);
+ ptr += 4;
+ }
+ }
+
return res;
}
diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h
index a6a936758e6..2afcd3d17b4 100644
--- a/mono/metadata/metadata-internals.h
+++ b/mono/metadata/metadata-internals.h
@@ -950,5 +950,8 @@ mono_loader_set_strict_strong_names (gboolean enabled);
gboolean
mono_loader_get_strict_strong_names (void);
+guint32
+mono_metadata_customdebuginfo_from_index (MonoImage *meta, guint32 index);
+
#endif /* __MONO_METADATA_INTERNALS_H__ */
diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c
index dd1ea04a33e..22e6a66592b 100644
--- a/mono/metadata/metadata.c
+++ b/mono/metadata/metadata.c
@@ -4743,6 +4743,38 @@ mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index)
return loc.result + 1;
}
+/*
+ * mono_metadata_customdebuginfo_from_index:
+ * @meta: metadata context
+ * @index: hascustomdebuginfo coded index
+ *
+ * Returns: the 1-based index into the CustomDebugInformation table of the first
+ * scope which belongs to the metadata object described by @index.
+ * Returns 0 if no such row is found.
+ */
+guint32
+mono_metadata_customdebuginfo_from_index (MonoImage *meta, guint32 index)
+{
+ MonoTableInfo *tdef = &meta->tables [MONO_TABLE_CUSTOMDEBUGINFORMATION];
+ locator_t loc;
+
+ if (!tdef->base)
+ return 0;
+
+ loc.idx = index;
+ loc.col_idx = MONO_CUSTOMDEBUGINFORMATION_PARENT;
+ loc.t = tdef;
+
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ return 0;
+
+ /* Find the first entry by searching backwards */
+ while ((loc.result > 0) && (mono_metadata_decode_row_col (tdef, loc.result - 1, MONO_CUSTOMDEBUGINFORMATION_PARENT) == index))
+ loc.result --;
+
+ return loc.result + 1;
+}
+
#ifdef DEBUG
static void
mono_backtrace (int limit)
diff --git a/mono/metadata/row-indexes.h b/mono/metadata/row-indexes.h
index 992dbdeea99..f5c71abd201 100644
--- a/mono/metadata/row-indexes.h
+++ b/mono/metadata/row-indexes.h
@@ -486,6 +486,12 @@ enum {
MONO_TYPEORMETHOD_MASK = 1
};
+enum {
+ MONO_HASCUSTOMDEBUGINFO_METHODDEF = 0,
+ MONO_HASCUSTOMDEBUGINFO_BITS = 5,
+ MONO_HASCUSTOMDEBUGINFO_MASK = 0x1f
+};
+
#endif /* __MONO_METADATA_ROW_INDEXES_H__ */
diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c
index bfdddb37547..1a4940a82cc 100644
--- a/mono/mini/debugger-agent.c
+++ b/mono/mini/debugger-agent.c
@@ -275,7 +275,7 @@ typedef struct {
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 45
+#define MINOR_VERSION 46
typedef enum {
CMD_SET_VM = 1,
@@ -9057,6 +9057,14 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
buffer_add_int (buf, locals->code_blocks [i].end_offset - locals->code_blocks [i].start_offset);
last_start = locals->code_blocks [i].start_offset;
}
+ if (CHECK_PROTOCOL_VERSION (2, 46)) {
+ /* Scopes for hoisted locals */
+ buffer_add_int (buf, locals->num_hoisted);
+ for (i = 0; i < locals->num_hoisted; ++i) {
+ buffer_add_int (buf, locals->code_blocks [i].start_offset);
+ buffer_add_int (buf, locals->code_blocks [i].end_offset);
+ }
+ }
}
num_locals = locals->num_locals;