GDB Vs LLDB debuggers - xcode

What is the difference between GDB & LLDB debuggers? I recently upgraded my Xcode version from 4.2 to 4.3 & started getting warning to upgrade my debugger from GDB to LLDB.

LLDB is part of the LLVM suite of tools that Apple is moving to, including Clang. There are tons of improved features, including improved performance. There's a quick intro for GDB users here: http://lldb.llvm.org/tutorial.html
However...
You might want to take a trip over to the forums at developer.apple.com. There's a fair bit of rumbling about issues with LLDB at the moment (in XCode 4.3.1). One nasty issue, which people from Apple have confirmed, is that viewing ivars while stepping may show you the wrong values.

1. By Difference of Definition
First, What is GDB?
"GDB is the standard debugger for the GNU software system"
The GNU Debugger, usually called just GDB and named gdb as an executable file, is the standard debugger for the GNU operating system. However, its use is not strictly limited to the GNU operating system; it is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Java1 and partially others.2
(quotation from wikipedia)
Second, What is LLDB?
"LLDB is a debugger built as a set of reusable components which highly leverage existing libraries in the larger LLVM Project, such as the Clang expression parser and LLVM disassembler. LLDB is Apple’s “from the ground up” replacement for GDB, developed in close coordination with the LLVM compilers to bring you state-of-the-art debugging with extensive capabilities in flow control and data inspection. Starting with Xcode 5, all new and preexisting development projects are automatically reconfigured to use LLDB. The standard LLDB installation provides you with an extensive set of commands designed to be compatible with familiar GDB commands. In addition to using the standard configuration, you can easily customize LLDB to suit your needs.
(quotation from Apple official site)
/* I tried to find actual / practical datas to prove the statement : LLDB is already much faster than GDB when debugging large programs.)
However, I could not find it. if there is someone having this related data, please edit this article. */
Both GDB and LLDB are of course excellent debuggers without doubt.
GDB is debugger part of the GNU project created to work along the GNU compiler.
LLDB is debugger part of the LLVM project created to work along LLVM compiler.
2. By Difference of Debugger Command usage
The majority of the commands are the same.
However, lldb and gdb, two different debuggers are developed by different set of developers and thus have a little bit different commands.
This is good link below for comparing difference of these two debugger commands.
let me link the detail below :
https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html
http://lldb.llvm.org/lldb-gdb.html
This clearly indicates and organizes the difference of commands.
In case the site is not accessible anymore, I summary the major difference of commands below from the linked site.
3. By Personal Opinion
LLDB has been fully integrated from Xcode IDE 5 by default as primary debugger.
From that time, there has been some complaint report about LLDB stability, performance issues and bugs.
However, LLVM with LLDB project has been being incredibly improved and upgraded so far as the one of the core open-source project in the world.
So, I think, at least, LLDB should be used for Apple development environment since LLDB stole the position of GDB and is already primary default debugger at least in Apple world.(In late September, 2016, Xcode 8 integrating LLVM and LLDB was officially released, meaning quite a lot of time has been passed since LLVM/LLDB is default tool-chain for Xcode.)
But, We all already know GDB has been historically and strongly verified and battle-proven debugger over 30 years, which is awesome.
So, I would say…
I would like to use lldb while using clang, use gdb while using gcc compiler as the good combination or pair because lldb is based on llvm, whereas gdb is a GNU debugger.
I wish it could be helpful for you.
Thanks.

Related

Where to find timeline and other info for GLIBCXX

Any Google search I've tried gives me information on GLIBC (not C++) library, GCC (the compiler), or an occasional hit involving the token GLIBCXX without any other relevance. I've tried searching for things like feature and roadmap which have returned similar information for the compiler syntax. But I'm looking for information on the library.
The Mac's development system appears to use Clang with GLIBCXX version 4.2.1 (that version at least on the system I looked at). I've seen from the Clang roadmap that C++11/14 support is pretty much a done deal. So I was surprised that it objected to using namespace std::string_literals;, since user-defined literals seem to be supported by Clang and "blah"s is a one-line bit of syntactic sugar to stick in the header.
Is there a roadmap or other documentation showing which C++11/14 standard library features are available, not available, not usable, coming soon, never coming, etc?
Any idea why such low-hanging fruit would not have been in there?
to clarify, even though the namespace is GLIBCXX, it's not actually relevant to glibc at all. this is entirely contained under the gcc project.
the reason Apple pinned to gcc-4.2 is because later versions switched to GPL-3. they didn't want to deal with that because they want to retain 100% control over the OS (and your hardware), so they never upgraded.
if you want to know more about the GNU libstdc++, then check out its homepage: https://gcc.gnu.org/libstdc++/
that has all the details you're looking for afaict.

