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

Idea: a more powerful trace client #110

Open
vitrun opened this issue Sep 27, 2022 · 4 comments
Open

Idea: a more powerful trace client #110

vitrun opened this issue Sep 27, 2022 · 4 comments

Comments

@vitrun
Copy link

vitrun commented Sep 27, 2022

Current trace client is a simple wrapper of eval

eval('hunter.trace({})'.format(options))

It works for simple or medium complex situations, such as:

  • hunter-trace -p 34313 stdlib=False
  • hunter-trace -p 34313 "hunter.Q(lambda event: event.locals.get(\"msg\") == \"ha\")"

However, it comes short when import or customization is required before hunter.trace.

from hunter import trace, Q, Debugger
from pdb import Pdb

trace(
    Q(
        # show code that contains "mumbo.jumbo" on the current line
        lambda event: event.locals.get("mumbo") == "jumbo",
        # and it's not in Python's stdlib
        stdlib=False,
        # and it contains "mumbo" on the current line
        source__contains="mumbo",
        action=Debugger(klass=Pdb)
    )
)

With due consideration of safety, it should be allowed to eval a whole snippet of codes.

@ionelmc
Copy link
Owner

ionelmc commented Sep 27, 2022

Try hunter-trace -p 123123 'action=hunter.Debugger(klass=__import__("pdb").Pdb)'.

Note that Pdb won't work as you expect anyway (won't be attached to the terminal of hunter-trace - a different issue).

@vitrun
Copy link
Author

vitrun commented Sep 28, 2022

Wouldn't it be nice to support hunter-trace -p 123123 -f CUSTOM_FILTER_ACTION.py?

@vitrun
Copy link
Author

vitrun commented Sep 28, 2022

won't be attached to the terminal of hunter-trace - a different issue

Can we make it attached to hunter-trace, say, by using rpdb?

@ionelmc
Copy link
Owner

ionelmc commented Sep 29, 2022

It could be possible, both ideas. Just need time to implement.

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