diff options
author | David Faust <david.faust@oracle.com> | 2024-05-30 14:06:27 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2024-07-02 10:16:12 -0700 |
commit | d3f586ec50d3d502e0727e8307ae76770fdaee79 (patch) | |
tree | 090ef7cc5f395d3eb5245a6f437ae5aa533da282 /gcc/btfout.cc | |
parent | d04c5537f5ae4a3acd3f5135347d7e2d8c218811 (diff) | |
download | gcc-d3f586ec50d3d502e0727e8307ae76770fdaee79.zip gcc-d3f586ec50d3d502e0727e8307ae76770fdaee79.tar.gz gcc-d3f586ec50d3d502e0727e8307ae76770fdaee79.tar.bz2 |
ctf, btf: restructure CTF/BTF emission
This commit makes some structural changes to the CTF/BTF debug info
emission. In particular:
a) CTF is new always fully generated and emitted before any
BTF-related procedures are run. This means that BTF-related
functions can change, even irreversibly, the shared in-memory
representation used by the two formats without issue.
b) BTF generation has fewer entry points, and is cleanly divided
into early_finish and finish.
c) BTF is now always emitted at finish (called from dwarf2out_finish),
for all targets in non-LTO builds, rather than being emitted at
early_finish for targets other than BPF CO-RE. In LTO builds,
BTF is emitted at early_finish as before.
Note that this change alone does not alter the contents of BTF at
all, regardless of whether it would have previously been emitted at
early_finish or finish, because the calculation of the BTF to be
emitted is not moved by this patch, only the write-out.
The changes are transparent to both CTF and BTF emission.
gcc/
* btfout.cc (btf_init_postprocess): Rename to...
(btf_early_finish): ...this.
(btf_output): Rename to...
(btf_finish): ...this.
* ctfc.h: Analogous changes.
* dwarf2ctf.cc (ctf_debug_early_finish): Conditionally call
btf_early_finish, or ctf_finalize as appropriate. Emit BTF
here for LTO builds.
(ctf_debug_finish): Always call btf_finish here if generating
BTF info in non-LTO builds.
(ctf_debug_finalize, ctf_debug_init_postprocess): Delete.
* dwarf2out.cc (dwarf2out_early_finish): Remove call to
ctf_debug_init_postprocess.
Diffstat (limited to 'gcc/btfout.cc')
-rw-r--r-- | gcc/btfout.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 07f066a..d5e9f3b 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -1491,6 +1491,34 @@ btf_finalize (void) tu_ctfc = NULL; } +/* Initial entry point of BTF generation, called at early_finish () after + CTF information has possibly been output. Translate all CTF information + to BTF, and do any processing that must be done early, such as creating + BTF_KIND_FUNC records. */ + +void +btf_early_finish (void) +{ + btf_init_postprocess (); +} + +/* Late entry point for BTF generation, called from dwarf2out_finish (). + Complete and emit BTF information. */ + +void +btf_finish (const char * filename) +{ + btf_output (filename); + + /* If compiling for BPF with CO-RE info, we cannot deallocate until after the + contents of the .BTF.ext section are finalized, which happens very late in + BPF backend. Therefore, the deallocation (i.e. btf_finalize ()) is delayed + until TARGET_ASM_FILE_END for BPF CO-RE. */ + if (!btf_with_core_debuginfo_p ()) + btf_finalize (); +} + + /* Traversal function for all BTF_KIND_FUNC type records. */ bool |