Index: src/libs/zbxregexp/zbxregexp.c
===================================================================
--- src/libs/zbxregexp/zbxregexp.c	(revision 78102)
+++ src/libs/zbxregexp/zbxregexp.c	(working copy)
@@ -19,6 +19,7 @@
 
 #include "common.h"
 #include "zbxregexp.h"
+#include "log.h"
 
 /******************************************************************************
  *                                                                            *
@@ -144,6 +145,8 @@
 	char				*c = NULL;
 	regmatch_t			match;
 
+	zabbix_log(LOG_LEVEL_WARNING, "In zbx_regexp()");
+
 	if (NULL != len)
 		*len = FAIL;
 
@@ -188,6 +191,8 @@
 		*len = SUCCEED;
 	}
 out:
+	zabbix_log(LOG_LEVEL_WARNING, "End of zbx_regexp() c: %s", ZBX_NULL2STR(c));
+
 	return c;
 }
 
@@ -321,27 +326,49 @@
 
 	regmatch_t			match[10];	/* up to 10 capture groups in regexp */
 
+	int				ret;
+	char				msgbuf[512];
+
+	zabbix_log(LOG_LEVEL_WARNING, "In regexp_sub_ex()"
+				"string: %s, pattern: %s, output_template: %s, flags: %d, out:%s",
+				string, pattern, ZBX_NULL2STR(output_template), flags, ZBX_NULL2STR(*out));
+
 	if (NULL == string)
 	{
 		zbx_free(*out);
+		zabbix_log(LOG_LEVEL_WARNING, "End of regexp_sub() SUCCEED (NULL == string)");
 		return SUCCEED;
 	}
 
 	if (NULL == output_template || '\0' == *output_template)
+	{
 		flags |= REG_NOSUB;
+		zabbix_log(LOG_LEVEL_WARNING, "flags |= REG_NOSUB");
+	}
 
 	/* performance optimization: if possible then reuse the last compiled regexp */
 
 	if (NULL == old_pattern)
+	{
+		zabbix_log(LOG_LEVEL_WARNING, "goto compile");
 		goto compile;
+	}
 
 	if (0 != strcmp(old_pattern, pattern) || old_flags != flags)
+	{
+		zabbix_log(LOG_LEVEL_WARNING, "before regfree(&re)");
 		regfree(&re);
+		zabbix_log(LOG_LEVEL_WARNING, "after regfree(&re)");
+	}
 	else
+	{
+		zabbix_log(LOG_LEVEL_WARNING, "goto execute");
 		goto execute;
+	}
 compile:
-	if (0 == regcomp(&re, pattern, flags))
+	if (0 == (ret = regcomp(&re, pattern, flags)))
 	{
+		zabbix_log(LOG_LEVEL_WARNING, "regcomp() succeeded");
 		old_pattern = zbx_strdup(old_pattern, pattern);
 		old_flags = flags;
 	}
@@ -352,14 +379,27 @@
 		/* allocated memory after regcomp() failure                        */
 		regfree(&re);
 #endif
+		regerror(ret, &re, msgbuf, sizeof(msgbuf));
+		zabbix_log(LOG_LEVEL_WARNING, "regcomp() faild error:%d, %s", ret, msgbuf);
+
 		zbx_free(old_pattern);
+		zabbix_log(LOG_LEVEL_WARNING, "End of regexp_sub() FAIL");
 		return FAIL;
 	}
 execute:
 	zbx_free(*out);
 
 	if (0 == regexec(&re, string, ARRSIZE(match), match, 0))
+	{
 		*out = regexp_sub_replace(string, output_template, match, ARRSIZE(match));
+	}
+	else
+	{
+		regerror(ret, &re, msgbuf, sizeof(msgbuf));
+		zabbix_log(LOG_LEVEL_WARNING, "regexec() faild error:%d, %s", ret, msgbuf);
+	}
+
+	zabbix_log(LOG_LEVEL_WARNING, "End of regexp_sub() SUCCEED, out: %s", ZBX_NULL2STR(*out));
 
 	return SUCCEED;
 }
@@ -498,11 +538,14 @@
 {
 	int	regexp_flags = REG_EXTENDED | REG_NEWLINE, ret;
 
+	zabbix_log(LOG_LEVEL_WARNING, "In regexp_match_ex_regsub()");
+
 	if (ZBX_IGNORE_CASE == case_sensitive)
 		regexp_flags |= REG_ICASE;
 
 	if (NULL == output)
 	{
+		zabbix_log(LOG_LEVEL_WARNING, "output is NULL");
 		if (NULL == zbx_regexp(string, pattern, &ret, regexp_flags))
 		{
 			if (FAIL != ret)
@@ -521,6 +564,8 @@
 			ret = FAIL;
 	}
 
+	zabbix_log(LOG_LEVEL_WARNING, "End of regexp_match_ex_regsub(), ret = %d", ret);
+
 	return ret;
 }
 
@@ -644,6 +689,10 @@
 	int	i, ret = FAIL;
 	char	*output_accu;		/* accumulator for 'output' when looping over global regexp subexpressions */
 
+	zabbix_log(LOG_LEVEL_WARNING, "In regexp_sub_ex()"
+			"string: %s, pattern: %s, case_sensitive = %d, output_template: %s, output:%s",
+			string, pattern, case_sensitive, ZBX_NULL2STR(output_template), ZBX_NULL2STR(*output));
+
 	if (NULL == pattern || '\0' == *pattern)
 	{
 		/* always match when no pattern is specified */
@@ -653,6 +702,7 @@
 
 	if ('@' != *pattern)				/* not a global regexp */
 	{
+		zabbix_log(LOG_LEVEL_WARNING, "not a global regexp");
 		ret = regexp_match_ex_regsub(string, pattern, case_sensitive, output_template, output);
 		goto out;
 	}
@@ -734,6 +784,8 @@
 		zbx_strcpy_alloc(output, &size, &offset, string);
 	}
 
+	zabbix_log(LOG_LEVEL_WARNING, "End of regexp_sub_ex() ret: %d", ret, ZBX_NULL2STR(*output));
+
 	return ret;
 }
 
