aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <[email protected]>2020-01-27 14:48:54 +0900
committerMITSUNARI Shigeo <[email protected]>2020-01-27 14:48:54 +0900
commit34f797e88f8cd172153e29b7833e331d28362741 (patch)
tree80138ad611fc758f14328dfecb4d8ccf59592334
parent6cc0f4dfc720ec19313ab0261bfbd2a3c483b10e (diff)
downloadxbyak-34f797e88f8cd172153e29b7833e331d28362741.tar.gz
xbyak-34f797e88f8cd172153e29b7833e331d28362741.zip
perf does not recognize too short function name
-rw-r--r--sample/profiler.cpp4
-rw-r--r--xbyak/xbyak_util.h14
2 files changed, 12 insertions, 6 deletions
diff --git a/sample/profiler.cpp b/sample/profiler.cpp
index 772e5c5..dc15d9b 100644
--- a/sample/profiler.cpp
+++ b/sample/profiler.cpp
@@ -6,7 +6,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#define XBYAK_NO_OP_NAMES
#include <xbyak/xbyak_util.h>
const int N = 3000000;
@@ -70,9 +69,6 @@ int main(int argc, char *argv[])
Xbyak::util::Profiler prof;
printf("mode=%d\n", mode);
prof.init(mode);
- /*
- func name must have three characters
- */
prof.set("f", (const void*)f, c.getSize());
prof.set("g", (const void*)g, c2.getSize());
diff --git a/xbyak/xbyak_util.h b/xbyak/xbyak_util.h
index 91b2e21..4f79d8f 100644
--- a/xbyak/xbyak_util.h
+++ b/xbyak/xbyak_util.h
@@ -1,5 +1,6 @@
#ifndef XBYAK_XBYAK_UTIL_H_
#define XBYAK_XBYAK_UTIL_H_
+#include <string.h>
/**
utility class and functions for Xbyak
@@ -759,7 +760,7 @@ public:
};
Profiler()
: mode_(None)
- , suffix_(0)
+ , suffix_("")
, startAddr_(0)
#ifdef XBYAK_USE_PERF
, fp_(0)
@@ -833,7 +834,16 @@ public:
#ifdef XBYAK_USE_PERF
if (mode_ == Perf) {
if (fp_ == 0) return;
- fprintf(fp_, "%llx %zx %s%s\n", (long long)startAddr, funcSize, funcName, suffix_);
+ fprintf(fp_, "%llx %zx %s%s", (long long)startAddr, funcSize, funcName, suffix_);
+ /*
+ perf does not recognize the function name which is less than 3,
+ so append '_' at the end of the name if necessary
+ */
+ size_t n = strlen(funcName) + strlen(suffix_);
+ for (size_t i = n; i < 3; i++) {
+ fprintf(fp_, "_");
+ }
+ fprintf(fp_, "\n");
fflush(fp_);
}
#endif