watch std::unordered_map

Sysprogs forums Forums VisualGDB watch std::unordered_map

Viewing 11 posts - 16 through 26 (of 26 total)
  • Author
    Posts
  • #31759
    elikfir
    Participant

    disabling verbose log doesn’t help.
    here is the output from command window (that’s the way to communicate with GDB)

    >Debug.MIDebugExec -var-create –frame 0 –thread 1 – * “m”
    result-class: done
    name: var22
    numchild: 0
    value: {…}
    type: std::unordered_map<int, float, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, float> > >
    thread-id: 1
    displayhint: map
    dynamic: 1
    has_more: 1

     

    Debug.MIDebugExec -var-list-children –simple-values “var22”
    result-class: done
    numchild: 2
    displayhint: map
    children: [child={name=var22.[0],exp=[0],numchild=0,value=5,type=const int,thread-id=1},child={name=var22.[1],exp=[1],numchild=0,value=5.0999999,type=float,thread-id=1}]
    has_more: 0

    here is from Visual GDB Session window:

    -var-create –frame 0 –thread 1 – * “m”
    ^done,name=”var33″,numchild=”1″,value=”{…}”,type=”std::unordered_map<int, float, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, float> > >”,thread-id=”1″,has_more=”0″
    -var-list-children –simple-values “var33″
    ^done,numchild=”1″,children=[child={name=”var33.private”,exp=”private”,numchild=”1″,value=””,thread-id=”1″}],has_more=”0″

    same thing I get when I enabled verbose on native VS debugger:

    >Debug.MIDebugExec -var-list-children –simple-values “var22”
    result-class: done
    numchild: 1
    children: [child={name=var22.private,exp=private,numchild=1,value=,thread-id=1}]
    has_more: 0

    >Debug.MIDebugExec p m
    $1 = std::unordered_map with 1 element = {[5] = 5.0999999}

    • This reply was modified 3 years ago by elikfir.
    #31761
    elikfir
    Participant

    I can validate it on simple command line that MI mode doesn’t contain the data from the pretty printer. it looks like a GDB bug:

    https://sourceware.org/bugzilla/show_bug.cgi?id=25153

    interesting that VS2022 native debugger get over that

    • This reply was modified 3 years ago by elikfir.
    #31768
    support
    Keymaster

    Hi,

    Unfortunately the VS log you provided does not show the command line used to launch GDB, and doesn’t show ALL commands issued to gdb (including the responses) before running theย  -var-list-children command.

    The only way to understand why GDB responds differently to the same command in 2 different cases is to compare its launch commands and the other commands issued before the command in question.

    #31774
    elikfir
    Participant

    the difference between VS (and vscode also) to visualGDB is the gdb command – “-enable-pretty-printing”. once I add it to VisualGDB GDBSession I can see the correct data when calling to relevant MI commands:

    -var-create –frame 0 –thread 1 – * “m”
    ^done,name=”var9″,numchild=”0″,value=”{…}”,type=”std::unordered_map<int, float, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, float> > >”,thread-id=”1″,displayhint=”map”,dynamic=”1″,has_more=”1″
    -complete “-var-list-children –simple-values “var9″
    Undefined MI command: complete”,code=”undefined-command
    -var-list-children –simple-values “var9″
    ^done,numchild=”2″,displayhint=”map”,children=[child={name=”var9.[0]”,exp=”[0]”,numchild=”0″,value=”5″,type=”const int”,thread-id=”1″},child={name=”var9.[1]”,exp=”[1]”,numchild=”0″,value=”5.0999999″,type=”float”,thread-id=”1″}],has_more=”0″

    see full log attached.

    the problem is now I cannot see anything in the watch (even not simple std::string) because visualGDB get it with a different format than a RAW data. all the classes looks like – “m : {}”. I geuss this happen also because VisualGDB doesn’t call to ‘-var-list-children” to retrieve values and count on the “value” property on the “-var-create” call which is empty due to an old GDB bug.

     

    Attachments:
    You must be logged in to view attached files.
    #31782
    support
    Keymaster

    Hi,

    No problem. VisualGDB was relying on the “numchild” field rather than “value” in order to determine whether an expression has children. As it is set to 0 for dynamic expressions, VisualGDB was indeed not showing any children in this case.

    We have fixed it in the following build: VisualGDB-5.6.101.4491.msi

    We have also added a setting under VisualGDB Project Properties -> Advanced GDB Settings -> Expression Evaluation that automatically issues the -enable-pretty-printing command.

    #31787
    elikfir
    Participant

    Hi,
    thanks for the drop, finally I can see std::unordered_map/set.
    two comments here:

    1. the call -var-info-path-expression “var2\.\[3\]”ย  crashed on GDB 8.11 and close debugging. on GDB 11 it just failed with “Invalid variable object (child of a dynamic varobj)
    2. when using GDBServer or when replacing GDB, the pretty printer of libstdcxx isn’t loaded and we need to manually load it (it’s a common issue on vscode as well). in order to do that we need to run:
      python import sys;sys.path.insert(0, ‘/usr/share/gcc-8/python’);from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)

    the log of the crash is:

    /build/gdb-veKdC1/gdb-8.1.1/gdb/c-varobj.c:887: internal-error: void cplus_describe_child(const varobj*, int, std::__cxx11::string*, value**, type**, std::__cxx11::string*): Assertion `access’ failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

    thanks ๐Ÿ™‚

    Eli

    • This reply was modified 3 years ago by elikfir.
    • This reply was modified 3 years ago by elikfir.
    #31791
    support
    Keymaster

    Hi,

    No problem, we have updated VisualGDB to suppress the -var-info-path-expression command for virtual expressions. Please try this build: VisualGDB-5.6.101.4492.msi

    Regarding the Python workaround, it looks like something very version-specific, so automating it on the VisualGDB side would likely only work for a very limited number of versions. That said, if applying it manually works, it should be the way to go.

    #31794
    elikfir
    Participant

    thanks, it works (and now gdb8.1 doesn’t crash)

    Regarding python – it’s fine to have it on “Additional GDB commands”. another option which will help other users is if you can add a bottom beside “Enable GDB-level pretty printing” to auto load that and a text box about the location of the gdb shared folder. You can also offer a default value according to what you find on the Linux machine (on my Linux I have one version of gcc, and I guess in most users this is the case). if it’s not correct user can change the path accordingly (as you have in “Debug Settings” tab which you let user to configure gdb path and gdb launch command line in fully custom option). it’s a good hint about issue and save users time googling it.

    #31795
    elikfir
    Participant

    Hi,
    the changes you made for me (starting from the the new version) cause that I cannot see simple classes like (even without -enable-pretty-printing flag):

    class A
    {
    public:
    int32_t a = 1;
    };

    class B : public A
    {
    public:
    int32_t b = 2;
    };

    int main()
    {
    B b;
    return 0;
    }

    the error I got:

    <sub>-var-create --frame 0 --thread 1 - * "b"</sub>
    <sub>^done,name="var5",numchild="2",value="{...}",type="B",thread-id="1",has_more="0"</sub>
    <sub>ptype/mt B</sub>
    <sub>&"ptype/mt B\n"</sub>
    <sub>type = class B : public A {</sub>
    <sub>public:</sub>
    <sub>int32_t b;</sub>
    <sub>}</sub>
    <sub>OK</sub>
    <sub>-var-list-children --simple-values "var5"</sub>
    <sub>^done,numchild="2",children=[child={name="var5.A",exp="A",numchild="1",type="A",thread-id="1"},child={name="var5.public",exp="public",numchild="1",value="",thread-id="1"}],has_more="0"</sub>
    <sub>ptype/mt A</sub>
    <sub>&"ptype/mt A\n"</sub>
    <sub>type = class A {</sub>
    <sub>public:</sub>
    <sub>int32_t a;</sub>
    <sub>}</sub>
    <sub>OK</sub>
    <sub>-var-info-type "var5\.public"</sub>
    <sub>^done,type=""</sub>
    <sub>ptype/mt</sub>
    <sub>&"ptype/mt \n"</sub>
    <sub>&"expected space after format\n"</sub>
    <sub>expected space after format</sub>

    with the old version (5.6) it works. here is the log of 5.6:

    <sub>-var-create –frame 0 –thread 1 – * “b”</sub>
    <sub>^done,name=”var4″,numchild=”2″,value=”{…}”,type=”B”,thread-id=”1″,has_more=”0″</sub>
    <sub>ptype/mt B</sub>
    <sub>&”ptype/mt B\n”</sub>
    <sub>type = class B : public A {</sub>
    <sub>public:</sub>
    <sub>int32_t b;</sub>
    <sub>}</sub>
    <sub>OK</sub>
    <sub>ptype/mt B</sub>
    <sub>&”ptype/mt B\n”</sub>
    <sub>type = class B : public A {</sub>
    <sub>public:</sub>
    <sub>int32_t b;</sub>
    <sub>}</sub>
    <sub>OK</sub>
    <sub>-var-list-children –simple-values “var4″ 0 2</sub>
    <sub>^done,numchild=”2″,children=[child={name=”var4.A”,exp=”A”,numchild=”1″,type=”A”,thread-id=”1″},child={name=”var4.public”,exp=”public”,numchild=”1″,value=””,thread-id=”1″}],has_more=”0″</sub>
    <sub>ptype/mt A</sub>
    <sub>&”ptype/mt A\n”</sub>
    <sub>type = class A {</sub>
    <sub>public:</sub>
    <sub>int32_t a;</sub>
    <sub>}</sub>
    <sub>OK</sub>
    <sub>ptype/mt A</sub>
    <sub>&”ptype/mt A\n”</sub>
    <sub>type = class A {</sub>
    <sub>public:</sub>
    <sub>int32_t a;</sub>
    <sub>}</sub>
    <sub>OK</sub>
    <sub>-var-evaluate-expression “var4\.A”</sub>
    <sub>^done,value=”{…}”</sub>
    <sub>-var-list-children –simple-values “var4\.public” 0 1</sub>
    <sub>^done,numchild=”1″,children=[child={name=”var4.public.b”,exp=”b”,numchild=”0″,value=”2″,type=”int32_t”,thread-id=”1″}],has_more=”0″</sub>
    <sub>ptype/mt int32_t</sub>
    <sub>&”ptype/mt int32_t\n”</sub>
    <sub>type = int</sub>
    <sub>OK</sub>
    <sub>ptype/mt int32_t</sub>
    <sub>&”ptype/mt int32_t\n”</sub>
    <sub>type = int</sub>
    <sub>OK</sub>
    <sub>-stack-list-frames –thread 1</sub>
    <sub>^done,stack=[frame={level=”0″,addr=”0x0000555555401236″,func=”main”,file=”../../../Source.cpp”,fullname=”/home/nvidia/.vs/Project3/Source.cpp”,line=”29″}]</sub>
    <sub>-stack-list-arguments –thread 1 0</sub>
    <sub>^done,stack-args=[frame={level=”0″,args=[]}]</sub>
    <sub>-var-list-children –simple-values “var4\.A” 0 1</sub>
    <sub>^done,numchild=”1″,children=[child={name=”var4.A.public”,exp=”public”,numchild=”1″,value=””,thread-id=”1″}],has_more=”0″</sub>
    <sub>-var-list-children –simple-values “var4\.A\.public” 0 1</sub>
    <sub>^done,numchild=”1″,children=[child={name=”var4.A.public.a”,exp=”a”,numchild=”0″,value=”1″,type=”int32_t”,thread-id=”1″}],has_more=”0″</sub>
    <sub>ptype/mt int32_t</sub>
    <sub>&”ptype/mt int32_t\n”</sub>
    <sub>type = int</sub>
    <sub>OK</sub>

    I guess the problem is unhandled exception which throw on ptype/mt without and data type for var5.public

    thanks

     

    • This reply was modified 3 years ago by elikfir.
    #31798
    support
    Keymaster

    No problem. We indeed didn’t run all our integration tests on the new build yet, and there was a glitch triggered by objects with exactly 2 gdb-level children. We have fixed it in this build: VisualGDB-5.6.101.4493.msi

    Regarding the settings for pretty-printing, it is still a relatively niche option, and the “additional GDB commands” setting fully covers all cases where gdb doesn’t handle it out-of-the-box, so we will keep it this way for now.

    #31799
    elikfir
    Participant

    thanks ๐Ÿ™‚

Viewing 11 posts - 16 through 26 (of 26 total)
  • You must be logged in to reply to this topic.