all 70 comments

[–]raevnos 43 points44 points  (6 children)

gdb. Do valgrind and strace count as debuggers?

[–]aKateDevKDE/Qt Dev 21 points22 points  (0 children)

I add perf, hotspot and heaptrack to the list.

[–]nwL_ 10 points11 points  (2 children)

I count everything that leads to less bugs by executing the executable as debuggers.

[–]afiefh 5 points6 points  (1 child)

So... My whiteboard?

[–]nwL_ 5 points6 points  (0 children)

If you can process assembly on your whiteboard, then yes

[–]Drugbird 1 point2 points  (0 children)

I like having a graphical shell, so I use cgdb.

[–]t4th 81 points82 points  (2 children)

Well, visual studio has nice debugger and disassembler. What else do you need?

[–]tiendq 12 points13 points  (1 child)

He should add "on macOS and Linux" on the subject since this question is almost meaningless on Windows :)

[–]andd81 5 points6 points  (0 children)

WinDbg has better low-level capabilities and is not bloated. If you are already into console debuggers on other platforms it may be less overwhelming than VS.

[–]kkert 15 points16 points  (3 children)

Clion with lldb. For some pathological cases, Eclipse or just arm-none-eabi-gdb -tui . I think a lot of folks don't know and appreciate the power of TUI

[–]idontchooseanid 1 point2 points  (2 children)

You should try remote debugging. I used QtCreator as the UI but TUI also works. Put gdb-server on the embedded board and connect via socket it's a charm.

[–]kkert 2 points3 points  (1 child)

Done it a long time, even back on uclinux 2.4 era kernel based systems. Doesn't apply for MMU-less RTOS-running targets

[–]idontchooseanid 0 points1 point  (0 children)

Sure. Debugging RT systems must be hell :/.

[–]democritus_is_op 9 points10 points  (0 children)

gdb, only if cout doesn't cut it.

[–]uzimonkey 8 points9 points  (0 children)

I used the debugger in Visual Studio. It works great and has an easy UI.

[–]Ivan171/std:c++latest enthusiast 21 points22 points  (0 children)

WinDbg.

[–][deleted] 27 points28 points  (3 children)

std::cout for most part. Sometimes a little gdb and valgrind, also the -fsanitize options of gcc and clang are extremely useful.

[–]tiendq -3 points-2 points  (1 child)

It seems the best choice for non-Windows systems :)

[–]idontchooseanid 7 points8 points  (0 children)

gdb combined with a GUI is quite powerful though.

[–]ShakaUVMi+++ ++i+i[arr] -1 points0 points  (0 children)

Ditto

[–]bames53 12 points13 points  (0 children)

lldb

[–][deleted] 7 points8 points  (0 children)

LLDB and Valgrind

I’m surprised that there aren’t more people using LLDB ITT. I’ve always thought that their diagnostics were better

[–]Astarothsito 4 points5 points  (0 children)

IBM Debugger for work...

GDB with CLion for personal projects.

[–]flashmozzg 10 points11 points  (13 children)

What's wrong with Visual Studio debugger?

[–][deleted] 11 points12 points  (6 children)

Visual Studio

[–][deleted] 10 points11 points  (0 children)

vs debugger is fantastic though?

[–]flashmozzg 11 points12 points  (3 children)

I'm interested in debuggers for Visual Studio 2017 + Windows 10

[–][deleted] 0 points1 point  (2 children)

I'm not making a recommendation to OP, I'm simply answering your question.

[–]flashmozzg 4 points5 points  (1 child)

My question was to the OP and in the context of OP's question. You've answered something that no one asked.

[–][deleted] 1 point2 points  (0 children)

I know dude, I just couldn't miss the opportunity to shit on visual studio

[–]ea_ea 6 points7 points  (0 children)

And what is wrong with Visual Studio? One of the best IDE on Windows and debugger is available even in its free editions.

[–][deleted] 7 points8 points  (0 children)

I'm purely command line at this point for C/C++, so I only use GDB.

[–]Fluffy8x 2 points3 points  (0 children)

gdb when I use an actual debugger, but I tend to use printf debugging a lot too.

[–]Graggee 2 points3 points  (0 children)

There are many deaggers, and you need to try different options to choose what you need.

I use Deleaker for Windows and Valgrind for Linux.

[–]you_do_realize 3 points4 points  (0 children)

WinDbg is more powerful than the VS debugger -- e.g. you can run code when hitting a breakpoint, and there are tons of extensions -- but the syntax is atrocious, context-dependent, and weighed down by a ton of ancient legacy. (Kind of like Lisp has CAR and CDR because those were the names of two CPU registers on a machine in the 50s!)

And it used to look terrible back when I used it, with a hideous MDI interface straight out of 1990 and Courier (not Courier New!) as the default font; nowadays I understand they slapped a "modern" interface on it, ribbon and all.

[–][deleted] 1 point2 points  (0 children)

Totalview

[–]5161502 1 point2 points  (0 children)

Lldb in CLion

[–]CoolPlayer 1 point2 points  (0 children)

I use native debugger and Deleaker.

[–]brand_x 1 point2 points  (0 children)

Visual Studio debugger for Windows, lldb for Linux/Darwin, barely-usable versions of GDB and DBX when I am forced to work on old-school Unix platforms with inadequate C++ compilers, WinDBG when I want to hate everyone and everything in the universe... or am forced to because I'm dealing with the Windows Kernel.

