summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-03-31 15:27:36 +0200
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-04-08 17:55:52 +0300
commitc900307ca2db204572bde2c02c471ec954ec8c1a (patch)
treeb3e71185ca8d0d0e58cc17696da47e98736ea8ab
parentcac8839211fc5bb53592d3d04c344834c4c054df (diff)
pass variable number of arguments to --profile-perf5.4
The option --profile-perf now takes a comma-separated list of arguments that will be passed directly to perf. Commas can be escaped by doubling them. Change-Id: Ifdb982122b15c0771634adf9c81bcb5e195a2cdf Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com> Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
-rw-r--r--main.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/main.cpp b/main.cpp
index 741523c..fb52564 100644
--- a/main.cpp
+++ b/main.cpp
@@ -238,6 +238,30 @@ static bool makeDefault(const QString &filepath)
return true;
}
+static QStringList extractPerfParams(QString s)
+{
+ QStringList lst;
+ int h = 0;
+ int i = 0;
+ for (;;) {
+ i = s.indexOf(QLatin1Char(','), i);
+ if (i >= 0) {
+ if (i + 1 < s.length() && s.at(i + 1) == QLatin1Char(',')) {
+ s.remove(i, 1);
+ i++;
+ continue;
+ }
+ lst << s.mid(h, i - h);
+ i++;
+ h = i;
+ } else {
+ lst << s.mid(h);
+ break;
+ }
+ }
+ return lst;
+}
+
int main(int argc, char **argv)
{
// Save arguments before QCoreApplication handles them
@@ -281,13 +305,14 @@ int main(int argc, char **argv)
} else if (arg == "--debug-qml") {
useQML = true;
} else if (arg == "--profile-perf") {
- if (args.isEmpty() ||
- (perfParams = args.takeFirst().split(QLatin1Char(','))).length() != 3) {
- fprintf(stderr, "--profile-perf requires a parameter specification of"
- " \"<method>,<size>,<freq>\" where <method> can be \"fp\" or "
- " \"dwarf\", amd <size> and <freq> are integers.");
+ if (args.isEmpty()) {
+ fprintf(stderr, "--profile-perf requires comma-separated list of parameters that "
+ "get passed to \"perf record\". Arguments \"-o -\" are "
+ "automatically appended to capture the output as stream. "
+ "Escape commas by doubling them.");
return 1;
}
+ perfParams = extractPerfParams(args.takeFirst());
} else if (arg == "--stop") {
stop();
return 0;
@@ -418,14 +443,10 @@ int main(int argc, char **argv)
process.setDebug();
process.setSocketNotifier(new QSocketNotifier(serverSocket, QSocketNotifier::Read, &process));
- if (perfParams.length() == 3) {
+ if (!perfParams.isEmpty()) {
QStringList allArgs;
- allArgs << QLatin1String("perf") << QLatin1String("record") << QLatin1String("--call-graph");
- if (perfParams[0] == QLatin1String("dwarf"))
- allArgs << QString(QLatin1String("dwarf,%1")).arg(perfParams[1]);
- else
- allArgs << perfParams[0];
- allArgs << QLatin1String("-F") << perfParams[2] << QLatin1String("-o") << QLatin1String("-")
+ allArgs << QLatin1String("perf") << QLatin1String("record")
+ << perfParams << QLatin1String("-o") << QLatin1String("-")
<< QLatin1String("--") << defaultArgs.join(QLatin1Char(' '));
PerfProcessHandler *server = new PerfProcessHandler(&process, allArgs);