0

There's a code, which is probably written in C and compiled into wasm. I don't own the source, I'd just like to peek into the code what it does.

This particular code takes a string as a parameter, and does some magic checks on it, then returns some number.

I started debugging it in Firefox, but I'm stuck at the first step. I pass the function a string parameter, but in the debugger I see it as: (param $var0 i32)Even though it's a string I can see it as: 5253456 It looks like some kind of pointer, which would be logical, but I'm unsure where is it stored? How can I see the contents of it? Of course, in my current case it's just the parameter, I control the data of it, but I'd like to know generally how these pointer-like things are handled and how can I debug it to see and maybe even control the data it uses.

Edit: I've got some cool answers about how wasm stores memory object, now I'm curious how to easily read that memory region from browser-debugger.

original.roland
  • 640
  • 5
  • 17
  • Does this answer your question? [Using emscripten how to get C++ uint8\_t array to JS Blob or UInt8Array](https://stackoverflow.com/questions/53602955/using-emscripten-how-to-get-c-uint8-t-array-to-js-blob-or-uint8array) – Bumsik Kim Dec 13 '19 at 08:21
  • Just replace UInt8Array in the answer with the "pointer-like" strings – Bumsik Kim Dec 13 '19 at 08:26
  • Does this answer your question? [How can I return a JavaScript string from a WebAssembly function](https://stackoverflow.com/questions/41353389/how-can-i-return-a-javascript-string-from-a-webassembly-function) – ColinE Dec 13 '19 at 08:27
  • More or less answers. Thanks for pointing to the rich in-theory part, it's great to know, but in practice without source I don't think I can actually use it when I have no source, just a browser and its debugger. However! I've just realized that if I'm not using firefox, but instead using chrome, its debugger is capable to show the current memory of the wasm module in real time! Which is actually awesome. Now I'm curious if there's any easier approach than searching every "pointer" by hand every time. – original.roland Dec 13 '19 at 08:31

0 Answers0