locked
Updating threads name from VS 2013 Threads window (after a breakpoint is hit?) RRS feed

  • Question

  • Hi all,

    as we already know, the RaiseException approach is generally used for setting the thread name inside the VS IDE Threads window.

    This works fine for the case when the number of thread name changes is low.

    Otherwise the time while debugging grows up to 4-5x times (in our case) due to the thread name updates.


    I am not familiar with VS integration approaches for my problem. However I would happily ask here if there is an event based approach for updating the thread name inside the VS 2013 Threads window from outside my C++ application, after a debugger break-point is hit or something similar.  This would eliminate the need of setting the thread name each time in my C++ code and would be done only when the debugger break-point is hit -- and thus will not influence performance.

    Basically this "plugin/addon" would have to:

    - wait for a breakpoint to be hit

    - iterate through all available threads in the active process

       - grab the thread name from a private member (Thread::_name)

       - update the VS IDE Threads window with the above thread name.

    Any ideas if such a plugin/addon is already available? .. or how it could be created?

    Kind regards,

    Marius



    • Edited by MariusDe Wednesday, May 14, 2014 7:30 AM
    Wednesday, May 14, 2014 7:29 AM

Answers

All replies

  • Hi,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    We will let you know if any progress is made.

    Sorry for any inconvenience.

    Best regards,

    Friday, May 16, 2014 8:20 AM
  • Hi Anna and thanks for your support!

    Sure, I will patiently wait.

    Please let me know if I can help with validating the prototype solution your colleagues might have.

    Kind regards,

    Marius

    Monday, May 19, 2014 6:28 AM
  • Hi Anna, is there perhaps any news regarding this issue?

    Thanks!

    Tuesday, July 8, 2014 12:17 PM
  • What the C++ application are you developing? Is it a visual studio addin? Why your C++ code need update thread name?

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Jacky Wu
    Microsoft Online Community Support

    Tuesday, July 15, 2014 10:03 AM
  • Hi Jacky and thanks for your message,

    as mentioned above, my application is a normal C++ application (and not VisualStudio addin) which needs to update the thread name frequently, as there are many threads running in parallel, so when a break-point is hit one has two choices:

    - in the VS Threads window, browse through each thread call-stack and then find the "right" thread name stored in some member variable inside a given class (this is OK when one has under 5 threads, but for more threads this is not optimal..)

    - or have the name of the threads in the VS Threads window and go directly to the one which is of interest.

    Kind regards,

    Marius

    Monday, August 11, 2014 11:32 AM
  • Your request could be achieved by IDebugThread2 interface, you can refer to http://msdn.microsoft.com/en-us/library/bb145332.aspx , as you can see the interface supports GetName and SetThreadName. You can refer to the samples in http://code.msdn.microsoft.com/site/search?f%5B0%5D.Type=Contributors&f%5B0%5D.Value=Microsoft%20-%20Visual%20Studio%20Platform%20Team&f%5B0%5D.Text=Visual%20Studio%20Platform%20team about how to begin a VS plug in.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Jacky Wu
    Microsoft Online Community Support

    • Marked as answer by MariusDe Thursday, September 25, 2014 12:01 PM
    Saturday, August 30, 2014 12:40 PM
  • Hi Jacky and thank you for your help!

    I shortly took a look over the suggested links and it seems to be what I am looking for.So I'll mark this as answered. I would however mention here IEnumDebugThreads2 API as well, for iterating over the available threads:

    http://msdn.microsoft.com/en-us/library/bb145142.aspx

    Now my last question is: can I access from the VS plug-in a certain static method (or a member variable from a class) from the application under debug (as the application being debugged contains the thread name which will have to be set using SetThreadName when a Breakpoint is reached).

    Kind regards,

    Marius


    • Edited by MariusDe Thursday, September 25, 2014 12:02 PM update
    Thursday, September 25, 2014 12:01 PM