Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kamy

macrumors member
Original poster
Jul 27, 2011
44
0
Hey guys,

I use CLang compiler to build our binaries for the MACOSX platform.
I also provide the '-g' option which ensures that debugging symbols are enabled.

This is my CLang command with the flags - Do note that the '-g' flag is provided

clang -I/ac/head/tools/mtxtests -I/ac/head/library/include -I/ac/head/library/src/VersLib -I/ac/head/library/src/XmlLib -I/ac/head/library/src/ZipLib -I/ac/head/tools/googletest/include -DAGENT_VERS_MAJ=0 -DAGENT_VERS_MIN=0 -DAGENT_VERS_REV=\"0\" -DBUILDNUMBER=\"Undefined\" -DUNIX -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DMACOSX -DDEBUG -DIMPORT_MTXLIBS -DUNICODE -D_UNICODE -m64 -stdlib=libstdc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -Wall -fPIC -fpermissive -g -fvisibility=hidden -E /ac/head/tools/mtxtests/library/PortLib/MtxString.cpp
I want to use XCode to debug an isssue.
I issue a sleep(30) command, my program waits 30 seconds, so that gives me time to go to XCode - Debug-->Attach To Process --> mtxtests (my executable)

As soon as XCode attaches, the sleep is aborted and teh execution continues!
Thus, I cant debug any code.
Also my XCode project has 'C++ library' as the target

What could be the problem?

If i remember i used to be able to debug fine when i used to use the LLVM-GCC compiler. But with Maverics, we need to move to CLang...

Any suggestions would be appreciated.
 
Last edited:
C++ Sample file debugging

I dug around some more info. Apparently xcode you can build executables with "dsym" debug information, which puts the debug info in a separate file (instead of embedding it in the executable)

But as we are using the command line, i dont see any DEBUG Symbol files or "dsym" files.

So i used the util to generate the Symbol files
dsymutil mtxtests -o mtxtests.dSYM

Still the same behavior. The executable sleeps and as soon as we attach the process , the process resumes without allowing me to debug!!!
 
Trying some more

Ok. This is me again trying more stuff...

I created a simple .C file
And compiled using CLang

clang -g -o tempraturefn tempraturefn.c

This time i see 'tempraturefn.dSYM' automatically created...

i see that the executable sleeps and then i open the file in XCode and try to attach my executable and voilla i can debug!!

So this means that something is wrong with the flags am sending, while compiling my code .....
clang -I/ac/head/tools/mtxtests -I/ac/head/library/include -I/ac/head/library/src/VersLib -I/ac/head/library/src/XmlLib -I/ac/head/library/src/ZipLib -I/ac/head/tools/googletest/include -DAGENT_VERS_MAJ=0 -DAGENT_VERS_MIN=0 -DAGENT_VERS_REV=\"0\" -DBUILDNUMBER=\"Undefined\" -DUNIX -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DMACOSX -DDEBUG -DIMPORT_MTXLIBS -DUNICODE -D_UNICODE -m64 -stdlib=libstdc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -Wall -fPIC -fpermissive -g -fvisibility=hidden -E /ac/head/tools/mtxtests/library/PortLib/MtxString.cpp
 
But as we are using the command line, i dont see any DEBUG Symbol files or "dsym" files.

Just add the -g flag and a .dSYM file will be created with the same name as your target. So for example,

Code:
clang test.c -g

will create a.out and a.out.dSYM

So this means that something is wrong with the flags am sending, while compiling my code .....

Have you considered using a makefile?
 
Just add the -g flag and a .dSYM file will be created with the same name as your target. So for example,

Code:
clang test.c -g

will create a.out and a.out.dSYM



Have you considered using a makefile?

Hey subsonix,

if you see the flags for our compilation command, we do pass the "-g" flag.
Yes we do use a Makefile.

But when i use our compilation command, it does not generate any 'dSYM' file.

Is a 'dSYM' file mandatory for debugging?
If yes, that explains the fact that my sample file could be dubbuged, but not my main executable.
 
Hey subsonix,

if you see the flags for our compilation command, we do pass the "-g" flag.
Yes we do use a Makefile.

But when i use our compilation command, it does not generate any 'dSYM' file.

Is a 'dSYM' file mandatory for debugging?
If yes, that explains the fact that my sample file could be dubbuged, but not my main executable.

As far as I know it gives you more information when you debug with debug symbols, but you should be able to attach a debugger anyway. However, it should create a dSYM file, perhaps it has something to do with the fact that you are building a library.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.