如何学习C调试和最佳实践 [英] How to Learn C Debugging and Best Practices

查看:209
本文介绍了如何学习C调试和最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写在C Apache模块在某些情况下,我可以得到它的段错误,但我不知道,为什么。在这一点上,它可能是我的code,也可能是我在编译程序的方式,也可能是在操作系统库中的缺陷(在通话过程中的段错误发生在执行dlopen())。

I've written an Apache module in C. Under certain conditions, I can get it to segfault, but I have no idea as to why. At this point, it could be my code, it could be the way I'm compiling the program, or it could be a bug in the OS library (the segfault happens during a call to dlopen()).

我试图通过GDB和Valgrind的没有成功运行。 GDB给了我一个回溯到出现无意义的dlopen()系统调用。在Valgrind的,错误实际上似乎消失或至少成为不可重现。在另一方面,我是一个新手总当谈到这些工具。

I've tried running through GDB and Valgrind with no success. GDB gives me a backtrace into the dlopen() system call that appears meaningless. In Valgrind, the bug actually seems to disappear or at least become non-reproducible. On the other hand, I'm a total novice when it comes to these tools.

我有点新的生产质量C编程(我很多年前就开始对C,但从来没有与它的专业的工作。)什么是我去学习程序调试的绳索的最好方法?还有什么其他的工具,我应该调查?总之,你是怎么想出如何应对新的挑战的bug?

I'm a little new to production quality C programming (I started on C many years ago, but have never worked professionally with it.) What is the best way for me to go about learning the ropes of debugging programs? What other tools should I be investigating? In summary, how do you figure out how to tackle new bug challenges?

编辑:
只是为了澄清,我要感谢Sydius的和dmckee的输入。我已经采取了看看Apache的指南,是相当熟悉的dlopen(和对dlsym和dlclose)。我的模块工作在大多数情况下(这是在3K左右code的线条和,只要我不激活这一节中,事情似乎工作得很好。)

Just to clarify, I want to thank Sydius's and dmckee's input. I had taken a look at Apache's guide and am fairly familiar with dlopen (and dlsym and dlclose). My module works for the most part (it's at about 3k lines of code and, as long as I don't activate this one section, things seem to work just fine.)

我想这就是我原来的问题来自 - 我不知道下一步该怎么做。我知道我没有使用GDB和Valgrind的,以充分发挥其潜力。我知道,我可能不准确的右旗进行编译。但我有麻烦找出更多。我能找到的告诉我,比我更需要知道,但没有指导初学者的指南,告诉我,我已经知道了,和手册页。

I guess this is where my original question comes from - I don't know what to do next. I know I haven't used GDB and Valgrind to their full potential. I know that I may not be compiling with the exact right flags. But I'm having trouble figuring out more. I can find beginner's guides that tell me what I already know, and man pages that tell me more than I need to know but with no guidance.

推荐答案

这链接可以帮助:阿帕奇调试指南与您的特定问题。具体问题的经验是在一般情况下,以获得更好的最佳途径之一。

This link may help: Apache Debugging Guide with your specific problem. Experience with specific problems is one of the best ways to get better in the general case.

这篇关于如何学习C调试和最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