![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
gcc&gdb&make
文章平均质量分 54
duyiwuer2009
这个作者很懒,什么都没留下…
展开
-
GNU C Compiler Internals/GNU C Compiler Architecture(GNU C编译器内部结构/架构)
tag: cc1, cpp, as, ld, collect2http://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Architecturehttp://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Archi原创 2012-01-19 20:03:51 · 915 阅读 · 0 评论 -
64位和32位平台下C/C++结构内存对齐
1. 在 64 位 Linux 下,结构体字段默认按 8 字节对齐;32 位 Linux 下,默认 4 字节对齐。2. 显示指定对齐方式时,会受到机器字长的约束,即 64 位 Linux 下可以按 8 字节及以下的任意字节对齐,32 位只能按 4 字节及以下任意字节对齐。#include #pragma pack(4)struct Test{ char c; long long原创 2016-03-07 11:26:55 · 6092 阅读 · 0 评论 -
gdb 一步一步调试程序
例子:#include #include #include int main (int argc, char *argv[]){ time_t time_stamp; struct tm info; info.tm_year = atoi(argv[1]) - 1900; info.tm_mon = 1 - 1; info.tm_mday =原创 2015-01-23 11:41:51 · 4779 阅读 · 0 评论 -
常见 core dump 原因分析signal 11 - SIGSEGV
signal 6 - SIGABRTfree 多次char *p = malloc(100);free(p);free(p);fclose 多次// fclose 内部调用 freeFILE *fp = fopen("test.txt", "wb+");printf("%p\n", fp);fclose(fp);printf("%p\n", fp);fc原创 2015-07-09 15:09:50 · 91173 阅读 · 2 评论 -
gcc 编译阶段
【编译阶段】预处理 --> 编译成汇编代码 --> 编译成机器码 --> 链接gcc -E: 预处理完之后停止gcc -S: 生成汇编代码之后停止gcc -c: 生成 .o 机器码之后停止cpp: The C Preprocessor. IN: .c, OUT: .i or othersas: The assembler. IN: .S, OUT: .o原创 2015-01-15 11:35:09 · 574 阅读 · 0 评论 -
Linux core dump
core file 的目录$ cat /proc/sys/kernel/core_pattern/data/corefile/core_%e_%t$ cat /proc/sys/kernel/core_uses_pid1%e, %t 的含义查看 man coreIf the /proc/sys/kernel/core_uses_pid file contains the val原创 2014-12-29 14:49:35 · 659 阅读 · 0 评论 -
防止全局变量、头文件重复包含与 extern 的使用
C语言中经常会出现文件重复包含而导致全局变量重复定义,下面以一个例子说明-----MakefileCC = gccOBJS = main.o errhandle.o strcopy.oCFLAGS = -Wall -std=c99main: ${OBJS} # or $(OBJS), ${OBJS} is shell style ${CC} ${CFLAGS} -o $@ ${原创 2012-08-17 21:25:57 · 2909 阅读 · 0 评论 -
GDB 调试段错误
原文:http://www.unknownroad.com/rtfm/gdbtut/gdbsegfault.htmlWe are going to use gdb to figure out why the following program causes a segmentation fault. The program is meant to read in a line of t转载 2013-11-28 20:27:36 · 1115 阅读 · 0 评论 -
使用 dmesg 和 addr2line 分析程序 core 原因
今天遇到这样一种情况:发现进程 tagent 在发送响应时退出了,退出原因未知,因为没有 core 文件,无从分析。core 文件生成目录和 ulimit 都没有任何问题,就是不生成 core 文件:$ cat /proc/sys/kernel/core_patterncore.%p_%e$ ulimit -cunlimited写了个小程序也能生成 core, 没有 core 文件,只能另觅他径原创 2016-04-13 17:49:55 · 4002 阅读 · 1 评论