Forums

Does -d:1 not implement /o- in Csharp automatically

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Does -d:1 not implement /o- in Csharp automatically

Postby RIGHT_THEN » Tue Jan 19, 2010 2:54 pm

Gentlemen,

when we pass -d:1 option to cobra compiler than does it not pass /o- option to
CSharp compiler to not optimize.

in sharpdevelop when i tried debugging cobra i was able to breakpoint
but variables use to show infomation not available in optimized mode
well debugging and all is preety heavy handed subject for me so i thought maybe
i am doing something wrong and i maynot have implemented certain features of
Sharpdevelop for debugging to work.since it is able to breakpoint properly and not show
variable values must be wrong something with my implementation.

but then today i thought why not try to send argument to Csharp compiler through
-sharp-args to not optimize. to see what exactly this sharpdevelop mean by optimised code

and it worked!!!!

now still values are not available in the Editor window but down below
in Local Variables pane all values are nicely displaying their bargin. and one can easily
see while stepping through code what is going on in what variable.

So my question is to getinsight in debugging as to what exactly -d: option means
i understand that it should spit out some pdb or some stuff for debuggers to understand
when using debuggers to debug application and as just seen if even with -d: option the
code is optimized as well the pdb is made than does it mean no debugger will be
able to show values. or is it only sharpdevelop implementation that way.

if it would be true with all debuggers than it is better to pass /o- to Csharp as well
otherwise what use is -d option . thou i have hardcoded it now in sharpdevelop when programm is compiled in debug mode.


2) what might be the reasons for not being able to reference
certain assemblies.when i am mentioning the path correctly
with -lib: . i thought maybe that directory is protected
i checked and even removed readonly option from directory containing it
but still i am unable to reference certain asemblies while others
are getting referenced properly.this feature i have noticed after
i downloaded the latest version of cobra before it was referencing
same assemblies properly.if you could give certain guidelines for
referencing assemblies for me to check before i can blame
cobra for that.


a few days back Mr. todd a.(Alexander) was asking about getting errors
while debugging . in 64 bit windows 7. so this could have been the reason also. because csharp by default compiles for anucpu unless COBRA
changes to something else which i doubt and i am also not
specifying anything specific for platforms. so it might work by
specifying -sharp-args:/o-. on 64 bit platform also.thou i am about to
upadate it after clarifying the referencing issue.


what tool does everybody use for debugging cobra programms?

Thankyou
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Does -d:1 not implement /o- in Csharp automatically

Postby gauthier » Tue Jan 19, 2010 3:18 pm

Hello M. RightThen

> So my question is to getinsight in debugging as to what exactly -d: option means

I've never searched through this issue, but it is the same when stepping in VS debugger, I'll try with csharp compiler arguments to report if that solves it (would be logical), I agree that passing debug option to cobra should cascade to csharp compiler

also nice to see someone working on integration of cobra in a .net IDE, I'll try to take a look at your work.

> what tool does everybody use for debugging cobra programms?

I'm using mostly VS (not as much usefull without var inspection) and unit tests
gauthier
 
Posts: 116

Re: Does -d:1 not implement /o- in Csharp automatically

Postby RIGHT_THEN » Tue Jan 19, 2010 4:08 pm

hello Mr. gauthier

thanks for your input


Thankyou
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Does -d:1 not implement /o- in Csharp automatically

Postby hopscc » Wed Jan 20, 2010 1:23 am

yo RIGHT_THEN,

You can see exactly what the cobra compiler invokes the C# compiler with by using -v:2 on the cobra compiler invocation line
Code: Select all
cobra -d:1 -v:2 hello.cobra

Search for line starting with 'Code Provider' in the output

-d and -o compiler options get passed to the c# compiler ( tho only enable options) - looks like theres no combinatorial suppression options from the
various cobra compiler switches.
Code: Select all
 cobra -d:1 -v:2 hello.cobra
Cobra Command Line 0.8.0 post-release
Copyright (C) 2003-2009 by Cobra Language LLC.

OS Version:   Microsoft Windows NT 5.1.2600 Service Pack 3
CLR Platform: .NET
CLR Version:  2.0.50727.3603
Current Directory: C:\home\hops\src\cobra\Tst
Current Exe: C:\home\hops\src\cobra\wkspace\Source\cobra.exe
Option Dictionary:
    reveal-internal-exceptions: true
    color: true
    debug: '+'
    verbosity: 2
    back-end: 'none'
    contracts: 'inline'
    correct-source: Set<of String>['none']
    debugging-tips: false
    embed-run-time: false
    include-asserts: true
    include-nil-checks: true
    include-tests: true
    include-traces: true
    native-compiler: 'auto'
    number: 'decimal'
    testify-results: 'r-testify'
Paths:
    hello.cobra
Phase: Binding Cobra run-time library
Referencing Cobra run-time
Adding reference to Cobra.Lang.dll
Phase: Reading libraries
Reading assembly:  mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
              at:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
Reading assembly:  System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
              at:  C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
Final assembly reference list:
0. Cobra.Lang.dll
Loading reference: Cobra.Lang.dll
Reading assembly:  Cobra.Lang, Version=0.8.0.1, Culture=neutral, PublicKeyToken=null
              at:  C:\home\hops\src\cobra\Tst\Cobra.Lang.dll
