Fix crash if print debug state changes during execution. Ensure ~ClangInternalState runs before ~PushTransactionRAII.

Signed-off-by: Vassil Vassilev <vvasilev@cern.ch>
This commit is contained in:
Roman Zulak 2016-07-13 00:21:39 -04:00 committed by sftnight
parent b47f842898
commit dde76efa31
2 changed files with 19 additions and 24 deletions
include/cling/Interpreter
lib/Interpreter

@ -95,7 +95,6 @@ namespace cling {
public:
StateDebuggerRAII(const Interpreter* i);
~StateDebuggerRAII();
void pop() const;
};
///\brief Describes the return result of the different routines that do the

@ -107,34 +107,30 @@ namespace cling {
Interpreter::StateDebuggerRAII::StateDebuggerRAII(const Interpreter* i)
: m_Interpreter(i) {
if (!i->isPrintingDebug())
return;
const CompilerInstance& CI = *m_Interpreter->getCI();
CodeGenerator* CG = i->m_IncrParser->getCodeGenerator();
if (m_Interpreter->isPrintingDebug()) {
const CompilerInstance& CI = *m_Interpreter->getCI();
CodeGenerator* CG = i->m_IncrParser->getCodeGenerator();
// The ClangInternalState constructor can provoke deserialization,
// we need a transaction.
PushTransactionRAII pushedT(i);
// The ClangInternalState constructor can provoke deserialization,
// we need a transaction.
PushTransactionRAII pushedT(i);
m_State.reset(new ClangInternalState(CI.getASTContext(),
CI.getPreprocessor(),
CG ? CG->GetModule() : 0,
CG,
"aName"));
m_State.reset(new ClangInternalState(CI.getASTContext(),
CI.getPreprocessor(),
CG ? CG->GetModule() : 0,
CG,
"aName"));
}
}
Interpreter::StateDebuggerRAII::~StateDebuggerRAII() {
// The ClangInternalState destructor can provoke deserialization,
// we need a transaction.
PushTransactionRAII pushedT(m_Interpreter);
pop();
}
void Interpreter::StateDebuggerRAII::pop() const {
if (!m_Interpreter->isPrintingDebug())
return;
m_State->compare("aName");
if (m_State) {
// The ClangInternalState destructor can provoke deserialization,
// we need a transaction.
PushTransactionRAII pushedT(m_Interpreter);
m_State->compare("aName");
m_State.reset();
}
}
const Parser& Interpreter::getParser() const {