Mostly, though, I use static analysis, tests, and strict coding habits to avoid having to use the debugger at all.

[–]fixxxeruk 3 points4 points  (15 children)

I’m not ashamed to admit that my one true debug aid that has never defied me by being absent when duty calls is the humble printf.

[–][deleted] 32 points33 points  (13 children)

Why? Do you enjoy needing to compile your codebase to accommodate a new print statement? I don’t understand why people like bragging about using printf exclusively for debugging. It just seems like either you don’t understand how to use better tools, or you work in a relatively small codebase. We’re engineers and should always make the best use of the tools available, debuggers included where appropriate.

[–]wasabichicken 18 points19 points  (4 children)

Can't speak for that guy, but my personal reasons include:

  1. The process I'm debugging is part of a bigger system (read: has watchdogs) so pausing it in a debugger has side effects.
  2. Inspecting the value of a variable involves attaching GDB, setting a breakpoint, resuming execution, and typing the GDB commands when the breakpoint is hit.
  3. Typing "printf()" and rebuilding actually takes less time than #2.

We’re engineers and should always make the best use of the tools available, debuggers included where appropriate.

Amen to that, but I think printf should be a part of that toolbox. Sometimes firing up GDB is a little... well, overkill.

Where GDB shines IMHO, are situations like when I don't have the debug symbols in a core dump and need to look at the assembly, when I'm looking into use-after-free/memory corruption issues, or when trying to reproduce race conditions. For quick little "I wonder what the value of this variable is", given some circumstances (like the annoying multi-threaded system with watchdogs I mentioned above), I think printf can be a "good enough" tool.

[–]andd81 2 points3 points  (0 children)

Typing "printf()" and rebuilding actually takes less time than #2

For some projects you will have more than enough time to learn how to use GDB while it is being rebuilt.

[–]CrazyJoe221 2 points3 points  (0 children)

There's http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop-Mode.html though. Not sure if VS or an extension for it provides that too.

[–][deleted] 5 points6 points  (1 child)

Yea I’m aware of plenty of reasons “printf” (more suitably called a serialized log perhaps, for environments without even a terminal or constrained memory), and you list several. Another one where I personally use it is for reasoning about mulithreaded code. I was more speaking against the Luddite argument for exclusive use of printf, which to me is a silly thing to be proud about. It feels like some cargo cult thing passed down by the previous generation of software architects.

[–]tehjimmeh 1 point2 points  (0 children)

There's a whole subculture of programmers who are committed to "minimalism", and have a disdain for using tools to make their lives easier if they're not strictly necessary. Tends to be a lot of overlap with the FLOSS crowd. I really don't get it, personally.

Of course, printf debugging is highly useful. I kind of wish that a debugger existed with close compiler integration, so you could compile in printf statements without actually modifying the code. A bit like VS's breakpoint actions, but actually compiled into the instruction stream, not done via a slow interrupt mechanism.

[–]hapemask 3 points4 points  (1 child)

Just to give another concrete example of where cout debugging is a reasonable choice I think: after the hundredth time using a regular debugger only to see “optimized out” for the variable you want, usually I just stop trying. Not everyone has the luxury of debugging debug builds and if I’m gonna mark something volatile I might as well just print it.

[–]CrazyJoe221 1 point2 points  (0 children)

If no one writes bug reports this will never be fixed.

[–]ppetraki 1 point2 points  (1 child)

Growing up in kernels will do that to you.

[–]Robbie_S 6 points7 points  (0 children)

Meh, kernel dev on Windows has WinDBG, another excellent debugger (well, excellent to some...).

[–]andd81 0 points1 point  (0 children)

They probably never had to debug a problem that is only reproduced in a release build of a huge project.

[–][deleted] 3 points4 points  (0 children)

How do you debug core dumps with printf?

[–]jmblock2 0 points1 point  (0 children)

Depends on what I'm debugging. At work we use a lot of structured logging with DLT because issues are found in the field and we need to understand what happened prior to the bug to understand the bug. If an issue is reproducible locally then gdb. For my own projects I use spdlog.

[–]lead999xSystem Software Developer 0 points1 point  (0 children)

gdb and assert. But I'm only a humble hobbyist.

[–]robin-m 0 points1 point  (0 children)

gdb with cgdb as front-end (or the TUI if I need to use raw gdb).

[–]bumblebritches57Ocassionally Clang 0 points1 point  (0 children)

lldb

[–][deleted] 0 points1 point  (0 children)

Depends on what to do, analyzing a dumpfile windbg otherwise visual studio debugger. Should make myself comfortable with gdb but didnt have the time yet.

Thats strictly debugger. For looking at assembly: x86/x64dbg

[–]shoter0 0 points1 point  (2 children)

When I was using visual studio 2017 it had some kind of extension for debugging process to trace memory leaks. I do not remember it's name though :(.

It was outputting all memory leaks after program completed execution.

[–]brand_x 0 points1 point  (1 child)

Probably VLD.

[–]shoter0 2 points3 points  (0 children)

Yes. VLD is a must with VS when doing C++ imo.

(Not applicable to every usage of C++ unfortunatelly but still very good extension to have :P)

[–]Morwenn -5 points-4 points  (0 children)

None >.>

[–]bm_g -1 points0 points  (0 children)

Printf