linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Better error messages for 'perf probe --add'
@ 2024-04-16  4:55 Dima Kogan
  2024-04-16  4:55 ` [PATCH 1/2] perf probe-event: un-hardcoded sizeof(buf) Dima Kogan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dima Kogan @ 2024-04-16  4:55 UTC (permalink / raw)
  To: linux-perf-users; +Cc: Dima Kogan

Hi.

I tried to add some userspace probes to some C++ code, and got this:

  $ sudo perf probe -x tst --add _ZN.....
  Error: Failed to add events.

Note the completely non-useful error message. The issue is that the C++ symbol
mangling can create very loooong symbol names, causing perf to try to use very
long probe names by default, causing this problem. It took a little while to
figure this out, and a better error message would have helped, hence these
patches.

To reproduce, here's a tst.cc:

  #include <stdio.h>

  namespace n1111111111111111111111111111111111111111111111111111111111111111 {
      namespace n2222222222222222222222222222222222222222222222222222222222222222 {

          void f(void)
          {
              printf("f()\n");
          }
      }
  }

  int main(void)
  {
      n1111111111111111111111111111111111111111111111111111111111111111::n2222222222222222222222222222222222222222222222222222222222222222::f();
      n1111111111111111111111111111111111111111111111111111111111111111::n2222222222222222222222222222222222222222222222222222222222222222::f();
      return 0;
  }

I then

  g++ -g -o tst tst.cc

and

  sudo perf probe -x ~/tmp/tst --add _ZN65n111111111111111111111111111111111111111111111111111111111111111165n22222222222222222222222222222222222222222222222222222222222222221fEv

After the patch a better error message results, and the workaround is clear:

  sudo perf probe -x ~/tmp/tst --add probe=_ZN65n111111111111111111111111111111111111111111111111111111111111111165n22222222222222222222222222222222222222222222222222222222222222221fEv

Dima Kogan (2):
  perf probe-event: un-hardcoded sizeof(buf)
  perf probe-event: better error message for a too-long probe name

 tools/perf/util/probe-event.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.42.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-18 14:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16  4:55 [PATCH 0/2] Better error messages for 'perf probe --add' Dima Kogan
2024-04-16  4:55 ` [PATCH 1/2] perf probe-event: un-hardcoded sizeof(buf) Dima Kogan
2024-04-16  4:55 ` [PATCH 2/2] perf probe-event: better error message for a too-long probe name Dima Kogan
2024-04-16 15:46 ` [PATCH 0/2] Better error messages for 'perf probe --add' Arnaldo Carvalho de Melo
2024-04-17 20:35   ` Masami Hiramatsu
2024-04-18 14:24     ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).