gcc源代码分析,在expand_call ()函数 和expand_expr_stmt ()函数的开始处加入debug_tree ()函数

2024-01-02 22:58

本文主要是介绍gcc源代码分析,在expand_call ()函数 和expand_expr_stmt ()函数的开始处加入debug_tree ()函数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

对于expand_call函数来说最主要的参数就是exp这个tree树,

打印出来之后我们终于看到了printfHello,world!

expand_call

 <call_expr 840f0
    type <integer_type 824d0 int permanent SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
        max <integer_cst 82534 literal permanent 2147483647
        pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
    volatile
    arg 0 <addr_expr 84090
        type <pointer_type 98f48 type <function_type 956e8>
            permanent unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
       
        arg 0 <function_decl 95740 printf type <function_type 956e8>
            external public permanent used QI file /usr/include/stdio.h line 214
            align 1 size_unit 1 offset 0 chain <function_decl 954d8 ungetc>
    arg 1 <tree_list 83270
        value <nop_expr 840d8 type <pointer_type 9117c>
            literal
            arg 0 <nop_expr 840c0 type <pointer_type 88a44>
                literal
                arg 0 <addr_expr 840a8 type <pointer_type 94f58>
                    literal
                    arg 0 <string_cst 84014 type <array_type 94ef4>
                        static literal " Hello, world!
"(nil)


下面是在 函数开始处加入debug_tree ()函数的结果

expand_expr_stmt
 <call_expr 840f0
    type <integer_type 824d0 int permanent SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
        max <integer_cst 82534 literal permanent 2147483647
        pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
    volatile
    arg 0 <addr_expr 84090
        type <pointer_type 98f48 type <function_type 956e8>
            permanent unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
       
        arg 0 <function_decl 95740 printf type <function_type 956e8>
            external public permanent used QI file /usr/include/stdio.h line 214
            align 1 size_unit 1 offset 0 chain <function_decl 954d8 ungetc>
    arg 1 <tree_list 83270
        value <nop_expr 840d8 type <pointer_type 9117c>
            literal
            arg 0 <nop_expr 840c0 type <pointer_type 88a44>
                literal
                arg 0 <addr_expr 840a8 type <pointer_type 94f58>
                    literal
                    arg 0 <string_cst 84014 type <array_type 94ef4>
                        static literal "Hello, world!
"(nil)


在c-parse.tab.c文件里面的stmt的定义出有对expand_expr_stmt()的调用,调用关系终于明朗了!

stmt:
      compstmt    {}
    | expr ';'
        { emit_line_note (input_filename, lineno);
          /* Do default conversion if safe and possibly important,
             in case within ({...}).  */
          if ((TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
               && lvalue_p ($1))
              || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
            $1 = default_conversion ($1);
          expand_expr_stmt ($1);
          clear_momentary (); }

这篇关于gcc源代码分析,在expand_call ()函数 和expand_expr_stmt ()函数的开始处加入debug_tree ()函数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/563889

相关文章

SpringBoot中六种批量更新Mysql的方式效率对比分析

《SpringBoot中六种批量更新Mysql的方式效率对比分析》文章比较了MySQL大数据量批量更新的多种方法,指出REPLACEINTO和ONDUPLICATEKEY效率最高但存在数据风险,MyB... 目录效率比较测试结构数据库初始化测试数据批量修改方案第一种 for第二种 case when第三种

解决1093 - You can‘t specify target table报错问题及原因分析

《解决1093-Youcan‘tspecifytargettable报错问题及原因分析》MySQL1093错误因UPDATE/DELETE语句的FROM子句直接引用目标表或嵌套子查询导致,... 目录报js错原因分析具体原因解决办法方法一:使用临时表方法二:使用JOIN方法三:使用EXISTS示例总结报错原

C++中assign函数的使用

《C++中assign函数的使用》在C++标准模板库中,std::list等容器都提供了assign成员函数,它比操作符更灵活,支持多种初始化方式,下面就来介绍一下assign的用法,具有一定的参考价... 目录​1.assign的基本功能​​语法​2. 具体用法示例​​​(1) 填充n个相同值​​(2)

MySql基本查询之表的增删查改+聚合函数案例详解

《MySql基本查询之表的增删查改+聚合函数案例详解》本文详解SQL的CURD操作INSERT用于数据插入(单行/多行及冲突处理),SELECT实现数据检索(列选择、条件过滤、排序分页),UPDATE... 目录一、Create1.1 单行数据 + 全列插入1.2 多行数据 + 指定列插入1.3 插入否则更

PostgreSQL中rank()窗口函数实用指南与示例

《PostgreSQL中rank()窗口函数实用指南与示例》在数据分析和数据库管理中,经常需要对数据进行排名操作,PostgreSQL提供了强大的窗口函数rank(),可以方便地对结果集中的行进行排名... 目录一、rank()函数简介二、基础示例:部门内员工薪资排名示例数据排名查询三、高级应用示例1. 每

全面掌握 SQL 中的 DATEDIFF函数及用法最佳实践

《全面掌握SQL中的DATEDIFF函数及用法最佳实践》本文解析DATEDIFF在不同数据库中的差异,强调其边界计算原理,探讨应用场景及陷阱,推荐根据需求选择TIMESTAMPDIFF或inte... 目录1. 核心概念:DATEDIFF 究竟在计算什么?2. 主流数据库中的 DATEDIFF 实现2.1

MySQL中的LENGTH()函数用法详解与实例分析

《MySQL中的LENGTH()函数用法详解与实例分析》MySQLLENGTH()函数用于计算字符串的字节长度,区别于CHAR_LENGTH()的字符长度,适用于多字节字符集(如UTF-8)的数据验证... 目录1. LENGTH()函数的基本语法2. LENGTH()函数的返回值2.1 示例1:计算字符串

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

MySQL 中的 CAST 函数详解及常见用法

《MySQL中的CAST函数详解及常见用法》CAST函数是MySQL中用于数据类型转换的重要函数,它允许你将一个值从一种数据类型转换为另一种数据类型,本文给大家介绍MySQL中的CAST... 目录mysql 中的 CAST 函数详解一、基本语法二、支持的数据类型三、常见用法示例1. 字符串转数字2. 数字

Python内置函数之classmethod函数使用详解

《Python内置函数之classmethod函数使用详解》:本文主要介绍Python内置函数之classmethod函数使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 类方法定义与基本语法2. 类方法 vs 实例方法 vs 静态方法3. 核心特性与用法(1编程客