linux-0.11调试教程,HIST_ENTRY结构中data域的用处
2013-03-06 20:27
411 查看
HIST_ENTRY结构中data域的使用出现在history.c文件中的replace_history_entry ()函数中。
而replace_history_entry ()函数在readline.c文件中有如下两处调用
char *
readline_internal ()
{
......
if (entry && rl_undo_list)
{
char *temp = savestring (the_line);
rl_revert_line ();
entry = replace_history_entry (where_history (), the_line,
(HIST_ENTRY *)NULL);
free_history_entry (entry);
strcpy (the_line, temp);
free (temp);
}
}
/* Perhaps put back the current line if it has changed. */
maybe_replace_line ()
{
HIST_ENTRY *temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), the_line, rl_undo_list);
free (temp->line);
free (temp);
}
}
下面是在[/root]# abcad ---> [/root]# aabcad之后按下向上方向键时在replace_history_entry
()函数出被截获。
其中参数rl_undo_list的值为0x5d7cc。指向undo_list结构,下面是undo_list结构的定义(readline.h中):
enum
undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
/*
What an element of THE_UNDO_LIST looks like. */
typedef struct undo_list {
struct undo_list *next;
int start, end; /* Where the change took place. */
char *text; /* The text to insert, if undoing a delete. */
enum undo_code what; /* Delete, Insert, Begin, End. */
} UNDO_LIST;
/* The current undo list for RL_LINE_BUFFER. */
extern UNDO_LIST *rl_undo_list;
rl_undo_list->next的值为0x5d78c
rl_undo_list->start的值为1
rl_undo_list->end的值为2
rl_undo_list->text的值为0既NULL
rl_undo_list->what的值为1既UNDO_INSERT
![](http://img.my.csdn.net/uploads/201303/06/1362573355_3194.jpg)
![](http://img.my.csdn.net/uploads/201303/06/1362573423_3842.jpg)
按下向下方向键,再按下向上方向键,
再次在previous_history ()函数下断点截获后发现data域不是0既NULL了。
这时是0x5d7cc,既是刚才的rl_undo_list的值!!!
而replace_history_entry ()函数在readline.c文件中有如下两处调用
char *
readline_internal ()
{
......
if (entry && rl_undo_list)
{
char *temp = savestring (the_line);
rl_revert_line ();
entry = replace_history_entry (where_history (), the_line,
(HIST_ENTRY *)NULL);
free_history_entry (entry);
strcpy (the_line, temp);
free (temp);
}
}
/* Perhaps put back the current line if it has changed. */
maybe_replace_line ()
{
HIST_ENTRY *temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), the_line, rl_undo_list);
free (temp->line);
free (temp);
}
}
下面是在[/root]# abcad ---> [/root]# aabcad之后按下向上方向键时在replace_history_entry
()函数出被截获。
其中参数rl_undo_list的值为0x5d7cc。指向undo_list结构,下面是undo_list结构的定义(readline.h中):
enum
undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
/*
What an element of THE_UNDO_LIST looks like. */
typedef struct undo_list {
struct undo_list *next;
int start, end; /* Where the change took place. */
char *text; /* The text to insert, if undoing a delete. */
enum undo_code what; /* Delete, Insert, Begin, End. */
} UNDO_LIST;
/* The current undo list for RL_LINE_BUFFER. */
extern UNDO_LIST *rl_undo_list;
rl_undo_list->next的值为0x5d78c
rl_undo_list->start的值为1
rl_undo_list->end的值为2
rl_undo_list->text的值为0既NULL
rl_undo_list->what的值为1既UNDO_INSERT
![](http://img.my.csdn.net/uploads/201303/06/1362573355_3194.jpg)
![](http://img.my.csdn.net/uploads/201303/06/1362573423_3842.jpg)
按下向下方向键,再按下向上方向键,
再次在previous_history ()函数下断点截获后发现data域不是0既NULL了。
这时是0x5d7cc,既是刚才的rl_undo_list的值!!!
![](http://img.my.csdn.net/uploads/201303/06/1362577407_8895.jpg)
相关文章推荐
- linux-0.11调试教程,task3(02)系统调用sys_alarm和sigaction结构
- linux-0.11调试教程 文件系统中b_uptodate字段的含义
- linux0.11调试教程,task3概述
- linux-0.11调试教程,con_init函数和右上角的EGAc
- linux-0.11调试教程,bash-1.12源代码分析readline.a和termcap.a的连接
- linux-0.11调试教程,task3(04),sa_restore函数
- linux-0.11调试教程,findipn根据i节点号返回路径和文件名
- linux-0.11调试教程,head.s页表项
- linux-0.11调试教程,load_history ()调用过程
- linux-0.11调试教程,minix-386-fd0-by-chenghao0511,最小的操作系统,只有360k。
- linux-0.11调试教程 tty_table
- linux-0.11调试教程,task3(03),do_signale之后的用户栈
- linux-0.11调试教程,fdisk for linux-0.11 by chenghao0511
- linux-0.11调试教程,rl_dispatch ()函数调用函数的参数的个数
- linux-0.11调试教程,rl_done什么时候为1?
- linux-0.11调试教程,readline()回显字符调用顺序
- linux-0.11调试教程,退格键的调用过程(2)
- linux-0.11内核 调试教程+GCC源代码
- linux-0.11调试教程,fwrite ()函数的作用
- linux-0.11调试教程,sh调用顺序