范文健康探索娱乐情感热点
投稿投诉
热点动态
科技财经
情感日志
励志美文
娱乐时尚
游戏搞笑
探索旅游
历史星座
健康养生
美丽育儿
范文作文
教案论文
国学影视

程序core了,看到的还是问号

  一 背景
  C程序发布的时候,经常去掉-g编译选项的,那么这就遇到一个问题,当程序运行core dump后,想去调试查看core的具体信息,会发现很多符号都被优化掉了,看到的栈信息要么是问号,要么变量无法打印值; 去掉符号表,却可以让程序体积更小,而且不容易泄漏程序的信息,更安全些。
  这就产生了矛盾,我们在运行的时候不需要符号表,调试的时候需要符合表,那我们能否把符号表在发布程序的时候删除,调试的时候加载符号表信息那,这样就满足了需要。 二 测试程序2.1 测试源码
  为了直观起见,先写个简单的c代码用于演示,代码如下:   1 #include    2    3 int func()   4 {   5     int a = 5;   6     int b = a*5+8;   7     int * pi = NULL;   8     *pi = 0;   9     printf("In func a is:%d b is:%d",a,b);  10 }  11   12 int main()  13 {  14     int a = func();  15     printf("%d ", a);  16 }  2.2 编译
  编译下: miao@ubuntu-lab:~/c-test$ gcc -o test testdebug.c
  gdb调试看看: root@ubuntu-lab:/home/miao/c-test# gdb ./test -q Reading symbols from ./test... (No debugging symbols found in ./test) (gdb) quit
  可以看到显示没有调试符号表信息,我们重新用-g编译选项试试: root@ubuntu-lab:/home/miao/c-test# gcc -o test-debug -g ./testdebug.c  root@ubuntu-lab:/home/miao/c-test# ls test  test-debug  testdebug.c root@ubuntu-lab:/home/miao/c-test# gdb ./test-debug -q Reading symbols from ./test-debug... (gdb)
  其实也不是完全没有符号,也还是有不少的,只是没有调试信息,可以用命令查看: root@ubuntu-lab:/home/miao/c-test# readelf -h ./test|grep "string table index"   Section header string table index: 30 root@ubuntu-lab:/home/miao/c-test#  root@ubuntu-lab:/home/miao/c-test# readelf -h ./test-debug|grep "string table index"   Section header string table index: 36
  两个符号表的大小是有差距的差距6个,这个表示符号表的index的个数。 查下段表更清晰: root@ubuntu-lab:/home/miao/c-test# readelf -S ./test-debug|grep ".debug"   [28] .debug_aranges    PROGBITS         0000000000000000  00003035   [29] .debug_info       PROGBITS         0000000000000000  00003065   [30] .debug_abbrev     PROGBITS         0000000000000000  00003159   [31] .debug_line       PROGBITS         0000000000000000  000031fd   [32] .debug_str        PROGBITS         0000000000000000  0000326e   [33] .debug_line_str   PROGBITS         0000000000000000  00003353 root@ubuntu-lab:/home/miao/c-test#  root@ubuntu-lab:/home/miao/c-test#  root@ubuntu-lab:/home/miao/c-test#  root@ubuntu-lab:/home/miao/c-test# readelf -S ./test|grep ".debug" root@ubuntu-lab:/home/miao/c-test#  2.3 删除符号表
  编译的时候可以采用-g编译,然后发布的时候去掉符号表,可以使用命令:strip。 如下最简单的处理下: root@ubuntu-lab:/home/miao/c-test# ll -al ./test* -rwxrwxr-x 1 miao miao 15984 Apr 30 10:41 ./test* -rwxr-xr-x 1 root root 17304 Apr 30 10:48 ./test-debug* -rw-rw-r-- 1 miao miao   171 Apr 30 10:41 ./testdebug.c root@ubuntu-lab:/home/miao/c-test# strip ./test-debug root@ubuntu-lab:/home/miao/c-test# ll -al total 44 drwxrwxr-x  2 miao miao  4096 Apr 30 11:19 ./ drwxr-x--- 16 miao miao  4096 Apr 30 10:41 ../ -rwxrwxr-x  1 miao miao 15984 Apr 30 10:41 test* -rwxr-xr-x  1 root root 14464 Apr 30 11:19 test-debug* -rw-rw-r--  1 miao miao   171 Apr 30 10:41 testdebug.c root@ubuntu-lab:/home/miao/c-test# nm -s test-debug nm: test-debug: no symbols root@ubuntu-lab:/home/miao/c-test# nm -s test 000000000000038c r __abi_tag 0000000000004010 B __bss_start 0000000000004010 b completed.0                  w __cxa_finalize@GLIBC_2.2.5 ...
  可以看到strip处理过的testdebug,比不用-g 选项的编译出来的test文件更小,通过nm命令验证下,确实任何符号都被删除了,而不用-g编译的文件还可以看到符号信息的。 三 符号表引入测试3.1 core测试
  默认情况下不会产生core文件,加大core文件尺寸: root@ubuntu-lab:/home/miao/c-test# ulimit -c unlimited root@ubuntu-lab:/home/miao/c-test# tail -f
  重新编译运行: root@ubuntu-lab:/home/miao/c-test# gcc  -g -o testdebug ./testdebug.c  root@ubuntu-lab:/home/miao/c-test# strip testdebug -o testdebug-strip
  看下core的信息: root@ubuntu-lab:/home/miao/c-test# tail -f /var/log/apport.log ERROR: apport (pid 125154) Sat Apr 30 11:52:20 2022: executable: /home/miao/c-test/testdebug-strip (command line "./testdebug-strip") ERROR: apport (pid 125154) Sat Apr 30 11:52:20 2022: executable does not belong to a package, ignoring ERROR: apport (pid 125154) Sat Apr 30 11:52:20 2022: writing core dump to core._home_miao_c-test_testdebug-strip.0.3fc6ea16-9440-4d72-81f8-7221d0b6684d.125153.3233349 (limit: -1)
  调试下看看: root@ubuntu-lab:/home/miao/c-test# gdb ./testdebug-strip /var/lib/apport/coredump/core._home_miao_c-test_testdebug-strip.0.3fc6ea16-9440-4d72-81f8-7221d0b6684d.125153.3233349 -q Reading symbols from ./testdebug-strip... (No debugging symbols found in ./testdebug-strip) [New LWP 125153] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./testdebug-strip". Program terminated with signal SIGSEGV, Segmentation fault. #0  0x000055d8d93bc178 in ?? () (gdb) where #0  0x000055d8d93bc178 in ?? () #1  0x000055d8d93bc1b3 in ?? () #2  0x00007f173a2ebfd0 in __libc_start_call_main (main=main@entry=0x55d8d93bc19d, argc=argc@entry=1, argv=argv@entry=0x7ffe16913908) at ../sysdeps/nptl/libc_start_call_main.h:58 #3  0x00007f173a2ec07d in __libc_start_main_impl (main=0x55d8d93bc19d, argc=1, argv=0x7ffe16913908, init=, fini=, rtld_fini=, stack_end=0x7ffe169138f8)     at ../csu/libc-start.c:409 #4  0x000055d8d93bc085 in ?? () (gdb) bt #0  0x000055d8d93bc178 in ?? () #1  0x000055d8d93bc1b3 in ?? () #2  0x00007f173a2ebfd0 in __libc_start_call_main (main=main@entry=0x55d8d93bc19d, argc=argc@entry=1, argv=argv@entry=0x7ffe16913908) at ../sysdeps/nptl/libc_start_call_main.h:58 #3  0x00007f173a2ec07d in __libc_start_main_impl (main=0x55d8d93bc19d, argc=1, argv=0x7ffe16913908, init=, fini=, rtld_fini=, stack_end=0x7ffe169138f8)     at ../csu/libc-start.c:409 #4  0x000055d8d93bc085 in ?? ()
  因为没有符号信息,很可惜看不到具体的符号信息,也不知道在哪里core了。 (gdb) symbol-file /home/miao/c-test/testdebug Load new symbol table from "/home/miao/c-test/testdebug"? (y or n) y Reading symbols from /home/miao/c-test/testdebug... (gdb) where #0  0x000055d8d93bc178 in func () at ./testdebug.c:8 #1  0x000055d8d93bc1b3 in main () at ./testdebug.c:14 (gdb)
  看重点,加载符号文件,这个是直接加载没有strip前的文件,是包含符号表的。我们清晰的可以看到core的位置是在第8行。
  顺便说下,gdb调试多线程,打印多线程堆栈信息命令:thread apply all bt full 3.2 提取符号表root@ubuntu-lab:/home/miao/c-test# eu-strip testdebug -f testdebug.sym root@ubuntu-lab:/home/miao/c-test# ll  total 100 drwxrwxr-x  2 miao miao  4096 Apr 30 12:23 ./ drwxr-x--- 16 miao miao  4096 Apr 30 12:09 ../ -rwxr-xr-x  1 root root 15984 Apr 30 11:23 test* -rwxr-xr-x  1 root root 14464 Apr 30 11:24 test-debug* -rwxr-xr-x  1 root root 14568 Apr 30 12:23 testdebug* -rw-rw-r--  1 miao miao   205 Apr 30 11:38 testdebug.c -rwxr-xr-x  1 root root 14464 Apr 30 11:52 testdebug-strip* -rwxr-xr-x  1 root root  5864 Apr 30 12:23 testdebug.sym* root@ubuntu-lab:/home/miao/c-test# file test.sym test.sym: cannot open `test.sym" (No such file or directory) root@ubuntu-lab:/home/miao/c-test# file ./testdebug.sym ./testdebug.sym: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter 04, BuildID[sha1]=5881c326d8f784139407ed0c7576149cb19270f4, for GNU/Linux 3.2.0, with debug_info, not stripped
  我们通过命令: eu-strip testdebug -f testdebug.sym 提取testdebug中的符号表,保存为文件testdebug.sym。
  我们gdb调试的时候导入这个符号试试: root@ubuntu-lab:/home/miao/c-test# gdb ./testdebug-strip /var/lib/apport/coredump/core._home_miao_c-test_testdebug-strip.0.3fc6ea16-9440-4d72-81f8-7221d0b6684d.125153.3233349 -q Reading symbols from ./testdebug-strip... (No debugging symbols found in ./testdebug-strip) [New LWP 125153] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./testdebug-strip". Program terminated with signal SIGSEGV, Segmentation fault. #0  0x000055d8d93bc178 in ?? () (gdb) symbol-file /home/miao/c-test/testdebug.sym Load new symbol table from "/home/miao/c-test/testdebug.sym"? (y or n) y Reading symbols from /home/miao/c-test/testdebug.sym... (gdb) where #0  0x000055d8d93bc178 in func () at testdebug.c:8 #1  0x000055d8d93bc1b3 in main () at testdebug.c:14 (gdb)   四 参考网站[https://blog.csdn.net/bluebubble/article/details/10407217](https://blog.csdn.net/bluebubble/article/details/10407217)

