i#7835: Add a helper function for creating syscall instruction in tests#7862
Open
i#7835: Add a helper function for creating syscall instruction in tests#7862
Conversation
| // XXX: Adding an XINST_CREATE_syscall macro will simplify this but there are | ||
| // complexities (xref create_syscall_instr()). | ||
| #ifdef X86 | ||
| return INSTR_CREATE_syscall(drcontext); |
Contributor
There was a problem hiding this comment.
OP_syscall is not supported on 32-bit Intel so this won't work for a test that needs to execute this instruction, which should be documented for a shared function. But, better to use sysenter I would think.
| instr_t * | ||
| create_test_syscall(void *drcontext) | ||
| { | ||
| // XXX: Adding an XINST_CREATE_syscall macro will simplify this but there are |
Contributor
There was a problem hiding this comment.
IMHO we should just add XINST_CREATE_syscall in the ir instr_create_api files, with comments clearly explaining what it does and what its limitations are (maybe hardcode as sysenter for x86_32 define and syscall for x86_64 (though we want to get away from ifdefs in the IR for better cross-arch support: #1684); maybe no WOW64 support). That should help multiple other use cases outside of drmemtrace as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a helper function (
create_test_syscall()) to reduce repeated code for creating a simple syscall instruction in unit tests. I created newtest_helpers_syscall.h/cppto put this helper function in.Alternatives considered:
Put the declaration and definition of this help function in existing
test_helpers.h/cpp. This way we don't need to add new files, however there are 2 drawbacks: 1).test_helpers(and therefore tests that usetest_helpers) now need to be linked againstdrdecode. 2) We probably need to change the unsupported architecture error from a compile time error to runtime error, because we want be able to compile other tests on those architectures.Declare the helper function in
test_helpers.h, define it intest_helpers_syscall.cpp. This is pretty much the same as what's currently implemented, just one less header file.Fixes #7835