argCnt, argVec, engVec alternatives

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

argCnt, argVec, engVec alternatives

EstebanLM

Hi,
Ok, I'm trying to run the UnixOSProcessPlugin on Cocoa Cog VM (own version, still not updated with latest from Eliot). One of the things I need to solve is some references to argCnt, argVec, engVec in plugin implementation... I think it is not-good give a plugin access to vm parameters through globals...
So, I wonder if there is an alternative to elegantly provide this...

Cheers,
Esteban
Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

johnmci

Well these aren't vm variables they are the environment,  and pointer(s) to arguments passed to the executable at launch time via the command line.  
it's all pure unix logic, nothing to do with the vm. You could of course have a fetch routine on the interpreter proxy to better hide the implementation details as you
already have an primitive to fetch the parms from the VM. Not sure about the environment variables I don't think there was an api to allow smalltalk code to get at those?

On 2011-01-05, at 10:01 AM, Esteban Lorenzano wrote:

>
> Hi,
> Ok, I'm trying to run the UnixOSProcessPlugin on Cocoa Cog VM (own version, still not updated with latest from Eliot). One of the things I need to solve is some references to argCnt, argVec, engVec in plugin implementation... I think it is not-good give a plugin access to vm parameters through globals...
> So, I wonder if there is an alternative to elegantly provide this...
>
> Cheers,
> Esteban

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

EstebanLM

ok... removing call to printAllStack in plugin and adding initialization of argCnt, argVec and engVec (plus the changes made last week), UnixOSProcessPlugin, without AioPlugin, is running in Cocoa Cog VM :D

I would like to commit a OSProcessPlugin package with modifications... or well, maybe project owner can do this changes for me (I just removed primitivePrintAllStacksOnSignal, printAllStacksFunctionAddress and printAllStacksOnSignal).

now... I will work on AioPlugin :P

Cheers,
Esteban

pd: btw... CommandShell is really funny ;)

El 05/01/2011, a las 3:08p.m., John M McIntosh escribió:

>
> Well these aren't vm variables they are the environment,  and pointer(s) to arguments passed to the executable at launch time via the command line.  
> it's all pure unix logic, nothing to do with the vm. You could of course have a fetch routine on the interpreter proxy to better hide the implementation details as you
> already have an primitive to fetch the parms from the VM. Not sure about the environment variables I don't think there was an api to allow smalltalk code to get at those?
>
> On 2011-01-05, at 10:01 AM, Esteban Lorenzano wrote:
>
>>
>> Hi,
>> Ok, I'm trying to run the UnixOSProcessPlugin on Cocoa Cog VM (own version, still not updated with latest from Eliot). One of the things I need to solve is some references to argCnt, argVec, engVec in plugin implementation... I think it is not-good give a plugin access to vm parameters through globals...
>> So, I wonder if there is an alternative to elegantly provide this...
>>
>> Cheers,
>> Esteban
>
> --
> ===========================================================================
> John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

Igor Stasenko

On 5 January 2011 19:30, Esteban Lorenzano <[hidden email]> wrote:
>
> ok... removing call to printAllStack in plugin and adding initialization of argCnt, argVec and engVec (plus the changes made last week), UnixOSProcessPlugin, without AioPlugin, is running in Cocoa Cog VM :D
>

i can't believe that there is no way to get a command line other than
from main() function in unix.
utils, like 'ps ax' indicating that its possible :)

At least in windows , there is a GetCommandLine() for that.


> I would like to commit a OSProcessPlugin package with modifications... or well, maybe project owner can do this changes for me (I just removed primitivePrintAllStacksOnSignal, printAllStacksFunctionAddress and printAllStacksOnSignal).
>
> now... I will work on AioPlugin :P
>
> Cheers,
> Esteban
>
> pd: btw... CommandShell is really funny ;)
>
> El 05/01/2011, a las 3:08p.m., John M McIntosh escribió:
>
>>
>> Well these aren't vm variables they are the environment,  and pointer(s) to arguments passed to the executable at launch time via the command line.
>> it's all pure unix logic, nothing to do with the vm. You could of course have a fetch routine on the interpreter proxy to better hide the implementation details as you
>> already have an primitive to fetch the parms from the VM. Not sure about the environment variables I don't think there was an api to allow smalltalk code to get at those?
>>
>> On 2011-01-05, at 10:01 AM, Esteban Lorenzano wrote:
>>
>>>
>>> Hi,
>>> Ok, I'm trying to run the UnixOSProcessPlugin on Cocoa Cog VM (own version, still not updated with latest from Eliot). One of the things I need to solve is some references to argCnt, argVec, engVec in plugin implementation... I think it is not-good give a plugin access to vm parameters through globals...
>>> So, I wonder if there is an alternative to elegantly provide this...
>>>
>>> Cheers,
>>> Esteban
>>
>> --
>> ===========================================================================
>> John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
>> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
>> ===========================================================================
>>
>>
>>
>>
>
>



