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

  • SEARCH
  • Home
  • 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 8550757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:01:39+00:00 2026-06-11T14:01:39+00:00

I use -finstrument-functions to generated enter and exit information of my each function call

  • 0

I use -finstrument-functions to generated enter and exit information of my each function call and use dot to draw it just like above. However, I found one problem, in my main function, I create two threads, one called driver_TASL, another is keyBoard_TASK. but in my generated picture, It seems like my keyBoard_TASK was called by driver_TASK. It should be like these two TASK called by main

Remark: I can NOT upload picture, so I describe it below:

after I generate function call, it should be like:

  • main call driver_TASK
  • main call keyBoard_TASK

however, it becomes

  • main call driver_TASK
  • driver_TASK call keyboard_TASK

Why the keyBoard_TASK was called by driver_TASK? It should be called by main I think

In my source code, I wrote them like (I deleted some print functions in code):

int main(/*@ unused @*/int argc, /*@ unused @*/char *argv[]) //comment for lint
{
    int         res;
    pthread_t   driver_thread, keyBoard_thread;
    void        *thread_result;

    res = pthread_create(&driver_thread, NULL, driver_TASK, (void *)&_gDriverStatus);
    if(res != 0)
    {
        perror("Thread Creation Failed");
        exit(EXIT_FAILURE);
    }

    sleep(1);

    res = pthread_create(&keyBoard_thread, NULL, keyBoard_TASK, (void *)&_gKeyStatus);
    if(res != 0)
    {
        perror("Thread Creation Failed");
        exit(EXIT_FAILURE);
    }

    res = pthread_join(driver_thread, &thread_result);
    if(res != 0)
    {
        perror("Thread Join Failed");
        exit(EXIT_FAILURE);
    }

    res = pthread_join(keyBoard_thread, &thread_result);
    if(res != 0)
    {
        perror("Thread Join Failed");
        exit(EXIT_FAILURE);
    }

    exit(EXIT_SUCCESS);
}

I also attached my automatically dot file, the function call flow chart is automatically generated by pvtace

digraph DEMO {

  main [shape=rectangle]
  driver_TASK [shape=rectangle]
  DDI_DRIVER_Probe [shape=rectangle]
  _Driver_Clear [shape=ellipse]
  _Driver [shape=ellipse]
  DRIVER_Probe_Demo [shape=ellipse]
  DDI_DRIVER_Init [shape=rectangle]
  DRIVER_Init_Demo [shape=rectangle]
  _DRIVER_Init_Demo [shape=ellipse]
  DDI_DRIVER_Running [shape=rectangle]
  DRIVER_Running_Demo [shape=rectangle]
  _DRIVER_Running_Demo [shape=ellipse]
  keyBoard_TASK [shape=rectangle]
  main -> DBG_PrintColor [label="2 calls" fontsize="10"]
  main -> driver_TASK [label="1 calls" fontsize="10"] //this is correct
  driver_TASK -> DBG_PrintColor [label="6 calls" fontsize="10"]
  driver_TASK -> DDI_DRIVER_Probe [label="1 calls" fontsize="10"]
  driver_TASK -> DDI_DRIVER_Init [label="1 calls" fontsize="10"]
  driver_TASK -> DDI_DRIVER_Running [label="1 calls" fontsize="10"]
  driver_TASK -> keyBoard_TASK [label="1 calls" fontsize="10"] //this is not correct
  DDI_DRIVER_Probe -> _Driver_Clear [label="1 calls" fontsize="10"]
  DDI_DRIVER_Probe -> _Driver [label="1 calls" fontsize="10"]
  DDI_DRIVER_Probe -> DRIVER_Probe_Demo [label="1 calls" fontsize="10"]
  DDI_DRIVER_Init -> _Driver [label="1 calls" fontsize="10"]
  DDI_DRIVER_Init -> DRIVER_Init_Demo [label="1 calls" fontsize="10"]
  DRIVER_Init_Demo -> _DRIVER_Init_Demo [label="1 calls" fontsize="10"]
  DDI_DRIVER_Running -> _Driver [label="1 calls" fontsize="10"]
  DDI_DRIVER_Running -> DRIVER_Running_Demo [label="1 calls" fontsize="10"]
  DRIVER_Running_Demo -> _DRIVER_Running_Demo [label="1 calls" fontsize="10"]
  keyBoard_TASK -> DBG_PrintColor [label="6 calls" fontsize="10"]

}
  • 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. Editorial Team
    Editorial Team
    2026-06-11T14:01:40+00:00Added an answer on June 11, 2026 at 2:01 pm

    I assume that you are using the ‘instrumental’ library for collecting the call graph information (if not, you should indicate what you are using and/or what you do do in the __cyg_profile_func_enter() and __cyg_profile_func_exit() routines).

    Looking at the implementation (available at http://www.suse.de/~krahmer/instrumental/), it’s clear that the call graph information is not collected in a thread safe manner. Each function called is simply recorded in the log file as it’s called, and the depth of the call graph is kept in a global variable (actually a static variable). Information about the call chain is also kept in a global array.

    So what’s happening is that something along the following line of events occurs:

    __cyg_profile_func_enter()  - for main() on main thread
    __cyg_profile_func_enter()  - for driver_TASK() on driver_thread
    __cyg_profile_func_enter()  - for keyBoard_TASK() on keyboard_thread
    
    ...
    

    The fact that these events happen to occur in this order, without intervening __cyg_profile_func_exit() events means that the instrumental library records things as if:

    main()
    |
    +--- driver_TASK()
         |
         +--- keyBoard_TASK()
    

    When there really should be separate call graphs for each thread (which would require thread awareness in the instrumentation). To fix the problem, you’ll need to do one of the following:

    • find an instrumentation library that’s thread aware
    • add thread awareness to the one you’re using now
    • fix up the generated logs by hand (which might be simple if the thread functions are relatively simple, but could turn out to be a large/complicated task)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to use gcc -fdump-rtl-expand and -finstrument-functions to do function call tracing, does
I'm looking for some performance test results for -finstrument-functions . I'm considering to use
I'm doing a app like photo browser just like the Photo on iTOuch. And
How can I use apply or a related function to create a new data
I recently read about using GCC's code generation features (specifically, the -finstrument-functions compiler flag)
I want to lazy load of @Lob properties. First ,i use javassist to instrument
What is the maximum memory one application can use? Please find instrument screenshot with
Use Case Show a photo uploaded by the user in a square box with
use C#,want to upload excel file on google doc. bellow syntax use to upload
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );

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.