预算五千左右买台台式电脑自己组装能多开玩游戏和大型游戏怎么配?现在玩游戏配电脑属于不理智!因为显卡这两年已经处在高位上,拿玩游戏性价比最高的1660ti举例(除了没光追性能跟2060差距在510),在挖矿未开始的时候也就1500元左右,但目前影视会员低价靠谱不?低价的会员一年批发价0。5元一个,这个是真实的。不是共享账号。激活码最低0。3元就能批发到。我之前手里有一批,不过我是用来免费送给他们用来引流做项目的而已。想想要是当初不直接送,我在头条无法保证更新频率,收益不多,是否该继续坚持?谢邀请干什么不都得先付出吗,种一棵桃树,还要管理三年,才能吃上鲜桃,以后才能越结桃越多,逮只小鸡还得撒把粮食,逮只鸽子也得撒几次碗豆呢。写头条道理也一样。做头条的目地如果是为了挣钱二三四五董秘回复公司不涉及数字货币业务不涉及冬奥会概念二三四五(002195)01月18日在投资者关系平台上答复了投资者关心的问题。投资者请问董秘,公司是否涉及数字货币?二三四五董秘您好,感谢对公司的关注。公司不涉及数字货币业务。谢谢微软宣布将以687亿美元的价格收购动视暴雪张枕河中国证券报中证网中证网讯(记者张枕河)当地时间1月18日,微软宣布将以每股95美元的价格收购动视暴雪,全现金交易总价值687亿美元,预计将在2023财年完成交易。受此提振,动亚马逊脸书贡献10亿欧元,欧洲2021数据保护罚款创纪录驱动中国2022年1月18日消息,去年,欧盟对亚马逊公司Facebook母公司Meta旗下WhatsApp的处罚帮助将欧盟数据保护罚款金额推高至创纪录水平。这表明,欧盟严格的隐私规太可怕了,你手机有绑定银行卡,两个开关一定要打开ampampquot隐私ampampquot安全ampampquot太可怕了,我也是刚知道这个消息,赶快想告诉大家,只要你的手机绑定了银行卡这个功能,你就一定要打开两个开关首先,打开手机里的设置,然后向下滑,找到应用设置里边儿系统应用的设置,然后打想请教大神们一下,家里每天打扫,还是感觉灰尘好多,这是为什么?其实每个家庭都一样,我每天都打扫,每天都有灰尘,其实不爱打扫的人看不见灰尘,其实生活在空气中哪能没灰尘。我跟你同感,家里一天不打扫就灰尘满天飞。我想了很多年,想明白的几点。第一,窗小米手机世界第二了,为什么还是这么多人黑小米手机?原因很简单,小米不光动了各个厂商的蛋糕,还动了无数赚差价的中间商的蛋糕。小米插线板49华为插线板149,小米氮化镓149华为氮化镓399不带线,小米手机换屏幕1000多华为手机换屏中金维持腾讯控股(00700)中性评级目标价下调4至527港元智通财经APP获悉,中金发布研究报告称,维持腾讯控股(00700)中性评级,目标价下调4至527港元,对应33x2022enonIFRSPE,较当前股价有13上行空间。引入2023索尼6400镜头群也算全面了,有必要全卖了升级全画幅吗?其实没有必要,当然如果完全是个大款不差钱儿的当我没说。6400能用到的镜头有很多超高性价比的牛头,比如的适马定焦三剑客。163056三个1。4大光圈头,画面品质惊人。二手只需要1k
腾讯陆续启用中文顶级域名QQ。中国和腾讯。中国新网域名资讯随着政策导向的日渐鲜明和移动互联网的不断发展,近年来,中文域名的技术和应用环境逐步提高。据中国互联网络信息中心(CNNIC)资讯腾讯公司于今年陆续开通解析了纯中文顶级域PR插件项目媒体修剪存档整理脚本PlumePackPR项目媒体修剪存档整理脚本PlumePack插件支持ProRes。BRAW。R3D图像序列以及压缩的H。264和H。265(HEVC),根据您的编辑删除未使用的帧来修剪文件,并带宝马3系强压雅阁赢得5月中级车销量冠军,中级车在走下坡?5月份,根据乘联会的最新数据显示,轿车销量为79。4万辆。同比增长3。3,环比增长3。4。相比于SUV,轿车市场无疑还是正向稳步提升。即便在新能源汽车销量快速攀升的当下,仍然有把蛋中国不需要道歉,该道歉的是无良媒体的种族主义!阿丘你今天道歉了吗首先,疫情首先出现在中国,但不一定起源于中国,想想猪流感是怎么来的吧,墨西哥道歉了吗?第二,只要是疾病,就会与全人类有关,这不是哪一个国家的问题,09年美国的H1媒体标记即将推出市场MediaMarkt即将在欧洲各地推出其新的市场功能。该平台已在德国奥地利和西班牙的Beta阶段推出。名单上的下一个是荷兰。之后,市场将进一步扩展到比荷卢。德国主要的消费电子产品零新网X青云战略合作,共谋未来7月29日,由青云科技主办的预见数字自由CIC2021云计算峰会在北京成功举办,峰会旨在全面展示交流分享云计算前沿技术最新应用和实践成果。新网受邀参加峰会,并在会上与青云科技正式达总裁班教务老师,未来的前途出路提升在哪里?资本策划师(CCP),人生腾飞的最佳选择朱老师,我是您去授课的北大金融总裁班的项目负责人小李老师,听说你们开了一个关于资本策划师(CCP)的认证班,我们几个也想报名去读参加认证,具河南暴雨后浸泡的汽车怎么办?保险的估损又是多少最后何去何从?2021年的7月20日八时,河南中北部出现有史以来的特大暴雨,最严重的郑州城区的下雨量高达500657毫米,国家防疫总局启动防汛级应急响应,针对暴雨引发的险情,应急部第一时间派出多三角梅的扦插技巧!如何用白糖促根?三角梅的扦插繁殖中,无论是老枝还是嫩枝,都可以利用生根剂处理达到枝条快速生根的效果。家庭养花繁殖中,在没有专用生根剂的情况下,可以利用什么来进行促根呢?这种促根剂就是我们家庭中常用一切成功都是酝酿了太久太久富爸爸,穷爸爸原创读书笔记有时创业也不能一味追求稳,太稳代表着一定程度的保守。有些时候特别害怕失败,不管是有没有过失败,发生失败是因为自己太害怕失败。有人勇于面对失败,因为失败会增加下一次成功的机会,有人遇生活日记水墨气息浓郁的机械键盘,谁说数码产品没有文艺范?引言说到机械键盘,我用过三款不同品牌的机械键盘,轴体有青轴和茶轴。其他的红轴,黑轴等各类轴体,我没有长时间使用过,但是就青轴和茶轴而言,如果你没有使用过机械键盘,我推荐你人生第一把