Debug symbols for libgcc in MSYS2 - debugging

I use the MSYS2 mingw-w64-x86_64-toolchain group to build my code and stack traces would be more useful if I had debug symbols for the standard library libgcc.
I have searched on the package manager and Google, but can't work out how to get debugging symbols for the standard library. I would expect a mingw-w64-x86_64-gcc-devel or mingw-w64-x86_64-gcc-dbgsym package.
Would I have to compile gcc from source?

Yes you need build GCC yourself with debug enabled. MSYS2 provide only release builds

Related

Looking for a mingw-w64 build of gcc that includes mudflap

I'm trying to debug a segfault in some code built with mingw-w64's version of gcc. Since no Windows build of gcc includes the Address Sanitizer, I've been looking for a version prior to 4.9 that would allow me to use Mudflap instead.
(It has to be 4.8 or earlier, since Mudflap was removed from gcc in 4.9 - see https://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging)
I've tried using downloads of 4.8.1 and 4.6.4 from https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/ - but my builds all fail with cc1plus.exe: fatal error: mf-runtime.h: No such file or directory.
I have tried using the original MinGW as well, but 4.5 as downloaded from
https://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.5.0-1/
just fails silently with error code 1.
Is there any site that still hosts a mingw-w64 build of gcc old enough to include mudflap? Preferably with SEH threads instead of SJLJ. If not, is there anywhere I can download a mingw-w64-compatible set of libraries and headers to install mudflap to work with an existing build?

Build clang format with Debug Symbols

I have built clang 3.6 from source and followed the rather straightforward instruction on the page and installed ninja, which I confirmed can build clang-format.
My question is quite simply how to pass some flags so I can get debug symbols because I do not want to do my work (modifying clang-format) using disassembly throughout.
This can be through the standard build (which uses CMake) or ninja.
I've faced similar issue recently (I wanted to debug clang's code itself). Turned out that you need to explicitly specify -DCMAKE_BUILD_TYPE=Debug when you run CMake to generate Ninja or standard makefiles.
BTW, be careful: with this Debug option ld "ate" about 4G of my RAM to link clang binary...

Debug symbols for LLVM libraries?

I'm using the Ubuntu packages to develop against the LLVM libraries. Here are the packages I have installed:
libllvm3.1
llvm-3.1
llvm-3.1-dev
llvm-3.1-runtime
llvm-3.1-source
'llvm-3.1-source' contains the source code, but as far as I can tell, none of them contain the debug symbols. So when I get a segfault deep inside some LLVM code, I can't tell at what line of source code it occurs.
How do I get the debug symbols?
LLVM is quick-and-easy to build from source. Download the source packages from http://llvm.org/releases/download.html#3.2 and follow the instructions to build in debug mode. Then you can have full debugging capability into LLVM itself.

C/C++ to MIPS Assembly

I know that to compile to assembly, I should use the -Soption with gcc or g++, but how do I get MIPS assembly?
I tried
g++ -march=mips2 dll.c
but that gives the error
dll.c:1:0: error: bad value (mips2) for -march= switch
I saw a suggestion of the compile command mips_gcc, but I can't find how to install that compiler.
I'm using Ubuntu 64-bit, if that helps.
You need a version of gcc that is built as a MIPS cross compiler. You can download the free Mentor/Codesourcery MIPS gnu/gcc cross compilation tool chain from here. This toolchain is available for both Windows and Linux.
After downloading, installing and adding the tool chain to your path you would say:
mips-linux-gnu-g++ -march=mips32r2 -S dll.c
to compile your code to MIPS32R2 assembly.
UPDATE 8/2017:
It looks like Sourcery CodeBench free cross compiler for MIPS is no longer available at Mentor's site.
Try the free toolchain at Imagination's site.

Does llvm/clang still need MinGW gcc after built?

I am new to llvm/clang and have successfully built clang with MinGW.
I have one simple question - is MinGW gcc still needed for clang to work as a c/c++ compiler?
Thanks,
jweiboman
Right now - unfortunately, yes. clang will use gcc to assemble / link the stuff. This is necessary to e.g. provide the proper cmdline for linker invocation adding CRT objects & libraries.
As soon as someone will provide the the complete "toolchain" definition for mingw in clang, this won't be necessary. Only assembler and linker (part of binutils) will be required.

Resources