Changeset View
Changeset View
Standalone View
Standalone View
src/parser/backtraceparsergdb.cpp
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | You should have received a copy of the GNU General Public License along | 14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | 15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | */ | 17 | */ | ||
18 | #include "backtraceparsergdb.h" | 18 | #include "backtraceparsergdb.h" | ||
19 | #include "backtraceparser_p.h" | 19 | #include "backtraceparser_p.h" | ||
20 | #include "drkonqi_parser_debug.h" | 20 | #include "drkonqi_parser_debug.h" | ||
21 | #include <QRegExp> | 21 | #include <QRegExp> | ||
22 | #include <QFileInfo> | ||||
22 | 23 | | |||
23 | //BEGIN BacktraceLineGdb | 24 | //BEGIN BacktraceLineGdb | ||
24 | 25 | | |||
25 | class BacktraceLineGdb : public BacktraceLine | | |||
26 | { | | |||
27 | public: | | |||
28 | BacktraceLineGdb(const QString & line); | | |||
29 | | ||||
30 | private: | | |||
31 | void parse(); | | |||
32 | void rate(); | | |||
33 | }; | | |||
34 | | ||||
35 | BacktraceLineGdb::BacktraceLineGdb(const QString & lineStr) | 26 | BacktraceLineGdb::BacktraceLineGdb(const QString & lineStr) | ||
36 | : BacktraceLine() | 27 | : BacktraceLine() | ||
37 | { | 28 | { | ||
38 | d->m_line = lineStr; | 29 | d->m_line = lineStr; | ||
39 | d->m_functionName = QLatin1String("??"); | 30 | d->m_functionName = QLatin1String("??"); | ||
40 | parse(); | 31 | parse(); | ||
41 | if (d->m_type == StackFrame) { | 32 | if (d->m_type == StackFrame) { | ||
42 | rate(); | 33 | rate(); | ||
Show All 12 Lines | 44 | } else if (d->m_line == QLatin1String("[KCrash Handler]\n")) { | |||
55 | return; | 46 | return; | ||
56 | } else if (d->m_line.contains(QLatin1String("<signal handler called>"))) { | 47 | } else if (d->m_line.contains(QLatin1String("<signal handler called>"))) { | ||
57 | d->m_type = SignalHandlerStart; | 48 | d->m_type = SignalHandlerStart; | ||
58 | return; | 49 | return; | ||
59 | } | 50 | } | ||
60 | 51 | | |||
61 | regExp.setPattern(QStringLiteral("^#([0-9]+)" //matches the stack frame number, ex. "#0" | 52 | regExp.setPattern(QStringLiteral("^#([0-9]+)" //matches the stack frame number, ex. "#0" | ||
62 | "[\\s]+(0x[0-9a-f]+[\\s]+in[\\s]+)?" // matches " 0x0000dead in " (optionally) | 53 | "[\\s]+(0x[0-9a-f]+[\\s]+in[\\s]+)?" // matches " 0x0000dead in " (optionally) | ||
63 | "((\\(anonymous namespace\\)::)?[^\\(]+)" //matches the function name | 54 | "((\\(anonymous namespace\\)::)?[^\\(]+)?" //matches the function name | ||
64 | //(anything except left parenthesis, which is the start of the arguments section) | 55 | //(anything except left parenthesis, which is the start of the arguments section) | ||
65 | //and optionally the prefix "(anonymous namespace)::" | 56 | //and optionally the prefix "(anonymous namespace)::" | ||
66 | "(\\(.*\\))?" //matches the function arguments | 57 | "(\\(.*\\))?" //matches the function arguments | ||
67 | //(when the app doesn't have debugging symbols) | 58 | //(when the app doesn't have debugging symbols) | ||
68 | "[\\s]+(const[\\s]+)?" //matches a traling const, if it exists | 59 | "[\\s]+(const[\\s]+)?" //matches a traling const, if it exists | ||
69 | "\\(.*\\)" //matches the arguments of the function with their values | 60 | "\\(.*\\)" //matches the arguments of the function with their values | ||
70 | //(when the app has debugging symbols) | 61 | //(when the app has debugging symbols) | ||
71 | "([\\s]+" //beginning of optional file information | 62 | "([\\s]+" //beginning of optional file information | ||
72 | "(from|at)[\\s]+" //matches "from " or "at " | 63 | "(from|at)[\\s]+" //matches "from " or "at " | ||
73 | "(.+)" //matches the filename (source file or shared library file) | 64 | "(.+)" //matches the filename (source file or shared library file) | ||
74 | ")?\n$")); //matches trailing newline. | 65 | ")?\n$")); //matches trailing newline. | ||
75 | //the )? at the end closes the parenthesis before [\\s]+(from|at) and | 66 | //the )? at the end closes the parenthesis before [\\s]+(from|at) and | ||
76 | //notes that the whole expression from there is optional. | 67 | //notes that the whole expression from there is optional. | ||
77 | 68 | | |||
78 | if (regExp.exactMatch(d->m_line)) { | 69 | if (regExp.exactMatch(d->m_line)) { | ||
79 | d->m_type = StackFrame; | 70 | d->m_type = StackFrame; | ||
80 | d->m_stackFrameNumber = regExp.cap(1).toInt(); | 71 | d->m_stackFrameNumber = regExp.cap(1).toInt(); | ||
81 | d->m_functionName = regExp.cap(3).trimmed(); | 72 | d->m_functionName = regExp.cap(3).trimmed(); | ||
82 | 73 | | |||
83 | if (!regExp.cap(7).isEmpty()) { //we have file information (stuff after from|at) | 74 | if (!regExp.cap(7).isEmpty()) { //we have file information (stuff after from|at) | ||
84 | if (regExp.cap(8) == QLatin1String("at")) { //'at' means we have a source file | 75 | bool file = regExp.cap(8) == QLatin1String("at"); //'at' means we have a source file (likely) | ||
76 | // Gdb isn't entirely consistent here, when it uses 'from' it always refers to a library, but | ||||
77 | // sometimes the stack can resolve to a library even when it uses the 'at' key word. | ||||
78 | // This specifically seems to happen when a frame has no function name. | ||||
79 | const QString path = regExp.cap(9); | ||||
80 | file = file && !QFileInfo(path).completeSuffix().contains(QLatin1String(".so")); | ||||
81 | if (file) { | ||||
85 | d->m_file = regExp.cap(9); | 82 | d->m_file = regExp.cap(9); | ||
86 | } else { //'from' means we have a library | 83 | } else { //'from' means we have a library | ||
87 | d->m_library = regExp.cap(9); | 84 | d->m_library = regExp.cap(9); | ||
88 | } | 85 | } | ||
89 | } | 86 | } | ||
90 | 87 | | |||
91 | qCDebug(DRKONQI_PARSER_LOG) << d->m_stackFrameNumber << d->m_functionName << d->m_file << d->m_library; | 88 | qCDebug(DRKONQI_PARSER_LOG) << d->m_stackFrameNumber << d->m_functionName << d->m_file << d->m_library; | ||
92 | return; | 89 | return; | ||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |