首页 > 代码库 > gcc源代码分析,expand_call()函数和printf("Hello, world!\n");的关系
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_callexpand_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");的关系
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。