[runtime] Rename mono_debug_symfile_get_line_numbers_full () to mono_debug_symfile_ge...
authorZoltan Varga <vargaz@gmail.com>
Sun, 10 May 2015 06:23:03 +0000 (02:23 -0400)
committerZoltan Varga <vargaz@gmail.com>
Sun, 10 May 2015 06:23:11 +0000 (02:23 -0400)
mono/metadata/debug-mono-symfile.c
mono/metadata/debug-mono-symfile.h
mono/mini/debugger-agent.c
mono/mini/dwarfwriter.c
mono/mini/method-to-ir.c
mono/mini/mini-llvm.c

index 5b42fb0ad092f5e76f093a990aff54206a81ceda..0378dfe5b1db22b4929dc6a577ba99b70737ca8a 100644 (file)
@@ -501,43 +501,35 @@ method_get_lnt_flags (MonoDebugMethodInfo *minfo)
 }
 
 /*
- * mono_debug_symfile_get_line_numbers_full:
+ * mono_debug_symfile_get_seq_points:
  *
  * On return, SOURCE_FILE_LIST will point to a GPtrArray of MonoDebugSourceFile
  * structures, and SOURCE_FILES will contain indexes into this array.
  * 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 **column_numbers, int **source_files, int **end_line_numbers, int **end_column_numbers)
+mono_debug_symfile_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points)
 {
        // FIXME: Unify this with mono_debug_symfile_lookup_location
        MonoSymbolFile *symfile;
        const unsigned char *ptr;
        StatementMachine stm;
-       uint32_t i, j;
+       uint32_t i, j, n;
        LineNumberTableFlags flags;
        GPtrArray *il_offset_array, *line_number_array, *source_file_array, *hidden_array;
        gboolean has_column_info, has_end_info;
-       gboolean column_info_read = FALSE;
+       MonoSymSeqPoint *sps;
 
        if (source_file_list)
                *source_file_list = NULL;
-       if (n_il_offsets)
-               *n_il_offsets = 0;
-       if (il_offsets)
-               *il_offsets = NULL;
+       if (seq_points)
+               *seq_points = NULL;
+       if (n_seq_points)
+               *n_seq_points = 0;
        if (source_files)
                *source_files = NULL;
        if (source_file)
                *source_file = NULL;
-       if (line_numbers)
-               *line_numbers = NULL;
-       if (column_numbers)
-               *column_numbers = NULL;
-       if (end_line_numbers)
-               *end_line_numbers = NULL;
-       if (end_column_numbers)
-               *end_column_numbers = NULL;
 
        if ((symfile = minfo->handle->symfile) == NULL)
                return;
@@ -663,63 +655,61 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
                }
        }                               
 
-       if (n_il_offsets) {
-               *n_il_offsets = il_offset_array->len;
+       if (n_seq_points) {
+               g_assert (seq_points);
+
+               n = il_offset_array->len;
                for (i = 0; i < il_offset_array->len; i++) {
                        if (GPOINTER_TO_UINT (g_ptr_array_index (hidden_array, i))) {
-                               (*n_il_offsets)--;
-                       }
-               }
-       }
-       if (il_offsets && line_numbers) {
-               *il_offsets = g_malloc (*n_il_offsets * sizeof (int));
-               *line_numbers = g_malloc (*n_il_offsets * sizeof (int));
-               j = 0;
-               for (i = 0; i < il_offset_array->len; ++i) {
-                       if (!GPOINTER_TO_UINT (g_ptr_array_index (hidden_array, i))) {
-                               (*il_offsets)[j] = GPOINTER_TO_UINT (g_ptr_array_index (il_offset_array, i));
-                               (*line_numbers)[j] = GPOINTER_TO_UINT (g_ptr_array_index (line_number_array, i));
-                               j++;
+                               n --;
                        }
                }
-       }
 
-       if (column_numbers && has_column_info) {
-               column_info_read = TRUE;
-               *column_numbers = g_malloc (*n_il_offsets * sizeof (int));
+               *n_seq_points = n;
+               *seq_points = sps = g_new0 (MonoSymSeqPoint, n);
                j = 0;
                for (i = 0; i < il_offset_array->len; ++i) {
-                       int column = read_leb128 (ptr, &ptr);
+                       MonoSymSeqPoint *sp = &(sps [j]);
                        if (!GPOINTER_TO_UINT (g_ptr_array_index (hidden_array, i))) {
-                               (*column_numbers) [j] = column;
-                               j++;
+                               sp->il_offset = GPOINTER_TO_UINT (g_ptr_array_index (il_offset_array, i));
+                               sp->line = GPOINTER_TO_UINT (g_ptr_array_index (line_number_array, i));
+                               sp->column = -1;
+                               sp->end_line = -1;
+                               sp->end_column = -1;
+                               j ++;
                        }
                }
-       }
 
-       if (has_end_info && end_line_numbers) {
-               g_assert (end_column_numbers);
-               *end_line_numbers = g_malloc (*n_il_offsets * sizeof (int));
-               *end_column_numbers = g_malloc (*n_il_offsets * sizeof (int));
-               if (has_column_info && !column_info_read) {
-                       for (i = 0; i < il_offset_array->len; ++i)
-                               read_leb128 (ptr, &ptr);
-               }
-               j = 0;
-               for (i = 0; i < il_offset_array->len; ++i) {
-                       int end_row, end_column = -1;
-
-                       end_row = read_leb128 (ptr, &ptr);
-                       if (end_row != 0xffffff) {
-                               end_row += GPOINTER_TO_UINT (g_ptr_array_index (line_number_array, i));
-                               end_column = read_leb128 (ptr, &ptr);
+               if (has_column_info) {
+                       j = 0;
+                       for (i = 0; i < il_offset_array->len; ++i) {
+                               MonoSymSeqPoint *sp = &(sps [j]);
+                               int column = read_leb128 (ptr, &ptr);
                                if (!GPOINTER_TO_UINT (g_ptr_array_index (hidden_array, i))) {
-                                       (*end_line_numbers)[j] = end_row;
-                                       (*end_column_numbers)[j] = end_column;
+                                       sp->column = column;
                                        j++;
                                }
                        }
                }
+
+               if (has_end_info) {
+                       j = 0;
+                       for (i = 0; i < il_offset_array->len; ++i) {
+                               MonoSymSeqPoint *sp = &(sps [j]);
+                               int end_row, end_column = -1;
+
+                               end_row = read_leb128 (ptr, &ptr);
+                               if (end_row != 0xffffff) {
+                                       end_row += GPOINTER_TO_UINT (g_ptr_array_index (line_number_array, i));
+                                       end_column = read_leb128 (ptr, &ptr);
+                                       if (!GPOINTER_TO_UINT (g_ptr_array_index (hidden_array, i))) {
+                                               sp->end_line = end_row;
+                                               sp->end_column = end_column;
+                                               j++;
+                                       }
+                               }
+                       }
+               }
        }
 
        g_ptr_array_free (il_offset_array, TRUE);
@@ -730,17 +720,6 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
        return;
 }
 
-/*
- * mono_debug_symfile_get_line_numbers:
- *
- *   All the output parameters can be NULL.
- */ 
-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, NULL, NULL, NULL);
-}
-
 static int
 compare_method (const void *key, const void *object)
 {
index 2eb42c0bcf8d4ecd33169bc2c8e4d57195c7b17c..c9f04d73ed82e2aeecd30a6a23959a1fb12f9ef2 100644 (file)
@@ -116,6 +116,12 @@ typedef struct {
        guint8 *guid, *hash;
 } MonoDebugSourceInfo;
 
+typedef struct {
+       int il_offset;
+       int line, column;
+       int end_line, end_column;
+} MonoSymSeqPoint;
+
 #define MONO_SYMBOL_FILE_MAJOR_VERSION         50
 #define MONO_SYMBOL_FILE_MINOR_VERSION         0
 #define MONO_SYMBOL_FILE_MAGIC                 0x45e82623fd7fa614ULL
@@ -151,11 +157,8 @@ mono_debug_symfile_lookup_locals (MonoDebugMethodInfo *minfo);
 MONO_API void
 mono_debug_symfile_free_locals (MonoDebugLocalsInfo *info);
 
-MONO_API void
-mono_debug_symfile_get_line_numbers (MonoDebugMethodInfo *minfo, char **source_file, int *n_il_offsets, int **il_offsets, int **line_numbers);
-
-MONO_API 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 **column_numbers, int **source_files, int **end_line_numbers, int **end_column_numbers);
+void
+mono_debug_symfile_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points);
 
 gboolean
 mono_debug_image_has_debug_info (MonoImage *image);
