summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drkonqi/backtrace.cpp65
-rw-r--r--drkonqi/debuggers/gdbrc3
-rw-r--r--drkonqi/krashconf.cpp1
-rw-r--r--drkonqi/krashconf.h2
4 files changed, 61 insertions, 10 deletions
diff --git a/drkonqi/backtrace.cpp b/drkonqi/backtrace.cpp
index 213e666b5..dc3eae01f 100644
--- a/drkonqi/backtrace.cpp
+++ b/drkonqi/backtrace.cpp
@@ -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");
+ }
+ }
}
diff --git a/drkonqi/debuggers/gdbrc b/drkonqi/debuggers/gdbrc
index 476f4fd3f..5b79293be 100644
--- a/drkonqi/debuggers/gdbrc
+++ b/drkonqi/debuggers/gdbrc
@@ -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]
diff --git a/drkonqi/krashconf.cpp b/drkonqi/krashconf.cpp
index bb263b32e..8b3d39252 100644
--- a/drkonqi/krashconf.cpp
+++ b/drkonqi/krashconf.cpp
@@ -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");
diff --git a/drkonqi/krashconf.h b/drkonqi/krashconf.h
index 57d2efa67..12b213a1f 100644
--- a/drkonqi/krashconf.h
+++ b/drkonqi/krashconf.h
@@ -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