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

相关文章

Python中的Walrus运算符分析示例详解

《Python中的Walrus运算符分析示例详解》Python中的Walrus运算符(:=)是Python3.8引入的一个新特性,允许在表达式中同时赋值和返回值,它的核心作用是减少重复计算,提升代码简... 目录1. 在循环中避免重复计算2. 在条件判断中同时赋值变量3. 在列表推导式或字典推导式中简化逻辑

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

Python正则表达式语法及re模块中的常用函数详解

《Python正则表达式语法及re模块中的常用函数详解》这篇文章主要给大家介绍了关于Python正则表达式语法及re模块中常用函数的相关资料,正则表达式是一种强大的字符串处理工具,可以用于匹配、切分、... 目录概念、作用和步骤语法re模块中的常用函数总结 概念、作用和步骤概念: 本身也是一个字符串,其中

Java程序进程起来了但是不打印日志的原因分析

《Java程序进程起来了但是不打印日志的原因分析》:本文主要介绍Java程序进程起来了但是不打印日志的原因分析,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Java程序进程起来了但是不打印日志的原因1、日志配置问题2、日志文件权限问题3、日志文件路径问题4、程序

Java字符串操作技巧之语法、示例与应用场景分析

《Java字符串操作技巧之语法、示例与应用场景分析》在Java算法题和日常开发中,字符串处理是必备的核心技能,本文全面梳理Java中字符串的常用操作语法,结合代码示例、应用场景和避坑指南,可快速掌握字... 目录引言1. 基础操作1.1 创建字符串1.2 获取长度1.3 访问字符2. 字符串处理2.1 子字

C++使用printf语句实现进制转换的示例代码

《C++使用printf语句实现进制转换的示例代码》在C语言中,printf函数可以直接实现部分进制转换功能,通过格式说明符(formatspecifier)快速输出不同进制的数值,下面给大家分享C+... 目录一、printf 原生支持的进制转换1. 十进制、八进制、十六进制转换2. 显示进制前缀3. 指

shell编程之函数与数组的使用详解

《shell编程之函数与数组的使用详解》:本文主要介绍shell编程之函数与数组的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录shell函数函数的用法俩个数求和系统资源监控并报警函数函数变量的作用范围函数的参数递归函数shell数组获取数组的长度读取某下的

MySQL高级查询之JOIN、子查询、窗口函数实际案例

《MySQL高级查询之JOIN、子查询、窗口函数实际案例》:本文主要介绍MySQL高级查询之JOIN、子查询、窗口函数实际案例的相关资料,JOIN用于多表关联查询,子查询用于数据筛选和过滤,窗口函... 目录前言1. JOIN(连接查询)1.1 内连接(INNER JOIN)1.2 左连接(LEFT JOI

MySQL中FIND_IN_SET函数与INSTR函数用法解析

《MySQL中FIND_IN_SET函数与INSTR函数用法解析》:本文主要介绍MySQL中FIND_IN_SET函数与INSTR函数用法解析,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一... 目录一、功能定义与语法1、FIND_IN_SET函数2、INSTR函数二、本质区别对比三、实际场景案例分

Python 迭代器和生成器概念及场景分析

《Python迭代器和生成器概念及场景分析》yield是Python中实现惰性计算和协程的核心工具,结合send()、throw()、close()等方法,能够构建高效、灵活的数据流和控制流模型,这... 目录迭代器的介绍自定义迭代器省略的迭代器生产器的介绍yield的普通用法yield的高级用法yidle