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

相关文章

Mysql的主从同步/复制的原理分析

《Mysql的主从同步/复制的原理分析》:本文主要介绍Mysql的主从同步/复制的原理分析,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录为什么要主从同步?mysql主从同步架构有哪些?Mysql主从复制的原理/整体流程级联复制架构为什么好?Mysql主从复制注意

Python中bisect_left 函数实现高效插入与有序列表管理

《Python中bisect_left函数实现高效插入与有序列表管理》Python的bisect_left函数通过二分查找高效定位有序列表插入位置,与bisect_right的区别在于处理重复元素时... 目录一、bisect_left 基本介绍1.1 函数定义1.2 核心功能二、bisect_left 与

java -jar命令运行 jar包时运行外部依赖jar包的场景分析

《java-jar命令运行jar包时运行外部依赖jar包的场景分析》:本文主要介绍java-jar命令运行jar包时运行外部依赖jar包的场景分析,本文给大家介绍的非常详细,对大家的学习或工作... 目录Java -jar命令运行 jar包时如何运行外部依赖jar包场景:解决:方法一、启动参数添加: -Xb

java中BigDecimal里面的subtract函数介绍及实现方法

《java中BigDecimal里面的subtract函数介绍及实现方法》在Java中实现减法操作需要根据数据类型选择不同方法,主要分为数值型减法和字符串减法两种场景,本文给大家介绍java中BigD... 目录Java中BigDecimal里面的subtract函数的意思?一、数值型减法(高精度计算)1.

C++/类与对象/默认成员函数@构造函数的用法

《C++/类与对象/默认成员函数@构造函数的用法》:本文主要介绍C++/类与对象/默认成员函数@构造函数的用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录名词概念默认成员函数构造函数概念函数特征显示构造函数隐式构造函数总结名词概念默认构造函数:不用传参就可以

C++类和对象之默认成员函数的使用解读

《C++类和对象之默认成员函数的使用解读》:本文主要介绍C++类和对象之默认成员函数的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、默认成员函数有哪些二、各默认成员函数详解默认构造函数析构函数拷贝构造函数拷贝赋值运算符三、默认成员函数的注意事项总结一

Apache 高级配置实战之从连接保持到日志分析的完整指南

《Apache高级配置实战之从连接保持到日志分析的完整指南》本文带你从连接保持优化开始,一路走到访问控制和日志管理,最后用AWStats来分析网站数据,对Apache配置日志分析相关知识感兴趣的朋友... 目录Apache 高级配置实战:从连接保持到日志分析的完整指南前言 一、Apache 连接保持 - 性

Python函数返回多个值的多种方法小结

《Python函数返回多个值的多种方法小结》在Python中,函数通常用于封装一段代码,使其可以重复调用,有时,我们希望一个函数能够返回多个值,Python提供了几种不同的方法来实现这一点,需要的朋友... 目录一、使用元组(Tuple):二、使用列表(list)三、使用字典(Dictionary)四、 使

Linux中的more 和 less区别对比分析

《Linux中的more和less区别对比分析》在Linux/Unix系统中,more和less都是用于分页查看文本文件的命令,但less是more的增强版,功能更强大,:本文主要介绍Linu... 目录1. 基础功能对比2. 常用操作对比less 的操作3. 实际使用示例4. 为什么推荐 less?5.

spring-gateway filters添加自定义过滤器实现流程分析(可插拔)

《spring-gatewayfilters添加自定义过滤器实现流程分析(可插拔)》:本文主要介绍spring-gatewayfilters添加自定义过滤器实现流程分析(可插拔),本文通过实例图... 目录需求背景需求拆解设计流程及作用域逻辑处理代码逻辑需求背景公司要求,通过公司网络代理访问的请求需要做请