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

Create Plugin for Single Source File Call Graph Construction #3

Open
abhisek opened this issue Jan 3, 2025 · 1 comment · May be fixed by #7
Open

Create Plugin for Single Source File Call Graph Construction #3

abhisek opened this issue Jan 3, 2025 · 1 comment · May be fixed by #7
Assignees

Comments

@abhisek
Copy link
Member

abhisek commented Jan 3, 2025

Problem

Call Graph building has the problem of call site resolution. For example:

def f1():
  f2()

def f2():
  pass

main():
  f1()

Here the call graph is simple to construct and looks like main -> f1 -> f2. But real world cases are more complex. Consider this:

import base64

class Encoding:
    def __init__(self):
        pass

    def apply(self, msg, func):
        return func(msg)

encoder = Encoding()

encoded = encoder.apply("Hello, World!".encode('utf-8') , base64.b64encode)
print(encoded)

decoded = encoder.apply(encoded, base64.b64decode)
print(decoded)

Ability to build a call graph here requires tracking the type of each variable during any function call invocation so that we can resolve the function target (call site). For example func in apply method above. Also OO programs has the added complexity of class and class hierarchy that need to be tracked. A good description of the problem is given in the following paper:

https://arxiv.org/abs/2103.00587

Requirements

We need the ability to build a call graph for Python language within a single source file including handling cases that require inter procedural analysis such as the example given above.

Limitations

  • Limit the call graph to a single source file only accepting the limitations of inter procedural analysis across source files
@abhisek
Copy link
Member Author

abhisek commented Jan 10, 2025

@OmkarPh Lets try to get the first draft version of the PR out so that we can iterate on the code.

@OmkarPh OmkarPh linked a pull request Jan 11, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants