VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

alistairgrant
 
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
Reply | Threaded
Open this post in threaded view
|

Re: VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

David T. Lewis
 
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
Reply | Threaded
Open this post in threaded view
|

Re: VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

alistairgrant
 
Thanks, Dave!

On Sun, 14 Oct 2018 at 23:15, David T. Lewis <[hidden email]> wrote:

>
>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

alistairgrant
In reply to this post by alistairgrant
 
On Sun, 14 Oct 2018 at 22:03, Alistair Grant <[hidden email]> 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):

There haven't been any negative comments, and it only affects the
simulator, so I'll take this as approval. :-)

What's the process for moving a package from the inbox to the main
repository?  I can use Monticello to copy the package across easily
enough, but how to remove it from the Inbox?  (I've got write
permission for the main repository).

Thanks,
Alistair



> 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
Reply | Threaded
Open this post in threaded view
|

Re: VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

Eliot Miranda-2
 
Hi Alistair,
On Mon, Oct 15, 2018 at 10:47 AM Alistair Grant <[hidden email]> wrote:
 
On Sun, 14 Oct 2018 at 22:03, Alistair Grant <[hidden email]> 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):

There haven't been any negative comments, and it only affects the
simulator, so I'll take this as approval. :-)

What's the process for moving a package from the inbox to the main
repository?  I can use Monticello to copy the package across easily
enough, but how to remove it from the Inbox?  (I've got write
permission for the main repository).

Simply don't bother deleting it; just leave it there.
 

Thanks,
Alistair



> 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


--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

Bert Freudenberg
 
On Mon, Oct 15, 2018 at 11:06 AM Eliot Miranda <[hidden email]> wrote:
On Mon, Oct 15, 2018 at 10:47 AM Alistair Grant <[hidden email]> wrote:

What's the process for moving a package from the inbox to the main
repository?  I can use Monticello to copy the package across easily
enough, but how to remove it from the Inbox?  (I've got write
permission for the main repository).

Simply don't bother deleting it; just leave it there.

We should enable registered developers to move / delete packages, but that would mean having to manually add everyone to the inbox repo, too. Probably better to make a vm-dev group, and give that one dev access to both the vm repo and the vm inbox.

- Bert -
Reply | Threaded
Open this post in threaded view
|

Re: VMMaker simulation - strlen, strcpy, getenv and FakeStdinStream

alistairgrant
In reply to this post by Eliot Miranda-2
 
On Mon, 15 Oct 2018 at 20:05, Eliot Miranda <[hidden email]> wrote:

>
> Hi Alistair,
> On Mon, Oct 15, 2018 at 10:47 AM Alistair Grant <[hidden email]> wrote:
>>
>> On Sun, 14 Oct 2018 at 22:03, Alistair Grant <[hidden email]> 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):
>>
>> There haven't been any negative comments, and it only affects the
>> simulator, so I'll take this as approval. :-)
>>
>> What's the process for moving a package from the inbox to the main
>> repository?  I can use Monticello to copy the package across easily
>> enough, but how to remove it from the Inbox?  (I've got write
>> permission for the main repository).
>
>
> Simply don't bother deleting it; just leave it there.

Done, thanks!

Cheers,
Alistair