简体   繁体   中英

gdb map shows incorrect member variables

I am trying to debug a core file that was generated on a test system. It was generated due to an assert() that was tripped.

The bt shows multiple frames with ?? followed by the actual functions. Not sure why that is so.

(gdb) bt
#0  0x00007f6c2d1eb035 in ?? ()
#1  0x00007f6c2d1ee79b in ?? ()
#2  0x00007f64fc3b0240 in ?? ()
#3  0x00007f6c2fdeb092 in ?? ()
#4  0x00007f6c2d1bbc58 in ?? ()
#5  0x00007f6c3205d9c0 in ?? ()
#6  0x0000000002a06a00 in ?? ()
#7  0x00007f64fc3b0150 in ?? ()
#8  0x00007f64fc3b0170 in ?? ()
#9 0x00000000018fb2cb in operator,<AssertCollectorBase> (this=<optimized out>, t=...) at ./shared/Assert.h:116
#10 X (platformContext=<optimized out>, severity=<optimized out>, msg=0x7f64fc3b0740 "Enabling poll on wrong connection.") at ss/*.cpp:497
#11 0x00000000025c2fd7 in Y (severity=1 '\001', msg=...) at *.cc:1065
#12 0x00000000025d0875 in Z (this=0x7f6bcbbbe440) at *.cc:870
#13 0x00007f6c2ebe0e9a in ?? ()
#14 0x0000000000000000 in ?? ()

I went to the frame containing the assert and tried printing out some local and member variables. Some of the variables keep saying 'Cannot access memory 0x< some-memory-addr >'
I tried to print an STL map - but the pointers returned are always invalid.

(gdb) pmap connmap_ int SmaConnection* 
elem[0].left: $1 = 219
elem[0].right: $2 = (SmaConnection *) 0x9c63d4e000007f6b
elem[1].left: $3 = 463
elem[1].right: $4 = (SmaConnection *) 0x9c63bd4000007f6b
elem[2].left: $5 = 469
elem[2].right: $6 = (SmaConnection *) 0x9c63e82000007f6b
elem[3].left: $7 = 471
(gdb) p *$2
Cannot access memory at address 0x9c63d4e000007f6b
(gdb) 

The pointer values in the map always seem to be reported incorrectly by gdb, even when nothing goes wrong with the program.
Is there something wrong with the way I store the pointers in the map?
Is there something wrong I am doing with examining the map?
Is there something else I can do to access the memory correctly?

I had a similar problem because my code was in Release mode. For example, did you add the flag -DCMAKE_BUILD_TYPE=Debug when you run cmake? Or gcc -g option flag? ( http://www.rapidtables.com/code/linux/gcc/gcc-g.htm )

The bt shows multiple frames with ?? followed by the actual functions. Not sure why that is so.

Most likely because of system library mismatch between the test and development systems. See this answer on how to fix it.

The pointer values in the map always seem to be reported incorrectly by gdb

If you do have a mismatch (which I am 99.9% certain you do), then you can ignore the rest of the stack -- it's guaranteed to be bogus.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM