Rd53a::writeRegister() not calling Rd53aDiffReg::write()
I'm quite confused with the behavior of lin_thresholdscan.json
with the Rd53a emulator test which results in segfault at its parameter loop of InjVcalDiff
. (note that Rd53aEmu
is sort of working for std_digitalscan.json
and lin_analogscan.json
so far).
If I understand correctly, InjVcalDiff
is a special "virtual" register for the sake of simplifying writing the scan config. For this purpose, Rd53aRegDiff
, a derived class of Rd53aReg
is specially created, and it overrides write()
function.
When the Rd53a::writeRegister()
is called, the segfault is happening for InjVcalDiff
.
void Rd53a::writeRegister(Rd53aReg Rd53aGlobalCfg::*ref, uint32_t value) {
(this->*ref).write(value);
wrRegister(m_chipId, (this->*ref).addr(), m_cfg[(this->*ref).addr()]);
}
Print debug showed that, in the above call of write()
, instead of Rd53aRegDiff::write()
, Rd53aReg::write()
is called and it makes segfault at the line
*m_cfg = (*m_cfg&(~(mask<<m_bOffset))) | ((value&mask)<<m_bOffset);
What I don't really understand is why overriding is not working... the way that Rd53aDiffReg::write()
is called is that the member pointer is passed to Rd53a::writeRegister()
as Rd53aReg
and not as Rd53aRegDiff
, but the usual mechanism of virtual function table should point to Rd53aDiff::write()
and overriding is expected to work.
Apparently the current scan configs in devel
is expected to be working in other environment with real Rd53a chips, I'm wondering if this may be just my env problem of using Apple LLVM version 9.0.0 (clang-900.0.39.2)
??
Tagging @theim for discussion.