summaryrefslogtreecommitdiff
path: root/Src/Modules/zprof.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2022-04-11 00:18:04 +0200
committerAxel Beckert <abe@deuxchevaux.org>2022-04-11 00:18:04 +0200
commit31bcc5c263aea983e967426e2b94269e7605dcd4 (patch)
tree7b48ad9d7799afe09b7d7d8adc980bd5db935bdf /Src/Modules/zprof.c
parent5086b5356abcef8849dc8a09902b7c55f01db3c0 (diff)
parentb09f4483416c54c1782824633dfabaf2ec0265b6 (diff)
downloadzsh-31bcc5c263aea983e967426e2b94269e7605dcd4.tar.gz
zsh-31bcc5c263aea983e967426e2b94269e7605dcd4.zip
Update upstream source from tag 'upstream/5.8.1.2-test'
Update to upstream version '5.8.1.2-test' with Debian dir b380d582bf51cd93149e4dea28fffa1ad85db4f5
Diffstat (limited to 'Src/Modules/zprof.c')
-rw-r--r--Src/Modules/zprof.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/Src/Modules/zprof.c b/Src/Modules/zprof.c
index bc97771c0..56cdab888 100644
--- a/Src/Modules/zprof.c
+++ b/Src/Modules/zprof.c
@@ -213,7 +213,25 @@ bin_zprof(UNUSED(char *nam), UNUSED(char **args), Options ops, UNUSED(int func))
return 0;
}
-/**/
+static char *
+name_for_anonymous_function(char *name)
+{
+ char lineno[DIGBUFSIZE];
+ char *parts[7];
+
+ convbase(lineno, funcstack[0].flineno, 10);
+
+ parts[0] = name;
+ parts[1] = " [";
+ parts[2] = funcstack[0].filename ? funcstack[0].filename : "";
+ parts[3] = ":";
+ parts[4] = lineno;
+ parts[5] = "]";
+ parts[6] = NULL;
+
+ return sepjoin(parts, "", 1);
+}
+
static int
zprof_wrapper(Eprog prog, FuncWrap w, char *name)
{
@@ -224,12 +242,19 @@ zprof_wrapper(Eprog prog, FuncWrap w, char *name)
struct timeval tv;
struct timezone dummy;
double prev = 0, now;
+ char *name_for_lookups;
+
+ if (is_anonymous_function_name(name)) {
+ name_for_lookups = name_for_anonymous_function(name);
+ } else {
+ name_for_lookups = name;
+ }
if (zprof_module && !(zprof_module->node.flags & MOD_UNLOAD)) {
active = 1;
- if (!(f = findpfunc(name))) {
+ if (!(f = findpfunc(name_for_lookups))) {
f = (Pfunc) zalloc(sizeof(*f));
- f->name = ztrdup(name);
+ f->name = ztrdup(name_for_lookups);
f->calls = 0;
f->time = f->self = 0.0;
f->next = calls;