Bert Freudenberg schrieb:
On Jun 14, 2007, at 11:28 , André Wendt wrote:
Hi,
I'm trying to invoke the primitiveFileOpen primitive from the FilePlugin from within the Interpreter:
<primitive: 'primitiveFileOpen' module: 'FilePlugin'>
obviously does not work: It doesn't get translated to C. How do I invoke a primitive of an (internal/external) plugin from within the Interpreter class?
This is generally a bad idea, because you would have to pass parameters on the smalltalk stack.
What are you actually trying to achieve?
Hi Bert,
I'm trying to write a logging facility for send (sample work for Prof. Hirschfeld, actually): Each time a message is sent, the target class, message and a couple of other properties should be logged.
That means I have to open a file upon initialization and write the file at each send. There's no other way than to do that in the Interpreter, as far as I can see.
André
On Jun 14, 2007, at 14:31 , André Wendt wrote:
Bert Freudenberg schrieb:
On Jun 14, 2007, at 11:28 , André Wendt wrote:
Hi,
I'm trying to invoke the primitiveFileOpen primitive from the FilePlugin from within the Interpreter:
<primitive: 'primitiveFileOpen' module: 'FilePlugin'>
obviously does not work: It doesn't get translated to C. How do I invoke a primitive of an (internal/external) plugin from within the Interpreter class?
This is generally a bad idea, because you would have to pass parameters on the smalltalk stack.
What are you actually trying to achieve?
Hi Bert,
I'm trying to write a logging facility for send (sample work for Prof. Hirschfeld, actually): Each time a message is sent, the target class, message and a couple of other properties should be logged.
I'm pretty sure John McIntosh did that before.
That means I have to open a file upon initialization and write the file at each send. There's no other way than to do that in the Interpreter, as far as I can see.
What about fopen()?
- Bert -
On 14.06.2007, at 14:31, André Wendt wrote:
Hi Bert,
I'm trying to write a logging facility for send (sample work for Prof. Hirschfeld, actually): Each time a message is sent, the target class, message and a couple of other properties should be logged.
That means I have to open a file upon initialization and write the file at each send. There's no other way than to do that in the Interpreter, as far as I can see.
Hacking the interpreter is one solution... but you can do it from inside the image, with no VM changes, too. It might be a bit slower, though. (and maybe not what you need at all, nevertheless, it is good to now all the options).
One way to achieve this with no VM change is to manipulate the bytecode of the methods.
So for logging sends, you would add bytecode in front of each send that does the logging. This bytecode can access all sorts of information, e.g. the sender or the arguments of the sends.
We did a library that makes this kind of manipulation relatively easy to do:
http://www.iam.unibe.ch/~scg/Research/ByteSurgeon/
The ByteSurgeon framework has been used for a "Log everything" Back- in-Time Debugger.
We now have an even better system (called "Reflectivity") for this kind of meta programming things (not based on bytecode manipulation). If you decide to play with logging sends from "inside" the image, this should be quite interesting. The resulting code is faster then doing bytecode manipulation, and it allows for far better control (it implements the model of Partial Behavioral Reflection found in Reflex for Java).
This is not yet released, but if you want to play with it, please send me a mail (I am happy about any users ;-)).
Marcus
vm-dev@lists.squeakfoundation.org