开发者

Do I need to know assembly to debug programs written in C?

I a开发者_StackOverflow中文版m learning C with "The C Programming Language", 2nd edition, and also doing each exercise.

Do I need to know assembly in order to debug C programs that I wrote as solutions to the books exercises?

Also, which debugger do you recommend?


You do not need to know assembly to program in C, including debugging. However, if you know assembly, C begins to make a lot of sense; it really helps to have some notions of assembly (preferably, some notions on several distinct architectures, such as x86 and ARM), and not only for debugging.


It is not required but sometimes is extremely helpful. If you're using MSVC++, just use the one in the IDE, it can show disassembly too.


No, you don't need to know assembly in order to learn C.

As far as debuggers go, perhaps the easiest choice is to use the debugger that's built into the IDE that you're using. On Windows, Microsoft Visual Studio is popular (there's a free version). Eclipse is another popular choice that's available on a number of platforms.

There are also command-line debuggers, such as gdb, but they'll be harder to get started with than a GUI-based one.


In order to debug step by step, it might be helpful, but not necessary, to know assembly. It also depends on the debugger if it is really necessary.

But there are other ways to debug a program, e.g. put printf() calls at strategic places.


No, asm is not required but helpful, like others have said, use a debugger... What others have not said, is that you could even use GDB, but be sure you disable compiler optimisations or debugging might be hard.


When you compile with the GCC -g2 or -g3 flag you can debug you program with GDB. Here you can find a short tutorial howto use GDB http://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html and here you can find a somewhat more extensive tutorial http://www.delorie.com/gnu/docs/gdb/gdb_toc.html


You don't need to learn assembly if you are going to debug your own programs. Compilers can embed source code information into the executable (-g flag with GCC) or into a side file (/Z family of flags with MSVC).

Getting started with a debugger is not hard (even if you use a command line one), and there are plenty of resources everywhere on the internet. It is the investment which will give you the most return.

Nevertheless, having some grasp of the assembly language can prove useful at times. Looking at the assembly generated by the compiler is sometimes (rarely) needed when you want to check how some optimizations are done. But this is something you shouldn't worry about unless you have a very specific job.


No, you don't. Microsoft Visual Studio has a nice debugger. Other options are Code::Blocks or Eclipse.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