linux-0.11调试教程,fflush()函数实现分析和FILE类型定义
来源:互联网 发布:ecs网络拓扑图图标 编辑:程序博客网 时间:2024/06/08 13:12
fflush()
__bwrflush()
__iowrite()
write()
typedef struct __iobuf {
__stdiobuf_t *__rptr; /* pointer into read buffer */__stdiobuf_t *__rend; /* point at end of read buffer */
__stdiobuf_t *__wptr; /* pointer into write buffer */
__stdiobuf_t *__wend; /* point at end of write buffer */
__stdiobuf_t *__base; /* base of buffer */
__stdiosize_t __bufsiz; /* size of buffer */
short __flag; /* flags */
char __file; /* channel number */
__stdiobuf_t __buf; /* small buffer */
int (*__filbuf) _STDIO_P_((struct __iobuf *)); /* fill input buffer */
int (*__flsbuf) _STDIO_P_((int, struct __iobuf *)); /* flush output buffer */
int (*__flush) _STDIO_P_((struct __iobuf *)); /* flush buffer */
struct __iobuf *__next; /* next in chain */
} FILE;
__bwrflush处下断点的情形:
第一块是断点,第二块是堆栈,0x442a8是FILE * 指针,
第三块是FILE*类型结构,缓冲区地址是0x4840c。
/* Flush a write buffer
** __bwrflush is a function that flushes the output buffer.
*/
static int __bwrflush F1(register FILE *, fp)
{
register __stdiosize_t length; /* bytes to write */
if (! TESTFLAG(fp, _IOERR)
#ifndef OPEN3
&& (! TESTFLAG(fp, _IOAPPEND) || lseek(fileno(fp), 0L, SEEK_END) != -1L)
#endif
) {
length = BYTESINWRITEBUFFER(fp);
INITWRITEBUFFER(fp);
if (__iowrite(fileno(fp), (char *) fp->__base, length) == length)
return 0;
}
SETFLAG(fp, _IOERR);
return EOF;
}
__iowrite处下断点时的情形:
在__iowrite之后下断点,会看到虚拟机中出现了字符f
附上__iowrite的定义:
#include "stdiolib.h"
/*LINTLIBRARY*/
__stdiosize_t __iowrite F3(int, fd, char *, p, __stdiosize_t, n)
{
register int wrote; /* bytes written by write call */
register __stdiosize_t wb; /* byte to write each call */
__stdiosize_t w; /* total bytes written */
for (w = 0; ; p += wrote) {
wb = n;
if (wb > INT_MAX)
wb = INT_MAX;
do
wrote = write(fd, p, (unsigned int) wb); //注意这里,终于看到write()函数了!!!
while (wrote == -1 && (errno == EINTR || errno == EAGAIN));
if (wrote == -1)
break;
w += wrote;
if ((n -= wrote) == 0)
break;
}
return w;
}
- linux-0.11调试教程,fflush()函数实现分析和FILE类型定义
- linux-0.11调试教程,update_line()函数分析,和update_line()函数的数据模型
- linux-0.11调试教程,终端的初始化init_terminal_io ()函数分析
- unix/linux编程实践教程----fflush函数有什么作用
- fflush(stdin)和fflush(stdout)函数
- linux-0.11调试教程,con_init函数和右上角的EGAc
- linux-0.11调试教程,rl_insert_text函数和the_line[]数组
- typedef定义函数类型分析
- linux-0.11调试教程,task2的参数,copy_strings()函数和create_tables()函数的关系
- linux-0.11调试教程,move_cursor_relative()函数和变量last_c_pos和变量c_pos的关系
- linux-0.11调试教程,bash-1.12源代码分析readline.a和termcap.a的连接
- linux-0.11调试教程,readline ()函数中,ECHO的关闭和开启
- fflush函数
- fflush()函数
- fflush函数
- fflush函数
- fflush函数
- fflush函数
- struts上传下载
- activeMQ的简单案例
- C#的数据类型
- java任务调度
- Python 正则表达式 Howto(2)
- linux-0.11调试教程,fflush()函数实现分析和FILE类型定义
- Good Sentence
- Android开发: The type ClipboardManager is deprecated
- Distance Metrics 距离度量
- 二叉树变成搜索二叉树
- Facebook广告瞄准技术:商户积分卡匹配帐号
- 小知识点
- 定时执行某项任务 ——MFC程序设计之计时器
- Android之Adapter用法总结