KDevelop API Documentation

valgrinditem.cpp

Go to the documentation of this file.
00001 #include "valgrinditem.h"
00002 
00003 #include <qregexp.h>
00004 #include <qstringlist.h>
00005 
00006 #include <kdebug.h>
00007 
00008 ValgrindBacktraceItem::ValgrindBacktraceItem( const QString& rawOutput ): _rawOutput( rawOutput ), _highlight( false )
00009 {
00010   QRegExp re1( "^==(\\d+)==\\s+(by|at) (0x[\\dABCDEF]+): (.*) \\((.*):(\\d+)\\)$" );
00011   QRegExp re2( "^==(\\d+)==\\s+(by|at) (0x[\\dABCDEF]+): (.*) \\(in (.*)\\)$" );
00012   QRegExp valRe( "==(\\d+)== (.*)" );
00013   if ( valRe.search( _rawOutput ) >= 0 )
00014     _message = valRe.cap( 2 );
00015   if ( re1.search( _rawOutput ) >= 0 ) {
00016     _type = SourceCode;
00017     _pid = re1.cap( 1 ).toInt();
00018     _address = re1.cap( 3 );
00019     _function = re1.cap( 4 );
00020     _url = re1.cap( 5 );
00021     _line = re1.cap( 6 ).toInt();
00022   } else if ( re2.search( _rawOutput ) >= 0 ) {
00023     _type = Library;
00024     _pid = re2.cap( 1 ).toInt();
00025     _address = re2.cap( 3 );
00026     _function = re2.cap( 4 );
00027     _url = re2.cap( 5 );
00028     _line = -1;
00029   } else {
00030     _type = Unknown;
00031     _line = -1;
00032     _pid = -1;
00033   }
00034 }
00035 
00036 ValgrindBacktraceItem::~ValgrindBacktraceItem()
00037 {
00038 }
00039 
00040 
00041 ValgrindItem::ValgrindItem( const QString& message ): _pid(-1)
00042 {
00043   QRegExp valRe( "==(\\d+)== (.*)" );
00044   QStringList lines = QStringList::split( "\n", message );
00045   QString curMsg;
00046   
00047   for ( QStringList::ConstIterator it = lines.begin(); it != lines.end(); ++it ) {
00048     if ( valRe.search( *it ) < 0 ) {
00049       kdDebug() << "ValgrindItem: got unrecognizable line '" << *it << "'" << endl;
00050       continue; // not of interest
00051     }
00052     if ( _pid == -1 )
00053       _pid = valRe.cap( 1 ).toInt();
00054     curMsg = valRe.cap( 2 );
00055 
00056     if ( curMsg.startsWith( " " ) ) {
00057       _backtrace.append( ValgrindBacktraceItem( *it ) );
00058     } else {
00059       if ( !_message.isEmpty() )
00060         _message += "\n";
00061       _message += curMsg;
00062     }
00063   }
00064 //  static int i = 0;
00065 //  kdDebug() << "got: " << ++i << ": " << _message << endl << message << endl;
00066 }
00067 
00068 
00069 ValgrindItem::~ValgrindItem()
00070 {
00071 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:58 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003