예제 #1
0
파일: test1_util.cpp 프로젝트: QC-git/MyLab
	void test6()
	{
		log4cxx::PropertyConfigurator::configure("log4cxx.properties");
		log4cxx::LoggerPtr loggerA(log4cxx::Logger::getLogger("aaa"));  
		log4cxx::LoggerPtr loggerB(log4cxx::Logger::getLogger("bbb")); 
		LOG_F("\n");
		LOG4CXX_INFO(loggerA, "this is log4cxx test"); 
		LOG4CXX_INFO(loggerB, "this is log4cxx test"); 


		log4cxx::LoggerPtr logger0(log4cxx::Logger::getLogger("logger0")); 
		LOG4CXX_DEBUG(logger0, "hello");
		LOG4CXX_TRACE(logger0, "hello");
		LOG4CXX_INFO(logger0, "hello");
		LOG4CXX_WARN(logger0, "hello");
		LOG4CXX_ERROR(logger0, "hello");
		LOG4CXX_FATAL(logger0, "hello");

// 		std::set<int> cList;
// 		LOG4CXX_INFO(logger0, cList);

		//log4j.logger.logger0 = INFO, ap0  

// 		INFO 23:02:03 -- hello
// 		WARN 23:02:04 -- hello
// 		ERROR 23:02:04 -- hello
// 		FATAL 23:02:04 -- hello

		LOG_F("\n");
	}
