Hi Immanuel,

the problem is probably related to your manipulation of the raw memory
pointer <https://groups.google.com/g/v8-dev/c/jQMLH3EkCoM/m/gHw9elpKDwAJ>.
For debugging, we are not using this pointer, but the WasmMemoryObject
<https://source.chromium.org/chromium/chromium/src/+/master:v8/src/wasm/wasm-objects.h;l=289;drc=69ca751bc8aace8c15a6a2d2e22d1658914e4145>
which is attached to the WasmInstanceObject
<https://source.chromium.org/chromium/chromium/src/+/master:v8/src/wasm/wasm-objects.h;l=370;drc=ee9e7e404e5a3f75a3ca0489aaf80490f625ca27>.
This one is still pointing to the original memory, not the one you set via
your added "SetWasmInstanceRawMemory" function.

The WasmMemoryObject has an attached JSArrayBuffer. Maybe you can set the
backing store of that array buffer to point to your external memory?
It should be clear that this is totally unsupported territory, so you will
have to try if that hack works.

I am thinking something along the lines of (extending
your SetWasmInstanceRawMemory function):
void SetWasmInstanceRawMemory(Local<Object> wasmInstance, uint8_t*
mem_start,
                              size_t mem_size) {
  auto instance =

i::Handle<i::WasmInstanceObject>::cast(Utils::OpenHandle(*wasmInstance));
  auto* i_isolate =
reinterpret_cast<i::Isolate*>(wasmInstance->GetIsolate());
  instance->SetRawMemory(mem_start, mem_size);
  std::unique_ptr<i::BackingStore> backing_store =
      i::BackingStore::WrapAllocation(i_isolate, mem_start, mem_size,
                                      i::SharedFlag::kNotShared, false);
  instance->memory_object().array_buffer().Attach(std::move(backing_store));
}

This code comes without any guarantees, it might or might not work, but
maybe it helps you understand the problem and develop a working solution
from there.

Cheers,
Clemens


On Tue, Sep 22, 2020 at 11:46 AM Immanuel Haffner <
haffner.imman...@gmail.com> wrote:

> I upgraded V8 to v8.6.405 and Chromium to 85.  Still the problem persists
> that the Wasm linear memory appears "all zeroes" although the Wasm code
> reads the correct data.  Could anybody please provide some help?
>
> Immanuel Haffner schrieb am Montag, 14. September 2020 um 14:21:28 UTC+2:
>
>> Hi all,
>>
>> I am trying to debug Wasm code that manipulates its linear memory.  I am
>> running the code in embedded V8 and I am using the V8 inspector API to
>> connect with CDT. Although I can verify on the embedder's side that the
>> linear memory was manipulated, all I see in CDT is zeroes.  The attached
>> image shows what I mean.
>>
>> [image: Screenshot_20200914_141705.png]
>> The memory of the Wasm instance is "all zeroes". What am I doing wrong?
>> Using the V8 API from the embedder I can verify that the linear memory was
>> written and contains some data I'd expect to see in CDT.
>>
>> Do you have any ideas what I am doing wrong?
>>
>> Thanks & regards,
>> Immanuel
>>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-users/13c9e3ab-3cfc-46be-b485-69f8292a73c9n%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-users/13c9e3ab-3cfc-46be-b485-69f8292a73c9n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

Clemens Backes

Software Engineer

cleme...@google.com

Google Germany GmbH

Erika-Mann-Straße 33

80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten
haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter,
löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen,
dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by mistake,
please don't forward it to anyone else, please erase all copies and
attachments, and please let me know that it has gone to the wrong person.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAGO%3DqhCeYGTjbMicbkzMWAFxtpVzwmFUjHRxN6Vf3p0W6KOjrQ%40mail.gmail.com.

Reply via email to