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

Collect Use-Def chain #1565

Open
bao00065 opened this issue Oct 9, 2024 · 0 comments
Open

Collect Use-Def chain #1565

bao00065 opened this issue Oct 9, 2024 · 0 comments

Comments

@bao00065
Copy link

bao00065 commented Oct 9, 2024

Hi,

I am trying to collect the use-def chain from a specific target point in the program, essentially performing backward slicing. After reviewing the example code (see https://github.com/SVF-tools/SVF-example), it appears that the traverseOnVFG function only handles use-def chains for top-level variables.

void traverseOnVFG(const SVFG* vfg, Value* val)
{
    SVFIR* pag = SVFIR::getPAG();
    SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);

    PAGNode* pNode = pag->getGNode(pag->getValueNode(svfval));
    const VFGNode* vNode = vfg->getDefSVFGNode(pNode);
    FIFOWorkList<const VFGNode*> worklist;
    Set<const VFGNode*> visited;
    worklist.push(vNode);

    /// Traverse along VFG
    while (!worklist.empty())
    {
        const VFGNode* vNode = worklist.pop();
        for (VFGNode::const_iterator it = vNode->OutEdgeBegin(), eit =
                    vNode->OutEdgeEnd(); it != eit; ++it)
        {
            VFGEdge* edge = *it;
            VFGNode* succNode = edge->getDstNode();
            if (visited.find(succNode) == visited.end())
            {
                visited.insert(succNode);
                worklist.push(succNode);
            }
        }
    }

    /// Collect all LLVM Values
    for(Set<const VFGNode*>::const_iterator it = visited.begin(), eit = visited.end(); it!=eit; ++it)
    {
        const VFGNode* node = *it;
        /// can only query VFGNode involving top-level pointers (starting with % or @ in LLVM IR)
        /// PAGNode* pNode = vfg->getLHSTopLevPtr(node);
        /// Value* val = pNode->getValue();
    }
}

For address-taken variables, is there an existing function I can leverage, or would I need to implement my own function to trace them? Additionally, are there any examples I can refer to for learning how to collect address-taken variables under SVF framework?

Thanks,
Andrew

@bao00065 bao00065 changed the title Collect Def-Use chain Collect Use-Def chain Oct 9, 2024
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

1 participant