Unable to debug std::map when cmake is configured with flag -std=c++11

Sysprogs forums Forums VisualGDB Unable to debug std::map when cmake is configured with flag -std=c++11

Viewing 15 posts - 1 through 15 (of 27 total)
  • Author
    Posts
  • #7402
    marrtin
    Participant

    Hi

    I am unable to debug node based STL containers when my project is compiled with flag -std=c++11. I am using Visual studio 2015 and VisualGDB 5.0.

    For the test purpose I have created this simple project.

    int main(int argc, char *argv[])
    {
        std::vector<std::string> vect;
    
        vect.push_back("dd");
        vect.push_back("ee");
        std::map<int, string> partial;
        partial[1] = "dd";
        partial[2] = "ee"; // assigned non typical c++11 way - possible compile without c++11
    }

    In debugger I can read the content of vector, but not std::map. I use compiled toolchain (arm poky linux gnueaby – for yocto linux). The problem of printing content of std::map I have only in Visual Studio with VisualGDB From Eclipse I can set .gdbinit with pretty python printers and it works well. I want to use Visual studio, but our project use several c++11 features. Can you advise me, how to fix it?

    #7406
    support
    Keymaster

    Hi,

    Thanks for reporting this. We have fixed it in this build: http://sysprogs.com/files/tmp/VisualGDB-5.1.0.613.msi

    #7438
    marrtin
    Participant

    Now it’s possible to debug the maps which are declared without typedef

    Snippet

    std::map<int32_t, std::string> myMap; // this is printed in debugger well
    

    But the typedef are used for maps very often. Our project contains lot of typedefs for containers

    when I trye to debug something like

    Snippet

    typedef std::map< int32_t, std::string > HandleValueT;
    

    no pretty output is still printed in debugger

     

     

    #7445
    support
    Keymaster

    Hi,

    This is a known limitation. The problem is that for typedef’ed types GDB reports the typedef name instead of the actual type name and resolving each unknown type would have a significant performance impact.

    #7447
    marrtin
    Participant

    I am not an expert how does GDB works, so hopefully you will explain me this.

    The same GDB called from other IDE for example QtCreator is able to print it.

    I want to use Visual Studio it’s the best IDE for me, but now I have to sometimes switch on Qt creator on my remote machine when I need to debug similar problems.

    How can the second tool to print the typedefs correctly?

    I have now commercial version of VisualGDB, so I am using it as my primary tool.

     

    2.Yesterday I found another interesting problem.

    I have initialization function in my class where some objects are created by using new operator. When I give the breakpoint in this init function where the certain object is created (by using new operator) and then I step into new operator and in the object’s constructor I can debug it without problems.

    But when I have no breakpoint in my init function and I let the breakpoint only in object’s constructor, this breakpoint is never hit.

    I don’t know why?

     

    #7471
    support
    Keymaster

    Hi,

    Qt creator may be explicitly querying the type of each variable or may be using some GDB extension that VisualGDB does not support.

    We can investigate this during the v5.2 release cycle, however if you could obtain a full GDB command log from Qt creator (if it supports creating such logs or shows the executed GDB commands somewhere), we may be able to include a fix in the upcoming v5.1 release.

    The breakpoint problem does not sound like any known issue, can you reproduce it on a “Hello, world” project and send it to us so that we can see what’s happening? You can also run the “info breakpoints” command in the GDB Session window to find out the address where the breakpoint was put and then use the disassembly window to understand whether this address is correct and actually contains the constructor code.

    #7475
    marrtin
    Participant

    Hi

    Ok let me divide this problem on two separate. The second breakpoint problem occurs today no more in my application. It occured probably when sometimes run the debugged service twice in my enviroment (on instance with GDB and on instance without GDB – Clients had then two same services). VisualGDB was 99.9% not the cause. Sorry Sorry.

    Now the first problem which I would like to fix. I hope that this helps more people because I am sure that this is very useful feature. So here is my sample code

    typedef std::map< int32_t, std::string > HandleValueMap;
    int main( int argc, char* argv[] )
    {
        HandleValueMap h = {{1,"ss"},{2,"xx"}};
        int k = 0;
    }

    I hit the breakpoint in the first line. I sent you gdb.log for gdb commands and gdb1.log for gdb answer until breakpoint was hit. Then I cleared log and I stepped over to the second line and I sent you gdbr.log for gdb commands and gdbr1.log for gdb answer. The Gdb log files was sent on your support email. I am unable to find here how to attach file.

    I hope that this helps.
    Thanks

     

    #7485
    support
    Keymaster

    Hi,

    Thanks for the log files. It looks like Qt Creator is using Python extensions to extract meaningful values from the STL variables. VisualGDB does the type matching on the Visual Studio side in order to support gdb builds without Python support. As a side effect of it, it cannot automatically resolve typedefs without issuing further commands.

    The upcoming VisualGDB 5.1 supports Natvis, so we could add an extension to its format in order to explicitly specify typedefed types and map them to STL containers. Would that be a reasonable option?

    #7487
    marrtin
    Participant

    Hi

    I will very satisfied if you will support that. It is very important feature for all projects in our company.

    Thanks

    #7524
    support
    Keymaster

    Hi,

    OK, please try the latest VisualGDB 5.1 Preview 2. You can tell it that a type A is an alias for type B by adding a .natvis file to your project with the following contents:

    <?xml version="1.0" encoding="utf-8"?>
    <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
      <Type Name="std::vector&lt;int&gt;">
        <AlternativeType Name="IntVector"/>
      </Type>
    </AutoVisualizer>

    Note that the Type element should not contain any elements other than AlternativeType, otherwise instead of using the normal STL visualizers VisualGDB will actually follow the Natvis rules defined in the .natvis file.

    #7569
    marrtin
    Participant

    Hi

    I tried it, but I was not successfull. I am using Visual 2013 Professional. I installed VisualGDB 5.1 Preview 2.

    I created the .natvis file exactly like descriped in your example (example IntVector) and added the .natvis file to the project with add existing item functionality.

    It’s interesting that VS 2013 has no possibility to add new .natvis file by wizard. There is no item under Add / New item / Visual C++ / Utility / Debugger visualization file (.natvis)

    Can you explain me please how to access this functionality. I am confused with it, because it’s very usefull feature and probable is possible to use it, but I don’t know how to configure it.

    Thanks

     

    #7573
    support
    Keymaster

    Hi,

    You should be able to add a normal text file and rename it to .natvis manually.

    If this does not help, can you archive the repro project and send it to us?

    #7590
    marrtin
    Participant

    Hi

    This works for me in Vs2015 not in 2013 – in 2015 I can there also add natvis file from wizard

    But I am not be able to do similar thing for  std::map. Following doesn’ t work

     

    typedef std::map<std::string, std::string> MapS;
    
    <Type Name="std::map&lt;std::string, std::string&gt;">
    	<AlternativeType Name="MapS"/>
    </Type>
    
    
    #7605
    support
    Keymaster

    Hi,

    OK, we have fixed the map problem in the upcoming Beta 1.

    #7607
    marrtin
    Participant

    Thank you, your very good product will be even better.

Viewing 15 posts - 1 through 15 (of 27 total)
  • You must be logged in to reply to this topic.