static const char* k_printTgidPath =
"/sys/kernel/debug/tracing/options/print-tgid";
+static const char* k_recordTgidPath =
+ "/sys/kernel/debug/tracing/options/record-tgid";
+
static const char* k_funcgraphAbsTimePath =
"/sys/kernel/debug/tracing/options/funcgraph-abstime";
return true;
}
+// Since Linux kernel 4.13, an option is added for printing
+// recorded TGID, namely 'record-tgid'.
+// In order to print TGID of tasks, atrace should enable
+// this option.
+static bool setRecordTgidEnableIfPresent(bool enable)
+{
+ if (fileExists(k_recordTgidPath)) {
+ return setKernelOptionEnable(k_recordTgidPath, enable);
+ }
+ return true;
+}
+
static bool getBootupTagStr(char* bootupTagStr, int strSize)
{
if(fileExists(BOOTUP_TRACE)) {
ok &= setKernelTraceFuncs(g_kernelTraceFuncs);
}
ok &= setPrintTgidEnableIfPresent(true);
+ ok &= setRecordTgidEnableIfPresent(true);
// Set up the tags property.
uint64_t tags = 0;
setTraceBufferSizeKB(1);
setBestClock(false);
setPrintTgidEnableIfPresent(false);
+ setRecordTgidEnableIfPresent(false);
setKernelTraceFuncs(nullptr);
}