Uh boy, this sure is complicated stuff Somebody made a double phd on hiding the palette from the outside world.
Here’s how to beat the guy:
- Figure out the name of the local symbol in TColor object file:
matevz@black trunk-build> nm core/base/CMakeFiles/Base.dir/src/TColor.cxx.o|grep Palette
0000000000000078 b _ZGVZN12_GLOBAL__N_1L15TColor__PaletteEvE13globalPalette
0000000000000050 b _ZGVZN12_GLOBAL__N_1L20TColor__PalettesListEvE18globalPalettesList
0000000000000090 t _ZN12_GLOBAL__N_1L15TColor__PaletteEv
0000000000000120 t _ZN12_GLOBAL__N_1L20TColor__PalettesListEv
0000000000001d00 T _ZN6TColor10SetPaletteEiPif
00000000000004f0 T _ZN6TColor15GetColorPaletteEi
0000000000000080 b _ZZN12_GLOBAL__N_1L15TColor__PaletteEvE13globalPalette
0000000000000060 b _ZZN12_GLOBAL__N_1L20TColor__PalettesListEvE18globalPalettesList
0000000000000000 b _ZZN6TColor10SetPaletteEiPifE11paletteType
- Fire up your executable in gdb and stop it just before the problematic section, then follow this:
(gdb) p _ZN12_GLOBAL__N_1L15TColor__PaletteEv()
$1 = (TArrayI &) @0x7ffff7b99270: {
<TArray> = {
_vptr.TArray = 0x7ffff7b69e48 <vtable for TArrayI+16>,
fN = 255,
static fgIsA = {
_M_b = {
_M_p = 0x0
}
}
},
members of TArrayI:
fArray = 0x65fee0,
static fgIsA = {
_M_b = {
_M_p = 0x0
}
}
}
(gdb) p _ZN12_GLOBAL__N_1L15TColor__PaletteEv().fN
$2 = 255
(gdb) p &_ZN12_GLOBAL__N_1L15TColor__PaletteEv().fN
$3 = (Int_t *) 0x7ffff7b99278 <(anonymous namespace)::TColor__Palette()::globalPalette+8>
(gdb) watch *((Int_t *) 0x7ffff7b99278)
Hardware watchpoint 1: *((Int_t *) 0x7ffff7b99278)
(gdb) c
Continuing.
Note, here you should substitute in the name of the static function from the nm dump (depends on compiler) and later the address that you get from dumping the address of fN. This makes it much easier for gdb as it can only watch a memory location and does not have to execute some code on every instruction (I rarely had success by watching anything other that plain memory).
- Run the code that does the change … gdb should break and then you can look where this is coming from, e.g.:
root [0] Int_t MyPalette[100];
root [1] Double_t Red[] = {0., 0.0, 1.0, 1.0, 1.0};
root [2] Double_t Green[] = {0., 0.0, 0.0, 1.0, 1.0};
root [3] Double_t Blue[] = {0., 1.0, 0.0, 0.0, 1.0};
root [4] Double_t Length[] = {0., .25, .50, .75, 1.0};
root [5] Int_t FI = TColor::CreateGradientColorTable(5, Length, Red, Green, Blue, 100);
Hardware watchpoint 1: *((Int_t *) 0x7ffff7b99278)
Old value = 255
New value = 100
TArrayI::Set (this=<optimized out>, n=<optimized out>) at /foo/matevz/root-dev/trunk/core/cont/src/TArrayI.cxx:123
123 }
(gdb) bt
#0 TArrayI::Set (this=<optimized out>, n=<optimized out>) at /foo/matevz/root-dev/trunk/core/cont/src/TArrayI.cxx:123
#1 0x00007ffff7780078 in TColor::SetPalette (ncolors=ncolors@entry=100, colors=colors@entry=0x12d4ac0, alpha=alpha@entry=1) at /foo/matevz/root-dev/trunk/core/base/src/TColor.cxx:3008
#2 0x00007ffff778b16a in TColor::CreateGradientColorTable (Number=5, Stops=0x7ffff7ff4240, Red=0x7ffff7ff41b0, Green=0x7ffff7ff41e0, Blue=0x7ffff7ff4210, NColors=100, alpha=1)
at /foo/matevz/root-dev/trunk/core/base/src/TColor.cxx:2176
#3 0x00007ffff7fe80b1 in ?? ()
#4 0x0000000000000000 in ?? ()
(gdb)
What fun!