时间紧张,先记一笔,后续优化与完善。
C程序:
/* 译编:$gcc -g3 -o gs this_file.c */ #include <stdio.h> int main(void) { int x = 3; if (x < 4) printf("AAAA\n"); else printf("BBBB\n"); return 0; }
gdb脚本:
#!/bin/bash #this file name is gdb-script.sh if [ `md5sum ./gs | awk '{print $1}'` = "7db9e82087eb6a49a571d28b0426ae1e" ]; then echo "OK, file right" else echo "Bad file" exit 0 fi echo $1 gdb << GDBEOF file ./gs b 7 run shell echo "OKkkk $1" set x=$1 continue quit GDBEOF
gdb脚本还可所以:
#!/bin/bash if [ `md5sum ./gs | awk '{print $1}'` = "7db9e82087eb6a49a571d28b0426ae1e" ]; then echo "OK, file right" else echo "Bad file" exit 0 fi echo $1 gdb << GDBEOF file ./gs define setx shell echo "OKkkk $1" set x=$1 end b 7 run setx continue quit GDBEOF
运行:
$chmod +x gdb-script.sh $./gdb-script.sh 9
文章结束给大家分享下程序员的一些笑话语录: 很多所谓的牛人也不过如此,离开了你,微软还是微软,Google还是Google,苹果还是苹果,暴雪还是暴雪,而这些牛人离开了公司,自己什么都不是。