/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* Request authorization to read mappings */
if (task_for_pid(mach_task_self(), pid, &map) != KERN_SUCCESS) {
std::perror("task_for_pid failed");
/* Request authorization to read mappings */
if (task_for_pid(mach_task_self(), pid, &map) != KERN_SUCCESS) {
std::perror("task_for_pid failed");
if (dladdr(reinterpret_cast<void*>(address), &dlinfo))
memreg.pathname = dlinfo.dli_fname;
if (dladdr(reinterpret_cast<void*>(address), &dlinfo))
memreg.pathname = dlinfo.dli_fname;
- XBT_DEBUG("Region: %016" PRIx64 "-%016" PRIx64 " | %c%c%c | %s", memreg.start_addr, memreg.end_addr,
+#if 0 /* debug */
+ std::fprintf(stderr, "Region: %016" PRIx64 "-%016" PRIx64 " | %c%c%c | %s\n", memreg.start_addr, memreg.end_addr,
(memreg.prot & PROT_READ) ? 'r' : '-', (memreg.prot & PROT_WRITE) ? 'w' : '-',
(memreg.prot & PROT_EXEC) ? 'x' : '-', memreg.pathname.c_str());
(memreg.prot & PROT_READ) ? 'r' : '-', (memreg.prot & PROT_WRITE) ? 'w' : '-',
(memreg.prot & PROT_EXEC) ? 'x' : '-', memreg.pathname.c_str());
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
- char* tok = strtok_r(lfields[0], "-", &saveptr);
- if (tok == nullptr)
- xbt_die("Start and end address of the map are not concatenated by a hyphen (-). Recovery impossible.");
+ const char* tok = strtok_r(lfields[0], "-", &saveptr);
+ if (tok == nullptr) {
+ std::fprintf(stderr,
+ "Start and end address of the map are not concatenated by a hyphen (-). Recovery impossible.\n");
+ abort();
+ }
VmMap memreg;
char *endptr;
memreg.start_addr = std::strtoull(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
VmMap memreg;
char *endptr;
memreg.start_addr = std::strtoull(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
memreg.end_addr = std::strtoull(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
memreg.end_addr = std::strtoull(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
- XBT_WARN("The protection is neither 'p' (private) nor 's' (shared) but '%s'. Let's assume shared, as on b0rken "
- "win-ubuntu systems.\nFull line: %s\n",
- lfields[1], line);
+ fprintf(stderr,
+ "The protection is neither 'p' (private) nor 's' (shared) but '%s'. Let's assume shared, as on b0rken "
+ "win-ubuntu systems.\nFull line: %s\n",
+ lfields[1], line);
}
/* Get the offset value */
memreg.offset = std::strtoull(lfields[2], &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
}
/* Get the offset value */
memreg.offset = std::strtoull(lfields[2], &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
/* Get the device major:minor bytes */
tok = strtok_r(lfields[3], ":", &saveptr);
if (tok == nullptr)
/* Get the device major:minor bytes */
tok = strtok_r(lfields[3], ":", &saveptr);
if (tok == nullptr)
memreg.dev_major = (char) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
memreg.dev_major = (char) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
memreg.dev_minor = (char) std::strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
memreg.dev_minor = (char) std::strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
if (*endptr != '\0')
/* Get the inode number and make sure that the entire string was a long int */
memreg.inode = strtoul(lfields[4], &endptr, 10);
if (*endptr != '\0')
/* Get the inode number and make sure that the entire string was a long int */
memreg.inode = strtoul(lfields[4], &endptr, 10);
if (*endptr != '\0')
/* Create space for a new map region in the region's array and copy the */
/* parsed stuff from the temporal memreg variable */
/* Create space for a new map region in the region's array and copy the */
/* parsed stuff from the temporal memreg variable */
}
if ((proc = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt)) == NULL) {
std::perror("procstat_open_sysctl failed");
}
if ((proc = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt)) == NULL) {
std::perror("procstat_open_sysctl failed");
}
if ((vmentries = procstat_getvmmap(prstat, proc, &cnt)) == NULL) {
std::perror("procstat_getvmmap failed");
}
if ((vmentries = procstat_getvmmap(prstat, proc, &cnt)) == NULL) {
std::perror("procstat_getvmmap failed");