debuging
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
];*/
|
||||
|
||||
buildPhase = ''
|
||||
g++ modules/print/src/*.cpp -fpic -shared -I src -I include -o $name
|
||||
g++ modules/print/src/*.cpp src/App.cpp -fpic -shared -I src -I include -o $name
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
||||
24
src/App.cpp
24
src/App.cpp
@@ -19,12 +19,16 @@ App::App(const int& argc, char* argv[]) {
|
||||
|
||||
App::~App() {
|
||||
|
||||
std::cout << "\nExiting...";
|
||||
std::cout << "\nExiting...\n";
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
void* handle = (*it)->getHandle();
|
||||
std::cout << "retrieved handle\n";
|
||||
delete *it;
|
||||
std::cout << "deleted module\n";
|
||||
dlclose(handle);
|
||||
modules.erase(it);
|
||||
std::cout << "closed lib\n";
|
||||
it = modules.erase(it);
|
||||
std::cout << "erased list node\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,28 +38,30 @@ void App::run() {
|
||||
// Main loop
|
||||
while (!done && !modules.empty()) {
|
||||
|
||||
for(auto it = modules.begin(); it != modules.end(); it++)
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
std::cout << "Running module: " << (*it)->getName() << std::endl;
|
||||
(*it)->run();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void App::load(std::string lib) {
|
||||
|
||||
void* handle = dlopen(lib.c_str(), RTLD_LAZY);
|
||||
void* h = dlopen(lib.c_str(), RTLD_NOW);
|
||||
|
||||
if(!handle) {
|
||||
std::cout << "could not open lib!\n";
|
||||
if(!h) {
|
||||
std::cout << "could not open lib: \"" << lib.c_str() << "\"\nError: " << dlerror() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Module::create_t* create = (Module::create_t*) dlsym(handle, "create");
|
||||
Module::create_t* create = (Module::create_t*) dlsym(h, "create");
|
||||
|
||||
if(dlerror()) {
|
||||
std::cout << "error finding create function in file: " << lib << std::endl;
|
||||
}
|
||||
|
||||
Module* m = create(handle);
|
||||
Module* m = create(h);
|
||||
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
|
||||
@@ -96,7 +102,7 @@ void App::handleArgs(const int& argc, char* argv[]) {
|
||||
}
|
||||
|
||||
while(i < argc) {
|
||||
|
||||
std::cout << "Attempting to load: " << argv[i] << std::endl;
|
||||
load(argv[i]);
|
||||
|
||||
i++;
|
||||
|
||||
Reference in New Issue
Block a user