Page 1 of 1

Why is Mdbg starting in MainWrapper.cobra?

PostPosted: Sat May 08, 2010 2:33 am
by Gameday
I tried to do some debugging on another computer. Here's a small source file which can reproduce the problem:

Code: Select all
class A
    def main
      a = CobraCore.commandLineArgs
      for i in a
         print i


and the output I get when I try to run it:

Code: Select all
F:\Documents and Settings\john\Desktop>cobra -d -compile x.cobra
Compilation succeeded

F:\Documents and Settings\john\Desktop>mdbg x.exe
MDbg (Managed debugger) v3.5.30729.1 (SP.030729-0100) started.
Copyright (C) Microsoft Corporation. All rights reserved.

For information about commands type "help";
to exit program type "quit".

run x.exe
STOP: Breakpoint Hit
located at line 1 in MainWrapper.cobra
[p#:0, t#:0] mdbg>


the name of the file is x.cobra

Re: Why is Mdbg starting in MainWrapper.cobra?

PostPosted: Sat May 08, 2010 2:50 am
by Gameday
Very interesting. If I add is shared to main, it will start normally. Any ideas why?

Re: Why is Mdbg starting in MainWrapper.cobra?

PostPosted: Sat May 08, 2010 3:37 am
by Charles
Cobra let's you have a .main method that is not shared/static. But this is a feature of the language that is not shared by the virtual machine (VM). So when your .main is not shared, Cobra creates a MainWrapper class to appease the VM gods:
class MainWrapper

def main is shared
YourProgram().main

Re: Why is Mdbg starting in MainWrapper.cobra?

PostPosted: Sat May 08, 2010 4:07 am
by Gameday
Ah, ok. I understand now. Thanks!