Linux C++ Debugger - c++

I'm looking for the perfect Linux C++ debugger. I don't expect success, but the search should be informative.
I am a quite capable gdb user but STL and Boost easily crush my debugging skills. It not that I can't get into the internals of a data structure, it's that it takes so long I usually find another way( "when in doubt, print it out" ).
The macro language for gdb is weird and not very adaptive. Just look at the code for the stanford gdb utils to print out stl structures.
In short I'm unhappy with what I've got.
I recently stumbled upon Zero Bugs. It looks like a silver bullet. What do the current Zero Bugs users think of it?
Has anyone found other good solutions to the Linux C++ Debugger problem?

A development branch of gdb (part of gdb's Project Archer) adds Python support to gdb (to replace gdb's macros). There's a series of blog postings starting here that extensively covers getting started with Python-enabled gdb and offers several tutorials on using Python for defining new gdb commands and pretty printing of C++ data structures.

UndoDB is amazing if you don't mind paying for it. The reversible capability is much much faster than GDB's. http://www.undo-software.com/

There are simple scripts which let you dump STL structures from GDB.
Take a look here

You can try NetBeans IDE 6.5 with gdb 6.8, it is quite powerful!
http://www.netbeans.org/downloads/index.html

ddd (data display debugger)is quite good.....it is basically a visual gdb....

I use the following environment:
http://ec-lang.org/
It is a complete development environment for the eC language.
However, you can have a project with just c or c++ files without any eC specific files and build and debug them using the IDE.
This is the closest you will ever come to a "Borland C" like experience under linux.
It can be installed on Ubuntu/Debian with the following command:
sudo apt-get install ecere-sdk

Recentg gdb (e.g. version 8.1) and g++ (e.g. GCC 7, in february 2018) are able to debug standard C++ containers thru Python scripts.

I haven't done C++ development in Linux for a while now but when I did I had good luck when KDevelop's debugger. Nothing revolutionary but it let you quickly explore object properties like you are looking for.

Try ddd.

You can use Eclipse to step through C and C++ code if you are looking for an IDE type of debugger instead of a command-line debugger. It isn't perfect, but I've found it to work well for people already familiar with IDE debugging tools.
I am also partial to Valgrind for detecting memory errors.

Related

Debugging C++ in (Neo)vim

I just switched from windows 10 to arch linux
I want to use (Neo)Vim as my code editor
I've sitted up autocomplition
and Fuzzy finder
But I have no idea how to debug in (Neo)Vim
Any helps!
For neovim there is nvim-dap which is an implementation of the debugging interface called DAP which vscode uses as well. For c/c++ check this page in nvim-dap's wiki.
Until this moment I have just used Neovim/Vim to change some small things in a code on terminal, but I think that installing the Kite plugin can help a little bit while you are coding and also, I found this answer, that has some considerations and possibilities of debuggers for Vim.
If you use gdb, you can use the in-built debugger plugin TermDebug. This works with both Vim and Neovim and is quite nice for C and C++ debugging.

Installing OCaml

I would like to start programming in OCaml. As I am a Windows user, I understand that it is preferred to do so using the OCaml plugin for Netbeans.
I have downloaded the aforementioned plugin from the following link: http://ocamlplugin.loki-a.com/ocamlplugin/updates/ . I have installed the plugin into Netbeans as instructed. I managed to open a project but even the sample "Hello World" won't run.
I then tried to install the OCaml IDE from here: http://ocamlplugin.loki-a.com/index.php?title=Main_Page#Download_2 , but it still wouldn't run anything.
I am not interested in working with Eclipse because that would include downloading Cygwin.
I would appreciate a simple solution. Thank you! :)
I would suggest OCaIDE under Eclipse, if you stick to Windows anyway.
But I don't understand your reluctancy to use cygwin, especially when there is such nice step-by-step tutorial for configuring cygwin for OcaIDE and Eclipse.
Another option, which I haven't tried but would strongly suggest you trying, is Sublime Text 2. It supports OCaml and is a very popular cross-platform text editor. But since I haven't tried it, I would not be able to provide you with details about it. Although it comes with a cost, you can evaluate it for free without time limit.
TypeRex has been my favourite for OCaml so far, and you can now use Emacs in Windows, so with some workaround in cygwin you can use TypeRex in Windows.
Another option is to use VirtualBox, install a normal linux distro and use Typerex+Emacs inside it. It is also not complicated, as it takes 1 hour to config at most.
The ocaml links that you gave have not been touched since 2009 (4 years ago). That probably means the odds of them running with the current NetBeans are equivalent to the proverbial sphere of solidified water in the Christian place of eternal theological punishment.
Since you are asking about running under Cygwin, it sounds like you want a Linux version of Eclipse as well. Eclipse runs quite well under Win7, at least, and under Mint (I use them under both) However, all my attempts to get ANY OCaml IDE running under either system have been borged (resistance is futile, and depends and capacitance anyway).
So, under Mint 15, emacs and vim (the old standards) work well as text editors. I wish I could suggest anything else.
Good luck!!!
By now, another option has appeared for Windows 10 users wanting to use OCaml: the Windows Subsystem for Linux.
Basically, what it does is that it allows you to run Bash and any non-GUI Linux program on your PC. Once installed, you can install OCaml and OPAM with apt-get and you're good to go.
As far as I am concerned, I use Windows 10 on my desktop PC, and I haven't had any inconvenience with WSL yet.
I personally use Merlin/... which is are plugins for emacs. But I can understand that you dont want to use emacs. I have been told that the support with Visual Studio Code is supposed to be quite good, especially when using it together with the builtin console. Also for smaller things there is Ocamltop but I have now idea how the Windows support is. In the end I suggest, using the Linux Shell on Windows as RichouHunter suggests.

