japaric / cargo-call-stack

Whole program static stack analysis
Apache License 2.0
579 stars 52 forks source link

JSON output + accompanying library #44

Open japaric opened 3 years ago

japaric commented 3 years ago

Being able to output JSON, instead of a .dot file, has a few uses:

we can probably just serialize a petgraph data structure into JSON to begin with. the node "weight" struct should contain at least this information:

struct Node {
   cumulative_stack_usage: Option<u64>,
   kind: NodeKind,
   local_stack_usage: Option<u64>,
   unmangled_name: String,
}

enum NodeKind {
    // matches to a symbol / routine in machine code
    Concrete,

    // "fictious" node that represents trait object dynamic dispatch
    DynamicDispatch { signature: String },

    // "fictious" node that represents function pointer calls
    FunctionPointer { signature: String },
}