index 46c31fa8169d4d3b0c45f1d103af6352ed042fa4..c23b2ccf783da6eed1659c53f8c9eec4677b4b69 100644 (file)
@@ -3453,7 +3453,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, NULL, NULL, NULL);
+                                                       mono_debug_symfile_get_seq_points (minfo, &source_file, &source_file_list, NULL, NULL, NULL);
                                                        for (i = 0; i < source_file_list->len; ++i) {
                                                                sinfo = g_ptr_array_index (source_file_list, i);
                                                                /*
@@ -6822,7 +6822,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, NULL, NULL, NULL);
+                       mono_debug_symfile_get_seq_points (minfo, NULL, &source_file_list, 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)
@@ -8318,13 +8318,9 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                MonoDebugMethodInfo *minfo;
                char *source_file;
                int i, j, n_il_offsets;
-               int *il_offsets;
-               int *line_numbers;
-               int *column_numbers;
-               int *end_line_numbers;
-               int *end_column_numbers;
                int *source_files;
                GPtrArray *source_file_list;
+               MonoSymSeqPoint *sym_seq_points;
 
                header = mono_method_get_header (method);
                if (!header) {
@@ -8343,7 +8339,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, &column_numbers, &source_files, &end_line_numbers, &end_column_numbers);
+               mono_debug_symfile_get_seq_points (minfo, &source_file, &source_file_list, &source_files, &sym_seq_points, &n_il_offsets);
                buffer_add_int (buf, header->code_size);
                if (CHECK_PROTOCOL_VERSION (2, 13)) {
                        buffer_add_int (buf, source_file_list->len);
@@ -8361,31 +8357,28 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                buffer_add_int (buf, n_il_offsets);
                DEBUG_PRINTF (10, "Line number table for method %s:\n", mono_method_full_name (method,  TRUE));
                for (i = 0; i < n_il_offsets; ++i) {
+                       MonoSymSeqPoint *sp = &sym_seq_points [i];
                        const char *srcfile = "";
 
                        if (source_files [i] != -1) {
                                MonoDebugSourceInfo *sinfo = g_ptr_array_index (source_file_list, source_files [i]);
                                srcfile = sinfo->source_file;
                        }
-                       DEBUG_PRINTF (10, "IL%x -> %s:%d %d %d %d\n", il_offsets [i], srcfile, line_numbers [i], column_numbers ? column_numbers [i] : -1, end_line_numbers ? end_line_numbers [i] : -1, end_column_numbers ? end_column_numbers [i] : -1);
-                       buffer_add_int (buf, il_offsets [i]);
-                       buffer_add_int (buf, line_numbers [i]);
+                       DEBUG_PRINTF (10, "IL%x -> %s:%d %d %d %d\n", sp->il_offset, srcfile, sp->line, sp->column, sp->end_line, sp->end_column);
+                       buffer_add_int (buf, sp->il_offset);
+                       buffer_add_int (buf, sp->line);
                        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);
+                               buffer_add_int (buf, sp->column);
                        if (CHECK_PROTOCOL_VERSION (2, 32)) {
-                               buffer_add_int (buf, end_line_numbers ? end_line_numbers [i] : -1);
-                               buffer_add_int (buf, end_column_numbers ? end_column_numbers [i] : -1);
+                               buffer_add_int (buf, sp->end_line);
+                               buffer_add_int (buf, sp->end_column);
                        }
                }
                g_free (source_file);
-               g_free (il_offsets);
-               g_free (line_numbers);
-               g_free (column_numbers);
-               g_free (end_line_numbers);
-               g_free (end_column_numbers);
                g_free (source_files);
+               g_free (sym_seq_points);
                g_ptr_array_free (source_file_list, TRUE);
                mono_metadata_free_mh (header);
                break;
index 2a6a56964b2cba43f60c74bc3cb37b705ee9a3a9..38c96b32c0d2ab54107d2e5b37c31f8cd3a74dce 100644 (file)
@@ -709,7 +709,6 @@ emit_all_line_number_info (MonoDwarfWriter *w)
        for (l = info_list; l; l = l->next) {
                MethodLineNumberInfo *info = l->data;
                MonoDebugMethodInfo *minfo;
-               char *source_file;
                GPtrArray *source_file_list;
 
                // FIXME: Free stuff
@@ -717,7 +716,7 @@ emit_all_line_number_info (MonoDwarfWriter *w)
                if (!minfo)
                        continue;
 
-               mono_debug_symfile_get_line_numbers_full (minfo, &source_file, &source_file_list, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+               mono_debug_symfile_get_seq_points (minfo, NULL, &source_file_list, NULL, NULL, NULL);
                for (i = 0; i < source_file_list->len; ++i) {
                        MonoDebugSourceInfo *sinfo = g_ptr_array_index (source_file_list, i);
                        add_line_number_file_name (w, sinfo->source_file, 0, 0);
index 14701ee98b5bf8f30a096306fd521c018aca95e1..ffe3219c935cbc8e12e898706b3e7b0efdb0e1c7 100644 (file)
@@ -7732,20 +7732,18 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
        if (cfg->gen_sdb_seq_points && cfg->method == method) {
                minfo = mono_debug_lookup_method (method);
                if (minfo) {
+                       MonoSymSeqPoint *sps;
                        int i, n_il_offsets;
-                       int *il_offsets;
-                       int *line_numbers;
 
-                       mono_debug_symfile_get_line_numbers_full (minfo, NULL, NULL, &n_il_offsets, &il_offsets, &line_numbers, NULL, NULL, NULL, NULL);
+                       mono_debug_symfile_get_seq_points (minfo, NULL, NULL, NULL, &sps, &n_il_offsets);
                        seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (cfg->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0);
                        seq_point_set_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) {
-                               if (il_offsets [i] < header->code_size)
-                                       mono_bitset_set_fast (seq_point_locs, il_offsets [i]);
+                               if (sps [i].il_offset < header->code_size)
+                                       mono_bitset_set_fast (seq_point_locs, sps [i].il_offset);
                        }
-                       g_free (il_offsets);
-                       g_free (line_numbers);
+                       g_free (sps);
                } else if (!method->wrapper_type && !method->dynamic && mono_debug_image_has_debug_info (method->klass->image)) {
                        /* Methods without line number info like auto-generated property accessors */
                        seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (cfg->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0);
index a436f52d410208cce21656a1aeb204adb6e6369f..d3baa203e55f29656aa9a0cc12e2eca3b669fdb6 100644 (file)
@@ -6086,14 +6086,13 @@ emit_dbg_subprogram (EmitContext *ctx, MonoCompile *cfg, LLVMValueRef method, co
        MonoDebugMethodInfo *minfo = ctx->minfo;
        char *source_file, *dir, *filename;
        LLVMValueRef md, args [16], ctx_args [16], md_args [64], type_args [16], ctx_md, type_md;
-       int n_il_offsets;
-       int *il_offsets;
-       int *line_numbers;
+       MonoSymSeqPoint *sym_seq_points;
+       int n_seq_points;
 
        if (!minfo)
                return NULL;
 
-       mono_debug_symfile_get_line_numbers_full (minfo, &source_file, NULL, &n_il_offsets, &il_offsets, &line_numbers, NULL, NULL, NULL, NULL);
+       mono_debug_symfile_get_seq_points (minfo, &source_file, NULL, NULL, &sym_seq_points, &n_seq_points);
        if (!source_file)
                source_file = g_strdup ("<unknown>");
        dir = g_path_get_dirname (source_file);
@@ -6133,8 +6132,8 @@ emit_dbg_subprogram (EmitContext *ctx, MonoCompile *cfg, LLVMValueRef method, co
        md_args [4] = md_string (name);
        md_args [5] = md_string (name);
        /* Line number */
-       if (n_il_offsets)
-               md_args [6] = LLVMConstInt (LLVMInt32Type (), line_numbers [0], FALSE);
+       if (n_seq_points)
+               md_args [6] = LLVMConstInt (LLVMInt32Type (), sym_seq_points [0].line, FALSE);
        else
                md_args [6] = LLVMConstInt (LLVMInt32Type (), 1, FALSE);
        /* Type */
@@ -6171,8 +6170,7 @@ emit_dbg_subprogram (EmitContext *ctx, MonoCompile *cfg, LLVMValueRef method, co
        g_free (dir);
        g_free (filename);
        g_free (source_file);
-       g_free (il_offsets);
-       g_free (line_numbers);
+       g_free (sym_seq_points);
 
        return md;
 }