* GDB Trace functions calls when executing a program
@ 2018-02-28 15:19 Satya Prakash Prasad
2018-03-07 1:44 ` Yubin Ruan
0 siblings, 1 reply; 4+ messages in thread
From: Satya Prakash Prasad @ 2018-02-28 15:19 UTC (permalink / raw)
To: gdb-info, gdb-faq, gdb
Please let me know if in GDB there is a way to print function names when
program is executing - this is to just track / trace the code flow.
Generally in projects which has thousands of lines of code - it is very
difficult to trace a flow. The first is to decide where to put a breakpoint
for analysis. But to know the place to put breakpoint we need to know where
to enable it - I mean it should be within a function of a flow.
So can we just enable some command and let the program when running using
gdb - gdb can simply print functions name as it executes them.
Is the same possible?
Regards,
Prakash
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GDB Trace functions calls when executing a program
2018-02-28 15:19 GDB Trace functions calls when executing a program Satya Prakash Prasad
@ 2018-03-07 1:44 ` Yubin Ruan
2018-03-07 6:17 ` Satya Prakash Prasad
0 siblings, 1 reply; 4+ messages in thread
From: Yubin Ruan @ 2018-03-07 1:44 UTC (permalink / raw)
To: Satya Prakash Prasad; +Cc: gdb-info, gdb-faq, gdb
On Wed, Feb 28, 2018 at 08:49:17PM +0530, Satya Prakash Prasad wrote:
> Please let me know if in GDB there is a way to print function names when
> program is executing - this is to just track / trace the code flow.
>
> Generally in projects which has thousands of lines of code - it is very
> difficult to trace a flow. The first is to decide where to put a breakpoint
> for analysis. But to know the place to put breakpoint we need to know where
> to enable it - I mean it should be within a function of a flow.
>
> So can we just enable some command and let the program when running using
> gdb - gdb can simply print functions name as it executes them.
>
> Is the same possible?
Do you have access to the source? If so, why not simply add a print at the
very beginning of every function call:
print("function called: %s\n", __FUNC__);
I know that strace can be used to trace system calls, but not normal function
calls. Maybe try LTTng: https://lttng.org/
Yubin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GDB Trace functions calls when executing a program
2018-03-07 1:44 ` Yubin Ruan
@ 2018-03-07 6:17 ` Satya Prakash Prasad
2018-03-07 6:46 ` Jonah Graham
0 siblings, 1 reply; 4+ messages in thread
From: Satya Prakash Prasad @ 2018-03-07 6:17 UTC (permalink / raw)
To: Yubin Ruan; +Cc: gdb-info, gdb-faq, gdb
Thanks for the details - please note that I am using Win7 and MingW for our
project and the LTTng tools is only for *nix platform. Can you please let
me know similar tool for Windows.
Also inserting printf in each function call is not possible cause it would
take long hours and effort for a code spreading thousands of lines.
Regards,
Prakash
On Thu, Mar 8, 2018 at 7:14 AM, Yubin Ruan <ablacktshirt@gmail.com> wrote:
> On Wed, Feb 28, 2018 at 08:49:17PM +0530, Satya Prakash Prasad wrote:
> > Please let me know if in GDB there is a way to print function names when
> > program is executing - this is to just track / trace the code flow.
> >
> > Generally in projects which has thousands of lines of code - it is very
> > difficult to trace a flow. The first is to decide where to put a
> breakpoint
> > for analysis. But to know the place to put breakpoint we need to know
> where
> > to enable it - I mean it should be within a function of a flow.
> >
> > So can we just enable some command and let the program when running using
> > gdb - gdb can simply print functions name as it executes them.
> >
> > Is the same possible?
>
> Do you have access to the source? If so, why not simply add a print at the
> very beginning of every function call:
>
> print("function called: %s\n", __FUNC__);
>
> I know that strace can be used to trace system calls, but not normal
> function
> calls. Maybe try LTTng: https://lttng.org/
>
> Yubin
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GDB Trace functions calls when executing a program
2018-03-07 6:17 ` Satya Prakash Prasad
@ 2018-03-07 6:46 ` Jonah Graham
0 siblings, 0 replies; 4+ messages in thread
From: Jonah Graham @ 2018-03-07 6:46 UTC (permalink / raw)
To: Satya Prakash Prasad; +Cc: Yubin Ruan, gdb-info, gdb-faq, gdb
On 7 Mar 2018 06:17, "Satya Prakash Prasad" <satyaprakash.prasad@gmail.com>
wrote:
Also inserting printf in each function call is not possible cause it would
take long hours and effort for a code spreading thousands of lines.
You can let the compiler do the heavy lifting by using
-finstrument-functions
Here is a nice blog post about it
https://mcuoneclipse.com/2015/04/04/poor-mans-trace-free-of-charge-function-entryexit-trace-with-gnu-tools/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-07 6:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 15:19 GDB Trace functions calls when executing a program Satya Prakash Prasad
2018-03-07 1:44 ` Yubin Ruan
2018-03-07 6:17 ` Satya Prakash Prasad
2018-03-07 6:46 ` Jonah Graham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox