Skip to content

Commit

Permalink
chore(core/emulator): recognize rust layouts in memory dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilata committed Oct 5, 2021
1 parent 062e921 commit 65657b7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,13 @@ void dump_value_opt(FILE *out, mp_const_obj_t value, bool eval_short) {
dump_protodef(out, value);
}

#if TREZOR_MODEL == 1
else if (mp_obj_is_type(value, ui_debug_layout_type())) {
print_type(out, "uilayout", NULL, value, true);

This comment has been minimized.

Copy link
@matejcik

matejcik Oct 5, 2021

Contributor

doesn't the uilayout object have an internal second allocation?

This comment has been minimized.

Copy link
@mmilata

mmilata Oct 5, 2021

Author Member

oh, it does ... i'll see if i can add it

This comment has been minimized.

Copy link
@mmilata

mmilata Oct 5, 2021

Author Member

fixed in ee93cc2

fprintf(out, ",\n");
}
#endif

else {
print_type(out, "unknown", NULL, value, true);
fprintf(out, ",\n");
Expand Down
4 changes: 4 additions & 0 deletions core/embed/rust/librust.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ mp_obj_t protobuf_debug_msg_def_type();
#endif

mp_obj_t ui_layout_new_example(mp_obj_t);

#ifdef TREZOR_EMULATOR
mp_obj_t ui_debug_layout_type();
#endif
5 changes: 5 additions & 0 deletions core/embed/rust/src/ui/layout/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ extern "C" fn ui_layout_paint(this: Obj) -> Obj {
unsafe { util::try_or_raise(block) }
}

#[no_mangle]

This comment has been minimized.

Copy link
@jpochyla

jpochyla Oct 5, 2021

Contributor

Maybe with #[cfg(feature = "ui_debug")]?

This comment has been minimized.

Copy link
@mmilata

mmilata Oct 5, 2021

Author Member

fixed in ee93cc2 ... as a consequence PYOPT=0 now implies ui and ui_debug features for emulator build but not for firmware

pub extern "C" fn ui_debug_layout_type() -> &'static Type {
LayoutObj::obj_type()
}

#[cfg(feature = "ui_debug")]
extern "C" fn ui_layout_trace(this: Obj, callback: Obj) -> Obj {
let block = || {
Expand Down
1 change: 1 addition & 0 deletions core/tools/analyze-memory-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def ptrval(self):
"qstrdata": "q",
"protomsg": "P",
"protodef": "p",
"uilayout": "u",
}

pixels_per_line = len(
Expand Down

0 comments on commit 65657b7

Please sign in to comment.