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

Add annotation for "am I under DR?" #1237

Open
derekbruening opened this issue Nov 28, 2014 · 4 comments
Open

Add annotation for "am I under DR?" #1237

derekbruening opened this issue Nov 28, 2014 · 4 comments

Comments

@derekbruening
Copy link
Contributor

From peter.goodman on July 30, 2013 12:17:38

What is the problem to solve?
I would like to know if some code executing under the control of DR, and specialize the behaviour of that code to DR's presence. For example, if I wanted to verify that DR has taken over all threads of a process, then each thread could execute code along the lines of:

if(!dr_is_enabled()) {
fprintf(stderr, "Not under control of DR!!\n");
}

Why is it important?
This is helpful for testing DR's takeover abilities. This might also be helpful for making some code interact nicely with DR. For example, if there is some tricky optimization in some application that doesn't behave well with DR, then that optimization can be disabled when instrumenting with DR. What are the possible approaches to solving the problem? Applications link with a shared library that exposes a function, e.g. dr_is_enabled. This function always returns false/0. When under the control of DR, DR translates CALLs to the function into MOV $1, %DR_REG_XAX; Which approach is being taken and why? This functionality does not appear to be supported. Support for this feature falls under the category of intentional breaks of transparency, as a means of changing program behavior. Any interesting details or challenges of the implementation? Ensuring that DR can replace calls to shared function. There are two potential ways of going about this, neither of which is mutually exclusive:

  1. Recognize specific CALLs, and replace them. The downside of this approach is that it introduces minor overhead to instruction translation for every CALL. I am not clear on whether or not this plays well with signal delaying / figuring out the app_pc for the translated mov cache_pc.

  2. Pre-populate the code cache hash table lookup function(s) with the app_pc address of the dr_enabled function, and have it target some gencode that does a MOV $1, %DR_REG_XAX; RET;. This approach should tie in transparently with existing code.

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=1237

@derekbruening
Copy link
Contributor Author

From peter.goodman on July 30, 2013 09:29:31

Note: This routine would be somewhat like 'dr_app_stop'.

@derekbruening
Copy link
Contributor Author

From [email protected] on July 30, 2013 10:47:36

The planned annotation infrastructure would provide this. Xref https://code.google.com/p/drmemory/issues/detail?id=61 , https://code.google.com/p/drmemory/issues/detail?id=283 , https://code.google.com/p/drmemory/issues/detail?id=572 , https://code.google.com/p/drmemory/issues/detail?id=573 . The plan is to have the annotation infrastructure be part of DR for DGC ( issue #242 ) and shared w/ tools.

Summary: Add annotation for "am I under DR?" (was: Generic API for querying DynamoRIO from potentially instrumented code.)

@derekbruening
Copy link
Contributor Author

From [email protected] on September 25, 2013 12:52:41

Status: Started
Owner: [email protected]

@derekbruening
Copy link
Contributor Author

This is finished, isn't it? DYNAMORIO_ANNOTATE_RUNNING_ON_DYNAMORIO or RUNNING_ON_VALGRIND should both work. Maybe what's missing is adding documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant