views:

300

answers:

8

Do I absolutely have to learn assembly language to be able to use the debugger optimally? I noticed that during debugging sessions, I see these cryptic codes and CPU registers... (eax... blah blah). I shall assume that that's assembly and I am supposed to somehow decipher the cause of the problem from it.

Is there some shortcut to understanding the debugger without having to learn assembly language?

PS: I saw an book on assembly that was almost 1000 pages and I don't have the stomach to go through it. Please help.
Edited:*I am using codeBlocks ide. But i guess the question still stands even for MSVC++*

+5  A: 

Sounds like control has hopped into a library whose source you don't have or that wasn't built with debug info.

Being at least familiar with your machine's architecture and assembly language can help, but it's not strictly necessary to using a debugger well.

Greg Bacon
A: 

You don't need to understand assembler to do effective debugging. The only time you really need to worry about the assembly code is when you are having optimization issues, but even then you better off dealing with the high level code than to try and code a more efficient assembler routine.

ennuikiller
A: 

What is your platform? VS2010 will improve debugging experience greatly.

Hamish Grubijan
You suggest beta software for debugging? Duh...
Kornel Kisielewicz
First, *how* will it improve the debugging experience, and second, how does this relate to his actual question? VS2008 is perfectly able to allow you to debug C++ code, so while 2010 might be better in other ways, the specific problem that the OP is asking about was solved long before 2010.
jalf
Well, I use C++, C++ CLI, and C# together and my current debugging experience sucks. I am looking forward to VS2010 when it is out of Beta.
Hamish Grubijan
+11  A: 

Although some asm knowledge might come very handy sometimes during debugging, a more valuable thing to do probably in your case is to get debugging symbols right.

In case of gcc pass it a -g flag. In case of Visual Studio compiler, enable debugging symbols generation (yes, even for release builds) in project settings. If you're using other compiler read its documentation on the subject.

And last, but not least, if you're on Windows, consider downloading debugging symbols for their binaries, as it might make your life a lot easier. Find those here: microsoft site

Dmitry
+1  A: 

Visual Studio on Windows or Data Display Debugger on Unix will do a very decent job provided you compile with debug symbols, and let you step through your C++ code without knowledge of assembler. Being familiar with the machine architecture at hand, basic understanding of the asm syntax, and how C++ constucts map to that will get you even further.

Nikolai N Fetissov
A: 

C++ doesn't require applications to store metadata to aid debugging. And if such metadata can not be found, then the debugger doesn't have much to work with. All it sees is the machine code that is being executed, so it has to fall back to showing you the plain assembly code.

However, compilers are generally able to build debug information that the debugger can use. These basically tells the compiler what the source code looks like (or where to find the source files), and which instructions match which lines of source code, allowing you to debug the actual C++ code you wrote.

You didn't specify which compiler or debugger you use, so I can't tell you how to use this in your specific case.

On GCC, you have to compile with -g as far as I can recall, in order to generate debug info for GDB to use.

In Visual Studio it should just work in most cases (although I believe if you start an "Empty C++ project", you have to enable debug information yourself, in project properties)

jalf
+2  A: 

Yes. In order to optimally debug, you have to understand assembly, which is nothing more than the language the processor speaks.

It is not scary. Programming languages do not get simpler than assembly.

Paul Nathan
Programming languages do get a lot simpler than assembly, and a lot more readable. They don't get more basic is all.
David Thornley
David: I guess I find assembly really simple: all the semantics are explicit and written out in the manual. No hidden VM under-the-hoodness, no compiler rewrites. Seems simple enough to me.
Paul Nathan
+2  A: 

You don't have to be an expert in assembly, but I would say that understanding assembly code is important for debugging. Find some "just enough assembly to get by" tutorial, such as this one.

Nemanja Trifunovic