@@ -222,15 +222,44 @@ def add_scope_to_local_variable(self, local_variable_debug_info, scope_value):
222222 """
223223 Add scope information to an existing local variable debug info object.
224224 """
225- #TODO: this is a workaround a flaw in the debug info generation. Fix this if possible in the future.
225+ # TODO: this is a workaround a flaw in the debug info generation. Fix this if possible in the future.
226226 # We should not be touching llvmlite's internals like this.
227- if hasattr (local_variable_debug_info , ' operands' ):
227+ if hasattr (local_variable_debug_info , " operands" ):
228228 # LLVM metadata operands is a tuple, so we need to rebuild it
229229 existing_operands = local_variable_debug_info .operands
230230
231231 # Convert tuple to list, add scope, convert back to tuple
232232 operands_list = list (existing_operands )
233- operands_list .append ((' scope' , scope_value ))
233+ operands_list .append ((" scope" , scope_value ))
234234
235235 # Reassign the new tuple
236- local_variable_debug_info .operands = tuple (operands_list )
236+ local_variable_debug_info .operands = tuple (operands_list )
237+
238+ def create_subprogram (
239+ self , name : str , subroutine_type : Any , retained_nodes : List [Any ]
240+ ) -> Any :
241+ """
242+ Create a DISubprogram for a function.
243+
244+ Args:
245+ name: Function name
246+ subroutine_type: DISubroutineType for the function signature
247+ retained_nodes: List of DILocalVariable nodes for function parameters/variables
248+
249+ Returns:
250+ DISubprogram metadata
251+ """
252+ return self .module .add_debug_info (
253+ "DISubprogram" ,
254+ {
255+ "name" : name ,
256+ "scope" : self .module ._file_metadata ,
257+ "file" : self .module ._file_metadata ,
258+ "type" : subroutine_type ,
259+ # "flags": dc.DW_FLAG_Prototyped | dc.DW_FLAG_AllCallsDescribed,
260+ # "spFlags": dc.DW_SPFLAG_Definition | dc.DW_SPFLAG_Optimized,
261+ "unit" : self .module ._debug_compile_unit ,
262+ "retainedNodes" : retained_nodes ,
263+ },
264+ is_distinct = True ,
265+ )
0 commit comments