gcc源代码分析,expand_call()函数和printf(Hello, world!\n);的关系

2024-01-02 22:58

本文主要是介绍gcc源代码分析,expand_call()函数和printf(Hello, world!\n);的关系,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

expand_call()函数在expr.c文件中。

下面是expand_call()函数的主要调试结果,记录之。

主要是加入了debug_tree()函数和debug_rtx()函数。

debug_tree()函数加入到了expand_expr()函数的开始。

debug_rtx()函数加入到了gen_rtx()函数的结束处。

emit_call_1()函数是何时调用的也能看出。emit_call_insn()是何时调用的也能看出。

主要的调试目的是expand_call()函数是如何生成rtx的?

既是如何一步步调用,在哪里调用gen_rtx()函数的?

当然只是针对hello.c文件中的:

printf("Hello, world!\n");

这一函数调用来分析的。


call_expr

expand_call
expand_expr code = 71
 <nop_expr 830d8
    type <pointer_type 9017c
        type <integer_type 90130 char readonly permanent QI
            size <integer_cst 81638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81608 literal permanent -128 precision 8 min <integer_cst 81608 -128>
            max <integer_cst 81620 literal permanent 127
            pointer_to_this <pointer_type 9017c>
        permanent unsigned SI
        size <integer_cst 8154c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <function_type 902c0>
    literal
    arg 0 <nop_expr 830c0
        type <pointer_type 87a44 type <integer_type 815bc char>
            permanent unsigned SI size <integer_cst 8154c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
            chain <array_type 87a90>
        literal
        arg 0 <addr_expr 830a8 type <pointer_type 93f58>
            literal
            arg 0 <string_cst 83014 type <array_type 93ef4>
                static literal "Hello, world!
"
expand_expr code = 71
 <nop_expr 830c0
    type <pointer_type 87a44
        type <integer_type 815bc char permanent QI
            size <integer_cst 81638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81608 literal permanent -128 precision 8 min <integer_cst 81608 -128>
            max <integer_cst 81620 literal permanent 127
            pointer_to_this <pointer_type 87a44> chain <integer_type 816a8 long int>
        permanent unsigned SI
        size <integer_cst 8154c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <array_type 87a90>
    literal
    arg 0 <addr_expr 830a8
        type <pointer_type 93f58 type <array_type 93ef4>
            unsigned SI size <integer_cst 8154c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
        literal
        arg 0 <string_cst 83014 type <array_type 93ef4>
            static literal "Hello, world!
"
expand_expr code = 74
 <addr_expr 830a8
    type <pointer_type 93f58
        type <array_type 93ef4 type <integer_type 815bc char>
            BLK
            size <integer_cst 93f40 literal 15
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81638 literal permanent 1 domain <integer_type 93ea8>
            pointer_to_this <pointer_type 93f58> chain <pointer_type 93f58>
        unsigned SI
        size <integer_cst 8154c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
    literal
    arg 0 <string_cst 83014 type <array_type 93ef4>
        static literal "Hello, world!
"
expand_expr code = 26
 <string_cst 83014
    type <array_type 93ef4
        type <integer_type 815bc char permanent QI
            size <integer_cst 81638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81608 literal permanent -128 precision 8 min <integer_cst 81608 -128>
            max <integer_cst 81620 literal permanent 127
            pointer_to_this <pointer_type 87a44> chain <integer_type 816a8 long int>
        BLK
        size <integer_cst 93f40 literal 15
        align 8 size_unit 8 sep_unit 8 symtab 0 sep <integer_cst 81638 1>
        domain <integer_type 93ea8 SI
            size <integer_cst 8154c literal permanent 4
            align 32 size_unit 8 sep_unit 32 symtab 0
            sep <integer_cst 83048 literal 0 precision 32 min <integer_cst 83048 0>
            max <integer_cst 83078 literal 14
        pointer_to_this <pointer_type 93f58> chain <pointer_type 93f58>
    static literal "Hello, world!
"
output_constant_def

(symbol_ref:SI ("*LC0"))

(mem:BLK (symbol_ref:SI ("*LC0")))
this this
addr_expr
force_operand 27
end addr_expr

(pre_dec:SI (reg:SI 7))

(mem:SI (pre_dec:SI (reg:SI 7)))

(set (mem:SI (pre_dec:SI (reg:SI 7)))
   (symbol_ref:SI ("*LC0")))

(insn_list 6 (nil))

(insn_list 2 (insn_list 6 (nil)))

(sequence[ ] )

(reg:SI 0)

(const_int 4)
emit_call_1 funexp symbol_ref

(mem:QI (symbol_ref/v:SI ("printf")))

(call (mem:QI (symbol_ref/v:SI ("printf")))
   (const_int 4))

(set (reg:SI 0)
   (call (mem:QI (symbol_ref/v:SI ("printf")))
       (const_int 4)))
emit_call_insn
end expand_call
c_expand_return

这篇关于gcc源代码分析,expand_call()函数和printf(Hello, world!\n);的关系的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

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编程客

Python函数作用域示例详解

《Python函数作用域示例详解》本文介绍了Python中的LEGB作用域规则,详细解析了变量查找的四个层级,通过具体代码示例,展示了各层级的变量访问规则和特性,对python函数作用域相关知识感兴趣... 目录一、LEGB 规则二、作用域实例2.1 局部作用域(Local)2.2 闭包作用域(Enclos

怎样通过分析GC日志来定位Java进程的内存问题

《怎样通过分析GC日志来定位Java进程的内存问题》:本文主要介绍怎样通过分析GC日志来定位Java进程的内存问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、GC 日志基础配置1. 启用详细 GC 日志2. 不同收集器的日志格式二、关键指标与分析维度1.

java中新生代和老生代的关系说明

《java中新生代和老生代的关系说明》:本文主要介绍java中新生代和老生代的关系说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、内存区域划分新生代老年代二、对象生命周期与晋升流程三、新生代与老年代的协作机制1. 跨代引用处理2. 动态年龄判定3. 空间分

MySQL count()聚合函数详解

《MySQLcount()聚合函数详解》MySQL中的COUNT()函数,它是SQL中最常用的聚合函数之一,用于计算表中符合特定条件的行数,本文给大家介绍MySQLcount()聚合函数,感兴趣的朋... 目录核心功能语法形式重要特性与行为如何选择使用哪种形式?总结深入剖析一下 mysql 中的 COUNT