我的程序不时崩溃,并在系统日志中显示以下消息。
这是否可以以某种方式对其进行修改,因此将有一条关于函数/行在哪里崩溃的可读消息而不是地址?
我可以访问程序源,并且可以通过 addr2line 查找函数。然而,我感兴趣的是我想让它解析指向函数的指针,所以它会在 syslog 中看到。请分享您对如何实现此功能的想法
UPD:我看到可以通过注册信号处理程序并执行 backtrace() 函数来完成。这是一种无需修改程序即可做到这一点的方法吗?或者是否可以进行一些通用修改,所以每个程序都会在崩溃时执行回溯?
[ 1775.374665] virt-manager[870]: unhandled level 3 translation fault (11) at 0x00000000, esr 0x92000007
[ 1775.383904] pgd = fffffe03dcee0000
[ 1775.387302] [00000000] *pgd=0000004018ea0003, *pud=0000004018ea0003, *pmd=0000004018ea0003, *pte=0000000000000000
[ 1775.397616]
[ 1775.399119] CPU: 2 PID: 870 Comm: virt-manager Tainted: G W 4.0.0-0.rc5.git4.1.fc22.aarch64 #1
[ 1775.408843] Hardware name: AppliedMicro Mustang/Mustang, BIOS 1.1.0-rh-0.15 Feb 20 2015
[ 1775.416836] task: fffffe03dc44da80 ti: fffffe03dc3d4000 task.ti: fffffe03dc3d4000
[ 1775.424320] PC is at 0x3ffad37ae5c
[ 1775.427715] LR is at 0x3ffad37ae5c
[ 1775.431128] pc : [<000003ffad37ae5c>] lr : [<000003ffad37ae5c>] pstate: 60000000
[ 1775.438493] sp : 000003ffe89cd3d0
[ 1775.441820] x29: 000003ffe89cd3d0 x28: 000000003ceb0620
[ 1775.447146] x27: 000000003c9600a0 x26: 0000000000000000
[ 1775.452490] x25: 000003ffb03b0000 x24: 000000003cdf10a0
[ 1775.457804] x23: 000003ffb03af000 x22: 000000003cab57a0
[ 1775.463156] x21: 0000000000000000 x20: 0000000000000001
[ 1775.468477] x19: 000000003cece200 x18: 000003ffb01e2460
[ 1775.473819] x17: 000003ffb715b790 x16: 000003ffb03305b0
[ 1775.479140] x15: 0000000000000020 x14: 0000000000000050
[ 1775.484479] x13: 000000003ceeca18 x12: 000000003ca86110
[ 1775.489799] x11: 000000003ceec9e0 x10: 000000003ceeb270
[ 1775.495142] x9 : 000003ffb7202560 x8 : 0000000000000062
[ 1775.500464] x7 : 0000000000000199 x6 : 0000000000000199
[ 1775.505805] x5 : 000000003ca9f280 x4 : 0000000000000000
[ 1775.511145] x3 : 0000000000000000 x2 : b5107af573d8a600
[ 1775.516458] x1 : 0000000000000000 x0 : 000000003cacbc20
[ 1775.521797]