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

feat(core/emulator): JSON memory map dump #1557

Merged
merged 2 commits into from
Jul 14, 2021
Merged

Conversation

matejcik
Copy link
Contributor

@matejcik matejcik commented Mar 31, 2021

use trezor.utils.mem_dump("somefile.json") in a key place, then
./tools/analyze-memory-dump.py src/somefile.json to look at what is going on. clickable analysis is in memorymap.html

it's pretty nice :)

requires the following micropython hack: 7f15dc3 (#6)

@matejcik matejcik requested a review from prusnak as a code owner March 31, 2021 10:09
Copy link
Member

@prusnak prusnak left a comment

Choose a reason for hiding this comment

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

We need to merge this PR first - https://github.com/trezor/trezor-firmware/pull/1548/files

Since it includes changes necessary for uPy 1.14 version bump (and your PR is bumping uPy to 1.14 too)

@@ -27,6 +27,12 @@
#error Use MPZ for MicroPython long int implementation.
#endif

#ifdef TREZOR_EMULATOR
#define STATICTYPE
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why not to just override STATIC completely for emulator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't understand reasons for STATIC in the first place so I made the change as non-invasive as possible.

of course if you think we can switch off STATIC that works too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for that matter, it would also remove the need for the micropython hack mentioned above, which would be good.

question is, won't removing STATIC get the emulator farther from the real thing in a noticeable way?

@matejcik matejcik force-pushed the matejcik/memorymap branch 2 times, most recently from 47abf0c to 81c128b Compare April 12, 2021 12:05
@tsusanka tsusanka added this to the 21.07 milestone May 20, 2021
@matejcik matejcik force-pushed the matejcik/memorymap branch from 81c128b to 7fb3e5d Compare June 4, 2021 10:17
This is perhaps a cleaner way to expose all relevant structures for
memory analysis.
@matejcik matejcik force-pushed the matejcik/memorymap branch from 7fb3e5d to 26e4bb8 Compare June 8, 2021 08:34
use `trezor.utils.mem_dump("somefile.json")` in a key place, then
`analyze.py src/somefile.json` to look at what is going on
@matejcik matejcik force-pushed the matejcik/memorymap branch from 26e4bb8 to 90cda82 Compare June 8, 2021 11:25
@matejcik
Copy link
Contributor Author

matejcik commented Jun 8, 2021

this is now ready to merge, no additional micropython patches required

@prusnak do you want to look at it again or should I just merge?

@matejcik matejcik merged commit b41d4c7 into master Jul 14, 2021
@matejcik matejcik deleted the matejcik/memorymap branch July 14, 2021 11:50
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