Hi,
I want to compare two objects (of the same class, inheriting from
TObject) field by field.
I thought I could use TMemeberInspector to accomplish this, but my test
program crashes:
#include "TMemberInspector.h"
#include "TH1F.h"
#include <iostream>
using namespace std;
class Insp: public TMemberInspector
{
public:
virtual void Inspect(TClass *cl, const char *parent, const char *name,
const void *addr)
{
cout << cl << " " << parent << name << " " << addr << endl;
}
};
void show_members()
{
TObject* obj = new TH1F("bar", "baz", 100, 0, 100);
Insp insp;
obj->ShowMembers(insp, "TH1F.");
}
> loon show_members.C+
loon [0]
Processing show_members.C+...
Info in <TUnixSystem::ACLiC>: creating shared library
/data/minos/bckhouse/tests/./show_members_C.so
0xa077468 TH1F.fNcells 0x9ffb0f4
0xa077468 TH1F.fXaxis 0x9ffb0f8
Segmentation fault
Running under gdb, I see the segfault is in strcat()
If I substitute a class from our framework instead of TH1F then I can see the line that crashes:
#1 0x03ea67a2 in ANtpHeaderInfo::ShowMembers (this=0x92ce0f0,
R__insp=@0xbff45e10, R__parent=0x503300 "TH1F.")
at
/data/minos/minos/software/OO/minossoft/releases/dev_2/tmp/Linux2.6-GCC_3_4/AnalysisNtuples/libAnalysisNtuples-shared/AnalysisNtuplesCint.cc:1362
1362 softVersion.ShowMembers(R__insp,
strcat(R__parent,"softVersion.")); R__parent[R__ncp] = 0;
Current language: auto; currently c++
(gdb) list
1357 R__insp.Inspect(R__cl, R__parent, "isGoodFDData",
&isGoodFDData);
1358 R__insp.Inspect(R__cl, R__parent, "snarlPE", &snarlPE); 1359 R__insp.Inspect(R__cl, R__parent, "sntpRow", &sntpRow); 1360 R__insp.Inspect(R__cl, R__parent, "isLI", &isLI); 1361 R__insp.Inspect(R__cl, R__parent, "softVersion", &softVersion); 1362 softVersion.ShowMembers(R__insp, strcat(R__parent,"softVersion.")); R__parent[R__ncp] = 0; 1363 TObject::ShowMembers(R__insp, R__parent);1364 }
I am using root trunk.
Any ideas? Am I using TMemberInspector right?
Thanks - Chris Received on Fri Dec 05 2008 - 20:33:35 CET
This archive was generated by hypermail 2.2.0 : Fri Dec 05 2008 - 23:50:02 CET