Static Value-Flow Analysis
Loading...
Searching...
No Matches
AbsExtAPI.h
Go to the documentation of this file.
1//===- AbsExtAPI.h -- Abstract Interpretation External API handler-----//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23
24// Created on: Sep 9, 2024
25// Author: Xiao Cheng, Jiawei Wang
26//
27#pragma once
29#include "AE/Core/ICFGWTO.h"
31#include "Util/SVFBugReport.h"
32
33namespace SVF
34{
35
36// Forward declaration of AbstractInterpretation class
37class AbstractInterpretation;
38
44{
45public:
51
57
61 void initExtFunMap();
62
69 std::string strRead(AbstractState& as, const SVFVar* rhs);
70
75 void handleExtAPI(const CallICFGNode *call);
76
77 // --- Shared primitives used by string/memory handlers ---
78
81
83 static bool isValidLength(const IntervalValue& len);
84
87
88 // --- String/memory operation handlers ---
89
90 void handleStrcpy(const CallICFGNode *call);
91 void handleStrcat(const CallICFGNode *call);
92 void handleStrncat(const CallICFGNode *call);
95
102
110
111protected:
115 Map<std::string, std::function<void(const CallICFGNode*)>> func_map;
116};
117
118} // namespace SVF
newitem type
Definition cJSON.cpp:2739
Handles external API calls and manages abstract states.
Definition AbsExtAPI.h:44
std::string strRead(AbstractState &as, const SVFVar *rhs)
Reads a string from the abstract state.
void handleMemset(AbstractState &as, const SVFVar *dst, IntervalValue elem, IntervalValue len)
void initExtFunMap()
Initializes the external function map.
Definition AbsExtAPI.cpp:42
IntervalValue getStrlen(AbstractState &as, const SVF::SVFVar *strValue)
Calculate the length of a null-terminated string in abstract state.
Map< const ICFGNode *, AbstractState > & abstractTrace
Map of ICFG nodes to abstract states.
Definition AbsExtAPI.h:114
void handleExtAPI(const CallICFGNode *call)
Handles an external API call.
void handleStrncat(const CallICFGNode *call)
static bool isValidLength(const IntervalValue &len)
Check if an interval length is usable (not bottom, not unbounded).
AbstractState & getAbsStateFromTrace(const ICFGNode *node)
Retrieves the abstract state from the trace for a given ICFG node.
void handleMemcpy(AbstractState &as, const SVF::SVFVar *dst, const SVF::SVFVar *src, IntervalValue len, u32_t start_idx)
Core memcpy: copy len bytes from src to dst starting at dst[start_idx].
SVFIR * svfir
Pointer to the SVF intermediate representation.
Definition AbsExtAPI.h:112
ExtAPIType
Enumeration of external API types.
Definition AbsExtAPI.h:50
IntervalValue getRangeLimitFromType(const SVFType *type)
Gets the range limit from a type.
ICFG * icfg
Pointer to the interprocedural control flow graph.
Definition AbsExtAPI.h:113
void handleStrcat(const CallICFGNode *call)
void handleStrcpy(const CallICFGNode *call)
u32_t getElementSize(AbstractState &as, const SVFVar *var)
Get the byte size of each element for a pointer/array variable.
Map< std::string, std::function< void(const CallICFGNode *)> > func_map
Map of function names to handlers.
Definition AbsExtAPI.h:115
for isBitcode
Definition BasicTypes.h:68
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
unsigned u32_t
Definition GeneralType.h:47