library/src/os_profiling/BP_OSProfiling.cc
// search processes and titles for regex.  Returns
search processes and titles for regex.  Returns
search processes and titles for regex . Returns
size_t * BP_OSProfSearchProcessesPCRE
(
	P_BP_OS_PROFILING_SESSION osprof_session,
	char * regex_proc_name,
	char * regex_proc_title,
	pid_t pid
)
{
	if(!osprof_session)
		return NULL;
	BP_OSPROF_SESSION_LOCK;
	size_t * ret_indexes = NULL;
	size_t   ret_index_n = 0;
	size_t n = 0;
	for(; n < osprof_session->process_stats_n; n++)
	{
		if(pid != (pid_t) -1)
		if(pid != osprof_session->process_stats[n].pid)
			continue;
		BP_REGEX_MATCH_INFO match = {0};
		memset(&match, 0x00, sizeof(match));
		size_t proc_name_matched  = 0;
		size_t proc_title_matched = 0;
		if(regex_proc_name)
		if(osprof_session->process_stats[n].process_name)
		if(BP_MatchRegularExpressionPCRE(osprof_session->process_stats[n].process_name, bpstrlen(osprof_session->process_stats[n].process_name), regex_proc_name, 0, 1024, &match, 0) == ERR_SUCCESS)
		{
			proc_name_matched=1;
		}
		BP_DestroyRegexpMatchInfo(&match);
		memset(&match, 0x00, sizeof(match));
		if(regex_proc_title)
		if(osprof_session->process_stats[n].proctitle)
		if(BP_MatchRegularExpressionPCRE(osprof_session->process_stats[n].proctitle, bpstrlen(osprof_session->process_stats[n].proctitle), regex_proc_title, 0, 1024, &match, 0) == ERR_SUCCESS)
		{
			proc_title_matched=1;
		}
		BP_DestroyRegexpMatchInfo(&match);
		memset(&match, 0x00, sizeof(match));
		if(regex_proc_name)
		if(!proc_name_matched)
			continue;
		if(regex_proc_title)
		if(!proc_title_matched)
			continue;
		ret_index_n++;
		ret_indexes = (size_t *) tq_realloc(osprof_session->m, ret_indexes, sizeof(size_t) * (ret_index_n+1), BPLN);
		ret_indexes[ret_index_n-1] = n;
		ret_indexes[ret_index_n]   = OSPROF_SEARCH_INDEX_TRUNCATION;
	}
	BP_OSPROF_SESSION_UNLOCK;
	return ret_indexes;
}
size_t * BP_OSProfSearchProcessesPCRE ( P_BP_OS_PROFILING_SESSION osprof_session , char * regex_proc_name , char * regex_proc_title , pid_t pid ) { if ( ! osprof_session ) return NULL ; BP_OSPROF_SESSION_LOCK ; size_t * ret_indexes = NULL ; size_t ret_index_n = 0 ; size_t n = 0 ; for ( ; n < osprof_session -> process_stats_n ; n ++ ) { if ( pid != ( pid_t ) - 1 ) if ( pid != osprof_session -> process_stats [ n ] . pid ) continue ; BP_REGEX_MATCH_INFO match = { 0 } ; memset ( & match , 0x00 , sizeof ( match ) ) ; size_t proc_name_matched = 0 ; size_t proc_title_matched = 0 ; if ( regex_proc_name ) if ( osprof_session -> process_stats [ n ] . process_name ) if ( BP_MatchRegularExpressionPCRE ( osprof_session -> process_stats [ n ] . process_name , bpstrlen ( osprof_session -> process_stats [ n ] . process_name ) , regex_proc_name , 0 , 1024 , & match , 0 ) == ERR_SUCCESS ) { proc_name_matched = 1 ; } BP_DestroyRegexpMatchInfo ( & match ) ; memset ( & match , 0x00 , sizeof ( match ) ) ; if ( regex_proc_title ) if ( osprof_session -> process_stats [ n ] . proctitle ) if ( BP_MatchRegularExpressionPCRE ( osprof_session -> process_stats [ n ] . proctitle , bpstrlen ( osprof_session -> process_stats [ n ] . proctitle ) , regex_proc_title , 0 , 1024 , & match , 0 ) == ERR_SUCCESS ) { proc_title_matched = 1 ; } BP_DestroyRegexpMatchInfo ( & match ) ; memset ( & match , 0x00 , sizeof ( match ) ) ; if ( regex_proc_name ) if ( ! proc_name_matched ) continue ; if ( regex_proc_title ) if ( ! proc_title_matched ) continue ; ret_index_n ++ ; ret_indexes = ( size_t * ) tq_realloc ( osprof_session -> m , ret_indexes , sizeof ( size_t ) * ( ret_index_n + 1 ) , BPLN ) ; ret_indexes [ ret_index_n - 1 ] = n ; ret_indexes [ ret_index_n ] = OSPROF_SEARCH_INDEX_TRUNCATION ; } BP_OSPROF_SESSION_UNLOCK ; return ret_indexes ; }
search processes and titles for regex.
search processes and titles for regex .
// lock session before display // create return index stack // walk all processes in the list and search on regexps // if we're doing pid matching, run checks here // set regexp match // flags for indicating if we match // destroy regexp match info // check title regex // destroy regexp match info // === Now Run Match Check Logic ================= // check to see if proc name is matched // check to see if proc title is set // increment the index count // at this point we've confirmed a match // set the ret index and truncate (for quick searching) // unlock session after display // return indicating success