}
static void
-generate_line_number (MonoDebugMethodInfo *minfo, guint32 address, guint32 offset)
+generate_line_number (MonoDebugMethodInfo *minfo, guint32 address, guint32 offset, int debug)
{
int i;
+ if (debug)
+ g_message (G_STRLOC ": searching IL offset %x", offset);
+
for (i = minfo->num_il_offsets - 1; i >= 0; i--) {
MonoDebugLineNumberEntry *lne;
if (minfo->il_offsets [i].offset > offset)
continue;
+ if (debug)
+ g_message (G_STRLOC ": found entry %d: offset = %x, row = %d",
+ i, minfo->il_offsets [i].offset, minfo->il_offsets [i].row);
+
if (minfo->jit->line_numbers->len) {
MonoDebugLineNumberEntry last = g_array_index (
minfo->jit->line_numbers, MonoDebugLineNumberEntry,
minfo->jit->line_numbers->len - 1);
- if (minfo->il_offsets [i].row <= last.line)
- continue;
+ /* Avoid writing more than one entry for the same line. */
+ if (minfo->il_offsets [i].row == last.line) {
+ if (debug)
+ g_message (G_STRLOC ": skipping line: line = %d, last line = %d, "
+ "last address = %x, address = %x, "
+ "last offset = %x, offset = %x",
+ last.line, minfo->il_offsets [i].row,
+ last.address, address, last.offset, offset);
+
+ return;
+ }
}
+ if (debug)
+ g_message (G_STRLOC ": writing entry: line = %d, offfset = %x, address = %x",
+ minfo->il_offsets [i].row, offset, address);
+
lne = g_new0 (MonoDebugLineNumberEntry, 1);
lne->address = address;
lne->offset = offset;
header = ((MonoMethodNormal*)minfo->method)->header;
#if 0
- if (!strcmp (minfo->method->name, "Main")) {
+ if (!strcmp (minfo->method->name, "Test") || !strcmp (minfo->method->name, "Main")) {
MonoMethodHeader *header = ((MonoMethodNormal*)minfo->method)->header;
debug = 1;
}
#endif
- generate_line_number (minfo, address, offset);
+ generate_line_number (minfo, address, offset, debug);
/* start lines of basic blocks */
for (i = 0; i < cfg->block_count; ++i) {
offset = t->cli_addr;
address = t->addr;
- generate_line_number (minfo, address, offset);
+ generate_line_number (minfo, address, offset, debug);
}
}
- generate_line_number (minfo, minfo->jit->epilogue_begin, header->code_size);
+ generate_line_number (minfo, minfo->jit->epilogue_begin, header->code_size, debug);
if (debug) {
for (i = 0; i < minfo->jit->line_numbers->len; i++) {
}
#define ADD_TREE(t,a) do { t->cli_addr = a; g_ptr_array_add (forest, (t)); } while (0)
-#define PUSH_TREE(t,k) do { int tt = k; *sp = t; t->svt = tt; sp++; } while (0)
+#define PUSH_TREE(t,k) do { int tt = k; *sp = t; t->svt = tt; t->cli_addr = cli_addr; sp++; } while (0)
#define LOCAL_POS(n) (1 + n)
(ii->arg_map [0]->op != MB_TERM_CHECKTHIS)) {
ii->arg_map [0] = mono_ctree_new (mp, MB_TERM_CHECKTHIS,
ii->arg_map [0], NULL);
- ADD_TREE (ii->arg_map [0], cli_addr);
+ ADD_TREE (ii->arg_map [0], ii->arg_map [0]->cli_addr);
}
if (cm->inline_count) {
for (k = nargs - 1; k >= 0; k--) {
t1 = mono_ctree_new (mp, mono_map_arg_type (csig->params [k]), arg_sp [k], NULL);
t1->data.arg_info = arg_info [k + 1];
- ADD_TREE (t1, cli_addr);
+ ADD_TREE (t1, arg_sp [k]->cli_addr);
}
if (csig->hasthis)
this = mono_ctree_new_leaf (mp, MB_TERM_NOP);
- if (MONO_TYPE_ISSTRUCT (csig->ret) && !array_rank) {
+ if (MONO_TYPE_ISSTRUCT (csig->ret)) {
int size, align;
if (csig->pinvoke)
size = mono_class_native_size (csig->ret->data.klass, &align);