예제 #2
0
void test_SIGSEGV_0()
{
	LOG_F(INFO, "Intentionally writing to nullptr:");
	int* ptr = nullptr;
	*ptr = 42;
	LOG_F(FATAL, "We shouldn't get here");
}
예제 #3
0
void test_thread_names()
{
	LOG_SCOPE_FUNCTION(INFO);

	{
		char thread_name[17];
		loguru::get_thread_name(thread_name, sizeof(thread_name), false);
		LOG_F(INFO, "Hello from main thread ('%s')", thread_name);
	}

	auto a = std::thread([](){
		char thread_name[17];
		loguru::get_thread_name(thread_name, sizeof(thread_name), false);
		LOG_F(INFO, "Hello from nameless thread ('%s')", thread_name);
	});

	auto b = std::thread([](){
		loguru::set_thread_name("renderer");
		char thread_name[17];
		loguru::get_thread_name(thread_name, sizeof(thread_name), false);
		LOG_F(INFO, "Hello from render thread ('%s')", thread_name);
	});

	auto c = std::thread([](){
		loguru::set_thread_name("abcdefghijklmnopqrstuvwxyz");
		char thread_name[17];
		loguru::get_thread_name(thread_name, sizeof(thread_name), false);
		LOG_F(INFO, "Hello from thread with a very long name ('%s')", thread_name);
	});

	a.join();
	b.join();
	c.join();
}
예제 #4
0
int main(int argc, char **argv)
{
    honggfuzz_t hfuzz;
    if (cmdlineParse(argc, argv, &hfuzz) == false) {
        LOG_F("Parsing of the cmd-line arguments failed");
    }

    if (!files_init(&hfuzz)) {
        LOG_F("Couldn't load input files");
        exit(EXIT_FAILURE);
    }

    if (hfuzz.dictionaryFile && (files_parseDictionary(&hfuzz) == false)) {
        LOG_F("Couldn't parse dictionary file ('%s')", hfuzz.dictionaryFile);
    }

    if (hfuzz.blacklistFile && (files_parseBlacklist(&hfuzz) == false)) {
        LOG_F("Couldn't parse stackhash blacklist file ('%s')", hfuzz.blacklistFile);
    }

    /*
     * So far so good
     */
    fuzz_main(&hfuzz);

    abort();                    /* NOTREACHED */
    return EXIT_SUCCESS;
}
예제 #5
0
void throw_on_fatal()
{
	loguru::set_fatal_handler([](const loguru::Message& message){
		LOG_F(INFO, "Throwing exception...");
		throw std::runtime_error(std::string(message.prefix) + message.message);
	});
	{
		LOG_SCOPE_F(INFO, "CHECK_F throw + catch");
		try {
			CHECK_F(false, "some CHECK_F message");
		} catch (std::runtime_error& e) {
			LOG_F(INFO, "CHECK_F threw this: '%s'", e.what());
		}
	}
#if LOGURU_WITH_STREAMS
	{
		LOG_SCOPE_F(INFO, "CHECK_S throw + catch");
		try {
			CHECK_S(false) << "Some CHECK_S message";
		} catch (std::runtime_error& e) {
			LOG_F(INFO, "CHECK_S threw this: '%s'", e.what());
		}
	}
	LOG_F(INFO, "Trying an uncaught exception:");
	CHECK_S(false);
#else
	CHECK_F(false);
#endif // LOGURU_WITH_STREAMS
}
예제 #6
0
파일: files.c 프로젝트: dyjakan/honggfuzz
bool files_parseBlacklist(honggfuzz_t * hfuzz)
{
    FILE *fBl = fopen(hfuzz->blacklistFile, "rb");
    if (fBl == NULL) {
        PLOG_W("Couldn't open '%s' - R/O mode", hfuzz->blacklistFile);
        return false;
    }
    defer {
        fclose(fBl);
    };

    char *lineptr = NULL;
    /* lineptr can be NULL, but it's fine for free() */
    defer {
        free(lineptr);
    };
    size_t n = 0;
    for (;;) {
        if (getline(&lineptr, &n, fBl) == -1) {
            break;
        }

        if ((hfuzz->blacklist =
             util_Realloc(hfuzz->blacklist,
                          (hfuzz->blacklistCnt + 1) * sizeof(hfuzz->blacklist[0]))) == NULL) {
            PLOG_W("realloc failed (sz=%zu)",
                   (hfuzz->blacklistCnt + 1) * sizeof(hfuzz->blacklist[0]));
            return false;
        }

        hfuzz->blacklist[hfuzz->blacklistCnt] = strtoull(lineptr, 0, 16);
        LOG_D("Blacklist: loaded %'" PRIu64 "'", hfuzz->blacklist[hfuzz->blacklistCnt]);

        // Verify entries are sorted so we can use interpolation search
        if (hfuzz->blacklistCnt > 1) {
            if (hfuzz->blacklist[hfuzz->blacklistCnt - 1] > hfuzz->blacklist[hfuzz->blacklistCnt]) {
                LOG_F
                    ("Blacklist file not sorted. Use 'tools/createStackBlacklist.sh' to sort records");
                return false;
            }
        }
        hfuzz->blacklistCnt += 1;
    }

    if (hfuzz->blacklistCnt > 0) {
        LOG_I("Loaded %zu stack hash(es) from the blacklist file", hfuzz->blacklistCnt);
    } else {
        LOG_F("Empty stack hashes blacklist file '%s'", hfuzz->blacklistFile);
    }
    return true;
}
예제 #7
0
int main_test(int argc, char* argv[])
{
	loguru::init(argc, argv);
	LOG_SCOPE_FUNCTION(INFO);
	LOG_F(INFO, "Doing some stuff...");
	for (int i=0; i<2; ++i) {
		LOG_SCOPE_F(1, "Iteration %d", i);
		auto result = some_expensive_operation();
		LOG_IF_F(WARNING, result == BAD, "Bad result");
	}
	LOG_F(INFO, "Time to go!");

	return 0;
}
예제 #8
0
파일: gl_lib.cpp 프로젝트: csulmone/emilib
unsigned load_shader(GLenum type, const char* source, const char* debug_name)
{
	CHECK_FOR_GL_ERROR;

	unsigned id = glCreateShader(type);

	const char* code = source;
	glShaderSource(id, 1, &code, nullptr);
	glCompileShader(id);

	CHECK_FOR_GL_ERROR;

	GLint status = 0;
	glGetShaderiv(id, GL_COMPILE_STATUS, &status);

	CHECK_FOR_GL_ERROR;

	//std::string log = Trim( GetShaderLog(id) );

	if (status == 0) {
		CHECK_FOR_GL_ERROR;

		LOG_F(INFO, "-------------------------------------");
		LOG_F(INFO, "%s", source);
		LOG_F(INFO, "-------------------------------------");

		LOG_F(ERROR, "Failed to compile %s shader for program \"%s\".",
					(type==GL_VERTEX_SHADER ? "vertex" : "fragment"), debug_name);

		GLint log_length = -1;
		glGetShaderiv(id, GL_INFO_LOG_LENGTH, &log_length);

		CHECK_FOR_GL_ERROR;

		if (log_length > 0)
		{
			std::vector<GLchar> log((unsigned)log_length);
			glGetShaderInfoLog(id, log_length, &log_length, log.data());
			LOG_F(ERROR, "Shader log:\n%s", log.data());
		}

		CHECK_FOR_GL_ERROR;

		glDeleteShader(id);

		throw std::runtime_error("Shader compilation error");
	}

	return id;
}
예제 #9
0
void test_hang_0()
{
	LOG_F(INFO, "Press ctrl-C to kill.");
	for(;;) {
		// LOG_F(INFO, "Press ctrl-C to break out of this infinite loop.");
	}
}
예제 #10
0
std::vector<uint8_t> read_binary_file(const std::string& path)
{
	FILEWrapper fp(path, "rb");

	size_t size = file_size(path);
	if (size <= 0) {
		// Fail?
		size_t chunk_size = 1024*128; // Size of first chunk
		size_t nRead = 0;

		std::vector<uint8_t> bytes;

		while (!fp.end_of_file()) {
			bytes.resize(nRead + chunk_size);
			size_t n = fp.try_read(&bytes[nRead], chunk_size);
			nRead += n;
			bytes.resize(nRead);
			chunk_size *= 2; // Read progressively larger chunks
		}

		bytes.shrink_to_fit();

		return bytes;
	} else {
		std::vector<uint8_t> bytes(size);
		size_t n = fp.try_read(bytes.data(), size);
		if (n != size) {
			LOG_F(ERROR, "read_binary_file failed");
		}

		return bytes;
	}
}
예제 #11
0
void SiteTask::GotResponse(int status_code, const char * buf, int len) {
    LOG_F(LS_VERBOSE) << "state:" << GetStateName(GetState())
        << " status:" << status_code << " len:" << len
        << " current: " << curact_;

    SignalActionResponse(site_.actions()[curact_], HttpResponse(status_code, buf, len));
}
예제 #12
0
파일: pt.c 프로젝트: anestisb/honggfuzz
inline static void perf_ptAnalyzePkt(honggfuzz_t * hfuzz, fuzzer_t * fuzzer,
                                     struct pt_packet *packet, struct pt_config *ptc,
                                     struct pt_last_ip *last_ip)
{
    switch (packet->type) {
    case ppt_tip:
    case ppt_fup:
    case ppt_tip_pge:
    case ppt_tip_pgd:
        break;
    default:
        return;
    }