Clang or GCC compiler for c++ 11 compatibility programming on Windows?

I was wondering which compiler is better to use on Windows OS (8.1) in temrs of compatibility to c++11's (and later 14) functions, liberies and features (like lambdas) and is also comfortable to use (less bugs).
I am a university student hence I'm not looking at the subject product-wise (even though I do like to code a bit more than just projects for my studies).
I am currently using eclipse luna IDE if it matters.
Notice that compiler != IDE.
VC++ is one of the most populars on Windows and depending on its version it has a good support for C++11 features. Check the list on the msdn blog to find out if there's everything you need.
Gcc is also ported to Windows and you can install MinGW to use it (4.8.1.4 at the moment of writing this). It is pretty complete on C++11.
Clang is also available for the Windows platform and it is also complete on C++11 support (plus it has good diagnostic messages), but notice that you will have to use another linker since clang doesn't ship with one (although there is an ongoing effort to write it: http://lld.llvm.org/)
All the compilers I cited above are pretty stable but, based on my experience, if you're looking for latest and greatest C++11/14/17 features, you might just want to go for gcc or clang (VC++ is slower in adding support for newest features and the compiler is undergoing a huge update to modernize). Just keep in mind that these are compilers and not just IDEs, an IDE is a front-end supporting program that uses a compiler undercover to compile files.
To set up a C++11 compiler, I suggest installing MSYS2, it has a package manager (pacman) that can install fresh versions of GCC, GDB, Clang and many libraries like SDL, Lua etc. Very easy to use too.
As far as GCC vs CLang goes - I really tried hard to make CLang work (which is presumably faster and more friendly than GCC - produces better warnings, etc.), but failed. Issues were that CLang (which comes with MSYS2) is hard-coded to use GCC linker which produces some strange linker errors when using libstdc++ (std implementation from GCC). libc++ (a new implementation designed to work with CLang) didn't worked for me on Windows either.
So you either try build CLang from sources and hope that some configuration will work with C++11 library, OR just stick with GCC which works just fine out of the box.
As IDE, I suggest to take a look at CLion. It is very comfortable (infinitely more user-friendly and intuitive than Visual Studio, IMO). Just install it and point it to the mingw64 (or mingw32) folder of MSYS2, it will auto-detect everything for you.
It only works with CMake projects though.

GCC on Windows OS

I was wondering is there a free Windows version of GCC.
I know there is minigw and something else but I don't know how to use them.
Sorry if this should be on SU.
The main choices are either MinGW or CygWin.
CygWin is a more complete UNIX-like environment than MinGW as it offers quite a lot of tools over and above development stuff. Even to the point of a full X-Windows server so you can develop software that'll run on both UNIX-like systems and Windows.
The installer is good but I would suggest installing everything even if you think you don't need it. Disk space is cheap and I've had problems in the past trying to get stuff going on partial installs (whether 1.7, or even earlier, fixes this, I don't know - I always do full installs).
However, it relies on the CygWin UNIX emulation DLL which, if I remember rightly, has restrictions for non-free software.
MinGW is more concentrated on the development tools. It generates native Windows applications rather than running under a emulation DLL like CygWin.
It used to be difficult to install with having to do MinGW, MSYS and others separately but it's come a long since then and has an easy graphical installer.
I believe it can do graphical applications using native Windows calls rather than via X-Windows, since it just links to the normal Windows runtimes.
If you want to know how to use either of them, you really have to look through the docs found at those links I provided - check the Documentation link on the left for MinGW (particularly Getting started) or the CygWin FAQ.
As for GUIs for development, I've never used one for CygWin - I'm old enough that I remember mark sense cards so I'm not scared of the command line interface :-).
I used Eclipse with CDT running over MinGW and wasn't that impressed although admittedly that was an early version. Don't get me wrong Eclipse is a brilliant tool and we use it for both Java and Linux/C development, I just had a lot of troubles with Eclipse/CDT under Windows.
Code::Blocks, on the other hand, was absolutely brilliant but you should check them all out to see which one suits you best. As I said, the last time I looked was about five years ago, an eternity in the IT world.
I am a bit late, but since the question may still arise...
gcc for Windows (including Ada, C, C++ and Fortran compilers) can be obtained from MinGW-builds on SourceForge: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/
As of august 2013, there are 32 and 64 bits versions of gcc-4.8.1.

Programmer's Debugging toolkit pack

What kind of debugging tools you've been using to debug working binaries?
Is there are debugging toolkits in addition to GDB?
The only reason is that I'm quite new for system debugging and I've been debugging my system service.
Sultan
I'd recommend Valgrind [1]. It's quite useful when dealing with memory leaks and segfaults.
The segfaults can be tracked by letting GDB run (without any breakpoint) and check the backtrace ('bt' command), after the crash.
P.S.: I don't remember if Valgrind is avaliable for other systems, but since you asked about alternatives to GDB, I'm assuming you're on a *nix box.
Have a nice debugging.
[1] http://valgrind.org/
Assuming you are on Linux systems, one of the most valuable tool is valgrind.
I don't really use anything else except for precondition/postcondition check in the code itself (i.e. assertion on methods' input values).

