CppPlugins/src/main/cpp/src/plugin.cpp

55 lines
1.0 KiB
C++
Raw Normal View History

2020-02-20 19:23:28 +01:00
#include <plugin.h>
2020-02-21 09:57:24 +01:00
#include <iostream>
2020-03-30 16:59:26 +02:00
#include <execinfo.h> //backtrace
#define STACKTRACEBUFFER 100
2020-02-21 09:57:24 +01:00
2020-02-22 09:08:07 +01:00
namespace Plugin {
2020-02-22 02:37:07 +01:00
void CppPlugin::onLoad(JNIEnv*) {
2020-02-20 19:23:28 +01:00
}
2020-02-22 02:37:07 +01:00
void CppPlugin::onEnable(JNIEnv*) {
2020-02-20 19:23:28 +01:00
}
2020-02-22 02:37:07 +01:00
void CppPlugin::onDisable(JNIEnv*) {
2020-02-20 19:23:28 +01:00
}
std::map<std::string, eventfptr> CppPlugin::getEvents() {
2020-03-30 16:59:26 +02:00
//std::cout << "Defaults::getEvents()" << std::endl;
2020-02-20 19:23:28 +01:00
return std::map<std::string, eventfptr>();
}
CppPlugin::~CppPlugin() {
2020-02-22 09:08:07 +01:00
}
2020-03-30 16:59:26 +02:00
void CppPlugin::printStacktrace() {
//create stacktrace
void *buffer[STACKTRACEBUFFER];
int count = backtrace(buffer, STACKTRACEBUFFER)-1; //dont print current frame
std::cout << "Plugin: " << name << " Creating Stacktrace: ";
std::cout << count << " Frames traced\n";
char** strings = nullptr;
strings = backtrace_symbols(buffer+1, count);
if(strings == nullptr) {
std::cout << "Error, could not read symbols - compiled with \"-g\"?" << std::endl;
} else {
for(int i = 0; i < count; i++) {
std::cout << strings[i] << "\n";
}
free(strings);
std::cout << std::endl;
}
}
2020-02-22 09:08:07 +01:00
} //namespace