Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to start debugger on a specific line? #120

Open
max-arnold opened this issue Dec 5, 2023 · 2 comments
Open

Is it possible to start debugger on a specific line? #120

max-arnold opened this issue Dec 5, 2023 · 2 comments

Comments

@max-arnold
Copy link

max-arnold commented Dec 5, 2023

Trying it like this:

PYTHONHUNTER='Q(kind="line",lineno=253,module_in=["mymodule"],action=Debugger())'

But the debugger starts not at the specified line (which is a variable assignment), but below it in the next function call.

Is that expected?

@ionelmc
Copy link
Owner

ionelmc commented Dec 6, 2023

Yes, it is, because tracing in general is post-facto, the action will be called after the code being traced has been executed.

Is there a specific problem you're trying to solve there? Seems like you could give more context...

@max-arnold
Copy link
Author

I'm trying to invoke pdb (for step-by step debugging and altering some variables) at specific line without editing the source code. The code fragment looks like this:

   def __init__(...
    ):
        """
        A docstring
        """

        self.parent_loader = None   #### TARGET LINE (253) ####
        self.inject_globals = {}
        self.pack = {} if pack is None else pack
        for i in self.pack:
            if isinstance(self.pack[i], salt.loader.context.NamedLoaderContext):
                self.pack[i] = self.pack[i].value()
        if opts is None:
            opts = {}
        opts = copy.deepcopy(opts)

But the debugger gets invoked in stdlib inside of the next (nearest) call:

-> def deepcopy(x, memo=None, _nil=[]):
(Pdb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants