DynamoRIO / DynamoRIO/dynamorio

Arrange documentation of DrWrap or Fix code.

Open
#2,881 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

According to the current documentation of DrWrap, it is possible to wrap a function multiple times, provided the NO_FRILLS flag is not set. Yet, one cannot wrap the function multiple times, if the pre and post wrappers match previous requests.

The code in question is found here in drwrap_wrap_ex:

```
wrap_entry_t *e;
/* things will break down w/ duplicate cbs */
for (e = wrap_cur; e != NULL; e = e->next) {
if (e->pre_cb == pre_func_cb && e->post_cb == post_func_cb) { **<-- Check!**
/* no-frills requires 1st entry to be the live one */
if (!TEST(DRWRAP_NO_FRILLS, global_flags) || e == wrap_cur) {
/* matches existing request: re-enable if necessary */
e->enabled = true;
/* be sure to update all fields (xref drmem i#816) */
e->user_data = user_data;
e->flags = flags;
dr_global_free(wrap_new, sizeof(*wrap_new));
dr_recurlock_unlock(wrap_lock);
return true;
} /* else continue */
```

We should either document this case, or arrange the code such that, rather than updating the stored request, we add the same request again. Seeing from the code, it seems the intended functionality is to update the request, and therefore we might want to arrange the docs to make this clear.

Having said that, I believe it would be better to support multiple requests with the same pre and post cbs. Although this may be risky as tools might be relying on current behaviour.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.