My Life in WordsAll about information and technology
|
我们在做GCC开发的时候,常常需要只运行指定的测试用例。只运行部分测试用例,你可以用命令“make check-gcc”、“make check-c”以及”make check-c++”等等。你还可以用RUNTESTFLAGS添加更多的参数来指定更具体的测试用例。比如:
make check-gcc RUNTESTFLAGS=“atomic.exp=c11*” 更多相关知识可以参考GCC官方文档。 https://gcc.gnu.org/wiki/Testing_GCC https://gcc.gnu.org/install/test.html https://gcc.gnu.org/onlinedocs/gccint/Makefile.html
0 Comments
When build gcc or run commands that need a long time, it's better to keep job running in background after exit the terminal. Most of the time, I will login into remote server by ssh. The command nohup can help to keep the job running in background.
nohup is a POSIX command to ignore the HUP (hangup) signal. The HUP signal is, by convention, the way a terminal warns dependent processes of logout. For example: $nohup make -j12 &>/dev/null & This will execute make -j12 even if the terminal that started this command is disconnected or closed. 在这里我将通过调试一个GCC前端的bug,介绍怎样用gdb调试GCC。 这是一个GCC bugzilla上的一个bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78987 非常明显,这是由于location定位不对而导致的diagnostic messages显示不准确。 去优化加调试信息 输出这条诊断信息的源代码如下图所示,它所在的文件是gcc/c-family/c-common.c。为了方便调试,我们可以重编译它。 If you have a fully bootstrapped build and you want to recompile only some files, you can do: $ touch $GCC_SRC_DIR/gcc/c-family/c-common.c $ cd gcc/ && make CXXFLAGS="-g3 -O0" 被调试的程序 "GCC is composed of a driver program (gcc, g++, gfortran, etc.) that calls the compiler itself (cc1, cc1plus, f951, etc.), the assembler (as) and the linker (ld or collect2). There is a compiler for each language. Most often, one wants to debug the compiler itself instead of the driver." Use gcc -v will get the exact command sequence. 在这里我们要调试的编译器是cc1。 测试用例 我们的测试用例是78987.c,用下面的命令得到确切的命令序列。 $./xgcc -B. -v ~/project/myproject/78987.c -c -Wall 制作一个gdbfile 下面就可以创建一个文件,把要要调试的文件、断点、要启动的测试用例等信息记录下来,这样当你修改了gcc代码进行调试的时候,不必每次都手动设置 ----------------------------- file ~/gcc_src/build/gcc/cc1 break c-common.c:3284 run -quiet -v -imultiarch x86_64-linux-gnu -iprefix /home/shujing/gcc_src/build/gcc/../lib/gcc/x86_64-pc-linux-gnu/7.0.1/ -isystem ./include -isystem ./include-fixed /home/shujing/project/myproject/78987.c -quiet -dumpbase 78987 .c -mtune=generic -march=x86-64 -auxbase 78987 -Wall -version -o /tmp/cc33An5m.s ------------------------------ 执行 $gdb -x gdbfile 调试 第一次停留的断点输出的诊断信息的位置是正确的,我们要调试的是第二次输出,所以继续 (gdb)c (gdb)bt 从backtrace函数调用栈,我们可以清楚的看到 location信息是由c_parser_binary_expression传递给parser_build_binary_op。所以解决这个bug就可以从分析c_parser_binary_expression开始。
参考资料 关于使用GDB调试GCC,gcc.gnu.org上有很好的官方文档 https://gcc.gnu.org/wiki/DebuggingGCC 这里也分享了很不错的经验,但是应该是针对较早版本的GCC,因为此文中采用的是 make CFLAG='-O0 -g3',而现在GCC已经采用g++编译。 http://www.cs.rochester.edu/twiki/bin/view/Main/CS255Spring09DebugCC1 sar(System Activity Reporter系统活动情况报告)是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,包括:文件的读写情况、系统调用的使用情况、磁盘I/O、CPU效率、内存使用状况、进程活动及IPC有关的活动等。下面介绍下本人如何用sar来监控高负载运行下Ubuntu 16.04系统。
安装 $sudo apt-get install sysstat 配置 编辑 /etc/default/sysstat 把 Enabled="false” 改成 Enabled="true” /etc/cron.d/sysstat 为一个定时作业的格式编写的,我们可以自己调整它的执行时间间隔。默认的设置是10分钟收集一次,可以把收集间隔改为2分钟 5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 改为 */2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 重启服务 $service sysstat restart 运行 本机正在编译gcc,看看有没有什么系统资源的使用情况. 执行命令的最后两个数字参数前一个表示interval, 后一个表示count, 2 2 表示每2秒钟采样一次,共采样两次。可以根据需要调整这两个数据。 $sar -n DEV 2 2 用来显示网络接口信息,从显示的信息看,此机的网络资源使用机会是0%。 $sar -r 2 2 可以用来查看内存的使用情况 $sar -B 2 2 可用来监控内存分页 $sar -d -p 2 2 可以用来查看磁盘设备的活动情况 $sar - u ALL 2 2 可以用来查看CPU的使用情况 $sar -P ALL 2 2可以查看每个CPU的使用情况,如果负载分配不平衡可以尝试均衡分配。 $sar -b 2 2 可以用来进行I/O和传送速率监控 $sar -q 2 2 可以进行进程队列长度和平均负载状态监控 $sar -W 2 2 可以用来查看系统交换活动信息监控 系统性能瓶颈判断
这些工具可以和vmstat、iostat结合起来进行系统性能分析和性能瓶颈判断。 Ubuntu的apt-get相当强大,下面几条比较特别:
$sudo apt-get build-dep gcc-5
$sudo apt-get update $sudo apt-get upgrade $sudo apt-get dist-upgrade $sudo update-manager $sudo do-release-upgrade -d dpkg-query也是一个常用的命令,如果你像我一样曾经在Ubuntu上找对应Red Hat上的rpm -q的命令,就知道这个是多么好用了。
|
AuthorThis is a blog that is about my works on Benchmarking Performance, Compiling Optimization, Optimize Compile, Parallel Programming, Virtualization, Container, Docker, Moby, Linuxkit, Open Source and any others. Archives
August 2018
Categories |