xx/gcc-cgex86
gdb xx.sim
class Ot11dpe12aFltSup { static Ot11dpe12aApsProtSup* pAPSS; ....... ....... }
2.get the address of static var
(gdb) x &(Ot11dpe12aFltSup::pAPSS)
0x8d9c7e8 <_ZN16Ot11dpe12aFltSup5pAPSSE>: 0x00000000 -----0x8d9c7e8
(gdb)
3.get the offset
pAPSS = new Ot11dpe12aApsProtSup(pMsg, heap memory
(gdb) p &(((Ot11dpe12aApsProtSup *)0x0)->protectionType)
$1 = (GroupProtectionType *) 0x1c2a <Address 0x1c2a out of bounds> ----0x1c2a is offset
(gdb)
run and attach the pid
(gdb) attach 3501 ====fault pid
(gdb) p/x *0x8d9c7e8
$1 = 0x91543e8
(gdb)c
4. get the protectionType memory (0x9156012 = 0x91543e8+0x1c2a)
(gdb) ctrl+c
(gdb) x/20x 0x9156000
0x9156000: 0x00000000 0x00000000 0x00000000 0x00000000
0x9156010: 0x00020000 0x00000000 0x00000002 0x00000000
0x9156020: 0x00000000 0x00000000 0x00000000 0x00000000
0x9156030: 0x00000000 0x00000000 0x00000000 0x00000000
0x9156040: 0x00000000 0x00000000 0x00000000 0x00000000
0x00020000 [addr:0x9156010~0x9156013] CPU (litter edition)
Little Endian
低地址 高地址
0x9156010 0x9156013
----------------------------------------->
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 00 | 00 | 02 | 00 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Old value = 2
New value = 32769
Ot11dpe12aApsProtSup::gen_go (this=0x91543e8) at Ot11dpe12aApsProtSup.C:886
886 for (int i = 0; i < MAX_OT_CL_LABELS_11DPE12A+MAX_OT_LI_LABELS_11DPE12A; i++)
(gdb) bt
#0 Ot11dpe12aApsProtSup::gen_go (this=0x91543e8) at Ot11dpe12aApsProtSup.C:886
#1 0x081459e4 in Ot11dpe12aFltSup::gen_go (this=0xb7f4f008) at Ot11dpe12aFltSup.C:890
#2 0x080731b4 in CApp::dispatch (this=0xb7f4f008) at CApp.C:1106
#3 0x084e5c3d in CBcApp::dispatch (this=0xb7f4f008) at CBcApp.C:394
#4 0x084ec148 in CFltSup::dispatch (this=0xb7f4f008) at CFltSup.C:1254
#5 0x0860eaee in COtFltSup::dispatch (this=0xb7f4f008) at COtFltSup.C:2112
#6 0x085fefb4 in COtFltSupLinx::dispatch (this=0xb7f4f008) at COtFltSupLinx.C:544
#7 0x08367e42 in COtFltSupLinx_sim::dispatch (this=0xb7f4f008) at COtFltSupLinx_sim.C:184
#8 0x0814b8e9 in Ot11dpe12aFltSup::dispatch (this=0xb7f4f008) at Ot11dpe12aFltSup.C:2332
#9 0x084e9e18 in CFltSup::runLoop (this=0xb7f4f008) at CFltSup.C:406
#10 0x085fd4bb in COtFltSupLinx::runLoop (this=0xb7f4f008) at COtFltSupLinx.C:217
#11 0x0807186b in CApp::runActiveStandbyLoop (this=0xb7f4f008) at CApp.C:641
#12 0x0807170c in CApp::init_dialog_loop (this=0xb7f4f008) at CApp.C:521
#13 0x08060c8c in MainHelperBase<Ot11dpe12aFltSup>::run (this=0xbffff600) at /vobs/lc/infra_lx/public/hdr/util/MainHelperBase.h:137
#14 0x0805fd8e in main (argc=2, argv=0xbffff6e4) at main.C:221
(gdb) x $pc
0x8174f6a <_ZN20Ot11dpe12aApsProtSup6gen_goEv+344>: 0x83f0458d
(gdb) info registers
eax 0x8001 32769
ecx 0xbe 190
edx 0x8000 32768
ebx 0x8d09558 147887448
esp 0xbffaef00 0xbffaef00
ebp 0xbffaef38 0xbffaef38
esi 0x91543e8 152388584
edi 0xbfffe420 -1073748960
eip 0x8174f6a 0x8174f6a
eflags 0x202 514
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x33 51
(gdb) info $sp
Undefined info command: "$sp". Try "help info".
(gdb) x/20x $sp
0xbffaef00: 0x00000008 0x00000005 0xbffaef27 0xbffaef26
0xbffaef10: 0x087cabae 0x087cac0d 0x00000001 0x00000009
0xbffaef20: 0x00000006 0x018086a0 0x00000001 0x087cac0d
0xbffaef30: 0x08d09558 0xb7f4f008 0xbffaef68 0x081459e4
0xbffaef40: 0x091543e8 0x087b954b 0x00000372 0x00000009
(gdb) x/20x $pc
0x8174f6a <_ZN20Ot11dpe12aApsProtSup6gen_goEv+344>: 0x83f0458d 0x43e90100 0xc7ffffff 0x0000e045
0x8174f7a <_ZN20Ot11dpe12aApsProtSup6gen_goEv+360>: 0x7d810000 0x000167e0 0x8b767f00 0xfff9fc93
0x8174f8a <_ZN20Ot11dpe12aApsProtSup6gen_goEv+376>: 0xe0458bff 0x8b82048b 0x4cc18308 0xf9fc938b
0x8174f9a <_ZN20Ot11dpe12aApsProtSup6gen_goEv+392>: 0x458bffff 0x82048be0 0x8b240489 0x84d0ff01
0x8174faa <_ZN20Ot11dpe12aApsProtSup6gen_goEv+408>: 0x8b3b75c0 0x4489e045 0x838d1424 0xffac16d4
(gdb) c
Continuing.