linux-0.11调试教程,rl_get_previous_history 调用过程
来源:互联网 发布:淘宝开发者平台流程图 编辑:程序博客网 时间:2024/06/10 12:07
linux-0.11调试教程,bash-1.12中readline()调用过程
http://blog.csdn.net/sitelist/article/details/8602108
这篇文是上面这篇文的后续,rl_get_previous_history (count)函数位于readline.c文件中,previous_history ()函数位于history.c文件中。rl_initialize ()函数中有调用using_history ()函数。
readline ()
rl_initialize ()
start_using_history ()
using_history ()
/* Begin a session in which the history functions might be used. This
initializes interactive variables. */
void
using_history ()
{
history_offset = history_length;
}
/* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */
rl_get_previous_history (count)
int count;
{
HIST_ENTRY *old_temp = (HIST_ENTRY *)NULL;
HIST_ENTRY *temp = (HIST_ENTRY *)NULL;
if (count < 0)
{
rl_get_next_history (-count);
return;
}
if (!count)
return;
/* If we don't have a line saved, then save this one. */
maybe_save_line ();
/* If the current line has changed, save the changes. */
maybe_replace_line ();
while (count)
{
temp = previous_history ();
if (!temp)
break;
else
old_temp = temp;
--count;
}
/* If there was a large argument, and we moved back to the start of the
history, that is not an error. So use the last value found. */
if (!temp && old_temp)
temp = old_temp;
if (!temp)
ding ();
else
{
int line_len;
line_len = strlen (temp->line);
if (line_len >= rl_line_buffer_len)
rl_extend_line_buffer (line_len);
strcpy (the_line, temp->line);
rl_undo_list = (UNDO_LIST *)temp->data;
rl_end = rl_point = line_len;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_point = 0;
#endif /* VI_MODE */
}
}
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry then returna NULL pointer. */
HIST_ENTRY *
previous_history ()
{
if (!history_offset)
return ((HIST_ENTRY *)NULL);
else
return (the_history[--history_offset]);
}
the_history的值为0x424c4是个二级指针,the_history[]数组是个指针数组。
history_offset的值为0x1f4。
the_history[--history_offset]的值为0x4faac是HIST_ENTRY类型指针
typedef struct _hist_entry {
char *line;
char *data;
} HIST_ENTRY;
下面是键入abcd回车后按下向上方向键后在previous_history ()函数处下断点时的情形
- linux-0.11调试教程,rl_get_previous_history 调用过程
- linux-0.11调试教程,load_history ()调用过程
- linux-0.11调试教程,系统调用sys_write的调用过程
- linux-0.11调试教程,bash-1.12中readline()调用过程
- linux-0.11调试教程,退格键的调用过程(2)
- linux-0.11调试教程,sh调用顺序
- linux-0.11调试教程,readline()回显字符调用顺序
- linux-0.11调试教程 tty_table
- linux-0.11调试教程,task2
- linux-0.11调试教程,task4
- linux-0.11调试教程,task3(02)系统调用sys_alarm和sigaction结构
- linux-0.11调试教程,rl_dispatch ()函数调用函数的参数的个数
- linux-0.11调试教程,head.s页表项
- linux-0.11调试教程,信号处理方式
- linux-0.11调试教程,filetutils的版本号
- linux-0.11调试教程,Bochs-2.1.1配置文件,精简版可拷贝,及img文件制作过程
- linux调试MCX314AL过程
- linux-0.11调试教程,bootsect.s文件调试,Loading system ...
- 《coredump问题原理探究》Linux x86版5.1节C风格数据结构内存布局之引言
- 设计模式之--状态模式
- CSS shorthand properties(CSS 缩写性质)
- 分层与模块设计:头文件
- javaWeb-07-jsp九大隐式对象-pageContext对象
- linux-0.11调试教程,rl_get_previous_history 调用过程
- 一个合格的程序员应该读过哪些书
- TCP通信与UDP通信WINDOWS实现流程总结
- javaWeb-08-jsp常用标签
- Win32程序设计基本原理 [大三TJB_708]
- Java Socket实战之四 传输压缩对象
- 工欲善其事必先利其器,工具之编译调试篇
- Java注意点
- 渐变启动欢迎界面——(开发第二日)