当前位置:Gxlcms > 数据库问题 > 《软件调试的艺术The Art of Debugging with GDB,DDD,and Eclipse》

《软件调试的艺术The Art of Debugging with GDB,DDD,and Eclipse》

时间:2021-07-01 10:21:17 帮助过:7人阅读


>每次程序访问通过调用malloc()或new创建的存储器时,都会发生堆访问,也需要读/写访问权限。
>程序执行的每个机器指令是从文本区域(或者从动态链接码的区域)取出的,因此需要具有读和执行文件。
#第7章 其它工具有两个函数使得错误代码的解释更容易:perror()和strerror()
>perror-example.c

    int main(void)    {        FILE    *fp;
        fp = fopen("/foo/bar","r");
        if (NULL == fp)            perror("I found an error");
        return 0;    }
>如果系统上没有/foo/bar,输出如下所示>>$./a.out>>I found an error: No such file or directory

__________>strerror-example.c
    int main(void)    {        close(s);        printf("%s\n",strerror(errno));        return 0;    }
>该程序的输出如下:>>$./a.out>>Bad file descriptor  

**更好地使用strace和ltrace**
strace输出程序进行的各个系统调用及其参数和返回值。
ltrace类似于strace,但它显示了库调用而不是系统调用。
**静态代码检查器:lint与其衍生**

来自为知笔记(Wiz)

《软件调试的艺术The Art of Debugging with GDB,DDD,and Eclipse》

标签:

人气教程排行