linux下gcc编译与gdb调试

    xiaoxiao2022-07-07  180

    简单代码如下:

    main.c

    #include <stdio.h> void debug(char *str) { printf("debug info :%s\n", str); } main(int argc, char *argv[]) { int i, j; j = 0; for (i = 0; i < 10; i++) { j += 5; debug("1"); } }

    gcc编译:

    gcc的基本用法 gcc  [options]  [filenames]

    详解见

    1.https://www.jianshu.com/p/a29d0e0da31e

    2.https://www.cnblogs.com/ibyte/p/5828445.html

    3.https://blog.csdn.net/czg13548930186/article/details/78331692

    在这里要程生成可执行文件:

    gcc -g -o main main.c

    gdb调试(参考博文https://www.cnblogs.com/HKUI/p/8955443.html)

    GDB调试 启动程序准备调试GDB yourpram 或者 先输入GDB 然后输入 file yourpram

    本文见:

    gdb main

     命令行输出为

    具体使用见https://www.cnblogs.com/HKUI/p/8955443.html

    参考:

    1.https://wizardforcel.gitbooks.io/100-gdb-tips/print-STL-container.html(重点)

    2.https://www.yanbinghu.com/2019/04/20/41283.html

    最新回复(0)