@@ -295,90 +295,11 @@ void PerfRecord::sendInput(const QByteArray& input)
295
295
m_perfRecordProcess->write (input);
296
296
}
297
297
298
- QString PerfRecord::currentUsername ()
299
- {
300
- return KUser ().loginName ();
301
- }
302
-
303
- bool PerfRecord::canTrace (const QString& path)
304
- {
305
- const auto info = QFileInfo (QLatin1String (" /sys/kernel/debug/tracing/" ) + path);
306
- if (!info.isDir () || !info.isReadable ()) {
307
- return false ;
308
- }
309
- QFile paranoid (QStringLiteral (" /proc/sys/kernel/perf_event_paranoid" ));
310
- return paranoid.open (QIODevice::ReadOnly) && paranoid.readAll ().trimmed () == " -1" ;
311
- }
312
-
313
- static QByteArray perfOutput (const QStringList& arguments)
314
- {
315
- QProcess process;
316
-
317
- auto reportError = [&]() {
318
- qWarning () << " Failed to run perf" << process.arguments () << process.error () << process.errorString ()
319
- << process.readAllStandardError ();
320
- };
321
-
322
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
323
- env.insert (QStringLiteral (" LANG" ), QStringLiteral (" C" ));
324
- process.setProcessEnvironment (env);
325
-
326
- QObject::connect (&process, &QProcess::errorOccurred, &process, reportError);
327
- process.start (PerfRecord::perfBinaryPath (), arguments);
328
- if (!process.waitForFinished (1000 ) || process.exitCode () != 0 )
329
- reportError ();
330
- return process.readAllStandardOutput ();
331
- }
332
-
333
- static QByteArray perfRecordHelp ()
334
- {
335
- static const QByteArray recordHelp = []() {
336
- static QByteArray help = perfOutput ({QStringLiteral (" record" ), QStringLiteral (" --help" )});
337
- if (help.isEmpty ()) {
338
- // no man page installed, assume the best
339
- help = " --sample-cpu --switch-events" ;
340
- }
341
- return help;
342
- }();
343
- return recordHelp;
344
- }
345
-
346
- static QByteArray perfBuildOptions ()
347
- {
348
- static const QByteArray buildOptions = perfOutput ({QStringLiteral (" version" ), QStringLiteral (" --build-options" )});
349
- return buildOptions;
350
- }
351
-
352
- bool PerfRecord::canProfileOffCpu ()
353
- {
354
- return canTrace (QStringLiteral (" events/sched/sched_switch" ));
355
- }
356
-
357
298
QStringList PerfRecord::offCpuProfilingOptions ()
358
299
{
359
300
return {QStringLiteral (" --switch-events" ), QStringLiteral (" --event" ), QStringLiteral (" sched:sched_switch" )};
360
301
}
361
302
362
- bool PerfRecord::canSampleCpu ()
363
- {
364
- return perfRecordHelp ().contains (" --sample-cpu" );
365
- }
366
-
367
- bool PerfRecord::canSwitchEvents ()
368
- {
369
- return perfRecordHelp ().contains (" --switch-events" );
370
- }
371
-
372
- bool PerfRecord::canUseAio ()
373
- {
374
- return perfBuildOptions ().contains (" aio: [ on ]" );
375
- }
376
-
377
- bool PerfRecord::canCompress ()
378
- {
379
- return Zstd_FOUND && perfBuildOptions ().contains (" zstd: [ on ]" );
380
- }
381
-
382
303
bool PerfRecord::canElevatePrivileges ()
383
304
{
384
305
return !findPkexec ().isEmpty ();
0 commit comments