1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
#include <tqlayout.h>
#include <tqcheckbox.h>
#include <tqregexp.h>
#include <tqwidgetstack.h>
#include <kprocess.h>
#include <klocale.h>
#include <kurlrequester.h>
#include <klineedit.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include "dialog_widget.h"
#include "valgrind_dialog.h"
#include "valgrind_dialog.moc"
ValgrindDialog::ValgrindDialog( Type type, TQWidget* tqparent )
: KDialogBase( tqparent, "valgrind dialog", true, i18n("Valgrind Memory Check"), Ok|Cancel ),
m_type(type)
{
w = new DialogWidget( this );
w->valExecutableEdit->setURL( "valgrind" );
w->executableEdit->setFocus();
w->stack->raiseWidget(m_type);
setMainWidget( w );
connect( w->executableEdit->lineEdit(), TQT_SIGNAL( textChanged( const TQString &)), this, TQT_SLOT( valgrindTextChanged()));
connect( w->valExecutableEdit->lineEdit(), TQT_SIGNAL( textChanged( const TQString &)), this, TQT_SLOT( valgrindTextChanged()));
connect( w->ctExecutableEdit->lineEdit(), TQT_SIGNAL( textChanged( const TQString &)), this, TQT_SLOT( valgrindTextChanged()));
connect( w->kcExecutableEdit->lineEdit(), TQT_SIGNAL( textChanged( const TQString &)), this, TQT_SLOT( valgrindTextChanged()));
enableButtonOK( false );
}
ValgrindDialog::~ValgrindDialog()
{
}
void ValgrindDialog::valgrindTextChanged()
{
if (m_type == Memcheck)
enableButtonOK( !w->valExecutableEdit->lineEdit()->text().isEmpty() && !w->executableEdit->lineEdit()->text().isEmpty() );
else if (m_type == Calltree)
enableButtonOK( !w->executableEdit->lineEdit()->text().isEmpty() && !w->ctExecutableEdit->lineEdit()->text().isEmpty() && !w->kcExecutableEdit->lineEdit()->text().isEmpty() );
}
TQString ValgrindDialog::executableName() const
{
return w->executableEdit->url();
}
void ValgrindDialog::setExecutable( const TQString& url )
{
w->executableEdit->setURL( url );
}
TQString ValgrindDialog::valExecutable() const
{
return w->valExecutableEdit->url();
}
TQString ValgrindDialog::parameters() const
{
return w->paramEdit->text();
}
void ValgrindDialog::setParameters( const TQString& params )
{
w->paramEdit->setText( params );
}
void ValgrindDialog::setValExecutable( const TQString& ve )
{
TQString vUrl = ve;
if ( vUrl.isEmpty() ) {
vUrl = KStandardDirs::findExe( "valgrind" );
}
if ( vUrl.isEmpty() ) {
KMessageBox::sorry( this, i18n( "Could not find valgrind in your $PATH. Please make "
"sure it is installed properly." ),
i18n( "Valgrind Not Found" ) );
w->valExecutableEdit->setURL( "valgrind" );
} else {
w->valExecutableEdit->setURL( vUrl );
}
}
static const TQString memCheckParam( "--tool=memcheck" );
static const TQString leakCheckParam( "--leak-check=yes" );
static const TQString reachableParam( "--show-reachable=yes" );
static const TQString tqchildrenParam( "--trace-tqchildren=yes" );
TQString ValgrindDialog::valParams() const
{
TQString params = w->valParamEdit->text();
if (isNewValgrindVersion())
params += " " + memCheckParam;
if ( w->memleakBox->isChecked() )
params += " " + leakCheckParam;
if ( w->reachableBox->isChecked() )
params += " " + reachableParam;
if ( w->tqchildrenBox->isChecked() )
params += " " + tqchildrenParam;
return params;
}
void ValgrindDialog::setValParams( const TQString& params )
{
TQString myParams = params;
if ( myParams.contains( leakCheckParam ) )
w->memleakBox->setChecked( true );
if ( myParams.contains( reachableParam ) )
w->reachableBox->setChecked( true );
if ( myParams.contains( tqchildrenParam ) )
w->tqchildrenBox->setChecked( true );
w->init();
myParams = myParams.replace( TQRegExp( memCheckParam ), "" );
myParams = myParams.replace( TQRegExp( leakCheckParam ), "" );
myParams = myParams.replace( TQRegExp( reachableParam ), "" );
myParams = myParams.replace( TQRegExp( tqchildrenParam ), "" );
myParams = myParams.stripWhiteSpace();
w->valParamEdit->setText( myParams );
}
TQString ValgrindDialog::ctExecutable() const
{
return w->ctExecutableEdit->url();
}
void ValgrindDialog::setCtExecutable( const TQString& ce )
{
TQString vUrl = ce;
if ( vUrl.isEmpty() ) {
vUrl = KStandardDirs::findExe( "valgrind" );
}
if ( vUrl.isEmpty() ) {
KMessageBox::sorry( this, i18n( "Could not find valgrind in your $PATH. Please make "
"sure it is installed properly." ),
i18n( "Valgrind Not Found" ) );
w->ctExecutableEdit->setURL( "valgrind" );
} else {
w->ctExecutableEdit->setURL( vUrl );
}
}
TQString ValgrindDialog::ctParams() const
{
TQString params = w->ctParamEdit->text();
if ( w->ctChildrenBox->isChecked() )
params += " " + tqchildrenParam;
return params;
}
void ValgrindDialog::setCtParams( const TQString& params )
{
TQString myParams = params;
//force --tool=callgrind if no params are given
if (myParams.isEmpty())
myParams = "--tool=callgrind";
if ( myParams.contains( tqchildrenParam ) )
w->ctChildrenBox->setChecked( true );
w->init();
myParams = myParams.replace( TQRegExp( tqchildrenParam ), "" );
myParams = myParams.stripWhiteSpace();
w->ctParamEdit->setText( myParams );
}
TQString ValgrindDialog::kcExecutable( ) const
{
return w->kcExecutableEdit->url();
}
void ValgrindDialog::setKcExecutable( const TQString& ke )
{
TQString vUrl = ke;
if ( vUrl.isEmpty() ) {
vUrl = KStandardDirs::findExe( "kcachegrind" );
}
if ( vUrl.isEmpty() ) {
KMessageBox::sorry( this, i18n( "Could not find kcachegrind in your $PATH. Please make "
"sure it is installed properly." ),
i18n( "KCachegrind Not Found" ) );
w->kcExecutableEdit->setURL( "kcachegrind" );
} else {
w->kcExecutableEdit->setURL( vUrl );
}
}
bool ValgrindDialog::isNewValgrindVersion( ) const
{
KProcess *proc = new KProcess;
proc->setUseShell(true);
*proc << "test \"valgrind-20\" == `valgrind --version | awk -F \\. '{print $1$2}'`";
proc->start(KProcess::Block);
if (proc->normalExit())
return proc->exitStatus();
return true;
}
// kate: space-indent on; indent-width 2; tab-width 2; show-tabs on;
|