summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/odebug.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/odebug.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/odebug.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index a40ef53..cac985b 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -1,260 +1,261 @@
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#ifdef OPIE_NO_DEBUG 37#ifdef OPIE_NO_DEBUG
38#undef odDebug 38#undef odDebug
39#undef odBacktrace 39#undef odBacktrace
40#endif 40#endif
41 41
42/* OPIE */ 42/* OPIE */
43 43
44#include <opie2/oapplication.h> 44#include <opie2/oapplication.h>
45#include <opie2/oglobalsettings.h> 45#include <opie2/oglobalsettings.h>
46#include <opie2/oconfig.h> 46#include <opie2/oconfig.h>
47 47
48/* QT */ 48/* QT */
49 49
50#include <qfile.h> 50#include <qfile.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qsocketdevice.h> 52#include <qsocketdevice.h>
53 53
54/* UNIX */ 54/* UNIX */
55 55
56#include <stdlib.h> // abort 56#include <stdlib.h> // abort
57#include <unistd.h> // getpid 57#include <unistd.h> // getpid
58#include <stdarg.h> // vararg stuff 58#include <stdarg.h> // vararg stuff
59#include <ctype.h> // isprint 59#include <ctype.h> // isprint
60#include <syslog.h> 60#include <syslog.h>
61#include <errno.h> 61#include <errno.h>
62#include <string.h> 62#include <string.h>
63 63
64#ifndef OPIE_NO_BACKTRACE 64#ifndef OPIE_NO_BACKTRACE
65#include <execinfo.h> 65#include <execinfo.h>
66#endif 66#endif
67 67
68 68namespace Opie {
69namespace Core {
69/*====================================================================================== 70/*======================================================================================
70 * debug levels 71 * debug levels
71 *======================================================================================*/ 72 *======================================================================================*/
72 73
73enum DebugLevels { 74enum DebugLevels {
74 ODEBUG_INFO = 0, 75 ODEBUG_INFO = 0,
75 ODEBUG_WARN = 1, 76 ODEBUG_WARN = 1,
76 ODEBUG_ERROR = 2, 77 ODEBUG_ERROR = 2,
77 ODEBUG_FATAL = 3 78 ODEBUG_FATAL = 3
78}; 79};
79 80
80/*====================================================================================== 81/*======================================================================================
81 * oDebug private data 82 * oDebug private data
82 *======================================================================================*/ 83 *======================================================================================*/
83 84
84/*====================================================================================== 85/*======================================================================================
85 * the main debug function 86 * the main debug function
86 *======================================================================================*/ 87 *======================================================================================*/
87 88
88static void oDebugBackend( unsigned short level, unsigned int area, const char *data) 89static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
89{ 90{
90 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 91 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
91 92
92 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 93 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
93 // ML: example use. I think it's not necessary to implement such a strategy here. 94 // ML: example use. I think it's not necessary to implement such a strategy here.
94 // ML: Comments? 95 // ML: Comments?
95 96
96 int priority = 0; 97 int priority = 0;
97 QString caption; 98 QString caption;
98 QString lev; 99 QString lev;
99 switch( level ) 100 switch( level )
100 { 101 {
101 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 102 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
102 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 103 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
103 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 104 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
104 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 105 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
105 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 106 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
106 } 107 }
107 108
108 short output = OGlobalSettings::debugMode(); 109 short output = OGlobalSettings::debugMode();
109 if (!oApp && (output == 1)) 110 if (!oApp && (output == 1))
110 { 111 {
111 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 112 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
112 output = 2; // need an application object to use MsgBox 113 output = 2; // need an application object to use MsgBox
113 } 114 }
114 115
115 // gcc 2.9x is dumb and sucks... can you hear it? 116 // gcc 2.9x is dumb and sucks... can you hear it?
116 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 117 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
117 QString areaName; 118 QString areaName;
118 if ( oApp ) areaName = oApp->appName(); 119 if ( oApp ) areaName = oApp->appName();
119 else areaName = "<unknown>"; 120 else areaName = "<unknown>";
120 121
121 // Output 122 // Output
122 switch( output ) 123 switch( output )
123 { 124 {
124 case -1: // ignore 125 case -1: // ignore
125 { 126 {
126 return; 127 return;
127 } 128 }
128 case 0: // File 129 case 0: // File
129 { 130 {
130 QString outputFilename = OGlobalSettings::debugOutput(); 131 QString outputFilename = OGlobalSettings::debugOutput();
131 132
132 const int BUFSIZE = 4096; 133 const int BUFSIZE = 4096;
133 char buf[BUFSIZE] = ""; 134 char buf[BUFSIZE] = "";
134 buf[BUFSIZE-1] = '\0'; 135 buf[BUFSIZE-1] = '\0';
135 int nSize; 136 int nSize;
136 137
137 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); 138 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data);
138 139
139 QFile outputFile( outputFilename ); 140 QFile outputFile( outputFilename );
140 if ( outputFile.open( IO_WriteOnly | IO_Append ) ) 141 if ( outputFile.open( IO_WriteOnly | IO_Append ) )
141 { 142 {
142 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) 143 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) )
143 { 144 {
144 outputFile.writeBlock( buf, BUFSIZE-1 ); 145 outputFile.writeBlock( buf, BUFSIZE-1 );
145 } 146 }
146 else 147 else
147 { 148 {
148 outputFile.writeBlock( buf, nSize ); 149 outputFile.writeBlock( buf, nSize );
149 } 150 }
150 } 151 }
151 else 152 else
152 { 153 {
153 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); 154 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) );
154 } 155 }
155 break; 156 break;
156 } // automatic close of file here 157 } // automatic close of file here
157 158
158 case 1: // Message Box 159 case 1: // Message Box
159 { 160 {
160 // Since we are in opiecore here, we cannot use OMsgBox and use 161 // Since we are in opiecore here, we cannot use OMsgBox and use
161 // QMessageBox instead 162 // QMessageBox instead
162 163
163 caption += QString("(") + areaName + ")"; 164 caption += QString("(") + areaName + ")";
164 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? 165 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr?
165 break; 166 break;
166 } 167 }
167 168
168 case 2: // Shell 169 case 2: // Shell
169 { 170 {
170 FILE *output = stderr; 171 FILE *output = stderr;
171 fprintf( output, "%s: ", (const char*) areaName ); 172 fprintf( output, "%s: ", (const char*) areaName );
172 fputs( data, output); 173 fputs( data, output);
173 break; 174 break;
174 } 175 }
175 176
176 case 3: // syslog 177 case 3: // syslog
177 { 178 {
178 syslog( priority, "%s", data); 179 syslog( priority, "%s", data);
179 break; 180 break;
180 } 181 }
181 182
182 case 4: // socket 183 case 4: // socket
183 { 184 {
184 QString destination = OGlobalSettings::debugOutput(); 185 QString destination = OGlobalSettings::debugOutput();
185 if ( destination && destination.find(":") != -1 ) 186 if ( destination && destination.find(":") != -1 )
186 { 187 {
187 QString host = destination.left( destination.find(":") ); 188 QString host = destination.left( destination.find(":") );
188 QString port = destination.right( destination.length()-host.length()-1 ); 189 QString port = destination.right( destination.length()-host.length()-1 );
189 QHostAddress addr; 190 QHostAddress addr;
190 addr.setAddress( host ); 191 addr.setAddress( host );
191 // TODO: sanity check the address 192 // TODO: sanity check the address
192 QString line; 193 QString line;
193 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); 194 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data );
194 QSocketDevice s( QSocketDevice::Datagram ); 195 QSocketDevice s( QSocketDevice::Datagram );
195 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); 196 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() );
196 if ( result == -1 ) 197 if ( result == -1 )
197 { 198 {
198 qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) ); 199 qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) );
199 } 200 }
200 } 201 }
201 break; 202 break;
202 } 203 }
203 } 204 }
204 205
205 // check if we should abort 206 // check if we should abort
206 207
207 /* 208 /*
208 209
209 if( ( nLevel == ODEBUG_FATAL ) 210 if( ( nLevel == ODEBUG_FATAL )
210 && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) 211 && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) )
211 abort(); 212 abort();
212 213
213 */ 214 */
214} 215}
215 216
216/*====================================================================================== 217/*======================================================================================
217 * odbgstream 218 * odbgstream
218 *======================================================================================*/ 219 *======================================================================================*/
219 220
220odbgstream& perror( odbgstream &s) 221odbgstream& perror( odbgstream &s)
221{ 222{
222 return s << QString::fromLocal8Bit(strerror(errno)); 223 return s << QString::fromLocal8Bit(strerror(errno));
223} 224}
224 225
225odbgstream odDebug(int area) 226odbgstream odDebug(int area)
226{ 227{
227 return odbgstream(area, ODEBUG_INFO); 228 return odbgstream(area, ODEBUG_INFO);
228} 229}
229odbgstream odDebug(bool cond, int area) 230odbgstream odDebug(bool cond, int area)
230{ 231{
231 if (cond) return odbgstream(area, ODEBUG_INFO); 232 if (cond) return odbgstream(area, ODEBUG_INFO);
232 else return odbgstream(0, 0, false); 233 else return odbgstream(0, 0, false);
233} 234}
234 235
235odbgstream odError(int area) 236odbgstream odError(int area)
236{ 237{
237 return odbgstream("ERROR: ", area, ODEBUG_ERROR); 238 return odbgstream("ERROR: ", area, ODEBUG_ERROR);
238} 239}
239 240
240odbgstream odError(bool cond, int area) 241odbgstream odError(bool cond, int area)
241{ 242{
242 if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false); 243 if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false);
243} 244}
244 245
245odbgstream odWarning(int area) 246odbgstream odWarning(int area)
246{ 247{
247 return odbgstream("WARNING: ", area, ODEBUG_WARN); 248 return odbgstream("WARNING: ", area, ODEBUG_WARN);
248} 249}
249 250
250odbgstream odWarning(bool cond, int area) 251odbgstream odWarning(bool cond, int area)
251{ 252{
252 if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false); 253 if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false);
253} 254}
254 255
255odbgstream odFatal(int area) 256odbgstream odFatal(int area)
256{ 257{
257 return odbgstream("FATAL: ", area, ODEBUG_FATAL); 258 return odbgstream("FATAL: ", area, ODEBUG_FATAL);
258} 259}
259 260
260odbgstream odFatal(bool cond, int area) 261odbgstream odFatal(bool cond, int area)
@@ -425,196 +426,200 @@ odbgstream::~odbgstream()
425 if (!output.isEmpty()) 426 if (!output.isEmpty())
426 { 427 {
427 fprintf(stderr, "ASSERT: debug output not ended with \\n\n"); 428 fprintf(stderr, "ASSERT: debug output not ended with \\n\n");
428 *this << "\n"; 429 *this << "\n";
429 } 430 }
430} 431}
431 432
432odbgstream& odbgstream::operator<<(char ch) 433odbgstream& odbgstream::operator<<(char ch)
433{ 434{
434 if (!print) return *this; 435 if (!print) return *this;
435 if (!isprint(ch)) 436 if (!isprint(ch))
436 { 437 {
437 output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2); 438 output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2);
438 } 439 }
439 else 440 else
440 { 441 {
441 output += ch; 442 output += ch;
442 if (ch == '\n') flush(); 443 if (ch == '\n') flush();
443 } 444 }
444 return *this; 445 return *this;
445} 446}
446 447
447odbgstream& odbgstream::operator<<( QWidget* widget ) 448odbgstream& odbgstream::operator<<( QWidget* widget )
448{ 449{
449 QString string, temp; 450 QString string, temp;
450 // ----- 451 // -----
451 if(widget==0) 452 if(widget==0)
452 { 453 {
453 string=(QString)"[Null pointer]"; 454 string=(QString)"[Null pointer]";
454 } else 455 } else
455 { 456 {
456 temp.setNum((ulong)widget, 16); 457 temp.setNum((ulong)widget, 16);
457 string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")"; 458 string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")";
458 if(widget->name(0)==0) 459 if(widget->name(0)==0)
459 { 460 {
460 string += " to unnamed widget, "; 461 string += " to unnamed widget, ";
461 } else 462 } else
462 { 463 {
463 string += (QString)" to widget " + widget->name() + ", "; 464 string += (QString)" to widget " + widget->name() + ", ";
464 } 465 }
465 string += "geometry=" 466 string += "geometry="
466 + QString().setNum(widget->width()) 467 + QString().setNum(widget->width())
467 + "x"+QString().setNum(widget->height()) 468 + "x"+QString().setNum(widget->height())
468 + "+"+QString().setNum(widget->x()) 469 + "+"+QString().setNum(widget->x())
469 + "+"+QString().setNum(widget->y()) 470 + "+"+QString().setNum(widget->y())
470 + "]"; 471 + "]";
471 } 472 }
472 if (!print) return *this; 473 if (!print) return *this;
473 474
474 output += string; 475 output += string;
475 if (output.at(output.length()-1) == '\n') 476 if (output.at(output.length()-1) == '\n')
476 { 477 {
477 flush(); 478 flush();
478 } 479 }
479 return *this; 480 return *this;
480} 481}
481 482
482/* 483/*
483 * either use 'output' directly and do the flush if needed 484 * either use 'output' directly and do the flush if needed
484 * or use the QString operator which calls the char* operator 485 * or use the QString operator which calls the char* operator
485 * 486 *
486 */ 487 */
487odbgstream& odbgstream::operator<<( const QDateTime& time) 488odbgstream& odbgstream::operator<<( const QDateTime& time)
488{ 489{
489 *this << time.toString(); 490 *this << time.toString();
490 return *this; 491 return *this;
491} 492}
492 493
493 494
494odbgstream& odbgstream::operator<<( const QDate& date) 495odbgstream& odbgstream::operator<<( const QDate& date)
495{ 496{
496 *this << date.toString(); 497 *this << date.toString();
497 498
498 return *this; 499 return *this;
499} 500}
500 501
501 502
502odbgstream& odbgstream::operator<<( const QTime& time ) 503odbgstream& odbgstream::operator<<( const QTime& time )
503{ 504{
504 *this << time.toString(); 505 *this << time.toString();
505 return *this; 506 return *this;
506} 507}
507 508
508 509
509odbgstream& odbgstream::operator<<( const QPoint& p ) 510odbgstream& odbgstream::operator<<( const QPoint& p )
510{ 511{
511 *this << "(" << p.x() << ", " << p.y() << ")"; 512 *this << "(" << p.x() << ", " << p.y() << ")";
512 return *this; 513 return *this;
513} 514}
514 515
515 516
516odbgstream& odbgstream::operator<<( const QSize& s ) 517odbgstream& odbgstream::operator<<( const QSize& s )
517{ 518{
518 *this << "[" << s.width() << "x" << s.height() << "]"; 519 *this << "[" << s.width() << "x" << s.height() << "]";
519 return *this; 520 return *this;
520} 521}
521 522
522 523
523odbgstream& odbgstream::operator<<( const QRect& r ) 524odbgstream& odbgstream::operator<<( const QRect& r )
524{ 525{
525 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]"; 526 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]";
526 return *this; 527 return *this;
527} 528}
528 529
529 530
530odbgstream& odbgstream::operator<<( const QRegion& reg ) 531odbgstream& odbgstream::operator<<( const QRegion& reg )
531{ 532{
532 /* Qt2 doesn't have a QMemArray... :( 533 /* Qt2 doesn't have a QMemArray... :(
533 *this << "[ "; 534 *this << "[ ";
534 QMemArray<QRect>rs=reg.rects(); 535 QMemArray<QRect>rs=reg.rects();
535 for (uint i=0;i<rs.size();++i) 536 for (uint i=0;i<rs.size();++i)
536 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ; 537 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ;
537 *this <<"]"; 538 *this <<"]";
538 */ 539 */
539 return *this; 540 return *this;
540} 541}
541 542
542 543
543odbgstream& odbgstream::operator<<( const QStringList& l ) 544odbgstream& odbgstream::operator<<( const QStringList& l )
544{ 545{
545 *this << "("; 546 *this << "(";
546 *this << l.join(","); 547 *this << l.join(",");
547 *this << ")"; 548 *this << ")";
548 549
549 return *this; 550 return *this;
550} 551}
551 552
552 553
553odbgstream& odbgstream::operator<<( const QColor& c ) 554odbgstream& odbgstream::operator<<( const QColor& c )
554{ 555{
555 if ( c.isValid() ) 556 if ( c.isValid() )
556 *this << c.name(); 557 *this << c.name();
557 else 558 else
558 *this << "(invalid/default)"; 559 *this << "(invalid/default)";
559 return *this; 560 return *this;
560} 561}
561 562
562 563
563odbgstream& odbgstream::operator<<( const QBrush& b) 564odbgstream& odbgstream::operator<<( const QBrush& b)
564{ 565{
565 static const char* const s_brushStyles[] = { 566 static const char* const s_brushStyles[] = {
566 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern", 567 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern",
567 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern", 568 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern",
568 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern", 569 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern",
569 "DiagCrossPattern" }; 570 "DiagCrossPattern" };
570 571
571 *this <<"[ style: "; 572 *this <<"[ style: ";
572 *this <<s_brushStyles[ b.style() ]; 573 *this <<s_brushStyles[ b.style() ];
573 *this <<" color: "; 574 *this <<" color: ";
574 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) 575 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
575 if ( b.color().isValid() ) 576 if ( b.color().isValid() )
576 *this <<b.color().name() ; 577 *this <<b.color().name() ;
577 else 578 else
578 *this <<"(invalid/default)"; 579 *this <<"(invalid/default)";
579 if ( b.pixmap() ) 580 if ( b.pixmap() )
580 *this <<" has a pixmap"; 581 *this <<" has a pixmap";
581 *this <<" ]"; 582 *this <<" ]";
582 return *this; 583 return *this;
583} 584}
584 585
585 586
586 587
587QString odBacktrace( int levels ) 588QString odBacktrace( int levels )
588{ 589{
589 QString s; 590 QString s;
590#ifndef OPIE_NO_BACKTRACE 591#ifndef OPIE_NO_BACKTRACE
591 void* trace[256]; 592 void* trace[256];
592 int n = backtrace(trace, 256); 593 int n = backtrace(trace, 256);
593 char** strings = backtrace_symbols (trace, n); 594 char** strings = backtrace_symbols (trace, n);
594 595
595 if ( levels != -1 ) 596 if ( levels != -1 )
596 n = QMIN( n, levels ); 597 n = QMIN( n, levels );
597 s = "[\n"; 598 s = "[\n";
598 599
599 for (int i = 0; i < n; ++i) 600 for (int i = 0; i < n; ++i)
600 s += QString::number(i) + 601 s += QString::number(i) +
601 QString::fromLatin1(": ") + 602 QString::fromLatin1(": ") +
602 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); 603 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
603 s += "]\n"; 604 s += "]\n";
604 free (strings); 605 free (strings);
605#endif 606#endif
606 return s; 607 return s;
607} 608}
608 609
609void odClearDebugConfig() 610void odClearDebugConfig()
610{ 611{
611 /* 612 /*
612 delete oDebug_data->config; 613 delete oDebug_data->config;
613 oDebug_data->config = 0; 614 oDebug_data->config = 0;
614 */ 615 */
615} 616}
616 617
618
617#ifdef OPIE_NO_DEBUG 619#ifdef OPIE_NO_DEBUG
618#define odDebug ondDebug 620#define odDebug ondDebug
619#define odBacktrace ondBacktrace 621#define odBacktrace ondBacktrace
620#endif 622#endif
623
624}
625} \ No newline at end of file