mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
sclog: wrap memmove.
I had a testsc run fail because of alignment-dependent control flow divergence in a glibc function with 'memmove' in the name, which appears to have been an accident of different memory allocation between two runs of the test in question. sclog was already giving special handling to memset for the same reason, so it's no trouble to add memmove to the same list of functions that are treated as an opaque primitive for logging purposes.
This commit is contained in:
parent
3bb12dff3b
commit
1c78d18acb
@ -269,6 +269,38 @@ static void wrap_memset_pre(void *wrapctx, void **user_data)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Similarly to the above, wrap some versions of memmove.
|
||||
*/
|
||||
static void wrap_memmove_pre(void *wrapctx, void **user_data)
|
||||
{
|
||||
uint was_already_paused = logging_paused++;
|
||||
|
||||
if (outfile == INVALID_FILE || was_already_paused)
|
||||
return;
|
||||
|
||||
const void *daddr = drwrap_get_arg(wrapctx, 0);
|
||||
const void *saddr = drwrap_get_arg(wrapctx, 1);
|
||||
size_t size = (size_t)drwrap_get_arg(wrapctx, 2);
|
||||
|
||||
|
||||
struct allocation *alloc;
|
||||
|
||||
dr_fprintf(outfile, "memmove %"PRIuMAX" ", (uintmax_t)size);
|
||||
if (!(alloc = find_allocation(daddr))) {
|
||||
dr_fprintf(outfile, "to %"PRIxMAX" ", (uintmax_t)daddr);
|
||||
} else {
|
||||
dr_fprintf(outfile, "to allocations[%"PRIuPTR"] + %"PRIxMAX" ",
|
||||
alloc->index, (uintmax_t)(daddr - alloc->start));
|
||||
}
|
||||
if (!(alloc = find_allocation(saddr))) {
|
||||
dr_fprintf(outfile, "from %"PRIxMAX"\n", (uintmax_t)saddr);
|
||||
} else {
|
||||
dr_fprintf(outfile, "from allocations[%"PRIuPTR"] + %"PRIxMAX"\n",
|
||||
alloc->index, (uintmax_t)(saddr - alloc->start));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Common post-wrapper function for memset and free, whose entire
|
||||
* function is to unpause the logging.
|
||||
@ -565,6 +597,7 @@ static void load_module(
|
||||
TRY_WRAP("realloc", wrap_realloc_pre, wrap_alloc_post);
|
||||
TRY_WRAP("free", wrap_free_pre, unpause_post);
|
||||
TRY_WRAP("memset", wrap_memset_pre, unpause_post);
|
||||
TRY_WRAP("memmove", wrap_memmove_pre, unpause_post);
|
||||
|
||||
/*
|
||||
* More strangely named versions of standard C library
|
||||
@ -585,6 +618,8 @@ static void load_module(
|
||||
TRY_WRAP("__GI___libc_free", wrap_free_pre, unpause_post);
|
||||
TRY_WRAP("__memset_sse2_unaligned", wrap_memset_pre, unpause_post);
|
||||
TRY_WRAP("__memset_sse2", wrap_memset_pre, unpause_post);
|
||||
TRY_WRAP("__memmove_avx_unaligned_erms", wrap_memmove_pre,
|
||||
unpause_post);
|
||||
TRY_WRAP("cfree", wrap_free_pre, unpause_post);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user