core file介紹及初步分析

2021-05-28 15:30:52 字數 1858 閱讀 1617

#include #include int main(int argc, char *argv)   

if ((corefile = fopen(argv[1], "r")) == null)

fread(&c_file, sizeof(c_file), 1, corefile);

fclose(corefile);

sprintf(command, "lquerypv -h %s 6e0 64 | head -1 | awk ''", argv[1]);

printf("core created by: \n");

system(command);

printf("signal number and cause of error number: %i\n", c_file.c_signo);

printf("core file type: %i\n", c_file.c_flag);

printf("number of core dump modules: %i\n", c_file.c_entries);

printf("core file format number: %i\n", c_file.c_version);

printf("thread identifier: %i\n", c_file.c_flt.th.ti_tid);

printf("process identifier: %i\n", c_file.c_flt.th.ti_pid);

printf("current effective priority: %i\n", c_file.c_flt.th.ti_pri);

printf("processor usage: %i\n", c_file.c_flt.th.ti_cpu);

printf("processor bound to: cpu%i\n", c_file.c_flt.th.ti_cpuid);

/*

if (c_file.c_flt.th.ti_cpu > 1)

printf("last processor: cpu%i\n", c_file.c_flt.th.ti_affinity);

*/

return 0;

}

gcc -o any any.c

b.產生core file的程式core.c

int main()
gcc -o core_test core.c

c.執行 core_test, 產生core file

./core_test

segmentation fault (core dumped)

d.執行any,檢視結果

./any core_test

e.結果如下

-bash-3.00$ ./anacore core

core created by: 

|pcore...........|

signal number and cause of error number: 11

core file type: 115

number of core dump modules: 0

core file format number: 267312561

thread identifier: 2113597

process identifier: 1347756

current effective priority: 60

processor usage: 0

processor bound to: cpu-1

corefile介紹與gdb除錯

一 什麼是coredump 應用程式由於某些異常或者bug而被強制退出時,linux系統會在當前目錄或指定目錄下生成乙個core檔案,供使用者除錯定位程式異常出現的位置。core檔案包含了程式執行時記憶體 暫存器狀態 函式呼叫堆疊等除錯資訊。二 core file的路徑檢視與設定 1 可通過如下命令...

vue初步介紹

摘要 vue.js 讀音類似於view 是一套構建使用者介面的漸進式框架。與其他重量級框架不同的是,vue 採用自底向上增量開發的設計。vue 的核心庫只關注檢視層,它不僅易於上手,還便於與第三方庫或既有專案整合。vue.js 讀音類似於view 是一套構建使用者介面的漸進式框架。與其他重量級框架不...

HTTPS 初步介紹

非對稱加密 基於數學方法,生成乙個公鑰 金鑰對,來對資料做加密 解密,被公鑰加密的資料只能被私鑰解密,同樣,被私鑰加密的資料也只能被公鑰解密。所以可以用別人公開的公鑰加密一段資訊然後傳送出去,只有擁有對應金鑰的那個人才能解密。但是缺點是加密 解密的計算成本高,比較占用cpu資源 對稱加密 和非對稱加...