-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 cs_insn_flags. Breaking API change. #2374
Conversation
@@ -354,9 +354,9 @@ static void usage(char *prog) | |||
static void print_details(csh handle, cs_arch arch, cs_mode md, cs_insn *ins) | |||
{ | |||
printf("\tID: %u (%s)\n", ins->id, cs_insn_name(handle, ins->id)); | |||
if (ins->is_alias) { | |||
if (ins->flags & CS_INSN_FLAG_ALIAS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a function to check for flags is better for the flag
field (something like cs_flag_set(insn->flags, CS_INSN_FLAG_ALIAS)
). Bit operations in conditions get messy after a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some macros to manage flags for more complex cases. See capstone.h
.
CS_INSN_FLAGS_ALL -- test if all flags is set
CS_INSN_FLAGS_ANY -- test if any flag is set
CS_INSN_FLAGS_SET -- enable flags if condition is true, disable flags if false
But forgot to add some documentation. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouh, sorry. Overlooked it. Just took a shallow look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait. I meant for checking if a flag is set. Like cs_flag_is_set(insn->flags, CS_INSN_FLAG_ALIAS)
=> true/false
.
But I'll review tomorrow again with a clear mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check it with CS_INSN_FLAGS_ANY(insn, CS_INSN_FLAG_ALIAS)
.
Replace dedicated cs_insn members for boolean flags with bitflags.
I'm closing PRs. We'll think about what can be done. |
Replace
cs_insn.is_alias
andcs_insn.usesAliasDetails
with bitflags.Your checklist for this pull request
Detailed description
Add instruction bitflags with reserved range for arch-specific usage. For example:
This information is critical and must be present even if instruction details is off.
But I'm not sure how many bitflags should be arch-specific.
Test plan
Update bindings and user software.