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 a bunch of type hints & fix a few issues with Linux platform emulation #1645

Merged
merged 18 commits into from
Apr 7, 2020

Conversation

bradlarsen
Copy link
Contributor

No description provided.

@bradlarsen bradlarsen requested a review from ekilmer March 31, 2020 22:41
Copy link
Contributor

@ekilmer ekilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add type hints in the actual Python code, then we should also try to remove them from the docstrings, since the docstring types aren't being checked by anything.

manticore/native/cpu/abstractcpu.py Outdated Show resolved Hide resolved
manticore/native/cpu/abstractcpu.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ekilmer ekilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

manticore/native/memory.py Show resolved Hide resolved
manticore/native/memory.py Show resolved Hide resolved
manticore/platforms/linux.py Show resolved Hide resolved
manticore/platforms/linux.py Outdated Show resolved Hide resolved
manticore/platforms/linux.py Outdated Show resolved Hide resolved
manticore/platforms/linux.py Outdated Show resolved Hide resolved
manticore/platforms/linux.py Show resolved Hide resolved
Copy link
Contributor

@ehennenfent ehennenfent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekilmer seems to have caught most everything here. Other than the fixes he proposed, lgtm.

Brad Larsen added 4 commits April 2, 2020 16:32
There has been an inconsistency in the `__init__` methods of the `Map`
superclass and its subclasses, specifically with regard to `**kwargs`.
Example: previously, in `Arraymap`, `**kwargs` would be taken but
silently ignored.
…sed instead

Additionally, add some more type hints from looking at methods that
immediately `assert isinstance(SOME_PARAM, SOME_TYPE)`.  (These ought to
be non-controversial types.)
@bradlarsen
Copy link
Contributor Author

I'm gonna run tests with the typeguard pytest integration (see #1584) before we should consider merging this.

Brad Larsen added 4 commits April 2, 2020 17:23
`Eventful` is not yet defined at the point the hint is used,
so use a forward reference instead.  Similar with the use of `Cpu`.
@bradlarsen
Copy link
Contributor Author

I'm gonna run tests with the typeguard pytest integration (see #1584) before we should consider merging this.

It turns out there are several lies in our type hints throughout Manticore that typeguard + pytest can identify. I looked at those results for a while, and I don't think I've introduced any new problems there.

I'm gonna do the work of fixing up what typeguard + pytest find in another PR from this.

@bradlarsen
Copy link
Contributor Author

@ehennenfent I think this is ready to go now.

@ehennenfent ehennenfent merged commit ba40906 into master Apr 7, 2020
@ehennenfent ehennenfent deleted the type-hints-and-syscalls branch April 7, 2020 15:43
ekilmer added a commit that referenced this pull request Apr 23, 2020
* master: (28 commits)
  Rework syscall invocation for proper behavior under typeguard (#1672)
  printable_bytes (#1671)
  Fix several incorrect type hints (#1668)
  Add type hints to several parts of Manticore (#1667)
  Fix type confusion in manual CPU tests; delete dead testing code (#1669)
  Rework WASM Imports and Fix Typos (#1666)
  Work on "Model is not Available" errors in tests (#1659)
  Fix TypeGuard Errors in WASM Module (#1601)
  Remove unused arg ans separate output from workspace (#1651)
  Add a badge to README.md for LGTM (#1647)
  Fix 2 problems in Linux `sys_open` support & add type hints (#1657)
  Fix LGTM Errors (#1656)
  Delay WASM Branch Condition Concretization (#1641)
  Add feature for SymbolicSocket through sys_accept (#1618)
  Add a bunch of type hints & fix a few issues with Linux platform emulation (#1645)
  Bump to CheckoutV2 (#1654)
  Add support for `sys_arm_fadvise64_64` (#1648)
  Add __slots__ to expressions (#1635)
  Swap remaining uses of `Z3Solver()` to use the singleton interface (#1649)
  CI: have pytest report 100 slowest tests (#1646)
  ...
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.

3 participants