Skip to content

Conversation

clark-ja
Copy link
Collaborator

@clark-ja clark-ja commented Jan 18, 2022

Add missing type hints (py3.6)

Description/Motivation/Screenshots

This PR adds still missing type hints to gef.py (Issue #787).

Also a few very minor type hint related issues have been fixed (e.g. removing return <expression> where expression always evaluates to None)

EDIT:
The PR also removes a few unnecessary function/method arguments

How Has This Been Tested?

Architecture Yes/No Comments
x86-32 ✔️
x86-64 ✔️
ARM ✖️
AARCH64 ✖️
MIPS ✖️
POWERPC ✖️
SPARC ✖️
RISC-V ✖️
make test ✔️

Checklist

  • My PR was done against the dev branch, not master.
  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • My change adds tests as appropriate.
  • I have read and agree to the CONTRIBUTING document.

@clark-ja clark-ja added this to the Release: next milestone Jan 18, 2022
@clark-ja clark-ja self-assigned this Jan 18, 2022
@clark-ja clark-ja linked an issue Jan 18, 2022 that may be closed by this pull request
Copy link
Owner

@hugsy hugsy left a comment

Choose a reason for hiding this comment

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

LGTM except just a few points to address

Cheers

Copy link
Collaborator

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

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

reviewed to line 5000

gef.py Outdated
try:
arena = gdb.parse_and_eval(addr)
malloc_state_t = cached_lookup_type("struct malloc_state")
self.__arena = arena.cast(malloc_state_t)
self.__arena = arena.cast(malloc_state_t) # "gdb.Value"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can't do self.__arena : "gdb.Value" = ...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

actually that is a comment for understanding the code better. I put it there to emphasize it for the reader because actually what we do is highly problematic (to sometimes have the arena be a gdb.Value and sometimes a MallocStateStruct with different ways of handling them)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its actually not a type hint. the type hint is a few lines above that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah. Let's reword it with basically what you just said?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is this better now? please resolve if you agree

@Grazfather Grazfather merged commit c6909e1 into hugsy:dev Jan 20, 2022
@clark-ja clark-ja deleted the type_hints_v2 branch January 20, 2022 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: complete type hints for py3.6 before release
3 participants