-------------------------------------------------------------------------------------------
int f3(){
print_stacktrace();
printf("hello f3\n");
LOG(INFO) << "Hello" << std::endl;
std::vector<int> vec = {1, 2, 3, 4};
int j = vec.at(20);
return j;
}
void f2(){
f3();
return;
}
void f1(){
f2();
return;
}
void WriteToStderr(const char* data, int size) {
//LOG(ERROR) << __pretty_function__ << ":Error..." << std::string(data,size);
LOG(ERROR) << __func__ << ":Error..." << std::string(data,size);
}
int main(int argc, char** argv){
std::string log_destination = "/home/geonuk/atlas/ws/test/output/log";
google::InstallFailureSignalHandler();
google::InstallFailureWriter(WriteToStderr);
google::InitGoogleLogging(argv[0]);
google::SetLogDestination(google::GLOG_INFO, log_destination.c_str() );
f3();
return 0;
}
-------------------------------------------------------------------------------------------
2) subtrace를 얻는법 예시
void print_trace(void) {
void *array[10];
char **strings;
size_t size = backtrace(array, 10);
backtrace_symbols_fd(array, size, STDERR_FILENO);
void print_trace(void) {
void *array[10];
char **strings;
size_t size = backtrace(array, 10);
backtrace_symbols_fd(array, size, STDERR_FILENO);
}
-------------------------------------------------------------------------------------------
No comments:
Post a Comment