public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: "李硕(lishuo122587 - 新诛仙世界服务器组)" <lishuo122587@pwrd.com>,
	"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: hello, is there anyway to count number of executed instructions of a function
Date: Wed, 07 Sep 2022 22:50:49 +0200	[thread overview]
Message-ID: <4f5098c4dd3286c730408e18a31e2f625a820fe5.camel@skynet.be> (raw)
In-Reply-To: <7029d52e99714f9f856611e625351bbb@pwrd.com>

On Fri, 2022-09-02 at 11:16 +0000, 李硕(lishuo122587 - 新诛仙世界服务器组) wrote:
> Dear programmers,
>        Hello, I’m a newer, does someone known how to count number of executed instructions of a function?
> 
> Yours, sincerely
> 
> 从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>发送
> 

To my knowledge, GDB does not have such a feature.
But for sure, there are various tools that can do that.
E.g. see valgrind  https://valgrind.org/docs/manual/manual.html 
and in particular the sections about callgrind and cachegrind (and possibly
the lackey tool).
Note that kcachegrind is a nice visualisation tool for callgrind output.

On linux, the "perf" command might also do what you want (significantly faster than
valgrind, which have a high performance impact).

Philippe





      reply	other threads:[~2022-09-07 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 11:16 李硕(lishuo122587 - 新诛仙世界服务器组)
2022-09-07 20:50 ` Philippe Waroquiers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f5098c4dd3286c730408e18a31e2f625a820fe5.camel@skynet.be \
    --to=philippe.waroquiers@skynet.be \
    --cc=gdb@sourceware.org \
    --cc=lishuo122587@pwrd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).