mono / sdb

A command line client for the Mono soft debugger.
https://www.mono-project.com
MIT License
116 stars 44 forks source link

sdb doesn't seem to build on Windows #20

Closed gturri closed 9 years ago

gturri commented 9 years ago

TL;DR:


I'm trying to build sdb on my Windows [1].

If I run make just after cloning the repo and the submodules, I get

mkdir -p bin                                                                                                       
cp LICENSE bin/LICENSE                                                                                             
mkdir -p bin                                                                                                       
cp README.md bin/README                                                                                            
cd dep/debugger-libs && xbuild /verbosity:quiet /nologo /property:Configuration=net_4_0_Debug debugger-libs.sln    
MSBUILD: error MSBUILD0004: Too many project files specified                                                       
make: *** [bin/ICSharpCode.NRefactory.dll] Erreur 1                                                                

using msbuild instead, with make XBUILD=msbuild.exe yields a similar error:

MSBUILD : error MSB1008: Only one project can be specified. 
Switch: debugger-libs.sln                                   

(I get the same error if I run the following commands manually

cd dep/debugger-libs
msbuild.exe /verbosity:quiet /nologo /property:Configuration=net_4_0_Debug debugger-libs.sln   

)

It appears I can bypass this issue if I remove /nologo from the switches. I have no idea why it fixes the issue, but running make XBUILD_FLAGS='/property:Configuration=net_4_0_Debug /verbosity:quiet' successfully builds

(It might be worth noticing that when it builds dep/debugger-libs, it outputs the warning

warning CS1685: The predefined type `System.Runtime.CompilerServices.ExtensionAttribute' is defined multiple times. Using definition from `mscorlib.dll' 

)

However, running the tests (make check FSHARPC=fsc) fails, with the errors (which I'm unable to output in English) :

fsc --debug+ --nologo --warnaserror --keyfile:mono.snk --out:chk/check.exe --target:exe chk/check.fs

error FS0082: Il existe une différence entre l'architecture de processeur du projet en cours de génération "MSIL" et l'architecture de processeur de référence "mscorlib.dll", "x86". Cette différence peut entraîner des problèmes de runtime. Veuillez modifier l'architecture de processeur ciblée de votre projet à l'aide du gestionnaire de configuration de façon à aligner les architectures de processeur entre votre projet et les références, ou prendre une dépendance sur les références avec une architecture de processeur correspondant à l'architecture de processeur ciblée de votre projet. (Code=MSB3270)

error FS0082: Il existe une différence entre l'architecture de processeur du projet en cours de génération "MSIL" et l'architecture de processeur de référence "System.Data.dll", "x86". Cette différence peut entraîner des problèmes de runtime. Veuillez modifier l'architecture de processeur ciblée de votre projet à l'aide du gestionnaire de configuration de façon à aligner les architectures de processeur entre votre projet et les références, ou prendre une dépendance sur les références avec une architecture de processeur correspondant à l'architecture de processeur ciblée de votre projet. (Code=MSB3270)

error FS0082: Il existe une différence entre l'architecture de processeur du projet en cours de génération "MSIL" et l'architecture de processeur de référence "System.Web.dll", "x86". Cette différence peut entraîner des problèmes de runtime. Veuillez modifier l'architecture de processeur ciblée de votre projet à l'aide du gestionnaire de configuration de façon à aligner les architectures de processeur entre votre projet et les références, ou prendre une dépendance sur les références avec une architecture de processeur correspondant à l'architecture de processeur ciblée de votre projet. (Code=MSB3270)

error FS0082: Il existe une différence entre l'architecture de processeur du projet en cours de génération "MSIL" et l'architecture de processeur de référence "mscorlib.dll", "x86". Cette différence peut entraîner des problèmes de runtime. Veuillez modifier l'architecture de processeur ciblée de votre projet à l'aide du gestionnaire de configuration de façon à aligner les architectures de processeur entre votre projet et les références, ou prendre une dépendance sur les références avec une architecture de processeur correspondant à l'architecture de processeur ciblée de votre projet. (Code=MSB3270)

error FS0082: Il existe une différence entre l'architecture de processeur du projet en cours de génération "MSIL" et l'architecture de processeur de référence "System.Data.dll", "x86". Cette différence peut entraîner des problèmes de runtime. Veuillez modifier l'architecture de processeur ciblée de votre projet à l'aide du gestionnaire de configuration de façon à aligner les architectures de processeur entre votre projet et les références, ou prendre une dépendance sur les références avec une architecture de processeur correspondant à l'architecture de processeur ciblée de votre projet. (Code=MSB3270)

error FS0082: Il existe une différence entre l'architecture de processeur du projet en cours de génération "MSIL" et l'architecture de processeur de référence "System.Web.dll", "x86". Cette différence peut entraîner des problèmes de runtime. Veuillez modifier l'architecture de processeur ciblée de votre projet à l'aide du gestionnaire de configuration de façon à aligner les architectures de processeur entre votre projet et les références, ou prendre une dépendance sur les références avec une architecture de processeur correspondant à l'architecture de processeur ciblée de votre projet. (Code=MSB3270)
make: *** [chk/check.exe] Erreur 1

and running the test example on the README gives:

$ sdb
Welcome to the Mono soft debugger (sdb 1.4.5485.17430)
Type 'help' for a list of commands or 'quit' to exit

(sdb) r test.exe
Failed to connect to 'test.exe'

[1] : Windows 7, make 3.81, mono 3.3.0, msbuild version 4.0.30319.17929 , Microsoft .NET Framework, version 4.0.30319.18063

alexrp commented 9 years ago

I just pushed some dependency updates in 39367e4e1b0578eb6ec344f82da984f65b5bae92. Can you try and see if this improves things as far as actually using SDB goes?

I'm not sure what the deal with F# is. Could you maybe try playing with architecture flags and see if that helps?

gturri commented 9 years ago

Thanks for replying so fast!

TL;DR:


I removed my local clone and re-started from scratch (on commit 39367e4e1b057). Since you removed /nologo from the default flags, I now build successfully with a simple make.

However, I still have the Failed to connect to 'test.exe' error when I follow the steps on the README.

On the other hand, please disregard the Fsharp warnings: I'm realizing I get them whenever I use fsc, even though I can actually compile successfully a few HelloWorld. (I didn't noticed it earlier because I just installed fsharp, in order to run those tests).

