Skip to content

Allow addition/change of fields after creation of debug info #1349

@varun-r-mallya

Description

@varun-r-mallya

Feature request

When we generate debug info for a module using .add_debug_info, updating it later, for example, to add a scope field to a DILocalVariable that was initially created with partial data, isn’t straightforward. The current workaround involves manually fetching the underlying tuple for that field, modifying it, and replacing it. It would be much cleaner if native functions existed to update such fields directly.

For example:

# Current workaround
var = module.add_debug_info("DILocalVariable", {
    "name": "ctx",
    "arg": 1,
    "file": module._file_metadata,
    "type": some_type
})

# Later we realize we need to add a scope
existing_operands = list(var.operands)
existing_operands.append(("scope", scope_value))
var.operands = tuple(existing_operands)

Ideally, this could instead be done through a helper like:

var.add_debug_info_field("scope", scope_value)

This would make the API safer and more maintainable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions