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

chore: Make memory traces clearer #236

Merged
merged 1 commit into from
Jan 23, 2023
Merged

chore: Make memory traces clearer #236

merged 1 commit into from
Jan 23, 2023

Conversation

bhelx
Copy link
Contributor

@bhelx bhelx commented Jan 23, 2023

If you look at the memory traces it's not really clear what the values are:

extism_runtime::memory TRACE 2023-01-23T10:05:16.918413-06:00 - store_u64: 656c626169726176 at offset 25
extism_runtime::memory TRACE 2023-01-23T10:05:16.918418-06:00 - store_u8: 20 at offset 33
extism_runtime::memory TRACE 2023-01-23T10:05:16.918423-06:00 - store_u8: 76 at offset 34
extism_runtime::memory TRACE 2023-01-23T10:05:16.918428-06:00 - store_u8: 61 at offset 35
extism_runtime::memory TRACE 2023-01-23T10:05:16.918433-06:00 - store_u8: 6c at offset 36
extism_runtime::memory TRACE 2023-01-23T10:05:16.918438-06:00 - store_u8: 75 at offset 37
extism_runtime::memory TRACE 2023-01-23T10:05:16.918443-06:00 - store_u8: 65 at offset 38

It's hard to tell that the value is hex and the offset is base10. This changes u8 values to the form 0x00 where there is always 2 digits and it will always use 16 digits for u64.

@@ -61,7 +61,7 @@ impl PluginMemory {

/// Write byte to memory
pub(crate) fn store_u8(&mut self, offs: usize, data: u8) -> Result<(), MemoryAccessError> {
trace!("store_u8: {data:x} at offset {offs}");
trace!("store_u8: offset={offs} data={data:#04x}");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's 04 instead of 02 because rust includes the 0x characters in the max width.

@bhelx bhelx merged commit 8b81198 into main Jan 23, 2023
@bhelx bhelx deleted the print-memory-trace-as-hex branch January 23, 2023 17:10
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.

None yet

2 participants