--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

David T. Lewis
In reply to this post by EstebanLM
 
On Wed, Jan 05, 2011 at 03:30:19PM -0300, Esteban Lorenzano wrote:
>
> ok... removing call to printAllStack in plugin and adding initialization
> of argCnt, argVec and engVec (plus the changes made last week),
> UnixOSProcessPlugin, without AioPlugin, is running in Cocoa Cog VM :D
>

Excellent!

> I would like to commit a OSProcessPlugin package with modifications...
> or well, maybe project owner can do this changes for me (I just removed
> primitivePrintAllStacksOnSignal, printAllStacksFunctionAddress and
> printAllStacksOnSignal).
>

Actually, if you don't mind working with me on this a bit more, I'd
like to debug it. I suspect we can can make this work on Cocoa.

We know now that external plugins can access global values such
as argVec and interpreterProxy, and we know that this works the
same on Unix and Mac. The last thing that is giving us problems
is when primitivePrintAllStacksOnSignal tries to access the address
of the function printAllStacks(). This happens here in the plugin:

  static void * printAllStacksFunctionAddress(void) {
      extern sqInt printAllStacks();
          return printAllStacks;
  }

So the declaration looks right, but apparently accessing the
address of a global function is not the same as accessing the
value of a global variable, and perhaps this is a difference
between the Unix/Linux systems and Mac.

So I am guessing that if, in the support code, we were to assign
the function address to a global variable, then the plugin would
be able to access it, and #primitivePrintAllStacksOnSignal would
work properly.

If this sounds like it might be right, I'll try to think of a way
to implement it without breaking the existing unix implementations.

> now... I will work on AioPlugin :P
>
> Cheers,
> Esteban
>
> pd: btw... CommandShell is really funny ;)

Well, I did write it mostly to entertain myself ;)

Cheers,
Dave

Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

EstebanLM

Hi,

El 05/01/2011, a las 10:56p.m., David T. Lewis escribió:

>
> On Wed, Jan 05, 2011 at 03:30:19PM -0300, Esteban Lorenzano wrote:
>>
>> ok... removing call to printAllStack in plugin and adding initialization
>> of argCnt, argVec and engVec (plus the changes made last week),
>> UnixOSProcessPlugin, without AioPlugin, is running in Cocoa Cog VM :D
>>
>
> Excellent!
>
>> I would like to commit a OSProcessPlugin package with modifications...
>> or well, maybe project owner can do this changes for me (I just removed
>> primitivePrintAllStacksOnSignal, printAllStacksFunctionAddress and
>> printAllStacksOnSignal).
>>
>
> Actually, if you don't mind working with me on this a bit more, I'd
> like to debug it. I suspect we can can make this work on Cocoa.
>
> We know now that external plugins can access global values such
> as argVec and interpreterProxy, and we know that this works the
> same on Unix and Mac. The last thing that is giving us problems
> is when primitivePrintAllStacksOnSignal tries to access the address
> of the function printAllStacks(). This happens here in the plugin:
>
>  static void * printAllStacksFunctionAddress(void) {
>      extern sqInt printAllStacks();
>          return printAllStacks;
>  }
>
> So the declaration looks right, but apparently accessing the
> address of a global function is not the same as accessing the
> value of a global variable, and perhaps this is a difference
> between the Unix/Linux systems and Mac.
>
> So I am guessing that if, in the support code, we were to assign
> the function address to a global variable, then the plugin would
> be able to access it, and #primitivePrintAllStacksOnSignal would
> work properly.
>
> If this sounds like it might be right, I'll try to think of a way
> to implement it without breaking the existing unix implementations.


yes, that would work. In fact, declaring printAllStacks() as:

EXPORT(sqint) printAllStacks();

