@@ -5665,8 +5665,8 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
56655665 }
56665666 else if (jl_array_len (src->linetable ) > 0 ) {
56675667 jl_value_t *locinfo = jl_array_ptr_ref (src->linetable , 0 );
5668- ctx.file = jl_symbol_name ((jl_sym_t *)jl_fieldref_noalloc (locinfo, 1 ));
5669- toplineno = jl_unbox_long (jl_fieldref (locinfo, 2 ));
5668+ ctx.file = jl_symbol_name ((jl_sym_t *)jl_fieldref_noalloc (locinfo, 2 ));
5669+ toplineno = jl_unbox_long (jl_fieldref (locinfo, 3 ));
56705670 }
56715671 if (ctx.file .empty ())
56725672 ctx.file = " <missing>" ;
@@ -6284,40 +6284,44 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
62846284 ssize_t line;
62856285 bool is_user_code;
62866286 unsigned inlined_at;
6287+ bool operator ==(const DebugLineTable &other) const {
6288+ return other.loc == loc && other.file == file && other.line == line && other.is_user_code == is_user_code && other.inlined_at == inlined_at;
6289+ }
62876290 };
62886291 std::vector<DebugLineTable> linetable;
6289- {
6292+ { // populate the linetable data format
62906293 assert (jl_is_array (src->linetable ));
62916294 size_t nlocs = jl_array_len (src->linetable );
62926295 std::map<std::tuple<StringRef, StringRef>, DISubprogram*> subprograms;
62936296 linetable.resize (nlocs + 1 );
6297+ DebugLineTable &topinfo = linetable[0 ];
6298+ topinfo.file = ctx.file ;
6299+ topinfo.line = toplineno;
6300+ topinfo.is_user_code = mod_is_user_mod;
6301+ topinfo.inlined_at = 0 ;
6302+ topinfo.loc = topdebugloc;
62946303 for (size_t i = 0 ; i < nlocs; i++) {
62956304 // LineInfoNode(mod::Module, method::Any, file::Symbol, line::Int, inlined_at::Int)
62966305 jl_value_t *locinfo = jl_array_ptr_ref (src->linetable , i);
62976306 DebugLineTable &info = linetable[i + 1 ];
62986307 assert (jl_typeis (locinfo, jl_lineinfonode_type));
6299- jl_value_t *method = jl_fieldref_noalloc (locinfo, 0 );
6300- if (jl_is_method_instance (method))
6301- method = ((jl_method_instance_t *)method)->def .value ;
6302- jl_sym_t *filesym = (jl_sym_t *)jl_fieldref_noalloc (locinfo, 1 );
6303- info.line = jl_unbox_long (jl_fieldref (locinfo, 2 ));
6304- info.inlined_at = jl_unbox_long (jl_fieldref (locinfo, 3 ));
6308+ jl_module_t *module = (jl_module_t *)jl_fieldref_noalloc (locinfo, 0 );
6309+ jl_value_t *method = jl_fieldref_noalloc (locinfo, 1 );
6310+ jl_sym_t *filesym = (jl_sym_t *)jl_fieldref_noalloc (locinfo, 2 );
6311+ info.line = jl_unbox_long (jl_fieldref (locinfo, 3 ));
6312+ info.inlined_at = jl_unbox_long (jl_fieldref (locinfo, 4 ));
63056313 assert (info.inlined_at <= i);
6306- if (jl_is_method (method)) {
6307- jl_module_t *module = ((jl_method_t *)method)->module ;
6308- if (module == ctx.module )
6309- info.is_user_code = mod_is_user_mod;
6310- else
6311- info.is_user_code = in_user_mod (module );
6312- }
6313- else {
6314- info.is_user_code = (info.inlined_at == 0 ) ? mod_is_user_mod : linetable.at (info.inlined_at ).is_user_code ;
6315- }
6314+ if (module == ctx.module )
6315+ info.is_user_code = mod_is_user_mod;
6316+ else
6317+ info.is_user_code = in_user_mod (module );
63166318 info.file = jl_symbol_name (filesym);
63176319 if (info.file .empty ())
63186320 info.file = " <missing>" ;
63196321 if (ctx.debug_enabled ) {
63206322 StringRef fname;
6323+ if (jl_is_method_instance (method))
6324+ method = ((jl_method_instance_t *)method)->def .value ;
63216325 if (jl_is_method (method))
63226326 method = (jl_value_t *)((jl_method_t *)method)->name ;
63236327 if (jl_is_symbol (method))
0 commit comments