summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--Makefile.in4
-rw-r--r--main.cxx3
-rw-r--r--runtime/staprun/common.c112
-rw-r--r--stap.1.in3
-rw-r--r--staprun.8.in3
6 files changed, 14 insertions, 115 deletions
diff --git a/Makefile.am b/Makefile.am
index 33563719..c9e123fb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -133,7 +133,7 @@ staprun_SOURCES = runtime/staprun/staprun.c runtime/staprun/staprun_funcs.c\
runtime/staprun/ctl.c runtime/staprun/common.c
staprun_CPPFLAGS = $(AM_CPPFLAGS)
-staprun_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -DSINGLE_THREADED -fno-strict-aliasing
+staprun_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -DSINGLE_THREADED -fno-strict-aliasing -fno-builtin-strftime
staprun_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
staprun_LDADD = @PROCFLAGS@
@@ -141,7 +141,7 @@ stapio_SOURCES = runtime/staprun/stapio.c \
runtime/staprun/mainloop.c runtime/staprun/common.c \
runtime/staprun/ctl.c \
runtime/staprun/relay.c runtime/staprun/relay_old.c
-stapio_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -fno-strict-aliasing
+stapio_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -fno-strict-aliasing -fno-builtin-strftime
stapio_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
stapio_LDADD = @PROCFLAGS@ -lpthread
diff --git a/Makefile.in b/Makefile.in
index 9c80e321..4fc0c8ff 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -342,7 +342,7 @@ staprun_SOURCES = runtime/staprun/staprun.c runtime/staprun/staprun_funcs.c\
runtime/staprun/ctl.c runtime/staprun/common.c
staprun_CPPFLAGS = $(AM_CPPFLAGS)
-staprun_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -DSINGLE_THREADED -fno-strict-aliasing
+staprun_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -DSINGLE_THREADED -fno-strict-aliasing -fno-builtin-strftime
staprun_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
staprun_LDADD = @PROCFLAGS@
stapio_SOURCES = runtime/staprun/stapio.c \
@@ -350,7 +350,7 @@ stapio_SOURCES = runtime/staprun/stapio.c \
runtime/staprun/ctl.c \
runtime/staprun/relay.c runtime/staprun/relay_old.c
-stapio_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -fno-strict-aliasing
+stapio_CFLAGS = @PROCFLAGS@ $(AM_CFLAGS) @PIECFLAGS@ -fno-strict-aliasing -fno-builtin-strftime
stapio_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
stapio_LDADD = @PROCFLAGS@ -lpthread
@BUILD_SERVER_TRUE@stap_client_connect_SOURCES = stap-client-connect.c
diff --git a/main.cxx b/main.cxx
index 37c5b135..1111b316 100644
--- a/main.cxx
+++ b/main.cxx
@@ -109,8 +109,7 @@ usage (systemtap_session& s, int exitcode)
<< " -m MODULE set probe module name, instead of " << endl
<< " " << s.module_name << endl
<< " -o FILE send script output to file, instead of stdout. This supports" << endl
- << " a subset of strftime(3) (%%,%C,%Y,%y,%m,%d,%e,%F,%H,%I,%j,%k," << endl
- << " %l,%M,%S,%R,%T,%u,%w) for FILE." << endl
+ << " strftime(3) formats for FILE" << endl
<< " -c CMD start the probes, run CMD, and exit when it finishes" << endl
<< " -x PID sets target() to PID" << endl
<< " -F run as on-file flight recorder with -o." << endl
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index 26b166c2..c67ce340 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -55,112 +55,15 @@ static char *get_abspath(char *path)
int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t)
{
- char *c = buf;
- const char *c2 = fmt, *end = buf + max;
- int ret, num;
struct tm tm;
+ size_t ret;
if (buf == NULL || fmt == NULL || max <= 1)
return -EINVAL;
localtime_r(&t, &tm);
-
- while (*c2 != '\0'){
- if (c + 1 >= end)
- return -EINVAL;
- if (*c2 != '%') {
- *c++ = *c2++;
- continue;
- }
- c2++;
- switch (*c2++) {
- case '%':
- *c++ = '%';
- break;
- case 'Y':
- num = tm.tm_year + 1900;
- goto numbering;
- case 'y':
- num = tm.tm_year % 100;
- goto numbering02;
- case 'C':
- num = ((tm.tm_year + 1900) / 100);
- goto numbering;
- case 'm':
- num = tm.tm_mon + 1;
- goto numbering02;
- case 'd':
- num = tm.tm_mday;
- goto numbering02;
- case 'e':
- num = tm.tm_mday;
- goto numbering;
- case 'F':
- ret = snprintf(c, end - c, "%d-%02d-%02d",
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
- if (ret < 0) return ret;
- c += ret;
- break;
- case 'H':
- num = tm.tm_hour;
- goto numbering02;
- case 'I':
- num = tm.tm_hour % 12;
- if (num == 0) num = 12;
- goto numbering02;
- case 'j':
- ret = snprintf(c, end - c, "%03d", tm.tm_yday + 1);
- if (ret < 0) return ret;
- c += ret;
- break;
- case 'k':
- num = tm.tm_hour;
- goto numbering;
- case 'l':
- num = tm.tm_hour % 12;
- if (num == 0) num = 12;
- ret = snprintf(c, end - c, "%2d", num);
- if (ret < 0) return ret;
- c += ret;
- break;
- case 'M':
- num = tm.tm_min;
- goto numbering02;
- case 'S':
- num = tm.tm_sec;
- goto numbering02;
- case 'R':
- ret = snprintf(c, end - c, "%02d:%02d",
- tm.tm_hour, tm.tm_min);
- if (ret < 0) return ret;
- c += ret;
- break;
- case 'T':
- ret = snprintf(c, end - c, "%02d:%02d:%02d",
- tm.tm_hour, tm.tm_min, tm.tm_sec);
- if (ret < 0) return ret;
- c += ret;
- break;
- case 'u':
- num = tm.tm_wday == 0 ? 7 : tm.tm_wday;
- goto numbering;
- case 'w':
- num = tm.tm_wday;
- goto numbering;
- default:
- return -EINVAL;
- }
- continue;
-numbering:
- ret = snprintf(c, end - c, "%d", num);
- if (ret < 0) return ret;
- c += ret;
- continue;
-numbering02:
- ret = snprintf(c, end - c, "%02d", num);
- if (ret < 0) return ret;
- c += ret;
- }
- *c = '\0';
- return c - buf;
+ ret = strftime(buf, max, fmt, &tm);
+ if (ret == 0)
+ return -EINVAL;
+ return (int)ret;
}
void parse_args(int argc, char **argv)
@@ -309,9 +212,8 @@ void usage(char *prog)
err(" exit when it does. The '_stp_target' variable\n");
err(" will contain the pid for the command.\n");
err("-x pid Sets the '_stp_target' variable to pid.\n");
- err("-o FILE Send output to FILE. This supports a subset of\n");
- err(" strftime(3) (%%%%,%%C,%%Y,%%y,%%m,%%d,%%e,%%F,%%H,%%I\n");
- err(" %%j,%%k,%%l,%%M,%%S,%%R,%%T,%%u,%%w) for FILE.\n");
+ err("-o FILE Send output to FILE. This supports strftime(3)\n");
+ err(" formats for FILE.\n");
err("-b buffer size The systemtap module specifies a buffer size.\n");
err(" Setting one here will override that value. The\n");
err(" value should be an integer between 1 and 4095 \n");
diff --git a/stap.1.in b/stap.1.in
index 82a62b6d..aed473d7 100644
--- a/stap.1.in
+++ b/stap.1.in
@@ -181,8 +181,7 @@ even if they do not have an explicit probe placed into them.
.BI \-o " FILE"
Send standard output to named file. In bulk mode, percpu files will
start with FILE_ (FILE_cpu with -F) followed by the cpu number.
-This supports a subset of strftime(3) (%%, %C, %Y, %y, %m, %d, %e, %F,
-%H, %I, %j, %l, %M, %S, %R, %T, %u, %w) for FILE.
+This supports strftime(3) formats for FILE.
.TP
.BI \-c " CMD"
Start the probes, run CMD, and exit when CMD finishes.
diff --git a/staprun.8.in b/staprun.8.in
index 5d2a72a6..b9993288 100644
--- a/staprun.8.in
+++ b/staprun.8.in
@@ -53,8 +53,7 @@ The '_stp_target' variable will be set to PID.
.B \-o FILE
Send output to FILE. If the module uses bulk mode, the output will
be in percpu files FILE_x(FILE_cpux in backgroud and bulk mode)
-where 'x' is the cpu number. This supports a subset of strftime(3)
-(%%, %C, %Y, %y, %m, %d, %e, %F, %H, %I, %j, %l, %M, %S, %R, %T, %u, %w)
+where 'x' is the cpu number. This supports strftime(3) formats
for FILE.
.TP
.B \-b BUFFER_SIZE