Skip to content

Commit

Permalink
s/INOUT/DR_PARAM_INOUT/; similarly for IN and OUT, to match the DR re…
Browse files Browse the repository at this point in the history
…names.
  • Loading branch information
derekbruening committed Jan 13, 2024
1 parent ff0b13d commit 1127fb4
Show file tree
Hide file tree
Showing 64 changed files with 697 additions and 666 deletions.
50 changes: 25 additions & 25 deletions common/alloc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2021 Google, Inc. All rights reserved.
* Copyright (c) 2010-2024 Google, Inc. All rights reserved.
* Copyright (c) 2008-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -138,7 +138,7 @@ set_brk(byte *new_val)
#endif

static void
alloc_hook(void *wrapcxt, INOUT void **user_data);
alloc_hook(void *wrapcxt, DR_PARAM_INOUT void **user_data);

static void
handle_alloc_post(void *wrapcxt, void *user_data);
Expand Down Expand Up @@ -967,7 +967,7 @@ replace_realloc_size_app(void *p)
}

static void
replace_realloc_size_pre(void *wrapcxt, OUT void **user_data)
replace_realloc_size_pre(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
cls_alloc_t *pt = (cls_alloc_t *)
drmgr_get_cls_field(dr_get_current_drcontext(), cls_idx_alloc);
Expand Down Expand Up @@ -1594,7 +1594,7 @@ modname_is_libc_or_libcpp(const char *modname)

static bool
distinguish_operator_by_decoding(routine_type_t generic_type,
routine_type_t *specific_type OUT,
routine_type_t *specific_type DR_PARAM_OUT,
const char *name, const module_data_t *mod,
size_t modoffs)
{
Expand Down Expand Up @@ -1691,7 +1691,7 @@ distinguish_operator_by_decoding(routine_type_t generic_type,
*/
static bool
distinguish_operator_no_argtypes(routine_type_t generic_type,
routine_type_t *specific_type OUT,
routine_type_t *specific_type DR_PARAM_OUT,
const char *name, const module_data_t *mod,
size_t modoffs)
{
Expand Down Expand Up @@ -2588,10 +2588,10 @@ malloc_wrap__unintercept(app_pc pc, routine_type_t type, alloc_routine_entry_t *
*/

#ifdef WINDOWS
typedef size_t (__stdcall *rtl_size_func_t)(IN reg_t /*really HANDLE*/ Heap,
IN ULONG flags,
IN PVOID ptr);
typedef size_t (*dbg_size_func_t)(IN byte *pc, int blocktype);
typedef size_t (__stdcall *rtl_size_func_t)(DR_PARAM_IN reg_t /*really HANDLE*/ Heap,
DR_PARAM_IN ULONG flags,
DR_PARAM_IN PVOID ptr);
typedef size_t (*dbg_size_func_t)(DR_PARAM_IN byte *pc, int blocktype);
#else
/* points at libc's version, used in initial heap walk */
alloc_size_func_t libc_malloc_usable_size;
Expand Down Expand Up @@ -2944,7 +2944,7 @@ malloc_entry_redzone_size(malloc_entry_t *e)
}

static void
malloc_entry_to_info(malloc_entry_t *e, malloc_info_t *info OUT)
malloc_entry_to_info(malloc_entry_t *e, malloc_info_t *info DR_PARAM_OUT)
{
info->struct_size = sizeof(*info);
info->base = e->start;
Expand Down Expand Up @@ -6391,23 +6391,23 @@ handle_userinfo_pre(void *drcontext, cls_alloc_t *pt, void *wrapcxt,
/* 3 related routines here:
* BOOLEAN NTAPI
* RtlGetUserInfoHeap(
* IN PVOID HeapHandle,
* IN ULONG Flags,
* IN PVOID BaseAddress,
* OUT PVOID *UserValue,
* OUT PULONG UserFlags);
* DR_PARAM_IN PVOID HeapHandle,
* DR_PARAM_IN ULONG Flags,
* DR_PARAM_IN PVOID BaseAddress,
* DR_PARAM_OUT PVOID *UserValue,
* DR_PARAM_OUT PULONG UserFlags);
* BOOLEAN NTAPI
* RtlSetUserValueHeap(
* IN PVOID HeapHandle,
* IN ULONG Flags,
* IN PVOID BaseAddress,
* IN PVOID UserValue);
* DR_PARAM_IN PVOID HeapHandle,
* DR_PARAM_IN ULONG Flags,
* DR_PARAM_IN PVOID BaseAddress,
* DR_PARAM_IN PVOID UserValue);
* BOOLEAN NTAPI
* RtlSetUserFlagsHeap(
* IN PVOID HeapHandle,
* IN ULONG Flags,
* IN PVOID BaseAddress,
* IN ULONG UserFlags);
* DR_PARAM_IN PVOID HeapHandle,
* DR_PARAM_IN ULONG Flags,
* DR_PARAM_IN PVOID BaseAddress,
* DR_PARAM_IN ULONG UserFlags);
*/
app_pc base = (app_pc) drwrap_get_arg(wrapcxt, 2);
if (malloc_is_native(base, pt, true))
Expand Down Expand Up @@ -6526,7 +6526,7 @@ handle_alloc_pre_ex(void *drcontext, cls_alloc_t *pt, void *wrapcxt,
alloc_routine_entry_t *routine);

static void
alloc_hook(void *wrapcxt, INOUT void **user_data)
alloc_hook(void *wrapcxt, DR_PARAM_INOUT void **user_data)
{
app_pc pc = drwrap_get_func(wrapcxt);
/* XXX: for -conservative we should do a lookup and not trust *user_data
Expand Down Expand Up @@ -6957,7 +6957,7 @@ malloc_large_remove(byte *start)
}

bool
malloc_large_lookup(byte *addr, byte **start OUT, size_t *size OUT)
malloc_large_lookup(byte *addr, byte **start DR_PARAM_OUT, size_t *size DR_PARAM_OUT)
{
bool res = false;
rb_node_t *node;
Expand Down
14 changes: 7 additions & 7 deletions common/alloc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2020 Google, Inc. All rights reserved.
* Copyright (c) 2010-2024 Google, Inc. All rights reserved.
* Copyright (c) 2008-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -194,7 +194,7 @@ malloc_add(app_pc start, app_pc end, app_pc real_end,

/* Looks up mallocs in the "large malloc table" (for mallocs used as stacks) */
bool
malloc_large_lookup(byte *addr, byte **start OUT, size_t *size OUT);
malloc_large_lookup(byte *addr, byte **start DR_PARAM_OUT, size_t *size DR_PARAM_OUT);

bool
malloc_is_pre_us_ex(app_pc start, bool ok_if_invalid);
Expand Down Expand Up @@ -275,17 +275,17 @@ alloc_replace_in_cur_arena(byte *addr);
/* overlap check includes redzone */
bool
alloc_replace_overlaps_delayed_free(byte *start, byte *end,
malloc_info_t *info INOUT);
malloc_info_t *info DR_PARAM_INOUT);

/* overlap check includes redzone */
bool
alloc_replace_overlaps_any_free(byte *start, byte *end,
malloc_info_t *info INOUT);
malloc_info_t *info DR_PARAM_INOUT);

/* overlap check includes redzone */
bool
alloc_replace_overlaps_malloc(byte *start, byte *end,
malloc_info_t *info INOUT);
malloc_info_t *info DR_PARAM_INOUT);

/* Allocate application memory for clients.
* This function can only be used with -replace_malloc and
Expand Down Expand Up @@ -379,7 +379,7 @@ client_handle_realloc_null(app_pc pc, dr_mcontext_t *mc);
* For wrapping:
* Up to the caller to delay, via its return value.
* Returns the value to pass to free(). Return "tofree" for no change.
* The Windows heap param is INOUT so it can be changed as well.
* The Windows heap param is DR_PARAM_INOUT so it can be changed as well.
* client_data is from client_add_malloc_routine().
* For replacing:
* The return value is ignored. Frees are always delayed, unless
Expand All @@ -394,7 +394,7 @@ client_handle_realloc_null(app_pc pc, dr_mcontext_t *mc);
app_pc
client_handle_free(malloc_info_t *info, byte *tofree, dr_mcontext_t *mc,
app_pc free_routine, void *routine_set_data, bool for_reuse
_IF_WINDOWS(ptr_int_t *auxarg INOUT));
_IF_WINDOWS(ptr_int_t *auxarg DR_PARAM_INOUT));

/* For wrapping:
* Never called.
Expand Down
26 changes: 14 additions & 12 deletions common/alloc_replace.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2012-2021 Google, Inc. All rights reserved.
* Copyright (c) 2012-2024 Google, Inc. All rights reserved.
* **********************************************************/

/* Dr. Memory: the memory debugger
Expand Down Expand Up @@ -1139,7 +1139,7 @@ arena_delayed_list_full(arena_header_t *arena)

static inline chunk_header_t *
next_chunk_forward(arena_header_t *arena, chunk_header_t *head,
arena_header_t **container_out OUT)
arena_header_t **container_out DR_PARAM_OUT)
{
arena_header_t *container;
byte *start = ptr_from_header(head);
Expand Down Expand Up @@ -2396,11 +2396,11 @@ alloc_iterate(malloc_iter_cb_t cb, void *iter_data, bool only_live)

static bool
overlap_helper(chunk_header_t *head,
malloc_info_t *info INOUT,
malloc_info_t *info DR_PARAM_INOUT,
uint positive_flags,
uint negative_flags)
{
/* XXX: this is the one INOUT case of this structure. Once we extend it,
/* XXX: this is the one DR_PARAM_INOUT case of this structure. Once we extend it,
* we need to handle back-compat struct size here. For now, header_to_info()
* is used here and by above internal code that doesn't set struct-size.
*/
Expand All @@ -2421,7 +2421,7 @@ overlap_helper(chunk_header_t *head,
/* Considers alloc_size to overlap, but returns request size in *found_end */
static bool
alloc_replace_overlaps_region(byte *start, byte *end,
malloc_info_t *info INOUT,
malloc_info_t *info DR_PARAM_INOUT,
uint positive_flags,
uint negative_flags)
{
Expand Down Expand Up @@ -2514,21 +2514,21 @@ alloc_replace_overlaps_region(byte *start, byte *end,

bool
alloc_replace_overlaps_delayed_free(byte *start, byte *end,
malloc_info_t *info OUT)
malloc_info_t *info DR_PARAM_OUT)
{
return alloc_replace_overlaps_region(start, end, info, CHUNK_DELAY_FREE, 0);
}

bool
alloc_replace_overlaps_any_free(byte *start, byte *end,
malloc_info_t *info OUT)
malloc_info_t *info DR_PARAM_OUT)
{
return alloc_replace_overlaps_region(start, end, info, CHUNK_FREED, 0);
}

bool
alloc_replace_overlaps_malloc(byte *start, byte *end,
malloc_info_t *info OUT)
malloc_info_t *info DR_PARAM_OUT)
{
return alloc_replace_overlaps_region(start, end, info, 0, CHUNK_FREED);
}
Expand Down Expand Up @@ -3574,7 +3574,7 @@ replace_context_exit(void *drcontext, bool thread_exit)
}

static void
replace_start_nosy_sequence(void *wrapcxt, OUT void **user_data)
replace_start_nosy_sequence(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
cls_replace_t *data = (cls_replace_t *)
drmgr_get_cls_field(dr_get_current_drcontext(), cls_idx_replace);
Expand All @@ -3588,7 +3588,7 @@ replace_start_nosy_sequence(void *wrapcxt, OUT void **user_data)
}

static void
replace_stop_nosy_sequence(void *wrapcxt, OUT void **user_data)
replace_stop_nosy_sequence(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
cls_replace_t *data = (cls_replace_t *)
drmgr_get_cls_field(dr_get_current_drcontext(), cls_idx_replace);
Expand Down Expand Up @@ -4201,7 +4201,8 @@ replace_ignore_arg5(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5)
* RtlHeap iteration replacement routines
*/

typedef NTSTATUS (*PHEAP_ENUMERATION_ROUTINE)(IN PVOID HeapHandle, IN PVOID UserParam);
typedef NTSTATUS (*PHEAP_ENUMERATION_ROUTINE)(DR_PARAM_IN PVOID HeapHandle,
DR_PARAM_IN PVOID UserParam);

typedef struct _getheaps_data_t {
ULONG actual_len;
Expand Down Expand Up @@ -4700,7 +4701,8 @@ alloc_entering_replace_routine(app_pc pc)

static bool
func_interceptor(routine_type_t type, bool check_mismatch, bool check_winapi_match,
void **routine OUT, bool *at_entry OUT, uint *stack OUT)
void **routine DR_PARAM_OUT, bool *at_entry DR_PARAM_OUT,
uint *stack DR_PARAM_OUT)
{
/* almost everything is at the callee entry */
*at_entry = true;
Expand Down
7 changes: 4 additions & 3 deletions common/asm_utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2021 Google, Inc. All rights reserved.
* Copyright (c) 2010-2024 Google, Inc. All rights reserved.
* Copyright (c) 2007-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand All @@ -25,11 +25,12 @@

/* Returns the current values of xsp and xbp */
void
get_stack_registers(reg_t *xsp OUT, reg_t *xbp OUT);
get_stack_registers(reg_t *xsp DR_PARAM_OUT, reg_t *xbp DR_PARAM_OUT);

/* Returns the current values of xsp and xbp */
void
get_unwind_registers(reg_t *xsp OUT, reg_t *xbp OUT, app_pc *xip OUT);
get_unwind_registers(reg_t *xsp DR_PARAM_OUT, reg_t *xbp DR_PARAM_OUT,
app_pc *xip DR_PARAM_OUT);

#ifdef UNIX
ptr_int_t
Expand Down
Loading

0 comments on commit 1127fb4

Please sign in to comment.