Skip to content

To do list #1

Description

@robinmoussu

Goal

Given the following rust code:

fn main() {
    let fct = get_fct();
    let fct = forward_fct(fct);
    fct();
}

fn foo() {
    bar()
}

fn bar() {
}

fn get_fct() -> impl Fn() {
    foo
}

fn forward_fct<Fct: Fn()>(fct: Fct) -> Fct {
    fct
}

Currently, this is what is being generated

current status


  • extracting all function information (ie, their name, arguments, types of arguments and return type) for the function that exists in the current crate
  • [ ] extract information about function not leaving in the current-crate
  • extract internal dependencies (dependencies between the arguments, return type, and the function call)
  • writing the graphviz generator (i.e. converting the internal representation to text)
  • use impl Trait instead of the concrete types
    • in arguments
    • in return types
    • in the dependent types of the struct being implemented
  • call it with cargo (as a drop-in replacement of rustdoc) to run it on a whole project

  • track indirect dependencies thought Fn/FnMut/FnOnce traits
  • group functions by modules
  • add link to documentation (ie, create clickable links to the output of rustdoc)

  • How do I create a Bar from a Foo? → highlight the callgraph
  • create a command line tool to answer "what are the caller of foo(), including through function pointers and traits"
  • add a big "you are here" in the svg
  • select which functions/crates should be extracted

General algorithm

This is what I am planning to do. This may change in the future if my understanding of the problem space changes.

First, for each functions (and function-like object like closure), locate all function call. Then for each arguments of the called function track if they come from the argument or the function being analyzed, a constant, or from the return value of another function called in the analyzed function. Multiple source are possible, and the control flow is ignored. Once done for all functions, we can walk back to the source of all arguments, and all indirect calls.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions