|
🛰️航天仿真算法库 SpaceAST 0.0.1
|
类型定义 | |
| typedef void(* | ast::ACrashCallback) (const char *crashType, int signalNum, const void *faultAddr, void *const *stackFrames, int frameCount) |
函数 | |
| errc_t | ast::aCrashHandlerInstall (ACrashCallback callback) |
| void | ast::aCrashHandlerUninstall () |
| errc_t | ast::aCrashHandlerSetLogDir (const char *dir) |
| const char * | ast::aCrashHandlerLastLogPath () |
| errc_t | ast::aCrashResolveSymbols (const char *logPath, const char *outPath) |
| errc_t | ast::aCrashSetReporterCommand (const char *command) |
| const char * | ast::aCrashGetReporterCommand () |
| typedef void(* ast::ACrashCallback) (const char *crashType, int signalNum, const void *faultAddr, void *const *stackFrames, int frameCount) |
崩溃回调函数类型
| crashType | 崩溃类型字符串(如 "SIGSEGV"、"SIGABRT"、"TERMINATE") |
| signalNum | 信号编号(terminate 时为 0) |
| faultAddr | 故障地址(不可用时为 nullptr) |
| stackFrames | 调用栈原始返回地址数组 |
| frameCount | 调用栈帧数 |
在崩溃日志写入文件之前调用。回调中不应执行复杂操作(如内存分配)。
| AST_FAULT_API const char * ast::aCrashGetReporterCommand | ( | ) |
获取当前设置的报告命令
| AST_FAULT_CAPI errc_t ast::aCrashHandlerInstall | ( | ACrashCallback | callback | ) |
安装崩溃处理器
| callback | 可选的用户回调,在写入崩溃日志前调用 |
注册以下处理器:
重复安装是安全的(第二次调用无操作)。
| AST_FAULT_API const char * ast::aCrashHandlerLastLogPath | ( | ) |
获取最后一次崩溃日志的完整路径
| AST_FAULT_CAPI errc_t ast::aCrashHandlerSetLogDir | ( | const char * | dir | ) |
设置崩溃日志输出目录
| dir | 目录路径(内部会复制到固定大小的缓冲区,最大 511 字符) |
默认目录为 aDataDir() + "/crash/"。如指定目录不存在,将尝试创建。
| AST_FAULT_CAPI void ast::aCrashHandlerUninstall | ( | ) |
卸载崩溃处理器
将所有处理器恢复为默认行为。重复卸载是安全的。
| AST_FAULT_CAPI errc_t ast::aCrashResolveSymbols | ( | const char * | logPath, |
| const char * | outPath ) |
解析崩溃日志中的堆栈地址,附加符号信息
| logPath | 原始崩溃日志文件路径 |
| outPath | 输出文件路径(为 nullptr 时覆盖原文件) |
在正常上下文中调用(非信号处理器),解析原始地址的符号信息:
将 "#NN 0x..." 行替换为 "#NN 0x... functionName [file.cpp:line]" 格式。 需要调试符号(.pdb / 未strip的 .so)可用时才能解析到文件名和行号。
| AST_FAULT_CAPI errc_t ast::aCrashSetReporterCommand | ( | const char * | command | ) |
设置崩溃后的报告命令
| command | 崩溃后执行的命令(如崩溃报告程序路径) |
崩溃处理器写完日志后,将调用此命令并传入日志路径作为参数。 设为 nullptr 则使用默认行为(Windows: MessageBox,Linux: stderr)。
命令格式: "command --flag" — 日志路径会作为最后一个参数追加。 仅在程序启动时(非信号上下文中)调用此函数。