summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-02-12 17:20:07 (UTC)
committer mickeyl <mickeyl>2005-02-12 17:20:07 (UTC)
commit5ad68456ddf0b1dc722f92d7f6c94b82677c637c (patch) (unidiff)
tree1f86710721e9ca624d3a2f59593b4f7be3ddbec6
parent292ce81455773c463a8d7ed9c1aef2d08b90514d (diff)
downloadopie-5ad68456ddf0b1dc722f92d7f6c94b82677c637c.zip
opie-5ad68456ddf0b1dc722f92d7f6c94b82677c637c.tar.gz
opie-5ad68456ddf0b1dc722f92d7f6c94b82677c637c.tar.bz2
disable backtracing if building against uclibc
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/odebug.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index d8dfe26..45709dc 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -1,164 +1,168 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 (C) 2002 Holger Freyther (freyther@kde.org) 4 (C) 2002 Holger Freyther (freyther@kde.org)
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo 32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
33// functions inlined to noops (which would then conflict with their definition here). 33// functions inlined to noops (which would then conflict with their definition here).
34 34
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37#if defined(__UCLIBC__)
38#define OPIE_NO_BACKTRACE
39#endif
40
37#ifdef OPIE_NO_DEBUG 41#ifdef OPIE_NO_DEBUG
38#undef odDebug 42#undef odDebug
39#undef odBacktrace 43#undef odBacktrace
40#endif 44#endif
41 45
42/* OPIE */ 46/* OPIE */
43 47
44#include <opie2/oapplication.h> 48#include <opie2/oapplication.h>
45#include <opie2/oglobalsettings.h> 49#include <opie2/oglobalsettings.h>
46#include <opie2/oconfig.h> 50#include <opie2/oconfig.h>
47 51
48/* QT */ 52/* QT */
49 53
50#include <qfile.h> 54#include <qfile.h>
51#include <qmessagebox.h> 55#include <qmessagebox.h>
52#include <qsocketdevice.h> 56#include <qsocketdevice.h>
53 57
54/* UNIX */ 58/* UNIX */
55 59
56#include <stdlib.h> // abort 60#include <stdlib.h> // abort
57#include <unistd.h> // getpid 61#include <unistd.h> // getpid
58#include <stdarg.h> // vararg stuff 62#include <stdarg.h> // vararg stuff
59#include <ctype.h> // isprint 63#include <ctype.h> // isprint
60#include <syslog.h> 64#include <syslog.h>
61#include <errno.h> 65#include <errno.h>
62#include <string.h> 66#include <string.h>
63 67
64#ifndef OPIE_NO_BACKTRACE 68#ifndef OPIE_NO_BACKTRACE
65#include <execinfo.h> 69#include <execinfo.h>
66#endif 70#endif
67 71
68namespace Opie { 72namespace Opie {
69namespace Core { 73namespace Core {
70namespace Internal { 74namespace Internal {
71/*====================================================================================== 75/*======================================================================================
72 * debug levels 76 * debug levels
73 *======================================================================================*/ 77 *======================================================================================*/
74 78
75enum DebugLevels { 79enum DebugLevels {
76 ODEBUG_INFO = 0, 80 ODEBUG_INFO = 0,
77 ODEBUG_WARN = 1, 81 ODEBUG_WARN = 1,
78 ODEBUG_ERROR = 2, 82 ODEBUG_ERROR = 2,
79 ODEBUG_FATAL = 3 83 ODEBUG_FATAL = 3
80}; 84};
81 85
82/*====================================================================================== 86/*======================================================================================
83 * oDebug private data 87 * oDebug private data
84 *======================================================================================*/ 88 *======================================================================================*/
85 89
86/*====================================================================================== 90/*======================================================================================
87 * the main debug function 91 * the main debug function
88 *======================================================================================*/ 92 *======================================================================================*/
89 93
90 94
91 95
92struct DebugBackend { 96struct DebugBackend {
93 DebugBackend() : m_opened( false ), m_file( 0 ) ,m_port( -1 ),m_sock( 0 ) { 97 DebugBackend() : m_opened( false ), m_file( 0 ) ,m_port( -1 ),m_sock( 0 ) {
94 m_outp = OGlobalSettings::debugMode(); 98 m_outp = OGlobalSettings::debugMode();
95 } 99 }
96 ~DebugBackend() { 100 ~DebugBackend() {
97 delete m_file; 101 delete m_file;
98 delete m_sock; 102 delete m_sock;
99 } 103 }
100 void debug( unsigned short level, unsigned int, const QString& data ); 104 void debug( unsigned short level, unsigned int, const QString& data );
101 105
102private: 106private:
103 void debugFile( const QString&, const QString& data ); 107 void debugFile( const QString&, const QString& data );
104 void debugMsgB( const QString&, const QString& data ); 108 void debugMsgB( const QString&, const QString& data );
105 void debugShel( const QString&, const QString& data ); 109 void debugShel( const QString&, const QString& data );
106 void debugSysl( int, const QString& ); 110 void debugSysl( int, const QString& );
107 void debugSock( const QString&, const QString& data ); 111 void debugSock( const QString&, const QString& data );
108 QCString line( const QString&, const QString& data ); 112 QCString line( const QString&, const QString& data );
109 bool m_opened : 1; 113 bool m_opened : 1;
110 QFile *m_file; 114 QFile *m_file;
111 QHostAddress m_addr; 115 QHostAddress m_addr;
112 int m_port; 116 int m_port;
113 QSocketDevice *m_sock; 117 QSocketDevice *m_sock;
114 short m_outp; 118 short m_outp;
115}; 119};
116 120
117void DebugBackend::debug(unsigned short level, unsigned int, const QString& data) { 121void DebugBackend::debug(unsigned short level, unsigned int, const QString& data) {
118 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 122 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
119 123
120 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 124 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
121 // ML: example use. I think it's not necessary to implement such a strategy here. 125 // ML: example use. I think it's not necessary to implement such a strategy here.
122 // ML: Comments? 126 // ML: Comments?
123 127
124 int priority = 0; 128 int priority = 0;
125 QString caption; 129 QString caption;
126 QString lev; 130 QString lev;
127 switch( level ) 131 switch( level )
128 { 132 {
129 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 133 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
130 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 134 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
131 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 135 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
132 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 136 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
133 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 137 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
134 } 138 }
135 139
136 if (!oApp && (m_outp == 1)) { 140 if (!oApp && (m_outp == 1)) {
137 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 141 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
138 m_outp = 2; // need an application object to use MsgBox 142 m_outp = 2; // need an application object to use MsgBox
139 } 143 }
140 144
141 // gcc 2.9x is dumb and sucks... can you hear it? 145 // gcc 2.9x is dumb and sucks... can you hear it?
142 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 146 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
143 QString areaName; 147 QString areaName;
144 if ( oApp ) areaName = oApp->appName(); 148 if ( oApp ) areaName = oApp->appName();
145 else areaName = "<unknown>"; 149 else areaName = "<unknown>";
146 150
147 switch( m_outp ) { 151 switch( m_outp ) {
148 case ODEBUG_IGNORE: 152 case ODEBUG_IGNORE:
149 return; 153 return;
150 case ODEBUG_FILE: 154 case ODEBUG_FILE:
151 return debugFile( areaName, data ); 155 return debugFile( areaName, data );
152 case ODEBUG_MSGBOX: 156 case ODEBUG_MSGBOX:
153 return debugMsgB( areaName, data ); 157 return debugMsgB( areaName, data );
154 case ODEBUG_STDERR: 158 case ODEBUG_STDERR:
155 return debugShel( areaName,data ); 159 return debugShel( areaName,data );
156 case ODEBUG_SYSLOG: 160 case ODEBUG_SYSLOG:
157 return debugSysl( priority, data ); 161 return debugSysl( priority, data );
158 case ODEBUG_SOCKET: 162 case ODEBUG_SOCKET:
159 return debugSock( areaName, data ); 163 return debugSock( areaName, data );
160 } 164 }
161} 165}
162 166
163inline void DebugBackend::debugFile(const QString& area, const QString& data) { 167inline void DebugBackend::debugFile(const QString& area, const QString& data) {
164 /* something went wrong with the file don't bother.. */ 168 /* something went wrong with the file don't bother.. */