// The userland tracing tags that the category enables.
uint64_t tags;
- // The fname==NULL terminated list of /sys/ files that the category
+ // The fname==nullptr terminated list of /sys/ files that the category
// enables.
struct {
// Whether the file must be writable in order to enable the tracing
static bool g_compress = false;
static bool g_nohup = false;
static int g_initialSleepSecs = 0;
-static const char* g_kernelTraceFuncs = NULL;
+static const char* g_kernelTraceFuncs = nullptr;
static const char* g_debugAppCmdLine = "";
/* Global state */
for (int i = 0; i < MAX_SYS_FILES; i++) {
const char* path = category.sysfiles[i].path;
bool req = category.sysfiles[i].required == REQ;
- if (path != NULL) {
+ if (path != nullptr) {
if (req) {
if (!fileIsWritable(path)) {
return false;
for (int i = 0; i < MAX_SYS_FILES; i++) {
const char* path = category.sysfiles[i].path;
bool req = category.sysfiles[i].required == REQ;
- if (path != NULL) {
+ if (path != nullptr) {
if (req) {
if (!fileExists(path)) {
return false;
static bool getBootupTagStr(char* bootupTagStr, int strSize)
{
if(fileExists(BOOTUP_TRACE)) {
- FILE *bootupTagFile = NULL;
+ FILE *bootupTagFile = nullptr;
bootupTagFile = fopen(BOOTUP_TRACE, "r");
- if (bootupTagFile == NULL) {
+ if (bootupTagFile == nullptr) {
return false;
}
if (fgets(bootupTagStr, strSize, bootupTagFile) == NULL) {
char* tagPtr;
char* nextTagPtr;
tagPtr = strtok_r(bootupTagStr, " \n", &nextTagPtr);
- while (tagPtr != NULL) {
+ while (tagPtr != nullptr) {
setCategoryEnable(tagPtr, true);
fprintf(stderr, "[Info] Tag %s enabled\n", tagPtr);
- tagPtr = strtok_r(NULL, " \n", &nextTagPtr);
+ tagPtr = strtok_r(nullptr, " \n", &nextTagPtr);
}
return;
}
static bool initEnabledTagFile()
{
- uint64_t *sm_for_enabled_tag = NULL;
+ uint64_t *sm_for_enabled_tag = nullptr;
int fd = -1;
if(fileExists(ENABLED_TAG_FILE)) {
close(fd);
return false;
}
- sm_for_enabled_tag = (uint64_t*)mmap(NULL, sizeof(uint64_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ sm_for_enabled_tag = (uint64_t*)mmap(nullptr, sizeof(uint64_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if(sm_for_enabled_tag == MAP_FAILED) {
fprintf(stderr, "mmap() failed(%s)\n", strerror_r(errno, str_error, sizeof(str_error)));
// processes to pick up the new value.
static bool setTagsProperty(uint64_t tags)
{
- uint64_t *sm_for_enabled_tag = NULL;
+ uint64_t *sm_for_enabled_tag = nullptr;
int fd = -1;
// atrace normal mode
fprintf(stderr, "Fail to open enabled_tag file: %s(%d)\n", strerror_r(errno, str_error, sizeof(str_error)), errno);
return false;
}
- sm_for_enabled_tag = (uint64_t*)mmap(NULL, sizeof(uint64_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ sm_for_enabled_tag = (uint64_t*)mmap(nullptr, sizeof(uint64_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if(sm_for_enabled_tag == MAP_FAILED) {
fprintf(stderr, "mmap() failed(%s)\n", strerror_r(errno, str_error, sizeof(str_error)));
close(fd);
const TracingCategory &c = k_categories[i];
for (int j = 0; j < MAX_SYS_FILES; j++) {
const char* path = c.sysfiles[j].path;
- if (path != NULL && fileIsWritable(path)) {
+ if (path != nullptr && fileIsWritable(path)) {
ok &= setKernelOptionEnable(path, false);
}
}
bool ok = true;
char *ptr[2];
- if (funcs == NULL || funcs[0] == '\0') {
+ if (funcs == nullptr || funcs[0] == '\0') {
// Disable kernel function tracing.
if (fileIsWritable(k_currentTracerPath)) {
ok &= writeStr(k_currentTracerPath, "nop");
for (int j = 0; j < MAX_SYS_FILES; j++) {
const char* path = c.sysfiles[j].path;
bool required = c.sysfiles[j].required == REQ;
- if (path != NULL) {
+ if (path != nullptr) {
if (fileIsWritable(path)) {
ok &= setKernelOptionEnable(path, true);
} else if (required) {
setTraceBufferSizeKB(1);
setGlobalClockEnable(false);
setPrintTgidEnableIfPresent(false);
- setKernelTraceFuncs(NULL);
+ setKernelTraceFuncs(nullptr);
}
// Disable tracing in the kernel.
const size_t bufSize = 64*1024;
in = (uint8_t*)malloc(bufSize);
out = (uint8_t*)malloc(bufSize);
- if ((in == NULL) || (out == NULL)) {
+ if ((in == nullptr) || (out == nullptr)) {
fprintf(stderr, "Could not allocate memory");
- if (in != NULL)
+ if (in != nullptr)
free(in);
- if (out != NULL)
+ if (out != nullptr)
free(out);
close(traceFD);
if (backup_fd > -1)
} else {
ssize_t sent = 0;
if (startup)
- while ((sent = sendfile(backup_fd, traceFD, NULL, 64*1024*1024)) > 0);
+ while ((sent = sendfile(backup_fd, traceFD, nullptr, 64*1024*1024)) > 0);
else
- while ((sent = sendfile(STDOUT_FILENO, traceFD, NULL, 64*1024*1024)) > 0);
+ while ((sent = sendfile(STDOUT_FILENO, traceFD, nullptr, 64*1024*1024)) > 0);
if (sent == -1) {
fprintf(stderr, "error dumping trace: %s (%d)\n", strerror_r(errno, str_error, sizeof(str_error)),
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = handleSignal;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGQUIT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGHUP, &sa, nullptr);
+ sigaction(SIGINT, &sa, nullptr);
+ sigaction(SIGQUIT, &sa, nullptr);
+ sigaction(SIGTERM, &sa, nullptr);
}
static bool setCategoryEnable(const char* name, bool enable)
int ret;
int option_index = 0;
static struct option long_options[] = {
- {"async_start", no_argument, 0, 0 },
- {"async_stop", no_argument, 0, 0 },
- {"async_dump", no_argument, 0, 0 },
- {"list_categories", no_argument, 0, 0 },
- {"init_exec", no_argument, 0, 0 },
- {"append", no_argument, 0, 0 },
- {"backup", no_argument, 0, 0 },
- {0, 0, 0, 0 }
+ {"async_start", no_argument, nullptr, 0 },
+ {"async_stop", no_argument, nullptr, 0 },
+ {"async_dump", no_argument, nullptr, 0 },
+ {"list_categories", no_argument, nullptr, 0 },
+ {"init_exec", no_argument, nullptr, 0 },
+ {"append", no_argument, nullptr, 0 },
+ {"backup", no_argument, nullptr, 0 },
+ {0, 0, nullptr, 0 }
};
ret = getopt_long(argc, argv, "b:ck:e:ns:t:z",
long_options, &option_index);