sanitizer_common: fix __sanitizer_get_module_and_offset_for_pc signature mismatch

This fixes the following error:

sanitizer_interface_internal.h:77:7: error: conflicting types for
     '__sanitizer_get_module_and_offset_for_pc'
  int __sanitizer_get_module_and_offset_for_pc(
common_interface_defs.h:349:5: note: previous declaration is here
int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path,

I am getting it on a code that uses sanitizer_common (includes internal headers),
but also transitively gets includes of the public headers in tests
via an internal version of gtest.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D118910
This commit is contained in:
Dmitry Vyukov 2022-02-03 16:04:34 +01:00
parent 23fc20e06c
commit 4f3f4d6722
4 changed files with 14 additions and 11 deletions

View File

@ -739,6 +739,9 @@ bool ReadFileToBuffer(const char *file_name, char **buff, uptr *buff_size,
uptr *read_len, uptr max_len = kDefaultFileMaxSize,
error_t *errno_p = nullptr);
int GetModuleAndOffsetForPc(uptr pc, char *module_name, uptr module_name_len,
uptr *pc_offset);
// When adding a new architecture, don't forget to also update
// script/asan_symbolize.py and sanitizer_symbolizer_libcdep.cpp.
inline const char *ModuleArchToString(ModuleArch arch) {

View File

@ -72,7 +72,7 @@ static void SanitizerDumpCoverage(const uptr* unsorted_pcs, uptr len) {
const uptr pc = pcs[i];
if (!pc) continue;
if (!__sanitizer_get_module_and_offset_for_pc(pc, nullptr, 0, &pcs[i])) {
if (!GetModuleAndOffsetForPc(pc, nullptr, 0, &pcs[i])) {
Printf("ERROR: unknown pc 0x%zx (may happen if dlclose is used)\n", pc);
continue;
}
@ -87,8 +87,7 @@ static void SanitizerDumpCoverage(const uptr* unsorted_pcs, uptr len) {
last_base = module_base;
module_start_idx = i;
module_found = true;
__sanitizer_get_module_and_offset_for_pc(pc, module_name, kMaxPathLength,
&pcs[i]);
GetModuleAndOffsetForPc(pc, module_name, kMaxPathLength, &pcs[i]);
}
}

View File

@ -75,8 +75,8 @@ extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
int __sanitizer_get_module_and_offset_for_pc(
__sanitizer::uptr pc, char *module_path,
__sanitizer::uptr module_path_len, __sanitizer::uptr *pc_offset);
void *pc, char *module_path, __sanitizer::uptr module_path_len,
void **pc_offset);
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
void __sanitizer_cov_trace_cmp();

View File

@ -166,8 +166,8 @@ void BufferedStackTrace::Unwind(u32 max_depth, uptr pc, uptr bp, void *context,
UnwindFast(pc, bp, stack_top, stack_bottom, max_depth);
}
static int GetModuleAndOffsetForPc(uptr pc, char *module_name,
uptr module_name_len, uptr *pc_offset) {
int GetModuleAndOffsetForPc(uptr pc, char *module_name, uptr module_name_len,
uptr *pc_offset) {
const char *found_module_name = nullptr;
bool ok = Symbolizer::GetOrInit()->GetModuleNameAndOffsetForPC(
pc, &found_module_name, pc_offset);
@ -216,10 +216,11 @@ void __sanitizer_symbolize_global(uptr data_addr, const char *fmt,
}
SANITIZER_INTERFACE_ATTRIBUTE
int __sanitizer_get_module_and_offset_for_pc(uptr pc, char *module_name,
int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_name,
uptr module_name_len,
uptr *pc_offset) {
return __sanitizer::GetModuleAndOffsetForPc(pc, module_name, module_name_len,
pc_offset);
void **pc_offset) {
return __sanitizer::GetModuleAndOffsetForPc(
reinterpret_cast<uptr>(pc), module_name, module_name_len,
reinterpret_cast<uptr *>(pc_offset));
}
} // extern "C"