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

相关文章

C/C++错误信息处理的常见方法及函数

《C/C++错误信息处理的常见方法及函数》C/C++是两种广泛使用的编程语言,特别是在系统编程、嵌入式开发以及高性能计算领域,:本文主要介绍C/C++错误信息处理的常见方法及函数,文中通过代码介绍... 目录前言1. errno 和 perror()示例:2. strerror()示例:3. perror(

kotlin中const 和val的区别及使用场景分析

《kotlin中const和val的区别及使用场景分析》在Kotlin中,const和val都是用来声明常量的,但它们的使用场景和功能有所不同,下面给大家介绍kotlin中const和val的区别,... 目录kotlin中const 和val的区别1. val:2. const:二 代码示例1 Java

Go标准库常见错误分析和解决办法

《Go标准库常见错误分析和解决办法》Go语言的标准库为开发者提供了丰富且高效的工具,涵盖了从网络编程到文件操作等各个方面,然而,标准库虽好,使用不当却可能适得其反,正所谓工欲善其事,必先利其器,本文将... 目录1. 使用了错误的time.Duration2. time.After导致的内存泄漏3. jsO

Kotlin 作用域函数apply、let、run、with、also使用指南

《Kotlin作用域函数apply、let、run、with、also使用指南》在Kotlin开发中,作用域函数(ScopeFunctions)是一组能让代码更简洁、更函数式的高阶函数,本文将... 目录一、引言:为什么需要作用域函数?二、作用域函China编程数详解1. apply:对象配置的 “流式构建器”最

Tomcat版本与Java版本的关系及说明

《Tomcat版本与Java版本的关系及说明》:本文主要介绍Tomcat版本与Java版本的关系及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Tomcat版本与Java版本的关系Tomcat历史版本对应的Java版本Tomcat支持哪些版本的pythonJ

Spring事务中@Transactional注解不生效的原因分析与解决

《Spring事务中@Transactional注解不生效的原因分析与解决》在Spring框架中,@Transactional注解是管理数据库事务的核心方式,本文将深入分析事务自调用的底层原理,解释为... 目录1. 引言2. 事务自调用问题重现2.1 示例代码2.2 问题现象3. 为什么事务自调用会失效3

找不到Anaconda prompt终端的原因分析及解决方案

《找不到Anacondaprompt终端的原因分析及解决方案》因为anaconda还没有初始化,在安装anaconda的过程中,有一行是否要添加anaconda到菜单目录中,由于没有勾选,导致没有菜... 目录问题原因问http://www.chinasem.cn题解决安装了 Anaconda 却找不到 An

Spring定时任务只执行一次的原因分析与解决方案

《Spring定时任务只执行一次的原因分析与解决方案》在使用Spring的@Scheduled定时任务时,你是否遇到过任务只执行一次,后续不再触发的情况?这种情况可能由多种原因导致,如未启用调度、线程... 目录1. 问题背景2. Spring定时任务的基本用法3. 为什么定时任务只执行一次?3.1 未启用

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

C++中::SHCreateDirectoryEx函数使用方法

《C++中::SHCreateDirectoryEx函数使用方法》::SHCreateDirectoryEx用于创建多级目录,类似于mkdir-p命令,本文主要介绍了C++中::SHCreateDir... 目录1. 函数原型与依赖项2. 基本使用示例示例 1:创建单层目录示例 2:创建多级目录3. 关键注