SMAT-Lab/Scalpel

Get all cfgs of a file?

Closed this issue · 5 comments

When calling cfg = CFGBuilder().build_from_file(name="test", filepath=path/to/file), the cfg for the corresponding file is created.
If the file contains a classes and methods, the cfg contains functioncfgs and class_cfgs. Does it makes sense to implement a method to get all cfgs of a file?

In my specific use case, I want to identify values of variables in the entire file. Hence, I always have to iterate through all functioncfgs and class_cfgs.

Jarvx commented

This is a new feature I am working on. Hopefully, I can make it available here in Sep. CFGs are stored in a nested way to represent their nested structure, I am working on flattening them so that we can jump from one to another one quickly.

Jarvx commented

But at the moment, you have to implement your own code to flatten them. This is a recursively way. Let me know if you need more information.

I've already implemented that for my use case. But I'm looking forward to your solution.

Jarvx commented

I've already implemented that for my use case. But I'm looking forward to your solution.

Thank you. I will put a note here after the API is implemented.

Jarvx commented

@simisimon This API has been implemented. By enabling the flattened keyword as True when building CFG, the generated CFGs will be like a k-v structure where k is the fully-qualified name.

I am curious about your implementation