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

Add parseAPI #45

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_subdirectory(instructionAPI)
add_subdirectory(interceptOutput)
add_subdirectory(maxMallocSize)
add_subdirectory(memoryAccessCounter)
add_subdirectory(parseAPI)
add_subdirectory(proccontrol)
add_subdirectory(readGlobalVariables)
add_subdirectory(stackwalker)
Expand Down
9 changes: 9 additions & 0 deletions parseAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project(parseAPI LANGUAGES CXX)

add_library(loopAnalysis SHARED loopAnalysis.cpp)
target_compile_options(loopAnalysis PRIVATE ${EXAMPLES_WARNING_FLAGS})
target_link_libraries(loopAnalysis PRIVATE Dyninst::parseAPI)

add_library(edgePredicate SHARED edgePredicate.cpp)
target_compile_options(edgePredicate PRIVATE ${EXAMPLES_WARNING_FLAGS})
target_link_libraries(edgePredicate PRIVATE Dyninst::parseAPI)
29 changes: 29 additions & 0 deletions parseAPI/edgePredicate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "CFG.h"

#include <vector>

namespace dp = Dyninst::ParseAPI;

void edge(dp::Function* func) {
std::vector<dp::Block*> work;
work.push_back(func->entry());

dp::Intraproc intra_pred; // ignore calls, returns
dp::Interproc inter_pred;

while(!work.empty()) {
dp::Block* block = work.back();
work.pop_back();

dp::Block::edgelist const& targets = block->targets();

for(dp::Edge *e : targets) {
if(intra_pred.pred_impl(e)) {
// Examine the Intraprocedural edge
}
if(inter_pred.pred_impl(e)) {
// Examine the Interprocedural edge
}
}
}
}
23 changes: 23 additions & 0 deletions parseAPI/loopAnalysis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "CFG.h"
#include <vector>

namespace dp = Dyninst::ParseAPI;

void GetLoopInFunc(dp::Function *f) {
std::vector<dp::Loop*> loops;
f->getLoops(loops);

for(dp::Loop *loop : loops) {
// Get all the entry blocks
std::vector<dp::Block*> entries;
loop->getLoopEntries(entries);

// Get all the blocks in the loop
std::vector<dp::Block*> blocks;
loop->getLoopBasicBlocks(blocks);

// Get all the back edges in the loop
std::vector<dp::Edge*> backEdges;
loop->getBackEdges(backEdges);
}
}