[5.6] Gdb does not output the correct value of a structure.

Solution Verified - Updated -

Issue

  • Gdb does not output the correct value of a structure in the following situation:

    • The target program links two libraries.
    • The two libraries have the same structure.
    • The structure is a global variable.
  • When gdb debugs the one of library, it does not output the correct value of the structure.

  • Please see the following log:

    # gdb ./test\_main
    ... (snip) ...  
    http://www.gnu.org/software/gdb/bugs/   
    Reading symbols from /root/iza/test/test\_main...done.
    (gdb) b A\_Main
    Function "A\_Main" not defined.
    Make breakpoint pending on future shared library load? (y or [n]) y
    Breakpoint 1 (A\_Main) pending.
    (gdb) run
    Starting program: /root/iza/test/test\_main  
    Breakpoint 1, A\_Main () at ./test2.c:23
    23                memset(&test, '\0', sizeof(TEST));
    (gdb) n
    25                test.num = 10;
    (gdb) n
    26                strcpy(test.c1, "aaaaa");
    (gdb) n
    27                strcpy(test.c2, "bbbbb");
    (gdb) n
    29                printf("ADDRESS of test: %p\n", &test);
    (gdb) n
    ADDRESS of test: 0xf7ffc718
    31                printf("test.c1 = %s\n", test.c1);
    (gdb) n
    test.c1 = aaaaa
    32                printf("test.c2 = %s\n", test.c2);
    (gdb) n
    test.c2 = bbbbb
    35                   }
    (gdb) p A::test
    $1 = {c1 = "\000\000\000\000\000", c2 = "\000\000\000\000\000", num = 0}
    
  • The value of "test" structure is not output though some values are set to the structure.

Environment

  • Red Hat Enterprise Linux 5 Update 6
  • Architecture: x86_64
  • Kernel Version: kernel-2.6.18-238.el5
  • Package Version: gdb-7.0.1-32.el5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content