if (getrlimit(RLIMIT_CORE, &rlmt) == -1) { return-1; } printf("After set rlimit CORE dump current is:%d, max is:%d\n", (int)rlmt.rlim_cur, (int)rlmt.rlim_max);
假设core文件为/cores/core.1630405848.pixelpai.19,我们就可以通过gdb解析对应的文件 bt # 获取最后退出堆栈的详细信息 frame 3 # 简写 f 3 切到第3个frame 并输出相关代码 p value # 展示所在帧value对象的值 up # 移到上一个帧 down # 移到下一个帧
gdb main /cores/core.1630405848.pixelpai.19 ... GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from cmake-build-debug/build/bin/main...done. [New LWP 17765] [New LWP 2336] [New LWP 29510] [New LWP 11379] [New LWP 2335] [New LWP 2334] [New LWP 20475] [New LWP 20476] [New LWP 20477]
warning: Could not load shared library symbols for 2 libraries, e.g. ./cjson.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `/home/never/work/pixelpai_server/cmake-build-debug/build/bin/main -props /home/'. Program terminated with signal SIGABRT, Aborted. #0 raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. [Current thread is 1 (Thread 0x7fca28917700 (LWP 17765))] (gdb) bt #0 raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x0000562abaf64e47 in console::handler (sig=11) at /home/never/work/pixelpai_server/src/server/main/console_linux.cpp:244 #2 <signal handler called> #3 0x00007fca316e0108 in Sprite::getSpriteSerialize (this=0x7fca00a66d00) at /home/never/work/pixelpai_server/src/server/world/virtualworld/scene/sprite.cpp:595 #4 0x00007fca3169a87a in Scene::sendEnterSceneToAll (this=0x7fca0217ba60, actorId=1685436067) at /home/never/work/pixelpai_server/src/server/world/virtualworld/scene/scene.cpp:535 ... (gdb) frame 3 #3 0x00007fca316e0108 in Sprite::getSpriteSerialize (this=0x7fca00a66d00) at /home/never/work/pixelpai_server/src/server/world/virtualworld/scene/sprite.cpp:595 (gdb) p animationSptr $1 = std::shared_ptr<IAnimation> (empty) = {get() = 0x0} (gdb) p spriteSptr $2 = std::shared_ptr<op_client::Sprite> (use count 1, weak count 0) = {get() = 0x7fca0d84cea0} (gdb) up #4 0x00007fca3169a87a in Scene::sendEnterSceneToAll (this=0x7fca0217ba60, actorId=1685436067) at /home/never/work/pixelpai_server/src/server/world/virtualworld/scene/scene.cpp:535 535 auto characterProto = pCharacter->getSpriteSerialize(); (gdb) down #3 0x00007fca316e0108 in Sprite::getSpriteSerialize (this=0x7fca00a66d00) at /home/never/work/pixelpai_server/src/server/world/virtualworld/scene/sprite.cpp:595