Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement column number support in sdb.

  • Loading branch information...
commit f9d3dedcf2c0e9363399ade2349d6415fdd9d82b 1 parent 104c122
@vargaz vargaz authored
View
8 mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
@@ -43,6 +43,7 @@ class DebugInfo {
public int max_il_offset;
public int[] il_offsets;
public int[] line_numbers;
+ public int[] column_numbers;
public SourceInfo[] source_files;
}
@@ -394,7 +395,7 @@ public abstract class Connection
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 18;
+ internal const int MINOR_VERSION = 19;
enum WPSuspendPolicy {
NONE = 0,
@@ -1690,6 +1691,7 @@ internal void SetSocketTimeouts (int send_timeout, int receive_timeout, int keep
info.il_offsets = new int [n_il_offsets];
info.line_numbers = new int [n_il_offsets];
info.source_files = new SourceInfo [n_il_offsets];
+ info.column_numbers = new int [n_il_offsets];
for (int i = 0; i < n_il_offsets; ++i) {
info.il_offsets [i] = res.ReadInt ();
info.line_numbers [i] = res.ReadInt ();
@@ -1699,6 +1701,10 @@ internal void SetSocketTimeouts (int send_timeout, int receive_timeout, int keep
} else {
info.source_files [i] = sources [0];
}
+ if (Version.AtLeast (2, 19))
+ info.column_numbers [i] = res.ReadInt ();
+ else
+ info.column_numbers [i] = 0;
}
return info;
View
11 mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Location.cs
@@ -10,7 +10,7 @@ public class Location : Mirror
string source_file;
int line_number;
byte[] hash;
- //int column_number;
+ int column_number;
internal Location (VirtualMachine vm, MethodMirror method, long native_addr, int il_offset, string source_file, int line_number, int column_number, byte[] hash) : base (vm, 0) {
this.method = method;
@@ -19,7 +19,7 @@ public class Location : Mirror
this.source_file = source_file;
this.line_number = line_number;
this.hash = hash;
- //this.column_number = column_number;
+ this.column_number = column_number;
}
public MethodMirror Method {
@@ -46,6 +46,13 @@ public class Location : Mirror
}
}
+ // Since protocol version 2.19, 0 in earlier protocol versions
+ public int ColumnNumber {
+ get {
+ return column_number;
+ }
+ }
+
// MD5 hash of source file
// Since protocol version 2.14, null in earlier protocol versions
public byte[] SourceFileHash {
View
6 mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs
@@ -303,24 +303,26 @@ public class MethodMirror : Mirror
var line_numbers = LineNumbers;
IList<Location> res = new Location [ILOffsets.Count];
for (int i = 0; i < il_offsets.Count; ++i)
- res [i] = new Location (vm, this, -1, il_offsets [i], debug_info.source_files [i].source_file, line_numbers [i], 0, debug_info.source_files [i].hash);
+ res [i] = new Location (vm, this, -1, il_offsets [i], debug_info.source_files [i].source_file, line_numbers [i], debug_info.column_numbers [i], debug_info.source_files [i].hash);
locations = res;
}
return locations;
}
}
- internal int il_offset_to_line_number (int il_offset, out string src_file, out byte[] src_hash) {
+ internal int il_offset_to_line_number (int il_offset, out string src_file, out byte[] src_hash, out int column_number) {
if (debug_info == null)
debug_info = vm.conn.Method_GetDebugInfo (id);
// FIXME: Optimize this
src_file = null;
src_hash = null;
+ column_number = 0;
for (int i = debug_info.il_offsets.Length - 1; i >= 0; --i) {
if (debug_info.il_offsets [i] <= il_offset) {
src_file = debug_info.source_files [i].source_file;
src_hash = debug_info.source_files [i].hash;
+ column_number = debug_info.column_numbers [i];
return debug_info.line_numbers [i];
}
}
View
5 mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/StackFrame.cs
@@ -44,13 +44,14 @@ public class StackFrame : Mirror
int line_number;
string src_file = null;
byte[] hash = null;
+ int column_number = 0;
if (il_offset == -1)
line_number = -1;
else
- line_number = method.il_offset_to_line_number (il_offset, out src_file, out hash);
+ line_number = method.il_offset_to_line_number (il_offset, out src_file, out hash, out column_number);
- location = new Location (vm, Method, 0, il_offset, src_file != null ? src_file : method.SourceFile, line_number, 0, hash);
+ location = new Location (vm, Method, 0, il_offset, src_file != null ? src_file : method.SourceFile, line_number, column_number, hash);
}
return location;
}
View
1  mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
@@ -1069,6 +1069,7 @@ public class LineNumbers
{
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ln1 () {
+ // Column 3
ln2 ();
ln3 ();
}
View
26 mcs/class/Mono.Debugger.Soft/Test/dtest.cs
@@ -1621,6 +1621,30 @@ public class DebuggerTests
}
[Test]
+ public void ColumnNumbers () {
+ Event e = run_until ("line_numbers");
+
+ // FIXME: Merge this with LineNumbers () when its fixed
+
+ step_req = vm.CreateStepRequest (e.Thread);
+ step_req.Depth = StepDepth.Into;
+ step_req.Enable ();
+
+ Location l;
+
+ vm.Resume ();
+
+ e = GetNextEvent ();
+ Assert.IsTrue (e is StepEvent);
+
+ l = e.Thread.GetFrames ()[0].Location;
+
+ Assert.AreEqual (3, l.ColumnNumber);
+
+ step_req.Disable ();
+ }
+
+ [Test]
// Broken by mcs+runtime changes (#5438)
[Category("NotWorking")]
public void LineNumbers () {
@@ -3010,7 +3034,7 @@ public class DebuggerTests
vm.Resume ();
var e2 = GetNextEvent ();
- Console.WriteLine (e2);
+ Assert.IsTrue (e2 is ExceptionEvent);
vm.Exit (0);
vm = null;
View
46 mono/metadata/debug-mono-symfile.c
@@ -464,6 +464,36 @@ get_source_info (MonoSymbolFile *symfile, int index)
return info;
}
+static gboolean
+method_has_column_info (MonoDebugMethodInfo *minfo)
+{
+ MonoSymbolFile *symfile;
+ const unsigned char *ptr;
+ guint32 flags;
+
+ if ((symfile = minfo->handle->symfile) == NULL)
+ return FALSE;
+
+ ptr = symfile->raw_contents + minfo->data_offset;
+
+ /* Has to read 'flags' which is preceeded by a bunch of other data */
+ /* compile_unit_index */
+ read_leb128 (ptr, &ptr);
+ /* local variable table offset */
+ read_leb128 (ptr, &ptr);
+ /* namespace id */
+ read_leb128 (ptr, &ptr);
+ /* code block table offset */
+ read_leb128 (ptr, &ptr);
+ /* scope variable table offset */
+ read_leb128 (ptr, &ptr);
+ /* real name offset */
+ read_leb128 (ptr, &ptr);
+
+ flags = read_leb128 (ptr, &ptr);
+ return (flags & 2) > 0;
+}
+
/*
* mono_debug_symfile_get_line_numbers_full:
*
@@ -472,7 +502,7 @@ get_source_info (MonoSymbolFile *symfile, int index)
* The MonoDebugSourceFile structures are owned by this module.
*/
void
-mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int *n_il_offsets, int **il_offsets, int **line_numbers, int **source_files)
+mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int *n_il_offsets, int **il_offsets, int **line_numbers, int **column_numbers, int **source_files)
{
// FIXME: Unify this with mono_debug_symfile_lookup_location
MonoSymbolFile *symfile;
@@ -480,6 +510,7 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
StatementMachine stm;
uint32_t i;
GPtrArray *il_offset_array, *line_number_array, *source_file_array;
+ gboolean has_column_info;
if (source_file_list)
*source_file_list = NULL;
@@ -489,10 +520,14 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
*source_files = NULL;
if (source_file)
*source_file = NULL;
+ if (column_numbers)
+ *column_numbers = NULL;
if ((symfile = minfo->handle->symfile) == NULL)
return;
+ has_column_info = method_has_column_info (minfo);
+
il_offset_array = g_ptr_array_new ();
line_number_array = g_ptr_array_new ();
source_file_array = g_ptr_array_new ();
@@ -620,6 +655,13 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
(*line_numbers) [i] = GPOINTER_TO_UINT (g_ptr_array_index (line_number_array, i));
}
}
+
+ if (column_numbers && has_column_info) {
+ *column_numbers = g_malloc (il_offset_array->len * sizeof (int));
+ for (i = 0; i < il_offset_array->len; ++i)
+ (*column_numbers) [i] = read_leb128 (ptr, &ptr);
+ }
+
g_ptr_array_free (il_offset_array, TRUE);
g_ptr_array_free (line_number_array, TRUE);
@@ -635,7 +677,7 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
void
mono_debug_symfile_get_line_numbers (MonoDebugMethodInfo *minfo, char **source_file, int *n_il_offsets, int **il_offsets, int **line_numbers)
{
- mono_debug_symfile_get_line_numbers_full (minfo, source_file, NULL, n_il_offsets, il_offsets, line_numbers, NULL);
+ mono_debug_symfile_get_line_numbers_full (minfo, source_file, NULL, n_il_offsets, il_offsets, line_numbers, NULL, NULL);
}
int32_t
View
2  mono/metadata/debug-mono-symfile.h
@@ -159,7 +159,7 @@ void
mono_debug_symfile_get_line_numbers (MonoDebugMethodInfo *minfo, char **source_file, int *n_il_offsets, int **il_offsets, int **line_numbers);
void
-mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int *n_il_offsets, int **il_offsets, int **line_numbers, int **source_files);
+mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int *n_il_offsets, int **il_offsets, int **line_numbers, int **column_numbers, int **source_files);
MONO_END_DECLS
View
13 mono/mini/debugger-agent.c
@@ -276,7 +276,7 @@ typedef struct {
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 18
+#define MINOR_VERSION 19
typedef enum {
CMD_SET_VM = 1,
@@ -3284,7 +3284,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo
MonoDebugMethodInfo *minfo = mono_debug_lookup_method (method);
if (minfo) {
- mono_debug_symfile_get_line_numbers_full (minfo, &source_file, &source_file_list, NULL, NULL, NULL, NULL);
+ mono_debug_symfile_get_line_numbers_full (minfo, &source_file, &source_file_list, NULL, NULL, NULL, NULL, NULL);
for (i = 0; i < source_file_list->len; ++i) {
sinfo = g_ptr_array_index (source_file_list, i);
/*
@@ -6141,7 +6141,7 @@ get_source_files_for_type (MonoClass *klass)
GPtrArray *source_file_list;
if (minfo) {
- mono_debug_symfile_get_line_numbers_full (minfo, NULL, &source_file_list, NULL, NULL, NULL, NULL);
+ mono_debug_symfile_get_line_numbers_full (minfo, NULL, &source_file_list, NULL, NULL, NULL, NULL, NULL);
for (j = 0; j < source_file_list->len; ++j) {
sinfo = g_ptr_array_index (source_file_list, j);
for (i = 0; i < files->len; ++i)
@@ -7560,6 +7560,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
int i, j, n_il_offsets;
int *il_offsets;
int *line_numbers;
+ int *column_numbers;
int *source_files;
GPtrArray *source_file_list;
@@ -7580,7 +7581,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
break;
}
- mono_debug_symfile_get_line_numbers_full (minfo, &source_file, &source_file_list, &n_il_offsets, &il_offsets, &line_numbers, &source_files);
+ mono_debug_symfile_get_line_numbers_full (minfo, &source_file, &source_file_list, &n_il_offsets, &il_offsets, &line_numbers, &column_numbers, &source_files);
buffer_add_int (buf, header->code_size);
if (CHECK_PROTOCOL_VERSION (2, 13)) {
buffer_add_int (buf, source_file_list->len);
@@ -7604,11 +7605,13 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
MonoDebugSourceInfo *sinfo = g_ptr_array_index (source_file_list, source_files [i]);
srcfile = sinfo->source_file;
}
- DEBUG (10, fprintf (log_file, "IL%x -> %s:%d\n", il_offsets [i], srcfile, line_numbers [i]));
+ DEBUG (10, fprintf (log_file, "IL%x -> %s:%d %d\n", il_offsets [i], srcfile, line_numbers [i], column_numbers ? column_numbers [i] : -1));
buffer_add_int (buf, il_offsets [i]);
buffer_add_int (buf, line_numbers [i]);
if (CHECK_PROTOCOL_VERSION (2, 13))
buffer_add_int (buf, source_files [i]);
+ if (CHECK_PROTOCOL_VERSION (2, 19))
+ buffer_add_int (buf, column_numbers ? column_numbers [i] : -1);
}
g_free (source_file);
g_free (il_offsets);
View
2  mono/mini/method-to-ir.c
@@ -5832,7 +5832,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
int *il_offsets;
int *line_numbers;
- mono_debug_symfile_get_line_numbers_full (minfo, NULL, NULL, &n_il_offsets, &il_offsets, &line_numbers, NULL);
+ mono_debug_symfile_get_line_numbers_full (minfo, NULL, NULL, &n_il_offsets, &il_offsets, &line_numbers, NULL, NULL);
seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (cfg->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0);
sym_seq_points = TRUE;
for (i = 0; i < n_il_offsets; ++i) {
Please sign in to comment.
Something went wrong with that request. Please try again.