From 7d13427ccf1f9bcf934a13d3bc9633c07f2ce6e3 Mon Sep 17 00:00:00 2001 From: Jacob Moody Date: Sun, 1 Dec 2024 00:39:27 +0000 Subject: [PATCH] flambe: right click to plumb functions also display percentage of base on hover --- sys/src/cmd/flambe.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/sys/src/cmd/flambe.c b/sys/src/cmd/flambe.c index 65ce63fa5..2cd72ef95 100644 --- a/sys/src/cmd/flambe.c +++ b/sys/src/cmd/flambe.c @@ -6,6 +6,7 @@ #include #include #include +#include typedef struct Data Data; @@ -100,6 +101,25 @@ name(ulong pc) return buf; } +static void +plumbpc(ulong pc) +{ + Symbol s; + char buf[256], wd[256]; + int fd; + + if(!findsym(pc, CTEXT, &s)) + return; + + fileline(buf, sizeof buf, pc); + fd = plumbopen("send", OWRITE); + if(fd < 0) + return; + getwd(wd, sizeof wd); + plumbsendtext(fd, "flambe", "edit", wd, buf); + close(fd); +} + int rowh; Image **cols; int ncols; @@ -149,7 +169,7 @@ onhover(int i) string(screen, r.min, display->black, ZP, font, name(data[i].pc)); r.min.y += font->height + 1; - snprint(buf, sizeof buf, "Time: %.8f(s), Calls: %lud", (double)data[i].time/cyclefreq, data[i].count); + snprint(buf, sizeof buf, "Time: %.8f(s) %.2f%%, Calls: %lud", (double)data[i].time/cyclefreq, (double)data[i].time/total * 100, data[i].count); string(screen, r.min, display->black, ZP, font, buf); flushimage(display, 1); } @@ -272,7 +292,7 @@ threadmain(int argc, char **argv) } break; case Cmouse: - if(m.buttons == 4 || m.buttons == 16){ + if(m.buttons == 16){ redraw(1); break; } @@ -286,6 +306,9 @@ threadmain(int argc, char **argv) case 1: case 8: redraw(i); break; + case 4: + plumbpc(data[i].pc); + break; } break; }