bash源代码分析----bison--debug或-t选项的作用
bison--debug或-t选项的作用bison -y parse.y/* Debug traces. */#ifndef YYDEBUG# define YYDEBUG 0#endif#if YYDEBUGextern int yydebug;#endifbison -y --debug parse.y/* Debug traces. */#ifndef YYDEBUG# define YYD
bison--debug或-t选项的作用
bison -y parse.y
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
bison -y --debug parse.y
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
eval.c文件里面在调用yyparse()之前加上如下代码:
extern int yydebug;
yydebug = 1;
[root@localhost bash-4.2.53]# ./bash --version
GNU bash, version 4.2.53(9)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
eval.c文件修改如下:
/* Call the YACC-generated parser and return the status of the parse.
Input is read from the current input stream (bash_input). yyparse
leaves the parsed command in the global variable GLOBAL_COMMAND.
This is where PROMPT_COMMAND is executed. */
int
parse_command ()
{
int r;
char *command_to_execute;
extern int yydebug;
yydebug = 1;
need_here_doc = 0;
run_pending_traps ();
parse.y里面加上最后一行
#ifdef DEBUG
# define YYDEBUG 1
#else
# define YYDEBUG 0
#endif
# define YYDEBUG 1
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)