    int errcode = pt_last_ip_update_ip(last_ip, &(packet->payload.ip), ptc);
    if (errcode < 0) {
        LOG_F("pt_last_ip_update_ip() failed: %s", pt_errstr(errcode));
    }

    /* Update only on TIP, other packets don't indicate a branch */
    if (packet->type == ppt_tip) {
        uint64_t ip;
        errcode = pt_last_ip_query(&ip, last_ip);
        if (errcode == 0) {
            ip &= _HF_PERF_BITMAP_BITSZ_MASK;
            register uint8_t prev = ATOMIC_BTS(hfuzz->feedback->bbMapPc, ip);
            if (!prev) {
                fuzzer->linux.hwCnts.newBBCnt++;
            }
        }
    }
    return;
}
예제 #13
0
void FILEWrapper::flush()
{
	if (fflush(_fp) != 0) {
		const auto errno_text = loguru::errno_as_text();
		LOG_F(WARNING, "fflush failed: %s", errno_text.c_str());
	}
}
예제 #14
0
//////////////////////////////////////////////////////////////////////////
//Implement Proxy p2p session
bool P2PProxySession::RegisterP2PProxySocket(
  P2PProxySocket *p2p_proxy_socket, bool is_server)
{
  ASSERT(signal_thread_->IsCurrent());
  if(state_ == P2P_CLOSING)
    state_ = P2P_CONNECTED;
  if(state_ == P2P_CLOSE)
    return false;
  P2PProxySockets::iterator iter = p2p_proxy_sockets_.find(
    p2p_proxy_socket->GetSocketNumber());

  if(iter != p2p_proxy_sockets_.end()){
    LOG_F(LS_ERROR) << "\t the proxy socket begin is existed" 
      << std::endl;
    return false;
  }
  p2p_proxy_sockets_.insert(P2PProxySockets::value_type(
    p2p_proxy_socket->GetSocketNumber(),p2p_proxy_socket));
  
    std::cout << "\n********* \n"
    << "Current p2p socket size is "
    << p2p_proxy_sockets_.size()
    << "\n*********" << std::endl;

  SignalPeerConnectSucceed.connect(p2p_proxy_socket,
    &P2PProxySocket::OnP2PConnectSucceed);
  SignalPeerConnectFailure.connect(p2p_proxy_socket,
    &P2PProxySocket::OnP2PClose);
  if(is_server && state_ == P2P_CONNECTED)
    p2p_proxy_socket->OnP2PConnectSucceed(this);
  return true;
}
예제 #15
0
파일: util.c 프로젝트: naisanza/honggfuzz
uint64_t util_rndGet(uint64_t min, uint64_t max)
{
    if (min > max) {
        LOG_F("min:%" PRIu64 " > max:%" PRIu64, min, max);
    }

    if (util_urandomFd == -1) {
        if ((util_urandomFd = open("/dev/urandom", O_RDONLY)) == -1) {
            PLOG_F("Couldn't open /dev/urandom for writing");
        }
    }

    if (rndIni == false) {
        if (files_readFromFd(util_urandomFd, (uint8_t *) & rndX, sizeof(rndX)) == false) {
            PLOG_F("Couldn't read '%zu' bytes from /dev/urandom", sizeof(rndX));
        }
        rndIni = true;
    }

    /* MMIX LCG PRNG */
    static const uint64_t a = 6364136223846793005ULL;
    static const uint64_t c = 1442695040888963407ULL;

    rndX = (a * rndX + c);

    return ((rndX % (max - min + 1)) + min);
}
예제 #16
0
void throw_on_signal()
{
	loguru::set_fatal_handler([](const loguru::Message& message){
		LOG_F(INFO, "Throwing exception...");
		throw std::runtime_error(std::string(message.prefix) + message.message);
	});
	test_SIGSEGV_0();
}
예제 #17
0
void test_scopes()
{
	LOG_SCOPE_FUNCTION(INFO);

	LOG_F(INFO, "Should be indented one step");
	LOG_F(1, "First thing");
	LOG_F(1, "Second thing");

	{
		LOG_SCOPE_F(1, "Some indentation at level 1");
		LOG_F(INFO, "Should only be indented one more step iff verbosity is 1 or higher");
		LOG_F(2, "Some info");
		sleep_ms(123);
	}

	sleep_ms(64);
}
예제 #18
0
void LinkScheduler::on_print_state(evutil_socket_t sock, short event, void *arg)
{
    LinkScheduler *linkScheduler = (LinkScheduler*)arg;
    LOG_F(INFO, "on_print_state table count=%d", linkScheduler->_linkTable.count());
    linkScheduler->_linkTable.printState();
    struct timeval t = {Conf::instance()->schedulerPrintStateInterval, 0 };
    evtimer_add(linkScheduler->_printStateEvent, &t);
}
예제 #19
0
파일: util.c 프로젝트: RishavT/nsjail
void *utilMalloc(size_t sz)
{
	void *ret = malloc(sz);
	if (ret == NULL) {
		LOG_F("malloc(sz=%zu) failed", sz);
	}
	return ret;
}
예제 #20
0
int GeneralTask::ProcessResponse() {
    LOG_F(LS_VERBOSE) << "state:" << GetStateName(GetState());
    Assert(sent_);
    
    sent_ = false;
    http_.Close();

    return STATE_DONE;
}
예제 #21
0
bool is_directory(const std::string& path)
{
	struct stat info;
	if (stat(path.c_str(), &info) != 0) {
		LOG_F(WARNING, "Failed to stat file %s", path.c_str());
		return false;
	}
	return S_ISDIR(info.st_mode);
}
예제 #22
0
time_t modified_time(const std::string& path)
{
	struct stat info;
	if (stat(path.c_str(), &info) != 0) {
		LOG_F(WARNING, "Failed to stat file %s", path.c_str());
		return 0;
	}
	return info.st_mtime;
}
예제 #23
0
size_t file_size(const std::string& path)
{
	struct stat info;
	if (stat(path.c_str(), &info) != 0) {
		LOG_F(WARNING, "Failed to stat file %s", path.c_str());
		return 0;
	}
	return (size_t)info.st_size;
}
예제 #24
0
파일: pt.c 프로젝트: anestisb/honggfuzz
void arch_ptAnalyze(honggfuzz_t * hfuzz, fuzzer_t * fuzzer)
{
    struct perf_event_mmap_page *pem = (struct perf_event_mmap_page *)fuzzer->linux.perfMmapBuf;

    struct pt_config ptc;
    pt_config_init(&ptc);
    ptc.begin = &fuzzer->linux.perfMmapAux[pem->aux_tail];
    ptc.end = &fuzzer->linux.perfMmapAux[pem->aux_head - 1];

    int errcode = pt_cpu_errata(&ptc.errata, &ptc.cpu);
    if (errcode < 0) {
        LOG_F("pt_errata() failed: %s", pt_errstr(errcode));
    }

    struct pt_packet_decoder *ptd = pt_pkt_alloc_decoder(&ptc);
    if (ptd == NULL) {
        LOG_F("pt_pkt_alloc_decoder() failed");
    }
    defer {
        pt_pkt_free_decoder(ptd);
    };

    errcode = pt_pkt_sync_forward(ptd);
    if (errcode < 0) {
        LOG_W("pt_pkt_sync_forward() failed: %s", pt_errstr(errcode));
        return;
    }

    struct pt_last_ip last_ip;
    pt_last_ip_init(&last_ip);
    for (;;) {
        struct pt_packet packet;
        errcode = pt_pkt_next(ptd, &packet, sizeof(packet));
        if (errcode == -pte_eos) {
            break;
        }
        if (errcode < 0) {
            LOG_W("pt_pkt_next() failed: %s", pt_errstr(errcode));
            break;
        }
        perf_ptAnalyzePkt(hfuzz, fuzzer, &packet, &ptc, &last_ip);
    }
}
예제 #25
0
파일: gl_lib.cpp 프로젝트: csulmone/emilib
void print_link_log(unsigned prog, const char* debug_name)
{
	GLint log_length;
	glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &log_length);
	if (log_length > 0) {
		std::vector<GLchar> log((unsigned)log_length+1);
		glGetProgramInfoLog(prog, log_length, &log_length, &log[0]);
		LOG_F(INFO, "Program '%s' link log:\n%s", debug_name, &log[0]);
	}
}
예제 #26
0
kern_return_t
catch_mach_exception_raise(mach_port_t exception_port,
                           mach_port_t thread,
                           mach_port_t task,
                           exception_type_t exception, mach_exception_data_t code,
                           mach_msg_type_number_t codeCnt)
{
    LOG_F("This function should never get called");
    return KERN_SUCCESS;
}
예제 #27
0
void add_log_metric(int src, int dst, int ctime, double metric, unsigned int label){
 unsigned int i;
 unsigned int j;
 unsigned int node_actif=0;

 //LOG_I(OTG,"[%d][%d] LOGG_ADDED ctime=%d, metric=%.2f  \n", src, dst, ctime, metric);

 switch (label) {
 case OTG_LATENCY:
   add_log_label(label, &start_log_latency);
   break;
 case OTG_LATENCY_BG:
   add_log_label(label, &start_log_latency_bg);
   break;
 case OTG_GP:
   add_log_label(label, &start_log_GP);
   break;
 case OTG_GP_BG:
   add_log_label(label, &start_log_GP_bg);
   break;
 case OTG_JITTER:
   add_log_label(label, &start_log_GP_bg);
   break;
    
 default:
   LOG_E(OTG, "File label unknown %d \n", label);
 }

 LOG_F(label,"%d  ", ctime);
  for (i=0; i<=(NB_eNB_INST + NB_UE_INST); i++){
    for (j=0; j<=(NB_eNB_INST + NB_UE_INST); j++){
    node_actif=0;
    if ((g_otg->idt_dist[i][j][0][PE_STATE]>0) || (g_otg->application_type[i][j][0] >0))
      node_actif=1;
    
    if ((node_actif>0) && ((i==src) && (j==dst)))
          LOG_F(label,"  %f  ", metric);
      if  ((node_actif>0) && ((i!=src) || (j!=dst)))
          LOG_F(label,"  %d  ", 0);
  }
 }
 LOG_F(label,"%f\n", metric);
}
예제 #28
0
파일: perf.c 프로젝트: quangnh89/honggfuzz
bool arch_perfEnable(pid_t pid, honggfuzz_t * hfuzz, perfFd_t * perfFds)
{
    if (hfuzz->dynFileMethod == _HF_DYNFILE_NONE) {
        return true;
    }
    if ((hfuzz->dynFileMethod & _HF_DYNFILE_UNIQUE_BLOCK_COUNT)
        && (hfuzz->dynFileMethod & _HF_DYNFILE_UNIQUE_EDGE_COUNT)) {
        LOG_F
            ("_HF_DYNFILE_UNIQUE_BLOCK_COUNT and _HF_DYNFILE_UNIQUE_EDGE_COUNT cannot be specified together");
    }

    perfBloom = NULL;
    perfPageSz = getpagesize();

    perfMmapSz = arch_perfGetMmapBufSz(hfuzz);
    perfCutOffAddr = hfuzz->dynamicCutOffAddr;

    perfFds->cpuInstrFd = -1;
    perfFds->cpuBranchFd = -1;
    perfFds->uniquePcFd = -1;
    perfFds->uniqueEdgeFd = -1;

    if (hfuzz->dynFileMethod & _HF_DYNFILE_INSTR_COUNT) {
        if (arch_perfOpen(pid, _HF_DYNFILE_INSTR_COUNT, &perfFds->cpuInstrFd) == false) {
            LOG_E("Cannot set up perf for PID=%d (_HF_DYNFILE_INSTR_COUNT)", pid);
            goto out;
        }
    }
    if (hfuzz->dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) {
        if (arch_perfOpen(pid, _HF_DYNFILE_BRANCH_COUNT, &perfFds->cpuBranchFd) == false) {
            LOG_E("Cannot set up perf for PID=%d (_HF_DYNFILE_BRANCH_COUNT)", pid);
            goto out;
        }
    }
    if (hfuzz->dynFileMethod & _HF_DYNFILE_UNIQUE_BLOCK_COUNT) {
        if (arch_perfOpen(pid, _HF_DYNFILE_UNIQUE_BLOCK_COUNT, &perfFds->uniquePcFd) == false) {
            LOG_E("Cannot set up perf for PID=%d (_HF_DYNFILE_UNIQUE_BLOCK_COUNT)", pid);
            goto out;
        }
    }
    if (hfuzz->dynFileMethod & _HF_DYNFILE_UNIQUE_EDGE_COUNT) {
        if (arch_perfOpen(pid, _HF_DYNFILE_UNIQUE_EDGE_COUNT, &perfFds->uniqueEdgeFd) == false) {
            LOG_E("Cannot set up perf for PID=%d (_HF_DYNFILE_UNIQUE_EDGE_COUNT)", pid);
            goto out;
        }
    }

    return true;
 out:
    close(perfFds->cpuInstrFd);
    close(perfFds->cpuBranchFd);
    close(perfFds->uniquePcFd);
    close(perfFds->uniqueEdgeFd);
    return false;
}
예제 #29
0
파일: gl_lib.cpp 프로젝트: csulmone/emilib
// Error callback
void on_gl_error(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
	const GLchar* message, const void* user_param)
{
	(void)source;
	(void)type;
	(void)id;
	(void)severity;
	(void)length;
	(void)user_param;
	LOG_F(WARNING, "GL debug: %s", message);
}
예제 #30
0
void  add_log_label(unsigned int label, unsigned int * start_log_metric){
 unsigned int i;
 unsigned int j;
 unsigned int node_actif=0;

 if (*start_log_metric==0){
 *start_log_metric=1;
   LOG_F(label,"Time   ");
   for (i=0; i<=(NB_eNB_INST + NB_UE_INST); i++){
     for (j=0; j<=(NB_eNB_INST + NB_UE_INST); j++){
       node_actif=0;
          if (g_otg->idt_dist[i][j][0][PE_STATE]>0 )
	    node_actif++; 
      if (node_actif>0)
        LOG_F(label,"%d->%d    ", i, j);  
    }
   }
   LOG_F(label,"Aggregated\n");
 }
}