sola-st / DynaPyt

Dynamic analysis framework for Python
MIT License
49 stars 13 forks source link

No instrumentation for context managers and decorators #34

Open nimamg opened 1 year ago

nimamg commented 1 year ago

DynaPyt does not attempt to instrument decorators and context manager usage (the "with" keyword). Is there a specific reason for that? Have you attempted to add them and faced any problems or challenges preventing it, or can they be added to the project? Thanks!

AryazE commented 1 year ago

We have not tried yet, mostly because of priority for other features. However, if you have a concrete analysis that needs them, let us know and we can try. For keeping a note, here are my ideas for how they might work:

khatchad commented 10 months ago
  • decorators: they should work with the current version as the function_enter and function_exit are instrumented. The only thing lacking is to know if a function is a decorator or not.

Couldn't you get that from the AST?

AryazE commented 8 months ago

Couldn't you get that from the AST?

Yes, we can. Now the question is should we have a separate hook for decorators, or have parameter in the hook that specifies if the function is a decorator?

AryazE commented 1 week ago

We now (e9c831a) can support with statements (context managers). It currently only supports one context manager in the statement (e.g. with open("foo.txt") as f: and not with open("foo.txt") as f, open("bar.txt") as b:), but we are working on extending it to multiple ones. Please let us know if this serves your purposes, and if there are any issues.