Author: toshok
Date: 2007-10-31 12:47:47 -0500 (Wed, 31 Oct 2007)
New Revision: 88585
Modified:
trunk/mndb/mndb.gdbinit
Log:
start on the mprint stuff. we're going to need to be reading the metadata
somehow to get variable names... also, start futzing with mndb_print_frame to
print line numbers instead of offsets
Modified: trunk/mndb/mndb.gdbinit
===================================================================
--- trunk/mndb/mndb.gdbinit 2007-10-31 17:41:15 UTC (rev 88584)
+++ trunk/mndb/mndb.gdbinit 2007-10-31 17:47:47 UTC (rev 88585)
@@ -44,6 +44,64 @@
end
end
+define mndb_print_variable_index
+# from mdb:
+# internal enum AddressMode : long
+# {
+# Register = 0,
+# RegOffset = 0x10000000,
+# TwoRegisters = 0x20000000
+# }
+#
+# const long AddressModeFlags = 0xf0000000;
+#
+# Mode = (AddressMode) (Index & AddressModeFlags);
+# Index = (int) ((long) Index & ~AddressModeFlags);
+
+ set $_mode = $arg0 & 0xf0000000
+ set $_index = $arg0 & ~0xf0000000
+
+# if ((Mode == AddressMode.Register) || (Mode ==
AddressMode.RegOffset))
+# Index = arch.RegisterMap [Index];
+#
+#
+# int[] register_map = { (int) I386Register.EAX, (int)
I386Register.ECX,
+# (int) I386Register.EDX, (int)
I386Register.EBX,
+# (int) I386Register.ESP, (int)
I386Register.EBP,
+# (int) I386Register.ESI, (int)
I386Register.EDI };
+
+ if ($_mode == 0 || $_mode == 0x10000000)
+# set $_index =
+ end
+end
+
+define mprint
+ set $jit_info = mono_jit_info_table_find (mono_domain_get (), $pc)
+ set $mono_method = mono_jit_info_get_method ($jit_info)
+
+ mndb_find_debug_handle_for_method $mono_method
+
+ mndb_get_debug_method_info $mono_method $mono_handle
+
+ set $jit_debug_info = mono_debug_find_method ($mono_method,
mono_domain_get ())
+
+ if (!strcmp ($arg0, "this"))
+ printf "this = %s\n", mono_type_get_name
($jit_debug_info->this_var->type)
+ mndb_print_variable_index $jit_debug_info->this_var->index
+ end
+ if (!strcmp ($arg0, "locals"))
+ printf "%d locals:\n", $jit_debug_info->num_locals
+
+ set $i = 0
+ while ($i < $jit_debug_info->num_locals)
+ printf " %d = %s\n", $i, mono_type_get_name
($jit_debug_info->locals[$i]->type)
+ printf " "
+ mndb_print_variable_index
$jit_debug_info->locals[$i]->index
+ set $i = $i + 1
+ end
+ end
+end
+
# thread support
# : mthread
@@ -149,8 +207,6 @@
set $jit_debug_info = mono_debug_find_method ($mono_method,
mono_domain_get ())
- set $addr_list = mono_debug_lookup_method_addresses ($mono_method)
-
set $native_offset = $pc - $jit_debug_info->code_start
set $source_location = mono_debug_lookup_source_location ($mono_method,
$native_offset, mono_domain_get ())
@@ -158,11 +214,11 @@
#printf "Current native offset = %d, il offset = %d\n", $native_offset,
$source_location->il_offset
# print out the current jit debug info line number table (native/il
offsets)
- #set $i = 0
- #while ($i < $jit_debug_info->num_line_numbers)
- # printf "jit_debug_info->line_numbers[%d] = %d, %d\n", $i,
$jit_debug_info->line_numbers[$i].il_offset,
$jit_debug_info->line_numbers[$i].native_offset
- # set $i = $i + 1
- #end
+ set $i = 0
+ while ($i < $jit_debug_info->num_line_numbers)
+ printf "jit_debug_info->line_numbers[%d] = %d, %d\n", $i,
$jit_debug_info->line_numbers[$i].il_offset,
$jit_debug_info->line_numbers[$i].native_offset
+ set $i = $i + 1
+ end
set $i = 0
while ($i < $jit_debug_info->num_line_numbers)
@@ -271,11 +327,42 @@
end
define mndb_print_frame
- set $foo = mono_pmip ($pc)
- if ($foo == 0x00)
- frame
+ set $mono_method = 0
+ set $jit_info = mono_jit_info_table_find (mono_domain_get (), $pc)
+ if ($jit_info != 0x00)
+ set $mono_method = mono_jit_info_get_method ($jit_info)
+
+ mndb_find_debug_handle_for_method $mono_method
+
+ mndb_get_debug_method_info $mono_method $mono_handle
+
+ set $jit_debug_info = mono_debug_find_method ($mono_method,
mono_domain_get ())
+
+ set $native_offset = $pc - $jit_debug_info->code_start
+
+ set $source_location = mono_debug_lookup_source_location
($mono_method, $native_offset, mono_domain_get ())
+ end
+
+ set $line_index = -1
+ if ($source_location != 0x00)
+ set $line_index = 0
+ while ($line_index < $jit_debug_info->num_line_numbers)
+ if ($source_location->il_offset <
$jit_debug_info->line_numbers[$line_index].il_offset)
+ loop_break
+ end
+ set $line_index = $line_index + 1
+ end
+ end
+
+ if ($line_index != -1 && $line_index !=
($jit_debug_info->num_line_numbers - 1))
+
else
- printf "0x%x in %s\n", $pc, $foo
+ set $foo = mono_pmip ($pc)
+ if ($foo == 0x00)
+ frame
+ else
+ printf "0x%x in %s\n", $pc, $foo
+ end
end
end
@@ -368,9 +455,6 @@
set $data = *(guint32*)($esp + 12)
set $arg = *(guint32*)($esp + 20)
-# print (MonoDebuggerEvent)$event
-# print (void*)$data
-
if ($event == MONO_DEBUGGER_EVENT_INITIALIZE_MANAGED_CODE)
print ">>> INITIALIZE_MANAGED_CODE"
return
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches