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

Fix Python bindings after changes to cs_detail #2041

Merged
merged 3 commits into from
Jun 9, 2023

Conversation

peace-maker
Copy link
Contributor

#2034 changed the regs_read array size and added a new writeback
element to the cs_detail struct.

Those changes weren't reflected in the Python bindings causing details to be missing.

I've included fixes for the RISCV and TriCore bindings as well, since they were related or popped up during testing of this change. I originally looked into the problems while testing the changes to the RISCV instruction groups #2007 in Python.

capstone-engine#2034 changed the `regs_read` array size and added a new `writeback`
element to the cs_detail struct.

Those changes weren't reflected in the Python bindings causing details
to be missing.
The structs were out of sync and were missing a few elements.

The `update_flags` element wasn't exposed at all.
The structs had changed and the `need_effective_addr` element wasn't exposed.
@XVilka
Copy link
Contributor

XVilka commented Jun 6, 2023

@imbillow take a look at Tricore changes please

@XVilka
Copy link
Contributor

XVilka commented Jun 6, 2023

@peace-maker could you please take a look at #2005 too? Since you are working on Python bindings anyway.

@XVilka
Copy link
Contributor

XVilka commented Jun 8, 2023

@kabeor @imbillow @aquynh

@imbillow
Copy link
Contributor

imbillow commented Jun 8, 2023

LGTM

@kabeor
Copy link
Member

kabeor commented Jun 9, 2023

Thanks a lot! Merged.

@kabeor kabeor merged commit ec48262 into capstone-engine:next Jun 9, 2023
@peace-maker peace-maker deleted the fix_python_bindings branch June 10, 2023 09:48
@peace-maker
Copy link
Contributor Author

@kabeor I think the same changes to the cs_detail structure are needed in the other language bindings too. I don't know powershell or ocaml though, so I'll leave this up to someone else actually using those bindings.

@XVilka
Copy link
Contributor

XVilka commented Jun 13, 2023

@peace-maker right, problem is because they aren't tested on CI: #1984 (comment)

@peace-maker
Copy link
Contributor Author

Are the changes to the cs_detail struct 100% required for the TriCore architecture @imbillow ? I don't see the writeback field getting used on a glance and the array size change feels like an oversight while refactoring using the defines. Maybe the struct can be reverted and the work avoided?

@XVilka
Copy link
Contributor

XVilka commented Jun 13, 2023

@peace-maker it was added for compatibility with ARM, AFAIR. It's used in Rizin's RzIL uplifting code, for example: https://github.com/rizinorg/rizin/blob/dev/librz/analysis/arch/arm/arm_il64.c#L1025

@imbillow
Copy link
Contributor

Are the changes to the cs_detail struct 100% required for the TriCore architecture @imbillow ? I don't see the writeback field getting used on a glance and the array size change feels like an oversight while refactoring using the defines. Maybe the struct can be reverted and the work avoided?

Those are just changes pulled from the auto-sync branch, and since the auto-sync branch hasn't been merged yet, it may indeed seem redundant for the current version of capstone.

@peace-maker
Copy link
Contributor Author

@peace-maker it was added for compatibility with ARM, AFAIR. It's used in Rizin's RzIL uplifting code, for example: https://github.com/rizinorg/rizin/blob/dev/librz/analysis/arch/arm/arm_il64.c#L1025

Ah, that accesses the field in the cs_arm64 detail struct though instead of using the newly added writeback field on the base cs_detail struct though. That looks redundant indeed, but I haven't looked at the auto-sync branch yet and I might be way off. Just wanted to point it out while stumbling over it in the capstone code.

@XVilka
Copy link
Contributor

XVilka commented Jun 14, 2023

Are the changes to the cs_detail struct 100% required for the TriCore architecture @imbillow ? I don't see the writeback field getting used on a glance and the array size change feels like an oversight while refactoring using the defines. Maybe the struct can be reverted and the work avoided?

Those are just changes pulled from the auto-sync branch, and since the auto-sync branch hasn't been merged yet, it may indeed seem redundant for the current version of capstone.

@Rot127 what do you think about that? Is it necessary path in current auto-sync state?

@XVilka XVilka mentioned this pull request Jun 14, 2023
@Rot127
Copy link
Collaborator

Rot127 commented Jun 14, 2023

what do you think about that? Is it necessary path in current auto-sync state?

If it isn't used in TriCore we can remove it for the v5 release I guess.

But for auto-sync it is definitely useful, because:

  1. This writeback variable was duplicated for each arch in their detail struct.
  2. We add the concept of operand binding from LLVM (which implies writeback). So more archs will use it in the future.

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

Successfully merging this pull request may close these issues.

5 participants