Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#3348 sym conflicts: add DR_PARAM_ to IN, OUT, INOUT #6455

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/samples/bbsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void
event_exit(void);
static dr_emit_flags_t
event_bb_analysis(void *drcontext, void *tag, instrlist_t *bb, bool for_trace,
bool translating, OUT void **user_data);
bool translating, DR_PARAM_OUT void **user_data);

DR_EXPORT void
dr_client_main(client_id_t id, int argc, const char *argv[])
Expand Down Expand Up @@ -110,7 +110,7 @@ event_exit(void)

static dr_emit_flags_t
event_bb_analysis(void *drcontext, void *tag, instrlist_t *bb, bool for_trace,
bool translating, OUT void **user_data)
bool translating, DR_PARAM_OUT void **user_data)
{
int cur_size = 0;

Expand Down
2 changes: 1 addition & 1 deletion api/samples/callstack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ print_qualified_function_name(app_pc pc)
}

static void
wrap_pre(void *wrapcxt, OUT void **user_data)
wrap_pre(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
dr_fprintf(STDERR, "%s called from:\n", trace_function.get_value().c_str());
// Get the context. The pc field is set by drwrap to the wrapped function
Expand Down
2 changes: 1 addition & 1 deletion api/samples/div.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ callback(app_pc addr, uint divisor)

/* If instr is unsigned division, return true and set *opnd to divisor. */
static bool
instr_is_div(instr_t *instr, OUT opnd_t *opnd)
instr_is_div(instr_t *instr, DR_PARAM_OUT opnd_t *opnd)
{
int opc = instr_get_opcode(instr);
#if defined(X86)
Expand Down
2 changes: 1 addition & 1 deletion api/samples/hot_bbcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ set_up_bb_dups(void *drbbdup_ctx, void *drcontext, void *tag, instrlist_t *bb,

static void
analyse_orig_bb(void *drcontext, void *tag, instrlist_t *bb, void *user_data,
IN void **orig_analysis_data)
DR_PARAM_IN void **orig_analysis_data)
{
/* Extract bb_pc and store it as analysis data. */
app_pc *bb_pc = dr_thread_alloc(drcontext, sizeof(app_pc));
Expand Down
2 changes: 1 addition & 1 deletion api/samples/opcode_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ event_opcode_instruction(void *drcontext, void *tag, instrlist_t *bb, instr_t *i

static dr_emit_flags_t
event_bb_analysis(void *drcontext, void *tag, instrlist_t *bb, bool for_trace,
bool translating, OUT void **user_data)
bool translating, DR_PARAM_OUT void **user_data)
{
intptr_t bb_size = (intptr_t)drx_instrlist_app_size(bb);
*user_data = (void *)bb_size;
Expand Down
8 changes: 4 additions & 4 deletions api/samples/ssljack.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@

/* OpenSSL and GnuTLS - shared wrappers */
static void
wrap_pre_SSL_write(void *wrapcxt, OUT void **user_data);
wrap_pre_SSL_write(void *wrapcxt, DR_PARAM_OUT void **user_data);
static void
wrap_pre_SSL_read(void *wrapcxt, OUT void **user_data);
wrap_pre_SSL_read(void *wrapcxt, DR_PARAM_OUT void **user_data);
static void
wrap_post_SSL_read(void *wrapcxt, void *user_data);

Expand Down Expand Up @@ -128,7 +128,7 @@ dr_init(client_id_t id)
}

static void
wrap_pre_SSL_write(void *wrapcxt, OUT void **user_data)
wrap_pre_SSL_write(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
/* int SSL_write(SSL *ssl, const void *buf, int num);
*
Expand Down Expand Up @@ -161,7 +161,7 @@ wrap_pre_SSL_write(void *wrapcxt, OUT void **user_data)
}

static void
wrap_pre_SSL_read(void *wrapcxt, OUT void **user_data)
wrap_pre_SSL_read(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
struct SSL_read_data *sd;

Expand Down
2 changes: 1 addition & 1 deletion api/samples/statecmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ error_callback(const char *msg, void *tag)

static dr_emit_flags_t
event_analysis(void *drcontext, void *tag, instrlist_t *bb, bool for_trace,
bool translating, OUT void **user_data)
bool translating, DR_PARAM_OUT void **user_data)
{

bool *side_effect_free = (bool *)dr_thread_alloc(drcontext, sizeof(bool));
Expand Down
4 changes: 2 additions & 2 deletions api/samples/wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
static void
event_exit(void);
static void
wrap_pre(void *wrapcxt, OUT void **user_data);
wrap_pre(void *wrapcxt, DR_PARAM_OUT void **user_data);
static void
wrap_post(void *wrapcxt, void *user_data);

Expand Down Expand Up @@ -141,7 +141,7 @@ event_exit(void)
}

static void
wrap_pre(void *wrapcxt, OUT void **user_data)
wrap_pre(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
/* malloc(size) or HeapAlloc(heap, flags, size) */
size_t sz = (size_t)drwrap_get_arg(wrapcxt, IF_WINDOWS_ELSE(2, 0));
Expand Down
12 changes: 6 additions & 6 deletions clients/drcachesim/common/named_pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ typedef int ssize_t;
# endif
#endif

#ifndef OUT
# define OUT // nothing
#ifndef DR_PARAM_OUT
# define DR_PARAM_OUT // nothing
#endif
#ifndef IN
# define IN // nothing
#ifndef DR_PARAM_IN
# define DR_PARAM_IN // nothing
#endif

// Usage is as follows:
Expand Down Expand Up @@ -98,12 +98,12 @@ class named_pipe_t {
// Returns < 0 on EOF or an error.
// On success (or partial read) returns number of bytes read.
ssize_t
read(void *buf OUT, size_t sz);
read(void *buf DR_PARAM_OUT, size_t sz);

// Returns < 0 on an error.
// On success (or partial write) returns number of bytes written.
ssize_t
write(const void *buf IN, size_t sz);
write(const void *buf DR_PARAM_IN, size_t sz);

#ifdef UNIX
// On UNIX, rather than calling open_for_{read,write}, The caller
Expand Down
4 changes: 2 additions & 2 deletions clients/drcachesim/common/named_pipe_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ named_pipe_t::set_fd(int fd)
}

ssize_t
named_pipe_t::read(void *buf OUT, size_t sz)
named_pipe_t::read(void *buf DR_PARAM_OUT, size_t sz)
{
int res = -1;
while (true) {
Expand All @@ -211,7 +211,7 @@ named_pipe_t::read(void *buf OUT, size_t sz)
}

ssize_t
named_pipe_t::write(const void *buf IN, size_t sz)
named_pipe_t::write(const void *buf DR_PARAM_IN, size_t sz)
{
int res = -1;
while (true) {
Expand Down
4 changes: 2 additions & 2 deletions clients/drcachesim/common/named_pipe_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ named_pipe_t::maximize_buffer()
}

ssize_t
named_pipe_t::read(void *buf OUT, size_t sz)
named_pipe_t::read(void *buf DR_PARAM_OUT, size_t sz)
{
DWORD actual;
BOOL res = ReadFile(fd_, buf, (DWORD)sz, &actual, NULL);
Expand All @@ -156,7 +156,7 @@ named_pipe_t::read(void *buf OUT, size_t sz)
}

ssize_t
named_pipe_t::write(const void *buf IN, size_t sz)
named_pipe_t::write(const void *buf DR_PARAM_IN, size_t sz)
{
DWORD actual;
BOOL res = WriteFile(fd_, buf, (DWORD)sz, &actual, NULL);
Expand Down
4 changes: 2 additions & 2 deletions clients/drcachesim/drpt2trace/drpt2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static droption_t<unsigned long long> op_sb_kernel_start(
*/

static void
print_results(IN drir_t &drir, IN std::vector<trace_entry_t> &entries)
print_results(DR_PARAM_IN drir_t &drir, DR_PARAM_IN std::vector<trace_entry_t> &entries)
{
if (drir.get_ilist() == nullptr) {
std::cerr << "The list to store decoded instructions is not initialized."
Expand Down Expand Up @@ -353,7 +353,7 @@ option_init(int argc, const char *argv[])

/* Load binary data from file into a vector. */
static bool
load_file(IN const std::string &path, OUT std::vector<uint8_t> &buffer)
load_file(DR_PARAM_IN const std::string &path, DR_PARAM_OUT std::vector<uint8_t> &buffer)
{
/* Under C++11, there is no good solution to get the file size after using ifstream to
* open a file. Because we will not change the PT raw trace file during converting, we
Expand Down
21 changes: 11 additions & 10 deletions clients/drcachesim/drpt2trace/elf_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ namespace drmemtrace {
#define ERRMSG_HEADER "[elf_loader] "

bool
elf_loader_t::load(IN const char *name, IN uint64_t base,
INOUT struct pt_image_section_cache *iscache,
INOUT struct pt_image *image)
elf_loader_t::load(DR_PARAM_IN const char *name, DR_PARAM_IN uint64_t base,
DR_PARAM_INOUT struct pt_image_section_cache *iscache,
DR_PARAM_INOUT struct pt_image *image)
{
if (iscache == nullptr || image == nullptr || name == nullptr) {
ERRMSG(ERRMSG_HEADER "Invalid arguments to load.\n");
Expand Down Expand Up @@ -77,9 +77,10 @@ elf_loader_t::load(IN const char *name, IN uint64_t base,

template <typename Elf_Ehdr, typename Elf_Half, typename Elf_Phdr>
bool
elf_loader_t::load_elf(IN std::ifstream &f, IN const char *name, IN uint64_t base,
INOUT struct pt_image_section_cache *iscache,
INOUT struct pt_image *image)
elf_loader_t::load_elf(DR_PARAM_IN std::ifstream &f, DR_PARAM_IN const char *name,
DR_PARAM_IN uint64_t base,
DR_PARAM_INOUT struct pt_image_section_cache *iscache,
DR_PARAM_INOUT struct pt_image *image)
{
if (!f.is_open()) {
ERRMSG(ERRMSG_HEADER "Failed to load ELF: invalid arguments to load_elf.\n");
Expand Down Expand Up @@ -147,10 +148,10 @@ elf_loader_t::load_elf(IN std::ifstream &f, IN const char *name, IN uint64_t bas
}

bool
elf_loader_t::load_section(IN const char *name, IN uint64_t offset, IN uint64_t size,
IN uint64_t vaddr,
INOUT struct pt_image_section_cache *iscache,
INOUT struct pt_image *image)
elf_loader_t::load_section(DR_PARAM_IN const char *name, DR_PARAM_IN uint64_t offset,
DR_PARAM_IN uint64_t size, DR_PARAM_IN uint64_t vaddr,
DR_PARAM_INOUT struct pt_image_section_cache *iscache,
DR_PARAM_INOUT struct pt_image *image)
{
int errcode = 0;
if (!iscache) {
Expand Down
30 changes: 17 additions & 13 deletions clients/drcachesim/drpt2trace/elf_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ struct pt_image_section_cache;
namespace dynamorio {
namespace drmemtrace {

#ifndef IN
# define IN // nothing
#ifndef DR_PARAM_IN
# define DR_PARAM_IN // nothing
#endif
#ifndef OUT
# define OUT // nothing
#ifndef DR_PARAM_OUT
# define DR_PARAM_OUT // nothing
#endif
#ifndef INOUT
# define INOUT // nothing
#ifndef DR_PARAM_INOUT
# define DR_PARAM_INOUT // nothing
#endif

class elf_loader_t {
Expand All @@ -80,8 +80,9 @@ class elf_loader_t {
* @return true if the ELF file is loaded successfully.
*/
static bool
load(IN const char *name, IN uint64_t base,
INOUT struct pt_image_section_cache *iscache, INOUT struct pt_image *image);
load(DR_PARAM_IN const char *name, DR_PARAM_IN uint64_t base,
DR_PARAM_INOUT struct pt_image_section_cache *iscache,
DR_PARAM_INOUT struct pt_image *image);

private:
/* The template function for loading the ELF file into either the pt_image instance or
Expand All @@ -91,16 +92,19 @@ class elf_loader_t {
*/
template <typename Elf_Ehdr, typename Elf_Half, typename Elf_Phdr>
static bool
load_elf(IN std::ifstream &f, IN const char *name, IN uint64_t base,
INOUT struct pt_image_section_cache *iscache, INOUT struct pt_image *image);
load_elf(DR_PARAM_IN std::ifstream &f, DR_PARAM_IN const char *name,
DR_PARAM_IN uint64_t base,
DR_PARAM_INOUT struct pt_image_section_cache *iscache,
DR_PARAM_INOUT struct pt_image *image);

/* Load a single section into either the pt_image instance or the
* pt_image_section_cache instance.
*/
static bool
load_section(IN const char *name, IN uint64_t offset, IN uint64_t size,
IN uint64_t vaddr, INOUT struct pt_image_section_cache *iscache,
INOUT struct pt_image *image);
load_section(DR_PARAM_IN const char *name, DR_PARAM_IN uint64_t offset,
DR_PARAM_IN uint64_t size, DR_PARAM_IN uint64_t vaddr,
DR_PARAM_INOUT struct pt_image_section_cache *iscache,
DR_PARAM_INOUT struct pt_image *image);
};

} // namespace drmemtrace
Expand Down
5 changes: 3 additions & 2 deletions clients/drcachesim/drpt2trace/ir2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ namespace drmemtrace {
#define ERRMSG_HEADER "[drpt2ir] "

ir2trace_convert_status_t
ir2trace_t::convert(IN drir_t &drir, INOUT std::vector<trace_entry_t> &trace,
IN int verbosity)
ir2trace_t::convert(DR_PARAM_IN drir_t &drir,
DR_PARAM_INOUT std::vector<trace_entry_t> &trace,
DR_PARAM_IN int verbosity)
{
if (drir.get_ilist() == NULL) {
return IR2TRACE_CONV_ERROR_INVALID_PARAMETER;
Expand Down
16 changes: 8 additions & 8 deletions clients/drcachesim/drpt2trace/ir2trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
namespace dynamorio {
namespace drmemtrace {

#ifndef IN
# define IN // nothing
#ifndef DR_PARAM_IN
# define DR_PARAM_IN // nothing
#endif
#ifndef OUT
# define OUT // nothing
#ifndef DR_PARAM_OUT
# define DR_PARAM_OUT // nothing
#endif
#ifndef INOUT
# define INOUT // nothing
#ifndef DR_PARAM_INOUT
# define DR_PARAM_INOUT // nothing
#endif

/**
Expand Down Expand Up @@ -92,8 +92,8 @@ class ir2trace_t {
* error code.
*/
static ir2trace_convert_status_t
convert(IN drir_t &drir, INOUT std::vector<trace_entry_t> &trace,
IN int verbosity = 0);
convert(DR_PARAM_IN drir_t &drir, DR_PARAM_INOUT std::vector<trace_entry_t> &trace,
DR_PARAM_IN int verbosity = 0);
};

} // namespace drmemtrace
Expand Down
8 changes: 5 additions & 3 deletions clients/drcachesim/drpt2trace/pt2ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pt2ir_t::~pt2ir_t()
}

bool
pt2ir_t::init(IN pt2ir_config_t &pt2ir_config, IN int verbosity)
pt2ir_t::init(DR_PARAM_IN pt2ir_config_t &pt2ir_config, DR_PARAM_IN int verbosity)
{
verbosity_ = verbosity;
if (pt2ir_initialized_) {
Expand Down Expand Up @@ -256,7 +256,8 @@ pt2ir_t::init(IN pt2ir_config_t &pt2ir_config, IN int verbosity)
}

pt2ir_convert_status_t
pt2ir_t::convert(IN const uint8_t *pt_data, IN size_t pt_data_size, INOUT drir_t &drir)
pt2ir_t::convert(DR_PARAM_IN const uint8_t *pt_data, DR_PARAM_IN size_t pt_data_size,
DR_PARAM_INOUT drir_t &drir)
{
if (!pt2ir_initialized_) {
return PT2IR_CONV_ERROR_NOT_INITIALIZED;
Expand Down Expand Up @@ -418,7 +419,8 @@ pt2ir_t::convert(IN const uint8_t *pt_data, IN size_t pt_data_size, INOUT drir_t
}

void
pt2ir_t::dx_decoding_error(IN int errcode, IN const char *errtype, IN uint64_t ip)
pt2ir_t::dx_decoding_error(DR_PARAM_IN int errcode, DR_PARAM_IN const char *errtype,
DR_PARAM_IN uint64_t ip)
{
int err = -pte_internal;
uint64_t pos = 0;
Expand Down
Loading
Loading