Probably not crazy but stupid or impossible to achieve...but anyway, I want to ask.. Scenario: I find myself navigating the VMMaker code (SLANG) and I want to put a "self halt" somewhere there. Forget the simulator for the moment. So...I need to go to C, and "translate in my mind" what that part of SLANG should look like in C, and search it in the C code. XCode is FAAAR to slow to browe the interp.c . Morever, with inlined methods it is even more difficult to find... Anyway, I was thinking how cool could be to create breakpoints from VMMaker. I think it is not possible to put breakpoints in C code, but what about doing something like: Interpreter >> haltVM "find a better name for this method" self cCode: 'raise(SIGINT); ' Of course, we need to add a #include <csignal> // or signal.h if C code I have NO IDEA the implicance or side effects of doing this. I haven't tried either. And it is complicated to do it cross platform..etc. Here is a link to do more or less this idea: http://stackoverflow.com/questions/4326414/set-breakpoint-in-c-or-c-code-programmatically-for-gdb-on-linux What I want is that if we are running with GDB and the VM calls haltVM() then the GDB is paused so that I can do bt, etc... What do you think? -- Mariano http://marianopeck.wordpress.com |
well, you can use self flag: #abdede and then find this in source code and put break there. On 12 April 2011 13:40, Mariano Martinez Peck <[hidden email]> wrote: > > Probably not crazy but stupid or impossible to achieve...but anyway, I want to ask.. > > Scenario: I find myself navigating the VMMaker code (SLANG) and I want to put a "self halt" somewhere there. Forget the simulator for the moment. So...I need to go to C, and "translate in my mind" what that part of SLANG should look like in C, and search it in the C code. XCode is FAAAR to slow to browe the interp.c . Morever, with inlined methods it is even more difficult to find... > > Anyway, I was thinking how cool could be to create breakpoints from VMMaker. I think it is not possible to put breakpoints in C code, but what about doing something like: > > Interpreter >> haltVM > "find a better name for this method" > self cCode: 'raise(SIGINT); ' > > Of course, we need to add a > #include <csignal> // or signal.h if C code > > I have NO IDEA the implicance or side effects of doing this. I haven't tried either. > > And it is complicated to do it cross platform..etc. Here is a link to do more or less this idea: http://stackoverflow.com/questions/4326414/set-breakpoint-in-c-or-c-code-programmatically-for-gdb-on-linux > > What I want is that if we are running with GDB and the VM calls haltVM() then the GDB is paused so that I can do bt, etc... > > What do you think? > > -- > Mariano > http://marianopeck.wordpress.com > > > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Mariano Martinez Peck
On Tue, Apr 12, 2011 at 01:40:22PM +0200, Mariano Martinez Peck wrote: > > So...I need to go to C, and "translate in my mind" what that part of SLANG > should look like in C, and search it in the C code. XCode is FAAAR to slow > to browe the interp.c . Morever, with inlined methods it is even more > difficult to find... XCode might be slow, but Squeak is fast :) Have a look at SlangBrowser for this. It has not been updated for either Pharo or oscog, but if anyone is interested maybe we can get that working too. Source is in the SqueakSource VMMaker project, and info at: http://wiki.squeak.org/squeak/5916 Dave |
In reply to this post by Igor Stasenko
On Tue, Apr 12, 2011 at 1:42 PM, Igor Stasenko <[hidden email]> wrote:
yes, true, that works :)
-- Mariano http://marianopeck.wordpress.com |
In reply to this post by David T. Lewis
On Tue, Apr 12, 2011 at 2:04 PM, David T. Lewis <[hidden email]> wrote:
Thanks Dave. I wasn't aware of what SlangBrowser was...I always saw it in the VMMaker repo but I didn't know what it was until today. Cool project. I really like the idea. It would be awesome to extendt it so that it can not only supports ObjectMemory/Interpreter/Plugins but also CompiledMethods of those classes :) For example, (Interpreter >>#lookupInMethodCacheSel:class:) asCString that would be lovely :) Just for the record (if you want to include it in the wiki), in order to make it work (the asCString) I needed to first load MemoryAccess because it is used in VMMaker class >>cCodeGenerator: aClass inCache: cache inlined: doInlining You can...or document that on the wiki or maybe add a Smalltalk at: ? Anyway, how much effort do you think it could be to adapt at least the asCString to the new Cog versions ? because this is a nice feature for when you are learning Thanks -- Mariano http://marianopeck.wordpress.com |
On Tue, Apr 12, 2011 at 05:50:56PM +0200, Mariano Martinez Peck wrote: > > On Tue, Apr 12, 2011 at 2:04 PM, David T. Lewis <[hidden email]> wrote: > > > > > On Tue, Apr 12, 2011 at 01:40:22PM +0200, Mariano Martinez Peck wrote: > > > > > > So...I need to go to C, and "translate in my mind" what that part of > > SLANG > > > should look like in C, and search it in the C code. XCode is FAAAR to > > slow > > > to browe the interp.c . Morever, with inlined methods it is even more > > > difficult to find... > > > > XCode might be slow, but Squeak is fast :) Have a look at SlangBrowser > > for this. It has not been updated for either Pharo or oscog, but if > > anyone is interested maybe we can get that working too. Source is in > > the SqueakSource VMMaker project, and info at: > > > > http://wiki.squeak.org/squeak/5916 > > > > > Thanks Dave. I wasn't aware of what SlangBrowser was...I always saw it in > the VMMaker repo but I didn't know what it was until today. Cool project. I > really like the idea. > It would be awesome to extendt it so that it can not only supports > ObjectMemory/Interpreter/Plugins but also CompiledMethods of those classes > :) > > For example, (Interpreter >>#lookupInMethodCacheSel:class:) asCString > that would be lovely :) Try this: Transcript open; clear; show: (Interpreter asCString: #lookupInMethodCacheSel:class:) > Just for the record (if you want to include it in the wiki), in order to > make it work (the asCString) I needed to first load MemoryAccess because it > is used in VMMaker class >>cCodeGenerator: aClass inCache: cache inlined: > doInlining > > You can...or document that on the wiki or maybe add a Smalltalk at: ? > Oops that's a bug, thanks. > Anyway, how much effort do you think it could be to adapt at least the > asCString to the new Cog versions ? because this is a nice feature for > when you are learning > It should not be too hard. It's just a matter of creating the CCodeGenerator for any given class in the same way that VMMaker would have done, and using it to generate the code into strings that you can browse in the image and/or display in the browser code pane. Dave |
On Tue, Apr 12, 2011 at 5:48 PM, David T. Lewis <[hidden email]> wrote:
Take a look at the Slang Test Workspace in http://www.squeakvm.org/svn/squeak/branches/Cog/image/VMMaker-Squeak4.1.image. It is all there... e.g. (see the sel := assignment).
Transcript show: [| sel s cg cogitClasses cogitClass structClasses progress | sel := #remapIfObjectRef:pc:hasYoung:.
cg := (VMMaker forPlatform: 'Cross') interpreterClass: CoInterpreter;
buildCodeGeneratorForCogit. cg removeUnneededBuiltins. cg vmClass preGenerationHook: cg.
cg retainMethods: { #compactCogCompiledCode. sel }. cg prepareMethods. cg doInlining: true.
s := ReadWriteStream on: String new. (cg methodNamed: sel) halt;
emitCCodeOn: s generator: cg. s contents] value
|
On Tue, Apr 12, 2011 at 05:57:25PM -0700, Eliot Miranda wrote: > > On Tue, Apr 12, 2011 at 5:48 PM, David T. Lewis <[hidden email]> wrote: > > > > > On Tue, Apr 12, 2011 at 05:50:56PM +0200, Mariano Martinez Peck wrote: > > > > > > On Tue, Apr 12, 2011 at 2:04 PM, David T. Lewis <[hidden email]> > > wrote: > > > > > > > > > > > On Tue, Apr 12, 2011 at 01:40:22PM +0200, Mariano Martinez Peck wrote: > > > > > > > > > > So...I need to go to C, and "translate in my mind" what that part of > > > > SLANG > > > > > should look like in C, and search it in the C code. XCode is FAAAR to > > > > slow > > > > > to browe the interp.c . Morever, with inlined methods it is even more > > > > > difficult to find... > > > > > > > > XCode might be slow, but Squeak is fast :) Have a look at SlangBrowser > > > > for this. It has not been updated for either Pharo or oscog, but if > > > > anyone is interested maybe we can get that working too. Source is in > > > > the SqueakSource VMMaker project, and info at: > > > > > > > > http://wiki.squeak.org/squeak/5916 > > > > > > > > > > > > > Thanks Dave. I wasn't aware of what SlangBrowser was...I always saw it in > > > the VMMaker repo but I didn't know what it was until today. Cool project. > > I > > > really like the idea. > > > It would be awesome to extendt it so that it can not only supports > > > ObjectMemory/Interpreter/Plugins but also CompiledMethods of those > > classes > > > :) > > > > > > For example, (Interpreter >>#lookupInMethodCacheSel:class:) asCString > > > that would be lovely :) > > > > Try this: > > > > Transcript > > open; > > clear; > > show: (Interpreter asCString: #lookupInMethodCacheSel:class:) > > > > > Just for the record (if you want to include it in the wiki), in order to > > > make it work (the asCString) I needed to first load MemoryAccess because > > it > > > is used in VMMaker class >>cCodeGenerator: aClass inCache: cache inlined: > > > doInlining > > > > > > You can...or document that on the wiki or maybe add a Smalltalk at: ? > > > > > > > Oops that's a bug, thanks. > > > > > Anyway, how much effort do you think it could be to adapt at least the > > > asCString to the new Cog versions ? because this is a nice feature for > > > when you are learning > > > > > > > It should not be too hard. It's just a matter of creating the > > CCodeGenerator > > for any given class in the same way that VMMaker would have done, and using > > it to generate the code into strings that you can browse in the image > > and/or > > display in the browser code pane. > > > > Take a look at the Slang Test Workspace in > http://www.squeakvm.org/svn/squeak/branches/Cog/image/VMMaker-Squeak4.1.image. > It is all there... e.g. (see the sel := assignment). > > Transcript show: [| sel s cg cogitClasses cogitClass structClasses progress > | > sel := #remapIfObjectRef:pc:hasYoung:. > cg := (VMMaker forPlatform: 'Cross') > interpreterClass: CoInterpreter; > buildCodeGeneratorForCogit. > > cg removeUnneededBuiltins. > cg vmClass preGenerationHook: cg. > cg retainMethods: { #compactCogCompiledCode. sel }. > cg prepareMethods. > cg doInlining: true. > s := ReadWriteStream on: String new. > (cg methodNamed: sel) > halt; > emitCCodeOn: s generator: cg. > s contents] value Thanks Eliot, that's what is needed. Dave |
In reply to this post by David T. Lewis
On Wed, Apr 13, 2011 at 2:48 AM, David T. Lewis <[hidden email]> wrote:
Thanks Dave. I tried but I only got this in the Transcript: /* Simulator subclasses with method overrides should not be translated. */ /* ObjectMemory class>>initializeConstants */
Let's do a deal, you adapt the asCString for Cog and I build a Glamour browser for it :) -- Mariano http://marianopeck.wordpress.com |
On Sun, Apr 17, 2011 at 12:29:21AM +0200, Mariano Martinez Peck wrote: > > On Wed, Apr 13, 2011 at 2:48 AM, David T. Lewis <[hidden email]> wrote: > > > > Try this: > > > > Transcript > > open; > > clear; > > show: (Interpreter asCString: #lookupInMethodCacheSel:class:) > > > > Thanks Dave. I tried but I only got this in the Transcript: > > /* Simulator subclasses with method overrides should not be translated. */ > /* ObjectMemory class>>initializeConstants */ > Sorry I was not clear, but SlangBrowser does not yet work in the oscog branch. Dave |
On Sun, Apr 17, 2011 at 3:22 PM, David T. Lewis <[hidden email]> wrote:
Now, I was trying in a Interpreter VM, not Cog. -- Mariano http://marianopeck.wordpress.com |
On Sun, Apr 17, 2011 at 03:37:35PM +0200, Mariano Martinez Peck wrote: > > On Sun, Apr 17, 2011 at 3:22 PM, David T. Lewis <[hidden email]> wrote: > > > > > On Sun, Apr 17, 2011 at 12:29:21AM +0200, Mariano Martinez Peck wrote: > > > > > > On Wed, Apr 13, 2011 at 2:48 AM, David T. Lewis <[hidden email]> > > wrote: > > > > > > > > Try this: > > > > > > > > Transcript > > > > open; > > > > clear; > > > > show: (Interpreter asCString: #lookupInMethodCacheSel:class:) > > > > > > > > > > Thanks Dave. I tried but I only got this in the Transcript: > > > > > > /* Simulator subclasses with method overrides should not be translated. > > */ > > > /* ObjectMemory class>>initializeConstants */ > > > > > > > Sorry I was not clear, but SlangBrowser does not yet work in the oscog > > branch. > > > > Now, I was trying in a Interpreter VM, not Cog. Sorry, I misread your message. The error message from SlangBrowser is misleading. The #initializeConstants method is not translated to C because only instance side methods are translated. The class side initializers set the values of various class variables that will appear as C macros in the generated source. When running the interpreter simulator, the class variables are just class variables. In the C code, they are #define macros that are used throughout the generated C code. Dave |
On Sun, Apr 17, 2011 at 4:30 PM, David T. Lewis <[hidden email]> wrote:
Maybe I was not clear. Want I meant is that I *ONLY* see that in the Transcript. NOthing else. I didn't see the C code of #lookupInMethodCacheSel:class: The class side initializers set the values of various class variables Interesting :) Dave -- Mariano http://marianopeck.wordpress.com |
On Mon, Apr 18, 2011 at 02:07:38AM +0200, Mariano Martinez Peck wrote: > On Sun, Apr 17, 2011 at 4:30 PM, David T. Lewis <[hidden email]> wrote: > > On Sun, Apr 17, 2011 at 03:37:35PM +0200, Mariano Martinez Peck wrote: > > > On Sun, Apr 17, 2011 at 3:22 PM, David T. Lewis <[hidden email]> wrote: > > > > On Sun, Apr 17, 2011 at 12:29:21AM +0200, Mariano Martinez Peck wrote: > > > > > On Wed, Apr 13, 2011 at 2:48 AM, David T. Lewis <[hidden email] wrote: > > > > > > > > > > > > Try this: > > > > > > > > > > > > Transcript > > > > > > open; > > > > > > clear; > > > > > > show: (Interpreter asCString: #lookupInMethodCacheSel:class:) > > > > > > > > > > Thanks Dave. I tried but I only got this in the Transcript: > > > > > > > > > > /* Simulator subclasses with method overrides should not be > > translated. > > > > */ > > > > > /* ObjectMemory class>>initializeConstants */ > > > > > > > > > > > > > Sorry I was not clear, but SlangBrowser does not yet work in the oscog > > > > branch. > > > > > > Now, I was trying in a Interpreter VM, not Cog. > > > > Sorry, I misread your message. The error message from SlangBrowser is > > misleading. The #initializeConstants method is not translated to C because > > only instance side methods are translated. > > > Maybe I was not clear. Want I meant is that I *ONLY* see that in the > Transcript. NOthing else. I didn't see the C code of > #lookupInMethodCacheSel:class: I guess I'm not sure what is wrong. Try "VMMaker clearCodeGeneratorCache" and see if that clears the problem. Are you using a Pharo image? If so, try it in Squeak so you can see how it works, and we can debug the Squeak/Pharo differences later. It will probably turn out to be an exception thrown during the code generation that I am not handling properly in SlangBrowser. Dave |
Free forum by Nabble | Edit this page |