errno 5追踪.

errno 5追踪.
----------------------------------------
author:hjjdebug
date:  2023年 06月 29日 星期四 14:32:02 CST
----------------------------------------

调试一个ffmpeg 程序,当调用av_read_frame()函数时,返回了-5, 这是什么意思?

-5, 这种小号的错误值是ffmpeg 把系统错误号取反形成的,
#define AVERROR(e) (-(e))   ///< Returns a negative error code from a POSIX error code, to return from library functions.
马上查找一下系统错误号为5是什么意思?
书写如下代码: 可起名为simple.c
#include <errno.h>
int main(void)
{ return 0;}

使用我喜欢的vim编辑器,打开errno.h文件 /usr/include/errno.h
里面浏览了一下,没有直接的内容,有3个包含文件,浏览一下,其中有用的是 <bits/errno.h> ->/usr/include/bits/errno.h
打开<bits/errno.h>,我们看到了错误号125 - 133的定义, 还有一个包含文件<linux/errno.h> -> /usr/include/linux/errno.h
打开<linux/errno.h>文件,只包含一行代码: #include <asm/errno.h> -> /usr/include/asm/errno.h
再打开<asm/errno.h>文件,只包含一行代码 #include <asm-generic/errno.h> -> /usr/include/asm-generic/errno.h
再打开<asm-generic/errno.h>文件,看到了35到133的错误号定义,它包含了一个文件 #include <asm-generic/errno-base.h> -> /usr/include/asm-generic/errno-base.h
再打开<asm-generic/errno-base.h>文件,看到了1到34的错误号定义,
错误号为5, 表示是一种IO 错误.
#define    EIO         5    /* I/O error */

是的,在播放码流时,我中断了发送的码流,引起了av_read_frame读不到数据产生 EIO 错误, 追踪结束.完美解决问题.


有没有更快,更有效的手段呢? 有, 把哪个简单的代码预处理一下,直接看输出,搜索结果,就不用一个一个打开文件了.
gcc -E -dD simple.c
它会对simple.c预处理并包含宏定义.将输出重定向到文件可以慢慢观察.

顺便copy 一下基础错误号定义吧, 是ubuntu20 系统

#define    EPERM         1    /* Operation not permitted */
#define    ENOENT         2    /* No such file or directory */
#define    ESRCH         3    /* No such process */
#define    EINTR         4    /* Interrupted system call */
#define    EIO         5    /* I/O error */
#define    ENXIO         6    /* No such device or address */
#define    E2BIG         7    /* Argument list too long */
#define    ENOEXEC         8    /* Exec format error */
#define    EBADF         9    /* Bad file number */
#define    ECHILD        10    /* No child processes */
#define    EAGAIN        11    /* Try again */
#define    ENOMEM        12    /* Out of memory */
#define    EACCES        13    /* Permission denied */
#define    EFAULT        14    /* Bad address */
#define    ENOTBLK        15    /* Block device required */
#define    EBUSY        16    /* Device or resource busy */
#define    EEXIST        17    /* File exists */
#define    EXDEV        18    /* Cross-device link */
#define    ENODEV        19    /* No such device */
#define    ENOTDIR        20    /* Not a directory */
#define    EISDIR        21    /* Is a directory */
#define    EINVAL        22    /* Invalid argument */
#define    ENFILE        23    /* File table overflow */
#define    EMFILE        24    /* Too many open files */
#define    ENOTTY        25    /* Not a typewriter */
#define    ETXTBSY        26    /* Text file busy */
#define    EFBIG        27    /* File too large */
#define    ENOSPC        28    /* No space left on device */
#define    ESPIPE        29    /* Illegal seek */
#define    EROFS        30    /* Read-only file system */
#define    EMLINK        31    /* Too many links */
#define    EPIPE        32    /* Broken pipe */
#define    EDOM        33    /* Math argument out of domain of func */
#define    ERANGE        34    /* Math result not representable */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值