Windows based development for ARM processors

I am a complete newbie to the ARM world. I need to be able to write C code, compile it, and then download into an ARM emulator, and execute. I need to use the GCC 4.1.2 compiler for the C code compilation.
Can anybody point me in the correct directions for the following issues?
What tool chain to use?
What emulator to use?
Are there tutorials or guides on setting up the tool chain?
building a gcc cross compiler yourself is pretty easy. the gcc library and the C library and other things not so much, an embedded library and such a little harder. Depends on how embedded you want to get. I have little use for gcclib or a c library so roll your own works great for me.
After many years of doing this, perhaps it is an age thing, I now just go get the code sourcery tools. the lite version works great. yagarto, devkitarm, winarm or something like that (the site with a zillion examples) all work fine. emdebian also has a good pre-built toolchain. a number of these places if not all have info on how they built their toolchains from gnu sources.
You asked about gcc, but bear in mind that llvm is a strong competitor, and as far as cross compiling goes, since it always cross compiles, it is a far easier cross compiler to download and build and get working than gcc. the recent version is now producing code (for arm) that competes with gcc for performance. gcc is in no way a leader in performance, other compilers I have used run circles around it, but it has been improving with each release (well the 3.x versions sometimes produce better code than the 4.x versions, but you need 4.x for the newer cores and thumb2). even if you go with gcc, try the stable release of llvm from time to time.
qemu is a good emulator, depending on what you are doing the gba emulator virtual gameboy advance is good. There are a couple of nds emulators too. GDB and other places have what appear to be ARMs own armulator. I found it hard to extract and use, so I wrote my own, but being lazy only implemented the thumb instruction set, I called mine the thumbulator. easy to use. Far easier than qemu and armulator to add peripherals to and watch and debug your code. ymmv.
Hmmm I posted a similar answer for someone recently. Google: arm verilog and at umich you will find a file isc.tgz in which is an arm10 behavioural (as in you cannot make a chip from it therefore you can find verilog on the net) model. Which for someone wanting to learn an instruction set, watching your code execute at the gate level is about as good as it gets. Be careful, like a drug, you can get addicted then have a hard time when you go back to silicon where you have relatively zero visibility into your code while it is executing. Somewhere in stackoverflow I posted the steps involved to get that arm10 model and another file or two to turn it into an arm emulator using icarus verilog. gtkwave is a good and free tool for examining the wave (vcd) files.
Above all else you will need the ARM ARM. (The ARM Architectural Reference Manual). Just google it and find it on ARM's web site. There is pseudo code for each instruction teaching you what they do. Use the thumbulator or armulator or others if you need to understand more (mame has an arm core in it too). I make no guarantees that the thumbulator is 100% debugged or accurate, I took some common programs and compared their output to silicon both arm and non-arm to debug the core.
Toolchain you can use Yagarto http://www.yagarto.de/
Emulator you can use Proteus ISIS http://www.labcenter.com/index.cfm
(There is a demo version)
and tutorials, well, google them =)
Good luck!

Resources