Phase: Parsing source code
Parsing hello.cobra
Phase: Binding use directives
Phase: Binding inheritance
Phase: Binding interface
Phase: Computing matching base members
Phase: Binding implementation
Phase: Identifying .main
Phase: Generating C# code
Phase: Compiling C# code
Compiling to produce hello.exe
Code Provider = Microsoft.CSharp.CSharpCodeProvider
    compilerOptions = "/r:Cobra.Lang.dll" "/debug+" "/nologo" "/nowarn:0108,0162,0169,0183,0184,0219,0414,0429,1717,1718" "/main:Hello" "
      -lib:C:\home\hops\src\cobra\wkspace\Source"
    referencedAssemblies = ['System.dll']
    generateExecutable = true
    outputAssembly = hello.exe
    sharpFileNameList = ['hello.cobra.cs']
Deleting intermediate files.
Running: hello


cobra compiler should probably explicitly suppress optimisation if debug is specified
(though a non brain damaged (Backend) compiler would do that anyway - (referring here to csc)

what tool does everybody use for debugging cobra programms?


I'm old school - stop and think, relentless application of the scientific method and 'print' or 'trace' statements seems to be sufficient so far. :)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Does -d:1 not implement /o- in Csharp automatically

Postby RIGHT_THEN » Wed Jan 20, 2010 9:55 am

yo Mr. hopscc


thanks for the -V:2 tip. so i take it that you
cuncurr the validation of /o- switch with -d:1
unless there is some other explanation for it.

hopscc wrote:I'm old school - stop and think, relentless application of the scientific method and 'print' or 'trace' statements seems to be sufficient so far.


may i say sir that old habits die hard :D
or
old soilders never die they just fade away :mrgreen: (pardon please)


gauthier wrote:I'm using mostly VS (not as much usefull without var inspection) and unit tests


@ gauthier pardon me sir if i got you wrong. to me above statement
implies that Var inspection is not possible the way you might want it
while debugging in VS. i just got it possible in a lay mans way.correct
me if you have better ideas.


now at the risk of sounding absurd and naive.
i want to share how to debug Cobra even with Visual Studio for new
comers like me .




HOW TO DEBUG COBRA PROGRAMMS
----------------------------
First Way:-
---------
since i dont have Vs 2008 professional or above i am using
VS 2008 Express and it does not allow Attach Process or if it does
enlighten me.

those who dont have professional or above editions can
downloaded Vs Integration shell which is free from

[url]http://www.microsoft.com/downloads/details.aspx?familyid=2e9a8c35-eb3d-43eb-9122-
a5ec195cd7bb&displaylang=en[/url]

install it,

it allows Attaching outside processes

compile the Cobra programms with -d:1 -sharp-args:/o-

but do the following in the main entry point function
i.e

def main is shared
Thread.sleep(10000) #we need enough time to attach this
#procees in VS debugger before it starts
#executing meaingful code
#so this should be implemented as
#the first line after entering main
#ALSO as yet i dont know any other way
#maybe through command line!!!

#then rest of your code

now before we do anything else open all your Code files ie *.cobra files
being used in your programm inside VS shell through menu File->open and set
break points on the lines you want to pause at
let it be the first line. after Thread.sleep(..)
to see if it worked

now in menu Tools->Attach to Process.. click it

the new window opened displays all running instances under current user of
computer by default.

now Run your Cobra Programm`s exe that you want to debug either from
Sharpdevelop or from commandline in a way that no debugger is attached to it.
i think double clicking it would do.( if you dont have Sharpdevelop or dont
want to do it with command line)

now back to Vs Shell click refresh in the window displaying all running processes
you will be able to see the name of your Programm "exe" too listed there.
select it and click Attach. thats it all this while our proccess/programm was
sleeping and when it will wake up it will find a new Master that has enslaved it
your Visual studio. you will see control stopping at breakpoints and when you will
move your mouse over your File you will see variables displaying their values.

if it does not work the first time it will from second time onwards.


althou same can be done in sharpdevelop if you are making your programms
in sharpdevelop and compiling with -sharp-args:/o-.




Thankyou
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Does -d:1 not implement /o- in Csharp automatically

Postby gissolved » Wed Oct 20, 2010 4:08 am

Instead of attaching to the program you can also add the following lines in your main or at the part you want to debug :

// Launch the debugger
sharp"System.Diagnostics.Debugger.Launch()"

// Add a breakpoint
sharp"System.Diagnostics.Debugger.Break()"

If you have compiled your Cobra program with -d:1 -sharp-args:/o- and then run it then Windows will prompt you to select a debugger and break at your breakpoint.
This works very well when you have Visual Studio 2010 running.

Strangely enough I didn't manage to directly write something like System.Diagnostics.Debugger.launch because this generated a NullReferenceException when I tried to compile my code.

Kind regards,

Samuel
gissolved
 
Posts: 1

Re: Does -d:1 not implement /o- in Csharp automatically

Postby Charles » Mon Oct 25, 2010 5:14 pm

The compiler was choking on a null value for a field of the Debugger class when reading its library symbols. I have checked in a fix with test case, and re-ran the test suite on both Win7/.NET and Mac/Mono.

Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 94 guests

cron