Debugging scripts on Windows

Hello,
I recently switched from 5.34.0 to 5.34.36 on Window 7 using vs2010. I used to be able set debug breakpoints in scripts that I compile and load as

.L myScript.cpp+
myFunc()

With root 5.34.0 I could break within myFunc() and examine variables, etc… However, w/ 5.34.36, I can no longer set breakpoints in myFunc(). Any idea of a work-around for this? Thanks
Ed

Did you remember to (re)compile ALL of ROOT with the “debug” switched on?

I am using the downloaded the debug binaries for the root part. My main application (not the script that I am attempting to debug) is compiled w/ debug.

What I don’t know is how root knows to invoke the compiler w/ debug options when I use

.L myScript.cpp+

As I say, it always worked with 5.34.0 - its as if something might have changed. Thanks
Ed

Try:
std::cout << gSystem->GetMakeSharedLib() << std::endl;
where “$Opt” is either:
std::cout << gSystem->GetFlagsDebug() << std::endl;
or:
std::cout << gSystem->GetFlagsOpt() << std::endl;
which usually depends on how you built ROOT and:
std::cout << gSystem->GetAclicMode() << std::endl;

Here’s what I get:

[quote]
root [1] std::cout << gSystem->GetMakeSharedLib() << std::endl;
cl $Opt -nologo -TP -c -nologo -IC:/Jenkins/workspace/root-release-5.34/BUILDTYPE/Debug/COMPILER/vc10/LABEL/winxp/source
s/root_v5.34.36/root/build/win -FIw32pragma.h -FIsehmap.h -MD -GR -EHsc- -W3 -wd4244 -D_WIN32 /MP $IncludePath $SourceF
iles -Fo$ObjectFiles && bindexplib $LibName $ObjectFiles > $BuildDir$LibName.def && lib -nologo -MACHINE:IX86 -out:$Bui
ldDir$LibName.lib $ObjectFiles -def:$BuildDir$LibName.def && link -nologo $ObjectFiles -DLL -out:$BuildDir$LibName.dl
l $BuildDir$LibName.exp -LIBPATH:%ROOTSYS%\lib $LinkedLibs libCore.lib libCint.lib kernel32.lib advapi32.lib user32.li
b gdi32.lib comdlg32.lib winspool.lib && if EXIST “$BuildDir$LibName.dll.manifest” ( mt -nologo -manifest “$BuildDir$L
ibName.dll.manifest” “-outputresource:$BuildDir$LibName.dll;2” && del “$BuildDir$LibName.dll.manifest” )[/quote]
and

and

[quote]
root [3] std::cout << gSystem->GetFlagsOpt() << std::endl;
-O2[/quote]

Does this explain why I cannot debug a script? Can I fix it? Thanks!
Ed

Hi Ed,

TrygSystem->SetAclicMode(TSystem::kDebug);
You can also try to set your own flags (or replace the one you want) with TSystem::SetMakeSharedLib
Something like:

TString cmd(gSystem->GetMakeSharedLib());
cmd.ReplaceAll("-MD ", "-MDd ");
cmd.ReplaceAll(" link -nologo ", " link -nologo -debug ");
gSystem->SetMakeSharedLib(cmd.Data());

Cheers, Bertrand.

Hi Bertrand,

I tried gSystem->SetAclicMode(TSystem::kDebug); that had no effect. As far as replacing "-MD " with "-MDd " I suspect that will not work as the debug root binaries where built with -MD (unlike the 5.34.0 binaries - which where build with -MDd)

However, here’s all that’s needed (note: works w/out first TSystem::SetAclicMode() call)

TString cmd(gSystem->GetMakeSharedLib())
cmd.ReplaceAll(" link -nologo ","link -nologo -debug")
gSystem->SetMakeSharedLib(cmd.Data())

Thanks for your help!!

Ed

This looks like a problem in ROOT’s building procedure on Windows (i.e. for “debug” builds, not all required flags are passed to ACLiC, “-debug” and “-MDd” are missing). I guess this should be fixed.

Hi Pepe,

In fact, only the “-debug” is missing in this particular case. We link against the non-debug version of the c++ libraries, so “-MD” is correct.

Cheers, Bertrand.