return pos;
}
+const char *StripModuleName(const char *module) {
+ if (module == 0)
+ return 0;
+ if (const char *slash_pos = internal_strrchr(module, '/'))
+ return slash_pos + 1;
+ return module;
+}
+
void PrintSourceLocation(InternalScopedString *buffer, const char *file,
int line, int column) {
CHECK(file);
return false;
}
-char *StripModuleName(const char *module) {
- if (module == 0)
- return 0;
- const char *short_module_name = internal_strrchr(module, '/');
- if (short_module_name)
- short_module_name += 1;
- else
- short_module_name = module;
- return internal_strdup(short_module_name);
-}
-
static atomic_uintptr_t g_total_mmaped;
void IncreaseTotalMmap(uptr size) {
// Error report formatting.
const char *StripPathPrefix(const char *filepath,
const char *strip_file_prefix);
+// Strip the directories from the module name.
+const char *StripModuleName(const char *module);
void PrintSourceLocation(InternalScopedString *buffer, const char *file,
int line, int column);
void PrintModuleAndOffset(InternalScopedString *buffer,
u64 NanoTime();
int Atexit(void (*function)(void));
void SortArray(uptr *array, uptr size);
-// Strip the directories from the module name, return a new string allocated
-// with internal_strdup.
-char *StripModuleName(const char *module);
// Exit
void NORETURN Abort();
CHECK_LE(diff, 0xffffffffU);
offsets.push_back(static_cast<u32>(diff));
}
- char *module_name = StripModuleName(module.data());
+ const char *module_name = StripModuleName(module.data());
if (cov_sandboxed) {
if (cov_fd >= 0) {
CovWritePacked(internal_getpid(), module_name, offsets.data(),
vb - old_vb);
}
}
- InternalFree(module_name);
}
}
if (cov_fd >= 0)
text.append("%d\n", sizeof(uptr) * 8);
for (int i = 0; i < n_modules; ++i) {
- char *module_name = StripModuleName(modules[i].full_name());
+ const char *module_name = StripModuleName(modules[i].full_name());
for (unsigned j = 0; j < modules[i].n_ranges(); ++j) {
if (modules[i].address_range_executable(j)) {
uptr start = modules[i].address_range_start(j);
cached_mapping.SetModuleRange(start, end);
}
}
- InternalFree(module_name);
}
int err;
if (ent->col)
Printf(":%d", ent->col);
if (ent->module && ent->offset) {
- char *stripped_module = StripModuleName(ent->module);
- Printf(" (%s+%p)\n", stripped_module, (void*)ent->offset);
- InternalFree(stripped_module);
+ Printf(" (%s+%p)\n", StripModuleName(ent->module), (void*)ent->offset);
} else {
Printf(" (%p)\n", (void*)ent->pc);
}
bool print_stack = false;
Printf("%s", d.Location());
if (loc->type == ReportLocationGlobal) {
- char *stripped_module = StripModuleName(loc->module);
- Printf(" Location is global '%s' of size %zu at %p (%s+%p)\n\n",
- loc->name, loc->size, loc->addr, stripped_module, loc->offset);
- InternalFree(stripped_module);
+ Printf(" Location is global '%s' of size %zu at %p (%s+%p)\n\n", loc->name,
+ loc->size, loc->addr, StripModuleName(loc->module), loc->offset);
} else if (loc->type == ReportLocationHeap) {
char thrbuf[kThreadBufSize];
Printf(" Location is heap block of size %zu at %p allocated by %s:\n",