Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:26:08+00:00 2026-05-10T22:26:08+00:00

I am looking for a tool like ltrace or strace that can trace locally

  • 0

I am looking for a tool like ltrace or strace that can trace locally defined functions in an executable. ltrace only traces dynamic library calls and strace only traces system calls. For example, given the following C program:

#include <stdio.h>  int triple ( int x ) {   return 3 * x; }  int main (void) {   printf('%d\n', triple(10));   return 0; } 

Running the program with ltrace will show the call to printf since that is a standard library function (which is a dynamic library on my system) and strace will show all the system calls from the startup code, the system calls used to implement printf, and the shutdown code, but I want something that will show me that the function triple was called. Assuming that the local functions have not been inlined by an optimizing compiler and that the binary has not been stripped (symbols removed), is there a tool that can do this?

Edit

A couple of clarifications:

  • It is okay if the tool also provides trace information for non-local functions.
  • I don’t want to have to recompile the program(s) with support for specific tools, the symbol information in the executable should be enough.
  • I would be really nice if I could use the tool to attach to existing processes like I can with ltrace/strace.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:26:09+00:00Added an answer on May 10, 2026 at 10:26 pm

    Assuming you only want to be notified for specific functions, you can do it like this:

    compile with debug informations (as you already have symbol informations, you probably also have enough debugs in)

    given

    #include <iostream>  int fac(int n) {     if(n == 0)         return 1;     return n * fac(n-1); }  int main() {     for(int i=0;i<4;i++)         std::cout << fac(i) << std::endl; } 

    Use gdb to trace:

    [js@HOST2 cpp]$ g++ -g3 test.cpp [js@HOST2 cpp]$ gdb ./a.out (gdb) b fac Breakpoint 1 at 0x804866a: file test.cpp, line 4. (gdb) commands 1 Type commands for when breakpoint 1 is hit, one per line. End with a line saying just 'end'. >silent >bt 1 >c >end (gdb) run Starting program: /home/js/cpp/a.out #0  fac (n=0) at test.cpp:4 1 #0  fac (n=1) at test.cpp:4 #0  fac (n=0) at test.cpp:4 1 #0  fac (n=2) at test.cpp:4 #0  fac (n=1) at test.cpp:4 #0  fac (n=0) at test.cpp:4 2 #0  fac (n=3) at test.cpp:4 #0  fac (n=2) at test.cpp:4 #0  fac (n=1) at test.cpp:4 #0  fac (n=0) at test.cpp:4 6  Program exited normally. (gdb) 

    Here is what i do to collect all function’s addresses:

    tmp=$(mktemp) readelf -s ./a.out | gawk ' {    if($4 == 'FUNC' && $2 != 0) {      print '# code for ' $NF;      print 'b *0x' $2;      print 'commands';      print 'silent';      print 'bt 1';      print 'c';      print 'end';      print '';    }  }' > $tmp;  gdb --command=$tmp ./a.out;  rm -f $tmp 

    Note that instead of just printing the current frame(bt 1), you can do anything you like, printing the value of some global, executing some shell command or mailing something if it hits the fatal_bomb_exploded function 🙂 Sadly, gcc outputs some ‘Current Language changed’ messages in between. But that’s easily grepped out. No big deal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 79k
  • Answers 79k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Maybe you have found a deficiency in the database design.… May 11, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer For the Uploading part you might consider ActsAsAttachment or (as… May 11, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer There used to be such an (undocumented) option, up until… May 11, 2026 at 4:01 pm

Related Questions

I am investigating GDI leaks issue in one of our smart-client application. I am
i am looking for svn admin a desktop application like VisualSVN Server only for
This obviously requires the source file to be under source control. I would ideally
I am looking for a tool to display/track changes in text a little bit

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.