Linux.com

GDB_Question

GDB_Question

  • Linux.com Member
  • Posts: 2
  • Member Since: 11 Sep 11
  • Last Logged In: 11 Sep 11

Latest Posts

Posted by
Topic
Post Preview
Posted
  • GDB_Question
    GDB singals waiting tasks when debugging my code
    Hello, I found out a problem when I run my code on linux on debug mode (it never happens when I run the exe file). On my code I use few tasks. On the start of running my code I send all of them to wait, using the command: sem_wait. Example: while (rc==-1) { rc = sem_wait(&m_sem); } Eventhough, sometimes my tasks are waking up without any reason. I did few searches, and I found out that the GDB signals my tasks and it is a known error. The solution that people offered is the following code: while (rc==-1) { rc = sem_wait(&m_sem); if (rc==-1 && errno == EINTR) { continue; } else { break; } } I am using Rhapsody 7.5.3 (for writing my code), and on Rhapsody's framework files I have the following code: while (rc==-1) { rc = sem_wait(&m_sem); #ifdef OM_SEMAPHORE_CAN_BE_INTERRUPTED if (rc==-1 && errno == EINTR) { continue; } else { #endif break; } } Like you can see, compile my code with the OM_SEMAPHORE_CAN_BE_INTERRUPTED can solve the problem. But, this is a lib file for me. Therefore, If I will change that flag for debug, it will be also changed when I execute my (as an exe file). Do you think it can create another problem for me or is it ok?
    Link to this post 11 Sep 11

    Hello,
    I found out a problem when I run my code on linux on debug mode (it never happens when I run the exe file).
    On my code I use few tasks. On the start of running my code I send all of them to wait, using the command: sem_wait.
    Example:
    while (rc==-1)
    {
    rc = sem_wait(&m_sem);
    }

    Eventhough, sometimes my tasks are waking up without any reason.
    I did few searches, and I found out that the GDB signals my tasks and it is a known error.
    The solution that people offered is the following code:
    while (rc==-1)
    {
    rc = sem_wait(&m_sem);
    if (rc==-1 && errno == EINTR)
    {
    continue;
    }
    else
    {
    break;
    }
    }

    I am using Rhapsody 7.5.3 (for writing my code), and on Rhapsody's framework files I have the following code:
    while (rc==-1)
    {
    rc = sem_wait(&m_sem);
    #ifdef OM_SEMAPHORE_CAN_BE_INTERRUPTED
    if (rc==-1 && errno == EINTR)
    {
    continue;
    }
    else
    {
    #endif
    break;
    }
    }

    Like you can see, compile my code with the OM_SEMAPHORE_CAN_BE_INTERRUPTED can solve the problem.
    But, this is a lib file for me. Therefore, If I will change that flag for debug, it will be also changed when I execute my (as an exe file).
    Do you think it can create another problem for me or is it ok?

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board