How to debug int _Mtx_lock(_Mtx_t mtx) inside mutex.c

GHANASHYAM SATPATHY 301 Reputation points
2020-12-08T16:03:39.937+00:00

I am having a hard time to debug the int _Mtx_lock(_Mtx_t mtx) function defined inside mutex.c

I could debug upto following implementation inside \include\mutex
void lock() {
_Check_C_return(_Mtx_lock(_Mymtx()));
}

However debug control never goes inside _Mtx_lock(), putting a breakpoint says "The Breakpoint currently will not be hit. No symbols have been loaded for this document"

I am using VS2019 Community edition,Version 16.8.2

Just trying to debug following code,
int mt_val = 0;
std::mutex mx;
{
std::lock_guard<std::mutex> gd(mx);
mt_val++;
}

Any help in this regard is highly appreciated.

Thanks

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,578 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,519 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
935 questions
0 comments No comments
{count} votes

Accepted answer
  1. GHANASHYAM SATPATHY 301 Reputation points
    2020-12-09T10:54:51.693+00:00

    > you should also configure the VS debugger to load symbols.

    What extra settings need to be done for this?


11 additional answers

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,406 Reputation points
    2020-12-09T02:57:52.76+00:00

    Hi GHANASHYAMSATPATHY,

    You could go to Tools/Options/Debugging/General, then disable "Enable just my code"
    46493-image.png

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**

    0 comments No comments

  2. GHANASHYAM SATPATHY 301 Reputation points
    2020-12-09T03:16:21.27+00:00

    I disabled "Enable just my code" from Tools/Options/Debugging/General and still see the same issue. Restarted the Visual Studio also , however issue still persists.

    I can't debug _Mtx_lock(_Mtx_t mtx) function defined inside mutex.c

    Thanks


  3. Guido Franzke 2,196 Reputation points
    2020-12-09T07:46:55.313+00:00

    Hello,
    it is a function in Visual Studio. If the function is not defined in the header file, then you cannot debug the source code because it's hidden in a library.

    Have a look at this example: lock_guard
    IMO if you think that you have problems with the function, it should already be a problem in your source code before. How do use the class? Please provide more information.

    Regards, Guido

    0 comments No comments

  4. GHANASHYAM SATPATHY 301 Reputation points
    2020-12-09T08:07:51.66+00:00

    I am trying to use and debug following code, similar to example you have shown.

    int mt_val = 0;
    std::mutex mx;
    {
    std::lock_guard<std::mutex> gd(mx);
    mt_val++;
    }

    And my intent is to debug _Mtx_lock(_Mtx_t mtx) function defined inside crt\src\stl\mutex.c which I am not able to. I am able to debug following and get inside of following implementation inside \include\mutex

    void lock() {
    _Check_C_return(_Mtx_lock(_Mymtx()));
    }