I still can't run the tests with make check FSHARPC=fsc, even if I remove the flags --warnaserror because make complains that there's no rule to build chk/fs/print.exe.mdb even though chk/fs/print.exe has been compiled. It's because fsc generates a print.pdb as a debug file, so I guess I should install the "F# compiler from mono", and that this issue is out of the scope of this bug report.

alexrp commented 9 years ago

However, I still have the Failed to connect to 'test.exe' error when I follow the steps on the README.

It sounds like what's happening here is that the wrong command (remote) is being invoked by r. Does an explicit run test.exe work?

It's because fsc generates a print.pdb as a debug file, so I guess I should install the "F# compiler from mono", and that this issue is out of the scope of this bug report.

Yep, if you're building with Mono tools, you'll need the Mono version of fsc. It's used to build the test programs to be tested under the Mono debugger, so it's important that Mono-compatible debugging info is generated.

gturri commented 9 years ago

An explicit run test.exe also gives Failed to connect to 'test.exe'

alexrp commented 9 years ago

That's... odd. It's definitely invoking the wrong command. I imagine something is going wrong here: https://github.com/mono/sdb/blob/master/src/MultiCommand.cs#L120

Could you try throwing in some Console.WriteLines around the command code and try to figure out what's going wrong here? I can't reproduce on non-Windows. :(

gturri commented 9 years ago

What I could find is:

I hope it helps.

btw, as far as I'm concern, I'm starting to work in a Linux VM, where I can run sdb without problem.

Thanks for proposing this software, and thanks for being so responsive!

alexrp commented 9 years ago

OK. Can you try this:

$ SDB_DEBUG=enable sdb
(sdb) cfg s DebugLogging true
(sdb) cfg s LogInternalErrors true
(sdb) cfg s LogRuntimeSpew true
(sdb) r test.exe
gturri commented 9 years ago
[g.turri@FR-9LFLC5J:~/Desktop]$ SDB_DEBUG=enable /c/miscRepos/sdb/sdb/bin/sdb
Welcome to the Mono soft debugger (sdb 1.4.5485.30778)                       
Type 'help' for a list of commands or 'quit' to exit                         

(sdb)          cfg s DebugLogging true                                       
'DebugLogging' = 'True' (was 'False')                                         
(sdb)          cfg s LogInternalErrors true                                  
'LogInternalErrors' = 'True' (was 'False')                                    
(sdb)          cfg s LogRuntimeSpew true                                     
'LogRuntimeSpew' = 'True' (was 'False')                                       
(sdb)          r test.exe                                                    
Failed to connect to 'test.exe'                                              
(sdb)          Event: 'TargetExited'                                         
alexrp commented 9 years ago

Just for reference, what's the source code for test.exe?

gturri commented 9 years ago

I copy pasted the test.cs from your README:

using System;
using System.Diagnostics;

static class Program
{
    static void Main()
    {
        var str = "Foo!";

        Foo(str);
    }

    static void Foo(string str)
    {
        Console.WriteLine(str);

        Bar();
    }

    static void Bar()
    {
        Debugger.Break();
    }
}
alexrp commented 9 years ago

OK, one last thing (hopefully): Can I get the output of cfg list?

gturri commented 9 years ago
Welcome to the Mono soft debugger (sdb 1.4.5485.30864)   
Type 'help' for a list of commands or 'quit' to exit     

(sdb)          cfg list                                  
'AllowMethodEvaluation' = 'True'                         
'AllowTargetInvoke' = 'True'                             
'AllowToStringCalls' = 'True'                            
'ChunkRawStrings' = 'False'                              
'ConnectionAttemptInterval' = '500'                      
'DefaultDatabaseFile' = ''                               
'DebugLogging' = 'True'                                  
'DisableColors' = 'False'                                
'EllipsizeStrings' = 'True'                              
'EllipsizeThreshold' = '100'                             
'EnableControlC' = 'True'                                
'EvaluationTimeout' = '1000'                             
'ExceptionIdentifier' = '$exception'                     
'FlattenHierarchy' = 'True'                              
'HexadecimalIntegers' = 'False'                          
'InputPrompt' = '(sdb)'                                  
'LoadDatabaseAutomatically' = 'False'                    
'LogInternalErrors' = 'True'                             
'LogRuntimeSpew' = 'True'                                
'MaxConnectionAttempts' = '1'                            
'MemberEvaluationTimeout' = '5000'                       
'PreferDisassembly' = 'False'                            
'RuntimePrefix' = '/usr'                                 
'SaveDatabaseAutomatically' = 'False'                    
'StepOverPropertiesAndOperators' = 'True'                
alexrp commented 9 years ago

That RuntimePrefix doesn't look right. It should be set to something along the lines of C:\Program Files (x86)\Mono 3.2.3. Does that work?

gturri commented 9 years ago

Well done, seems you nailed it!

(sdb)          cfg s RuntimePrefix C:\Program Files (x86)\Mono-3.2.3                                                        
'RuntimePrefix' = 'C:\Program Files (x86)\Mono-3.2.3' (was '/usr')                    
(sdb)          r test.exe                                                                                                   
Inferior process '6148' ('test.exe') started                                                                                
Event: 'TargetReady'                                                                                                        
[Mono] Loaded assembly: c:\Users\g.turri\Desktop\test.exe                                                                   
[Mono] Loaded assembly: C:\Program Files (x86)\Mono-3.2.3\lib\mono\gac\I18N\4.0.0.0__0738eb9f132ed756\I18N.dll              
[Mono] Loaded assembly: C:\Program Files (x86)\Mono-3.2.3\lib\mono\gac\I18N.West\4.0.0.0__0738eb9f132ed756\I18N.West.dll    
Foo!                                                                                                                        
Inferior process '6148' ('test.exe') suspended                                                                              
#0 [0x00000001] Program.Bar at c:\Users\g.turri\Desktop\test.cs:22                                                          
        Debugger.Break();                                                                                                   
Event: 'TargetStopped'                                                                                                      
(sdb)          bt                                                                                                           
#0 [0x00000001] Program.Bar at c:\Users\g.turri\Desktop\test.cs:22                                                          
        Debugger.Break();                                                                                                   
#1 [0x00000007] Program.Foo at c:\Users\g.turri\Desktop\test.cs:17                                                          
        Bar();                                                                                                              
#2 [0x00000008] Program.Main at c:\Users\g.turri\Desktop\test.cs:10                                                         
        Foo(str);      

Congrats for this remote-debugging!

alexrp commented 9 years ago

Yay! I'll close this then. I've opened another issue (#22) for the strange prompt behavior on Windows.