[Vm-dev] VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

David T. Lewis lewis at mail.msen.com
Sun Oct 14 21:15:12 UTC 2018


Thanks Alistair,

I just turned on the "send commit notices to vn-dev" setting so that
future commits to the VMMaker inbox will (hopefully) send notices to
the list.

Dave


On Sun, Oct 14, 2018 at 10:03:31PM +0200, Alistair Grant wrote:
>  
> Hi All,
> 
> Just in case there aren't automatic notifications of submissions to
> VMMakerInbox...
> 
> I've submitted the following changes (more information after the descriptions):
> 
> Name: VMMaker.oscog-AlistairGrant.2455
> Author: AlistairGrant
> Time: 14 October 2018, 8:59:01.383815 pm
> UUID: 9e8e4134-b30b-4734-9477-95d556650155
> Ancestors: VMMaker.oscog-eem.2454
> 
> VMClass strlen, strncpy and getenv
> 
> Pharo stores UTF8 encoded strings in ByteArrays (ByteString, strictly
> speaking, expects to only store characters that can be represented as
> a single byte in UTF8, e.g. ascii).  ByteArrays are also used within
> the simulator to represent buffers allocated by the simulator.  As
> such, the strings may either be the length of the ByteArray or less
> than the ByteArray size and null terminated.
> 
> These changes extend strlen: and strncpy:_:_: to handle ByteArrays and
> add some tests (tests for strings in the object memory are todo).
> 
> InterpreterPrimitives>>primitiveGetenv: returned nil rather than 0 in
> the simulator when a variable that isn't defined is requested.
> 
> 
> Name: VMMaker.oscog-AlistairGrant.2456
> Author: AlistairGrant
> Time: 14 October 2018, 9:25:11.249348 pm
> UUID: 47b0319d-df10-4ece-84fc-324d0d35fe1d
> Ancestors: VMMaker.oscog-AlistairGrant.2455
> 
> FakeStdinStream and FilePluginSimulator do double duty with the #atEnd
> flag to allow #sqFile:Read:Into:At: to break out of its loop.  This is
> brittle as a additional calls to #atEnd breaks the simulation - which
> is what Pharo does.
> 
> Instead of doing double duty with #atEnd, do the same as the actual
> plugin (sqFileReadIntoAt() in sqFilePluginBasicPrims.c) and ignore the
> number of bytes to read when input is from stdin (FakeStdinStream) and
> only ever read a single byte (fixes the problem and is closer to the
> real plugin behaviour).
> 
> 
> Background:
> 
> I've successfully got a Pharo 7 image (with FileAttributesPlugin)
> running StdioListener in the VM simulator, but have made a few changes
> at each level:
> 
> - Created a modified Pharo image that avoids FFI:
> -- It doesn't load FreeType fonts or Iceberg to avoid FFI callouts.
> -- Uses UnixOSProcessPlugin>>primitiveGetCurrentWorkingDirectory
> instead of an FFI callout.
> - StdioListener has changes to work with Zinc streams
> - VMMaker has changes (in addition to the patches above):
> -- Added UnixOSProcessPluginSimulator so that
> primitiveGetCurrentWorkingDirectory can be used instead of FFI.
> 
> Can someone tell me whether FFI is expected to work within the simulator?
> 
> Thanks,
> Alistair


More information about the Vm-dev mailing list