... works too. And even adding setting -fvisibility=default (which exports ALL symbols) will work too. But I think the last one is a little bit too much: visibility=default is default for plain gcc compiler, but not un mac now (I think that's the reason why it was working before and not now) :)

Cheers,
Esteban

Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

Igor Stasenko

On 6 January 2011 03:15, Esteban Lorenzano <[hidden email]> wrote:

>
> Hi,
>
> El 05/01/2011, a las 10:56p.m., David T. Lewis escribió:
>
>>
>> On Wed, Jan 05, 2011 at 03:30:19PM -0300, Esteban Lorenzano wrote:
>>>
>>> ok... removing call to printAllStack in plugin and adding initialization
>>> of argCnt, argVec and engVec (plus the changes made last week),
>>> UnixOSProcessPlugin, without AioPlugin, is running in Cocoa Cog VM :D
>>>
>>
>> Excellent!
>>
>>> I would like to commit a OSProcessPlugin package with modifications...
>>> or well, maybe project owner can do this changes for me (I just removed
>>> primitivePrintAllStacksOnSignal, printAllStacksFunctionAddress and
>>> printAllStacksOnSignal).
>>>
>>
>> Actually, if you don't mind working with me on this a bit more, I'd
>> like to debug it. I suspect we can can make this work on Cocoa.
>>
>> We know now that external plugins can access global values such
>> as argVec and interpreterProxy, and we know that this works the
>> same on Unix and Mac. The last thing that is giving us problems
>> is when primitivePrintAllStacksOnSignal tries to access the address
>> of the function printAllStacks(). This happens here in the plugin:
>>
>>  static void * printAllStacksFunctionAddress(void) {
>>      extern sqInt printAllStacks();
>>          return printAllStacks;
>>  }
>>
>> So the declaration looks right, but apparently accessing the
>> address of a global function is not the same as accessing the
>> value of a global variable, and perhaps this is a difference
>> between the Unix/Linux systems and Mac.
>>
>> So I am guessing that if, in the support code, we were to assign
>> the function address to a global variable, then the plugin would
>> be able to access it, and #primitivePrintAllStacksOnSignal would
>> work properly.
>>
>> If this sounds like it might be right, I'll try to think of a way
>> to implement it without breaking the existing unix implementations.
>
>
> yes, that would work. In fact, declaring printAllStacks() as:
>
> EXPORT(sqint) printAllStacks();
>
> ... works too. And even adding setting -fvisibility=default (which exports ALL symbols) will work too. But I think the last one is a little bit too much: visibility=default is default for plain gcc compiler, but not un mac now (I think that's the reason why it was working before and not now) :)
>

So, how it works for Squeak VM, where #printAllStacks is listed in
#requiredMethodNames,
which meand that generator should always retain this method in source code,
but it is not means that printAllStacks symbol is visible to external
module(s).. I mean the declaration is just:
sqInt printAllStacks(void);

Doesn't symbols should be marked for export to make them visible
externally? Or on unix systems its not necessary?

Ah.. -fvisibility=default explains this.

Heh.. but then out of curiosity,  why do we need to use
interpreterProxy struct, while plugins can just use any VM function(s)
directly,
even through dynamic linking?

Okay, in Cog this function marked as a part of api.
But i don't understand why then we using two different ways to access
VM functionality from external modules?

There should be either interpreterProxy or symbols export mechanism ,
but not both, because they are obviously overlap.

> Cheers,
> Esteban
>


--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: argCnt, argVec, engVec alternatives

David T. Lewis
 
On Thu, Jan 06, 2011 at 03:45:27AM +0100, Igor Stasenko wrote:

>
> On 6 January 2011 03:15, Esteban Lorenzano <[hidden email]> wrote:
> >
> > El 05/01/2011, a las 10:56p.m., David T. Lewis escribi??:
> >
> >> On Wed, Jan 05, 2011 at 03:30:19PM -0300, Esteban Lorenzano wrote:
> >>>
> >>> ok... removing call to printAllStack in plugin and adding initialization
> >>> of argCnt, argVec and engVec (plus the changes made last week),
> >>> UnixOSProcessPlugin, without AioPlugin, is running in Cocoa Cog VM :D
> >>
> >> Excellent!
> >>
> >>> I would like to commit a OSProcessPlugin package with modifications...
> >>> or well, maybe project owner can do this changes for me (I just removed
> >>> primitivePrintAllStacksOnSignal, printAllStacksFunctionAddress and
> >>> printAllStacksOnSignal).
> >>>
> >> Actually, if you don't mind working with me on this a bit more, I'd
> >> like to debug it. I suspect we can can make this work on Cocoa.
> >>
> >> We know now that external plugins can access global values such
> >> as argVec and interpreterProxy, and we know that this works the
> >> same on Unix and Mac. The last thing that is giving us problems
> >> is when primitivePrintAllStacksOnSignal tries to access the address
> >> of the function printAllStacks(). This happens here in the plugin:
> >>
> >> ??static void * printAllStacksFunctionAddress(void) {
> >> ?? ?? ??extern sqInt printAllStacks();
> >> ?? ?? ?? ?? ??return printAllStacks;
> >> ??}
> >>
> >> So the declaration looks right, but apparently accessing the
> >> address of a global function is not the same as accessing the
> >> value of a global variable, and perhaps this is a difference
> >> between the Unix/Linux systems and Mac.
> >>
> >> So I am guessing that if, in the support code, we were to assign
> >> the function address to a global variable, then the plugin would
> >> be able to access it, and #primitivePrintAllStacksOnSignal would
> >> work properly.
> >>
> >> If this sounds like it might be right, I'll try to think of a way
> >> to implement it without breaking the existing unix implementations.
> >
> >
> > yes, that would work. In fact, declaring printAllStacks() as:
> >
> > EXPORT(sqint) printAllStacks();
> >
> > ... works too. And even adding setting -fvisibility=default (which exports ALL symbols) will work too. But I think the last one is a little bit too much: visibility=default is default for plain gcc compiler, but not un mac now (I think that's the reason why it was working before and not now) :)
> >

Esteban, thanks. It's obvious now that you point it out. I added
the <export: true> to Interpreter>>printAllStacks in VMMaker trunk.

>
> So, how it works for Squeak VM, where #printAllStacks is listed in
> #requiredMethodNames,
> which meand that generator should always retain this method in source code,
> but it is not means that printAllStacks symbol is visible to external
> module(s).. I mean the declaration is just:
> sqInt printAllStacks(void);
>
> Doesn't symbols should be marked for export to make them visible
> externally? Or on unix systems its not necessary?
>
> Ah.. -fvisibility=default explains this.
>
> Heh.. but then out of curiosity,  why do we need to use
> interpreterProxy struct, while plugins can just use any VM function(s)
> directly,
> even through dynamic linking?
>
> Okay, in Cog this function marked as a part of api.

So is the problem already resolved in Cog, or do we need to add
an <export: true> in Cog also?

> But i don't understand why then we using two different ways to access
> VM functionality from external modules?
>
> There should be either interpreterProxy or symbols export mechanism ,
> but not both, because they are obviously overlap.

I miss Tim Rowledge on this list. If he were here, he would step in
right now to remind us that not all computers in the universe are
running Unix ;)

Dave

Reply | Threaded
Open this post in threaded view
|

[OT] Re: [Vm-dev] argCnt, argVec, engVec alternatives

David T. Lewis
In reply to this post by Igor Stasenko
 
On Wed, Jan 05, 2011 at 08:18:15PM +0100, Igor Stasenko wrote:
>
> i can't believe that there is no way to get a command line other than
> from main() function in unix.
> utils, like 'ps ax' indicating that its possible :)
>
> At least in windows , there is a GetCommandLine() for that.
>

<OT>
I hope I'm not being insulting, but I'm assuming you meant this
as a serious comment, so for background just in case this is not
generally known:

The basic model for process creation in Unix systems is the idea
of a fork() followed by an exec() call. The running system starts
with a single proto-process called "init", and every other running
process on the system is a descendent of that process, with each
child process created by its parent using fork() and exec()
system calls.

The fork() call creates a clone of the running process, and exec()
loads and runs a new program in that newly created process. The
exec() call sets up the argument list and environment for the new
program, and the remainder of the process is simply inherited from
the parent process that created it. The C programmer sees this as
the entry point to a program as a function called main() with
arguments supplied by the exec system call:

  int main(int argc, char *argv[], char *envp[])

Every Unix program written for the last 30 years works like this,
so no additional system services are required for a program to
access the argument list and environment for its process. The

On Windows, the conventions for program entry points (WinMain)
are different, but there are win32 calls available to provide
functions equivalent to the Unix conventions. GetCommandLine()
is an example of this.

On a Linux system, the exec() call is implemented as execve(),
so the manual page is "man 2 execve" for the modern equivalent
of exec().
</OT>

Dave