Git Product home page Git Product logo

in-struct-me's Introduction

In-Struct-Me

Introduction

This tool recursively searches for C structs in a user-chosen folder. It then creates a Graphviz dot file, which, in turn, generates an image showing how different C structs are interlinked.

This script can be helpful when trying to learn a new codebase, as often just looking at the structs can provide a good understanding of what the code is trying to accomplish.

Note: Currently, it only searches for "struct", therefore typedef'd structs won't be found.

Installation

Requirements that needs to be installed (apt, dnf, ...)

graphviz
python3
build-essential
  1. Clone the code:

    [email protected]:jbech-linaro/in-struct-me.git

Usage

Once installed, here's how you can use In-Struct-Me:

  1. Generate the dot file and PNG for the example code.

    make
  2. Same as "1", but make it verbose.

    make V=1
  3. Same as "1", but grep for "foo".

    make G=foo
  4. Scan another folder (can be combined with parameter as already shown)

    make F=~/linux_kernel/drivers/tee

    or to scan multiple folders

    make F="~/linux_kernel/drivers/tee ~/another/folder"
  5. Use another Graphviz tool (neato, circo, twopi, fdp) instead of the default dot.

    make T=circo
  6. Use another ignore file than the default

    make I=another-ignore-file.txt
  7. Generate a PNG with a user specified name

    make O=another-name.png

Configuration

If you encounter many nodes that aren't of interest, you can add text to the ignore.txt file. Everything added there will be removed from the generated graph and image.

Examples

Here are some examples to help you get started:

  • Structure relations in the Linux kernel OP-TEE folder

    make F=~/devel/linux/drivers/tee/optee
    images/example1.png
  • Same as above, but grep for shm

    make F=~/devel/linux/drivers/tee/optee G=shm
    images/example2.png
  • Same as above, but also show verbose

    make F=~/devel/linux/drivers/tee/optee G=shm V=1
    images/example3.png

FAQ

  1. Why are some nodes squares and others circles?

    Squares represent structs with complete definitions under the specified path. These structs may contain other structs not found under the path. Represented as circles, a link is created due to a lack of information about their definitions.

  2. Why does grep sometimes find things that I cannot see?

    This occurs when not using the verbose option. However, the script recognizes that this struct includes a variable matching your grep criteria, hence it is displayed.

  3. Things seems to crash?

    Most likely you have chosen a folder that contains too much data. Try to limit the amount of c and h files exposed to the script.

  4. Things are missing in the image?

    The ignore.txt in this git contains a few words already. See if what you are looking for is in that file. If it is, just remove it and save the file and re-run the script.

in-struct-me's People

Contributors

jbech-linaro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.