Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check if a constant value flows into a variable using source-sink checker? #1581

Open
DesNevermore opened this issue Oct 28, 2024 · 3 comments

Comments

@DesNevermore
Copy link

DesNevermore commented Oct 28, 2024

I created a class inherited from the class SrcSnkDDA and override the initSrcs() method by looking for the store statements and checking if the source node of the store statement is a constant or not as follows.

    for (auto pair: pag->getIcfgNode2SVFStmtsMap()) {
        for (auto* stmt: pair.second) {
            if (auto* storeStmt = SVFUtil::dyn_cast<StoreStmt>(stmt)) {
                auto* value = storeStmt->getRHSVar()->getValue();
                if (SVFUtil::isa<SVFConstantInt>(value)) {
                    auto* svfgNode1 = svfg->getDefSVFGNode(storeStmt->getRHSVar()); // No svfgNode.
                    auto* svfgNode2 = svfg->getStmtVFGNode(storeStmt); // No svfgNode.
                    if (svfgNode1 != nullptr) {
                        addToSources(svfgNode1);
                    }
                }
            }
        }
    }

But it turned out that the svfg nodes of both the constant variable (storeStmt->getRHSVar()) and the store statement cannot be found.
image

image

Is it normal that constant variables and their store statements have no corresponding svfg nodes? How to use the SrcSnkDDA checker to check if a constant value flows into a specific variable?

Thanks for answering.

@yuleisui
Copy link
Collaborator

Have you tried buildFullSVFG?

@DesNevermore
Copy link
Author

Have you tried buildFullSVFG?

Yes, I follow the example in svf-ex.cpp:

    svfgBuilder = new SVFGBuilder();
    svfg = svfgBuilder->buildFullSVFG(ander);

@DesNevermore
Copy link
Author

Have you tried buildFullSVFG?

Sorry, I just realized that SrcSnkDDA initialized another svfg which is ptr only by default. Now these two svfg nodes exist. Thanks for answering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants