Question

I am new to stackoverflow, but I got a lot of help until now, thanks to the community for that.

I'm trying to create a software showing me caller depandencys for legacycode.

I'parsing a directory with c code with pycparcer, and for each file i want to create a subgraph with pydot.

Two questions:

  1. When parsing a c file, the parser references the #includes, an i get also functions in my AST, from the included files. How can i know, if the function is included, or originaly from this actual file/ or ignore the #includes??

  2. For each file i want to create a subgraph, an then add all functions in this file to this subgraph. I don't know how many subgraphs i have to create...

I have a set of files, where each file is a frozenset with the functions of this file somthing like this is pssible?

    for files in SetOfFiles:
        #how to create subgraph with name of files?

        for function in files:
            self.graph.add_node(pydot.Node(funktion))  #--> add node to subgraph "files"

I hope you got my challange... any ideas?

Thanks!

EDIT:

I solved the question about pydot, it was quiet easy... So I stay with my pycparser problem :(

    for files in ListOfFuncs:
        cluster_x = pydot.Cluster(files, label=files)

        for functions in files:
            cluster_x.add_node(pydot.Node(functions))

        graph.add_subgraph(cluster_x)          

No correct solution

OTHER TIPS

I can address the pycparser part. The preprocessor leaves #line directives that specify which file & line code came for, and pycparser consumes those. You can get that information from the AST it creates (see tests for an example).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top