Properly obtain threading debug information in TDE crash handler

Fix potential TDE crash handler lockup uncer certain circumstances
Enhance crashtest program with three threads
(cherry picked from commit c12a32aec0)
v3.5.13-sru
Timothy Pearson 11 years ago committed by Slávek Banko
parent 742b626e07
commit 0e2ad64131

@ -175,8 +175,22 @@ void BackTrace::slotProcessExited(KProcess *proc)
bool BackTrace::usefulBacktrace()
{
// remove crap
if( !m_krashconf->removeFromBacktraceRegExp().isEmpty())
if( !m_krashconf->removeFromBacktraceRegExp().isEmpty()) {
m_strBt.replace(TQRegExp( m_krashconf->removeFromBacktraceRegExp()), TQString());
}
// fix threading info output
if( !m_krashconf->threadRegExp().isEmpty()) {
int pos = -1;
TQRegExp threadRegExpression( m_krashconf->threadRegExp());
do {
threadRegExpression.search(m_strBt);
pos = threadRegExpression.pos();
if (pos > -1) {
m_strBt.insert(threadRegExpression.pos()+1, "==== ");
}
} while (pos > -1);
}
if( m_krashconf->disableChecks())
return true;
@ -203,20 +217,32 @@ void BackTrace::processBacktrace()
{
if( !m_krashconf->kcrashRegExp().isEmpty()) {
TQRegExp kcrashregexp( m_krashconf->kcrashRegExp());
int pos = -1;
while ((pos = kcrashregexp.search( m_strBt )) >= 0) {
pos = kcrashregexp.search( m_strBt );
kcrashregexp.setMinimal(true);
int pos = 0;
int prevpos = 0;
while ((pos = kcrashregexp.search( m_strBt, pos )) >= 0) {
if (prevpos == pos) {
// Avoid infinite loop
// Shouldn't ever get here, but given that this is a crash handler, better safe than sorry!
break;
}
prevpos = pos;
if( pos >= 0 ) {
int len = kcrashregexp.matchedLength();
int nextinfochunkpos = m_strBt.find("====", pos);
if (nextinfochunkpos >= 0) {
// Trying to delete too much!
int chunkpos = pos;
TQString limitedstrBt = m_strBt.mid(pos, nextinfochunkpos - pos);
pos = kcrashregexp.search( limitedstrBt ) + chunkpos;
len = kcrashregexp.matchedLength();
int limitedlen = nextinfochunkpos - pos;
TQString limitedstrBt = m_strBt.mid(pos, limitedlen);
int limitedpos = kcrashregexp.search( limitedstrBt );
if (limitedpos >= 0) {
len = kcrashregexp.matchedLength();
}
else {
len = 0;
}
}
if (pos >= 0) {
if ((pos >= 0) && (len > 0)) {
if( m_strBt[ pos ] == '\n' ) {
++pos;
--len;
@ -225,6 +251,17 @@ void BackTrace::processBacktrace()
m_strBt.insert( pos, TQString::fromLatin1( "[KCrash handler]\n" ));
}
}
if (pos < 0) {
// Avoid infinite loop
// Shouldn't ever get here, but given that this is a crash handler, better safe than sorry!
break;
}
pos++;
if ((uint)pos >= m_strBt.length()) {
// Avoid infinite loop
// Shouldn't ever get here, but given that this is a crash handler, better safe than sorry!
break;
}
}
}
if( !m_krashconf->kcrashRegExpSingle().isEmpty()) {
@ -239,4 +276,14 @@ void BackTrace::processBacktrace()
m_strBt.remove( pos, len );
}
}
{
// Clean up hard to read debug blocks
TQRegExp kcrashregexp( "[^\n]\n==== ");
kcrashregexp.setMinimal(true);
int pos = 0;
while ((pos = kcrashregexp.search( m_strBt, pos )) >= 0) {
m_strBt.insert(pos+1, "\n");
}
}
}

@ -158,10 +158,11 @@ Comment[zu]=Umcoshi wamaphutha osekelwe umbhalo osuka kwi-GNU kwikhonsoli
Exec=konsole -e gdb -nw %execname %pid
ExecBatch=gdb -nw -n -batch -x %tempfile %execname %pid
TryExec=gdb
BacktraceCommand=echo \\n\necho ==== (gdb) bt ====\\n\nbt\necho \\n\\n\necho ==== (gdb) bt full ====\\n\nbt full\necho\\n\\n\necho ==== (gdb) thread apply all bt ====\\n\nthread apply all bt
BacktraceCommand=echo \\n\necho ==== (gdb) bt ====\\n\nbt\necho \\n\\n\necho ==== (gdb) bt full ====\\n\nbt full\necho\\n\\n\necho ==== (gdb) info thread ====\\n\ninfo thread\necho\\n\\n\necho ==== (gdb) thread apply all bt ====\\n\nthread apply all bt
RemoveFromBacktraceRegExp=\(no debugging symbols found\)\.\.\.\\n?
InvalidStackFrameRegExp=\\n#[0-9]+\\s+0x[0-9A-Fa-f]+ \w* \?\?
FrameRegExp=\\n#[0-9]+\\s+0x[0-9A-Fa-f]+
NeededInValidBacktraceRegExp=\\n#5
KCrashRegExp=\\n#0[ ]*0x[0123456789abcdefABCDEF]+.*<signal handler called>[ ]*\\n
KCrashRegExpSingle=\\n0x[0123456789abcdefABCDEF][^\\n]*\\n
ThreadRegExp=\\nThread [0123456789]

@ -112,6 +112,7 @@ void KrashConfig :: readConfig()
m_neededInValidBacktraceRegExp = debuggers.readEntry("NeededInValidBacktraceRegExp");
m_kcrashRegExp = debuggers.readEntry("KCrashRegExp");
m_kcrashRegExpSingle = debuggers.readEntry("KCrashRegExpSingle");
m_threadRegExp = debuggers.readEntry("ThreadRegExp");
KConfig preset(TQString::fromLatin1("presets/%1rc").arg(configname),
true, false, "appdata");

@ -67,6 +67,7 @@ public:
TQString neededInValidBacktraceRegExp() const { return m_neededInValidBacktraceRegExp; }
TQString kcrashRegExp() const { return m_kcrashRegExp; }
TQString kcrashRegExpSingle() const { return m_kcrashRegExpSingle; }
TQString threadRegExp() const { return m_threadRegExp; }
bool showBacktrace() const { return m_showbacktrace; };
bool showDebugger() const { return m_showdebugger && !m_debugger.isNull(); };
bool showBugReport() const { return m_showbugreport; };
@ -110,6 +111,7 @@ private:
TQString m_neededInValidBacktraceRegExp;
TQString m_kcrashRegExp;
TQString m_kcrashRegExpSingle;
TQString m_threadRegExp;
};
#endif

Loading…
Cancel
Save