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/simpleParser #24

Merged
merged 1 commit into from
Jan 10, 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
5 changes: 5 additions & 0 deletions parseAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ project(parseAPI)

add_executable(parseAPI_includes includes.cpp)
target_link_libraries(parseAPI_includes PRIVATE Dyninst::parseAPI)

add_executable(simpleParser simpleParser.cpp)
target_link_libraries(simpleParser PRIVATE Dyninst::parseAPI)
add_test(NAME parseAPI_simpleParser
COMMAND sh -c "./simpleParser simpleParser")
23 changes: 23 additions & 0 deletions parseAPI/simpleParser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "CFG.h"
#include "CodeObject.h"
#include <iostream>

namespace dp = Dyninst::ParseAPI;
int main(int argc, char* argv[]) {
if(argc < 2 || argc > 3) {
std::cerr << "Usage: " << argv[0] << " file\n";
return -1;
}

try {
auto* sts = new dp::SymtabCodeSource(argv[1]);
auto* co = new dp::CodeObject(sts);
co->parse();
} catch(std::exception &e) {
std::cerr << e.what() << '\n';
return -1;
} catch(...) {
std::cerr << "unknown exception occurred\n";
return -1;
}
}