-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are two main types of conversions in C: - Explicit conversions, i.e., casts. - Implicit conversions, which are applied for variable assignments, assigning arguments to function parameters, return values, etc. These have stricter rules about what types can be converted. drgn currently only has a cast() function to do an explicit conversion. This adds an implicit_convert() function to do an implicit conversion. The most obvious use case is allowing helpers to type check their parameters and perform the same conversions that happen in C (e.g, automatically converting `void *` to the appropriate pointer type but rejecting other pointer types): >>> def foo(task: Object): ... task = implicit_convert("struct task_struct *", task) ... >>> foo(Object(prog, "void *", 0)) >>> foo(Object(prog, "struct mm_struct *", 0)) Traceback (most recent call last): ... TypeError: cannot convert 'struct mm_struct *' to incompatible type 'struct task_struct *' I haven't measured the performance overhead of doing this yet, so I'm not going to add this to existing helpers yet. But, I do have another use case for type checking function calls coming up soon. Signed-off-by: Omar Sandoval <[email protected]>
- Loading branch information
Showing
12 changed files
with
1,198 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.