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 {
* 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,
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 ();
MethodBodyMirror body;
MethodMirror gmd;
TypeMirror[] type_args;
+ LocalScope[] hoisted_scopes;
internal MethodMirror (VirtualMachine vm, long id) : base (vm, id) {
}
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 ();
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;
}
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
}
MonoDebugCodeBlock *block;
} MonoDebugLocalVar;
+typedef struct {
+ int start_offset, end_offset;
+} MonoHoistedLocalScope;
+
/*
* Information about local variables retrieved from a symbol file.
*/
MonoDebugLocalVar *locals;
int num_blocks;
MonoDebugCodeBlock *code_blocks;
+ int num_hoisted;
+ MonoHoistedLocalScope *hoisted;
};
/*
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)
{
}
}
+ /*
+ * 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;
}
gboolean
mono_loader_get_strict_strong_names (void);
+guint32
+mono_metadata_customdebuginfo_from_index (MonoImage *meta, guint32 index);
+
#endif /* __MONO_METADATA_INTERNALS_H__ */
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)
MONO_TYPEORMETHOD_MASK = 1
};
+enum {
+ MONO_HASCUSTOMDEBUGINFO_METHODDEF = 0,
+ MONO_HASCUSTOMDEBUGINFO_BITS = 5,
+ MONO_HASCUSTOMDEBUGINFO_MASK = 0x1f
+};
+
#endif /* __MONO_METADATA_ROW_INDEXES_H__ */
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 45
+#define MINOR_VERSION 46
typedef enum {
CMD_SET_VM = 1,
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;