Searching good Debugger for C++

i was wondering if there was a good debugger you can recommend for C++.
thanks for helping
Whats wrong with Visual studio unless you use linux.
ANyway my suggestion is Visual studio.
But this also depends on what sort of a c++ project you work with.
General answer: use whatever debugger comes with your IDE - something that knows about your project structure will help you immensely when navigating, setting breakpoints, inspecting variables, evaluating expressions, and possibly offering features like edit-and-continue instead of forcing a recompile. Personally, I find Visual Studio to have a pretty darn decent debugger.
If you don't use an IDE, your options are limited... especially if you want symbolic debugging. Your options will pretty much boil down to GDB (with or without frontends), or WinDBG on Windows.
i recommend emacs + gdb. best combination ever.
http://www.cs.cmu.edu/~gilpin/tutorial/
You basically have two choices :
the visual studio debugger if you're under Visual (just press F5)
GDB, and its various user interfaces (this goes from a harsh Emacs mode to QtCreator integration
For Linux you could also try Zero.
Intel has a debugger called idb which is nice and works rather well.
code blocks
Code::Blocks is a free C, C++ and Fortran IDE built to meet the most demanding needs of its users. It is designed to be very extensible and fully configurable.
Finally, an IDE with all the features you need, having a consistent look, feel and operation across platforms.
Built around a plugin framework, Code::Blocks can be extended with plugins. Any kind of functionality can be added by installing/coding a plugin. For instance, compiling and debugging functionality is already provided by plugins!
Special credits go to darmar for his great work on the FortranProject plugin, bundled since release 13.12.
We hope you enjoy using Code::Blocks!

Good C++ Debugging/IDE Environment for Linux?

I have a friend who is trying to make the switch to Linux, but is hung up on the apparent lack of debugging/IDE environments for C++, especially as they relate to template programming. He has been using visual studio for years and is maybe a little spoiled by their awesome IDE. Does anyone have any good suggestions for an environment where he can, under Linux, develop and debug with all of the usual things (Breakpoints, line highlighting for compilation errors, step in/over/out/etc, etc) that he's accustomed to? Thanks!
How about Eclipse + CDT ?
Although many people think of it as a Java IDE, he could try NetBeans. I've used it on Windows for C and C++ development without a problem, and I know NetBeans is supported on Linux, so it would be worth a shot.
It looks like most of the features he wants are included in the C/C++ development toolkit, including integration with GDB, a profiler, and more.
Visual Studio is good, indeed.
On the free side:
Qt Creator is getting quite good too, it's worth a try. There are advantageous by-products coming from the Qt framework:
huge library - not only to build GUI applications but for other domains as well
portability on multiple platforms
A version 1.3 beta is available as a preview of the upcoming release but the current 1.2.1 is already all you need to manage projects.
Eclipse has already been mentioned, it's a very good environment offering many plug-ins (Mylyn, SVN, ...).
MonoDevelop somewhat supports C++ (more and more, I didn't check the latest version).
I've used Eclipse for C/C++ and it's pretty useful. It's also used at ACM ICPC World Finals http://cm.baylor.edu/welcome.icpc
I'd recommand Code::Blocks (but use a nighty build). It can be coupled with gdb to enable step by step debugging and all that stuff.
Not exactly an IDE but SublimeText 2/3 is available on Linux now. There may be a debugger plugin for it too, who knows.
Edit
Here's a gdb plugin for SublimeText
I havn't explored it personally, but Emacs has a C++ development addon that looks very much like a full IDE.
About 7 years ago I used KDevelop that was shipped with KDE. I found it quite good back than, and I hope it also improved with the time. I found it quite comparable to VC++ 6 at this time.
It also contains Qt support, if you are in need for some GUI toolkit.
Depends, Code::Blocks is good, Eclipse is very nice too, but you will need a very good computer. In my opinion the best choice iss gcc, gdb and ViM or Gedit.
My buddies from work use Eclipse + Scons, they also use Valgrind(spelling?) for tracking memory leaks and such.
Many of the IDE features you listed were debugger features. The ddd (Data Display Debugger) debugger is quite a nice GUI wrapper for gdb, allowing graphical representation of data structures, a non-crappy source listing window (ie. unlike the l command of gdb where you don't get context), and also allows you to use any and all native gdb commands directly if desired.
Have a look at CodeLite. It's available for Ubuntu and Fedora out of the box and even for Windows and Mac. So you can have the same IDE on different platforms.
We tried Eclipse and NetBeans but left them due to their huge CPU and memory usage. We have a development server and all the developers connect to it via RDC. Thats why these IDEs miserably failed in our model.
So, we looked for some native IDE. Found CodeBlocks to be very good and super fast. We sort of settled on it but later found CodeLite and liked it better than CodeBlocks.
I just seeing this question after 12+ years. AnyHow I just writing my answer. I personally use Quincy IDE for C and C++ development. it is very lite weight and debugging watch list is very much good and easy to use. I'm just attaching the link to the site. try it.
But you have to install it with wine.
Quincy <-- Click here

What tools do you use to develop C++ applications on Linux? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I develop C++ applications in a Linux environment. The tools I use every day include Eclipse with the CDT plugin, gdb and valgrind.
What tools do other people use? Is there anything out there for Linux that rivals the slickness of Microsoft Visual Studio?
I use a bunch of terminal windows. I have vim running on interesting source files, make and g++ output on another for compiler errors or a gdb session for runtime errors. If I need help finding definitions I run cscope and use vim's cscope support to jump around.
Eclipse CDT is my second choice. It's nice but huge, ungainly and slow compared to vim.
Using terminal windows and vim is very flexible because I do not need to carry 400 MB of Java around with me I can use SSH sessions from anywhere.
I use valgrind when I need to find a memory issue.
I use strace to watch what my software is doing on a system call level. This lets me clean up really stupid code that calls time(0) four times in a row or makes too many calls to poll() or non-blocking read() or things like calling read() on a socket to read 1 byte at a time. (That is super inefficient and lazy!)
I use objdump -d to inspect the machine code, especially for performance sensitive inner loops. That is how I find things like the slowness of the array index operator on strings compared to using iterators.
I use oprofile to try to find hot spots in optimized code, I find that it often works a little better than gprof, and it can do things like look for data and instruction cache misses. That can show you where to drop some helpful prefetch hints using GCC's __builtin_prefetch. I tried to use it to find hot mis-predicted branches as well, but couldn't get that to work for me.
Update: I've found that perf works way better than oprofile. At least on Linux. Learn to use perf and love it as I do.
g++ of course, but also Code::Blocks which is an absolutely fantastic cross platform IDE (Win32, *nix, Mac).
I use the nightly (more like weekly lately) builds from the SVN. It has almost all the bells and whistles you would expect from a modern IDE. It's really a truly fantastic Open Source project.
Also, on Linux you get the joy of using Valgrind which is probably the best memory tracker (it does other things as well) tool that money can buy. And it's free :) Track down memory leaks and more with ease.
And there is just so much more! Linux is such a great dev platform :)
(edit) Just realized you mentioned Valgrind in your question, silly me for reading it too fast.
When develop C++ apps for linux, i prefer using a bunch of cmdline tools.
Vim extended with a lot of plugins.
Gdb with ddd, valgrind, libefence
and SCons (automake is a pain in ... you know where)
g++
emacs
bash command line
gdb-mode in emacs (type M-X gdb)
make
emacs, cmake, gdb, git, valgrind. It may not be as slick as Visual Studio but it works well, and it's easy to add functionality via bash scripting or emacs lisp.
Right now I use Qt Creator. It's cross-platform and integrates pretty nicely with Qt, though (of course) you have the option of creating a standalone application.
g++ and make
I believe KDevelop is what would be the closest from Microsoft Visual Studio.
You get pretty much everything (except unfortunately VS debugger which is indeed a killer).
Its already mature and its development is pretty fast and promising.
It actually implement a few stuff you won't even see in VS. For instance, open header file and cpp file in vertical tile mode, and have the cursor synchronized in both,
ie: when you select a functions prototype, you always have its implementation on your right.
KDevelop is a KDE project, but run on Gnome. Anjuta is an equivalent project on Gnome, but I find it unusable for real work. For the rest of the stack gcc make valgrind ddd (a gdb IDE) and python for scripting my code.
If you're ok to try a different approach than the VS IDE. You may consider trying vim. It takes a long time to get used to it though.
Eclipse CDT is really quite nice. I still have to resort to Emacs from time to time but I really love the indexing, call trees, type trees, refactoring support (thought it's nothing like Java refactoring), etc. Syntax highlighting is quite powerful if you customize it (can have separate colors for local variables, function arguments, methods, etc.). The code completion is really handy too. I've mostly used Eclipse 3.3 but 3.4 is great too.
Also, mostly I'm using this for a somewhat large project (~1e6 sloc) -- it may be overkill for toy projects.
When I developed C++ code on linux, I used emacs as an editor and as a gdb front-end. Later, my company purchased SlickEdit for all of the programmers, which is a nice IDE, maybe not on a par with Visual Studio. We used gdb extensively, with the occasional use of valgrind and gprof. I highly recommend using a scripting language to complement C++ on day-to-day tasks. I went from PERL to python to the current ruby. All of them get the job done and have strengths where C++ has weaknesses. And, of course, you have all the shell commands at your disposal. I daily use sort(), uniq(), awk, etc. And one more recommendation is ack, a grep successor.
You need a standard toolchain + an IDE.
There's nothing much to say about the standard toolchain. Just install e.g. on Ubuntu/Debian via
aptitude install build-essential
The interesting part is about an IDE.
My personal impression is that nowadays - in the 21th century - vi/emacs/make/autotools/configure is not enough for developing software projects above a certain size (... and yes, please please please blame me for the heritage heresy ...).
Which IDE to choose is simply a matter of taste. You will find a lot of threads on SOF. Here is a permalink discussing which C++ IDE might be the "best": C++ IDE for Linux.
I use the NetBeans C++ plugin, which is superb and integrates with CVS and SVN. The project management side is also very good. I was up and running with it in minutes. It's an impressive IDE but being Java, can be a little sluggish.
GCC
GHC
Vim
Cmake
cscope
GDB
Valgrind
strace
git
Is there really anything else you could possibly need?
Bash
Vim
Make
G++
GDB
Valgrind
Gprof
svn
Never a GUI to be seen except a good terminal with tab support; keep code, debugger, output, etc all in separate windows and tab back and forwards really quickly.
In addition to many already listed, we use the autoconf toolset for deploying our program to users.
CMake
vim
g++
kdevelop (compiled from SVN daily!)
Mercurial when I can, SVN when I have to, git when there's really no other choice (contributing to project that uses it)
valgrind
Anjuta is a nice idea that makes Linux C++ dev quite enjoyable as well.
I'm another for KDevelop. It has a very diverse set of tools. I'm not real familiar with VS and whether or not it has integrated console access via its interface, but KDevelop can allow you to run a konsole inside the IDE, which I always find very useful. You could always give Netbeans a go now that it has full C/C++ support.
Other than that, I make good use of gdb and its gui-based version ddd for problems with the code or other bugs. For throw-away programs, like others that already posted - I use g++ at the terminal and make for some larger projects.
Eclipse CDT for editing, SVN for source control, SCons for build management, CruiseControl for automated builds and a proprietary unit test framework.
I use Eclipse+CDT on Windows and Cygwin + g++ to cross compile for Linux.
(Cross compilers are built using crosstool, a nice script-set for generating cross compilers)
Mi first choice is allways emacs with a lot of plugins: ecb gives some buffers to navigate on the folders, gdb, svn or git integration... This is mi first choice using Python too.
As a second choice, Netbeans with C++ plugin, is very simple and quite powerfull, but too heavy I think.
I use whatever is on the system. I prefer Eclipse CDT as an editor, and g++ as a compiler. However, if eclipse is not an option I use vi, which is fine as well.
The Eclipse incubation project Linux Tools integrates C/C++ Development tools.
It's a GUI plugin to integrate tools like Valgrind, GProf, GCov, SystemTap etc into the Eclipse C++ CDT IDE.
Search for Eclipse Helios IDE for C/C++ Linux Developers (includes Incubating components), (120 MB)
Found this after trying to build Linux Tools using the .psf file available.
Thankfully found this package hiding right at the bottom of the Helios packages download page.
Note that this is an incubation project so you can expect the support to only get better with time.
See Also:
For updated info on installing and using Eclipse Linux Tools Click Here
FlexeLint for static code analysis, in addition to mentioned above:
Eclipse with CDT, gcc, make, gdb, valgrind, bash shell.
Source version control: Clearcase or git, depending on project.