Skip to content

Commit

Permalink
Add parseAPI/simpleParser (#24)
Browse files Browse the repository at this point in the history
This is both a good sanity check for PRs and can be used as a larger
system-level parser for things like running through /usr/lib.
  • Loading branch information
hainest authored Jan 10, 2024
1 parent 95f7910 commit 36a69fb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
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;
}
}

0 comments on commit 36a69fb

Please sign in to comment.