| ... | @@ -2465,18 +2465,52 @@ pub const Object = struct { | ... | @@ -2465,18 +2465,52 @@ pub const Object = struct { |
| 2465 | try o.builder.metadataString(decl_name), | 2465 | try o.builder.metadataString(decl_name), |
| 2466 | try o.getDebugFile(namespace.fileScope(zcu)), | 2466 | try o.getDebugFile(namespace.fileScope(zcu)), |
| 2467 | fwd_ref, | 2467 | fwd_ref, |
| 2468 | 0, | 2468 | 0, // Line |
| 2469 | try o.lowerDebugType(nested_type, false), | 2469 | try o.lowerDebugType(nested_type, false), |
| 2470 | 0, // Align | 2470 | 0, // Align |
| 2471 | )); | 2471 | )); |
| 2472 | } else if (decl.val.getVariable(zcu)) |v| { | 2472 | } else if (decl.val.getVariable(zcu)) |v| { |
| 2473 | fields.appendAssumeCapacity(try o.builder.debugStaticMemberType( | 2473 | // Imitate a C++ static member variable since neither |
| 2474 | try o.builder.metadataString(decl_name), | 2474 | // GDB or LLDB can really cope with regular variables |
| 2475 | try o.getDebugFile(namespace.fileScope(zcu)), | 2475 | // directly inside a struct type. |
| | 2476 | |
| | 2477 | const vglobal = (o.decl_map.get(decl_id) orelse continue).ptr(&o.builder); |
| | 2478 | |
| | 2479 | const linkage_name = try o.builder.metadataStringFromStrtabString(vglobal.kind.variable.name(&o.builder)); |
| | 2480 | const var_name = try o.builder.metadataString(decl.name.toSlice(ip)); |
| | 2481 | const var_type = try o.lowerDebugType(Type.fromInterned(v.ty), false); |
| | 2482 | const debug_file = try o.getDebugFile(namespace.fileScope(zcu)); |
| | 2483 | const debug_line = decl.navSrcLine(zcu) + 1; |
| | 2484 | |
| | 2485 | const static_member = try o.builder.debugStaticMemberType( |
| | 2486 | var_name, |
| | 2487 | debug_file, |
| 2476 | fwd_ref, | 2488 | fwd_ref, |
| 2477 | 0, | 2489 | debug_line, |
| 2478 | try o.lowerDebugType(Type.fromInterned(v.ty), false), | 2490 | var_type, |
| 2479 | )); | 2491 | ); |
| | 2492 | fields.appendAssumeCapacity(static_member); |
| | 2493 | |
| | 2494 | const debug_global_var = try o.builder.debugGlobalVar( |
| | 2495 | var_name, |
| | 2496 | linkage_name, |
| | 2497 | debug_file, |
| | 2498 | debug_file, |
| | 2499 | debug_line, |
| | 2500 | var_type, |
| | 2501 | vglobal.kind.variable, |
| | 2502 | static_member, |
| | 2503 | .internal, |
| | 2504 | ); |
| | 2505 | |
| | 2506 | const debug_expression = try o.builder.debugExpression(&.{}); |
| | 2507 | |
| | 2508 | const resolved_var = try o.builder.debugGlobalVarExpression( |
| | 2509 | debug_global_var, |
| | 2510 | debug_expression, |
| | 2511 | ); |
| | 2512 | vglobal.dbg = resolved_var; |
| | 2513 | try o.debug_globals.append(o.gpa, resolved_var); |
| 2480 | } | 2514 | } |
| 2481 | } | 2515 | } |
| 2482 | } | 2516 | } |
| ... | @@ -4742,58 +4776,34 @@ pub const DeclGen = struct { | ... | @@ -4742,58 +4776,34 @@ pub const DeclGen = struct { |
| 4742 | | 4776 | |
| 4743 | if (!owner_mod.strip) { | 4777 | if (!owner_mod.strip) { |
| 4744 | const debug_file = try o.getDebugFile(file_scope); | 4778 | const debug_file = try o.getDebugFile(file_scope); |
| 4745 | const debug_scope = try o.namespaceToDebugScope(decl.src_namespace); | | |
| 4746 | | 4779 | |
| 4747 | const linkage_name = try o.builder.metadataStringFromStrtabString(variable_index.name(&o.builder)); | 4780 | const linkage_name = try o.builder.metadataStringFromStrtabString(variable_index.name(&o.builder)); |
| 4748 | | 4781 | |
| 4749 | const debug_global_var = if (!decl.isExtern(zcu)) blk: { | 4782 | if (!decl.isExtern(zcu)) { |
| 4750 | // Imitate a C++ static member variable since neither | 4783 | // Make it a static member variable, which is resolved later in genNamespaces. |
| 4751 | // GDB or LLDB can really cope with regular variables | 4784 | _ = try o.namespaceToDebugScope(decl.src_namespace); |
| 4752 | // directly inside a struct type. | 4785 | } else { |
| 4753 | const ty = try o.lowerDebugType(decl.typeOf(zcu), true); | 4786 | const debug_global_var = try o.builder.debugGlobalVar( |
| 4754 | const name = try o.builder.metadataString(decl.name.toSlice(ip)); | 4787 | linkage_name, |
| 4755 | | | |
| 4756 | const variable = try o.builder.debugGlobalVar( | | |
| 4757 | name, | | |
| 4758 | linkage_name, | 4788 | linkage_name, |
| 4759 | debug_file, | 4789 | debug_file, |
| 4760 | debug_file, | 4790 | debug_file, |
| 4761 | line_number, | 4791 | line_number, |
| 4762 | ty, | 4792 | try o.lowerDebugType(decl.typeOf(zcu), true), |
| 4763 | variable_index, | 4793 | variable_index, |
| 4764 | .none, | 4794 | .none, |
| 4765 | .external, | 4795 | .external, |
| 4766 | ); | 4796 | ); |
| | 4797 | const debug_expression = try o.builder.debugExpression(&.{}); |
| 4767 | | 4798 | |
| 4768 | try o.debug_imports.append(o.gpa, try o.builder.debugImportDeclaration( | 4799 | const debug_global_var_expression = try o.builder.debugGlobalVarExpression( |
| 4769 | name, | 4800 | debug_global_var, |
| 4770 | debug_file, | 4801 | debug_expression, |
| 4771 | debug_scope, | 4802 | ); |
| 4772 | line_number, | | |
| 4773 | variable, | | |
| 4774 | )); | | |
| 4775 | | | |
| 4776 | break :blk variable; | | |
| 4777 | } else try o.builder.debugGlobalVar( | | |
| 4778 | linkage_name, | | |
| 4779 | linkage_name, | | |
| 4780 | debug_file, | | |
| 4781 | debug_file, | | |
| 4782 | line_number, | | |
| 4783 | try o.lowerDebugType(decl.typeOf(zcu), true), | | |
| 4784 | variable_index, | | |
| 4785 | .none, | | |
| 4786 | .external, | | |
| 4787 | ); | | |
| 4788 | const debug_expression = try o.builder.debugExpression(&.{}); | | |
| 4789 | | | |
| 4790 | const debug_global_var_expression = try o.builder.debugGlobalVarExpression( | | |
| 4791 | debug_global_var, | | |
| 4792 | debug_expression, | | |
| 4793 | ); | | |
| 4794 | | 4803 | |
| 4795 | variable_index.setGlobalVariableExpression(debug_global_var_expression, &o.builder); | 4804 | variable_index.setGlobalVariableExpression(debug_global_var_expression, &o.builder); |
| 4796 | try o.debug_globals.append(o.gpa, debug_global_var_expression); | 4805 | try o.debug_globals.append(o.gpa, debug_global_var_expression); |
| | 4806 | } |
| 4797 | } | 4807 | } |
| 4798 | } | 4808 | } |
| 4799 | | 4809 | |