microsoft / vscode-hexeditor

VS Code Hex Editor
https://marketplace.visualstudio.com/items?itemName=ms-vscode.hexeditor
MIT License
525 stars 85 forks source link

When debug rust code, editor doesnt show the current offset correctly. #472

Closed jgardona closed 7 months ago

jgardona commented 7 months ago

Hello, good morning.

I was debugging some code and using hex viewer, and observed that when we click in the debug watcher to show a variable in hex viewer, it shows another offset that is not related with the variable. In the example below, I tryed to find the "abcde" string, that would be 0x61, 0x62, 0x63, 0x64, 0x65

image

System info win 10 x64 vscode -

Version: 1.85.2 (user setup) Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681 Date: 2024-01-18T06:40:10.514Z Electron: 25.9.7 ElectronBuildId: 26354273 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19044

hex editor - v1.9.12

connor4312 commented 7 months ago

Unlike C, Rust strings are not just a pointer to some characters. A &str variable is a pointer followed by a length. Your debugger does not dereference the string point but instead gives you the location of the variable, and you can see that that's the memory address starting at byte 0 with println!("address: {:p}", my_str)

More about strings in Rust: https://habr.com/en/articles/657547/