File indexing completed on 2023-09-24 09:32:09
0001 /* 0002 SPDX-FileCopyrightText: 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef BACKTRACELINE_H 0007 #define BACKTRACELINE_H 0008 0009 #include <QSharedData> 0010 #include <QString> 0011 0012 class BacktraceLine 0013 { 0014 public: 0015 enum LineType { 0016 Unknown, // unknown type. the default 0017 EmptyLine, // line is empty 0018 Crap, // line is gdb's crap (like "(no debugging symbols found)", 0019 //"[New Thread 0x4275c950 (LWP 11931)]", etc...) 0020 KCrash, // line is "[KCrash Handler]" 0021 ThreadIndicator, // line indicates the current thread, 0022 // ex. "[Current thread is 0 (process 11313)]" 0023 ThreadStart, // line indicates the start of a thread's stack. 0024 SignalHandlerStart, // line indicates the signal handler start 0025 //(contains "<signal handler called>") 0026 StackFrame, // line is a normal stack frame 0027 Info, //< additional information on the bt 0028 }; 0029 0030 enum LineRating { 0031 /* RATING -- EXAMPLE */ 0032 MissingEverything = 0, // #0 0x0000dead in ?? () 0033 MissingFunction = 1, // #0 0x0000dead in ?? () from /usr/lib/libfoobar.so.4 0034 MissingLibrary = 2, // #0 0x0000dead in foobar() 0035 MissingSourceFile = 3, // #0 0x0000dead in FooBar::FooBar () from /usr/lib/libfoobar.so.4 0036 Good = 4, // #0 0x0000dead in FooBar::crash (this=0x0) at /home/user/foobar.cpp:204 0037 InvalidRating = -1, // (dummy invalid value) 0038 }; 0039 0040 static const LineRating BestRating = Good; 0041 0042 BacktraceLine() 0043 : d(new Data) 0044 { 0045 } 0046 0047 QString toString() const 0048 { 0049 return d->m_line; 0050 } 0051 LineType type() const 0052 { 0053 return d->m_type; 0054 } 0055 LineRating rating() const 0056 { 0057 return d->m_rating; 0058 } 0059 0060 int frameNumber() const 0061 { 0062 return d->m_stackFrameNumber; 0063 } 0064 QString functionName() const 0065 { 0066 return d->m_functionName; 0067 } 0068 QString fileName() const 0069 { 0070 return d->m_file; 0071 } 0072 QString libraryName() const 0073 { 0074 return d->m_library; 0075 } 0076 0077 protected: 0078 class Data : public QSharedData 0079 { 0080 public: 0081 Data() 0082 : m_type(Unknown) 0083 , m_rating(InvalidRating) 0084 , m_stackFrameNumber(-1) 0085 { 0086 } 0087 0088 QString m_line; 0089 LineType m_type; 0090 LineRating m_rating; 0091 int m_stackFrameNumber; 0092 QString m_functionName; 0093 QString m_file; 0094 QString m_library; 0095 }; 0096 QExplicitlySharedDataPointer<Data> d; 0097 }; 0098 0099 #endif // BACKTRACELINE_H