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/dwarf2ctf.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/dwarf2ctf.cc')
-rw-r--r-- | gcc/dwarf2ctf.cc | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/gcc/dwarf2ctf.cc b/gcc/dwarf2ctf.cc index dc59569..8f9e2fa 100644 --- a/gcc/dwarf2ctf.cc +++ b/gcc/dwarf2ctf.cc @@ -933,30 +933,6 @@ gen_ctf_type (ctf_container_ref ctfc, dw_die_ref die) return type_id; } -/* Prepare for output and write out the CTF debug information. */ - -static void -ctf_debug_finalize (const char *filename, bool btf) -{ - if (btf) - { - btf_output (filename); - /* btf_finalize when compiling BPF applciations gets deallocated by the - BPF target in bpf_file_end. */ - if (btf_debuginfo_p () && !btf_with_core_debuginfo_p ()) - btf_finalize (); - } - - else - { - /* Emit the collected CTF information. */ - ctf_output (filename); - - /* Reset the CTF state. */ - ctf_finalize (); - } -} - bool ctf_do_die (dw_die_ref die) { @@ -996,27 +972,27 @@ ctf_debug_init (void) add_name_attribute (ctf_unknown_die, "unknown"); } -/* Preprocess the CTF debug information after initialization. */ - -void -ctf_debug_init_postprocess (bool btf) -{ - /* Only BTF requires postprocessing right after init. */ - if (btf) - btf_init_postprocess (); -} - /* Early finish CTF/BTF debug info. */ void ctf_debug_early_finish (const char * filename) { - /* Emit CTF debug info early always. */ - if (ctf_debug_info_level > CTFINFO_LEVEL_NONE - /* Emit BTF debug info early if CO-RE relocations are not - required. */ - || (btf_debuginfo_p () && !btf_with_core_debuginfo_p ())) - ctf_debug_finalize (filename, btf_debuginfo_p ()); + /* Emit the collected CTF information. */ + if (ctf_debug_info_level > CTFINFO_LEVEL_NONE) + ctf_output (filename); + + /* If emitting BTF, start translation to BTF. */ + if (btf_debuginfo_p ()) + { + btf_early_finish (); + + /* For LTO builds, also emit BTF now. */ + if (flag_lto && !in_lto_p) + btf_finish (filename); + } + else + /* Otherwise, done with the CTF container. */ + ctf_finalize (); } /* Finish CTF/BTF debug info emission. */ @@ -1024,11 +1000,10 @@ ctf_debug_early_finish (const char * filename) void ctf_debug_finish (const char * filename) { - /* Emit BTF debug info here when CO-RE relocations need to be generated. - BTF with CO-RE relocations needs to be generated when CO-RE is in effect - for the BPF target. */ - if (btf_debuginfo_p () && btf_with_core_debuginfo_p ()) - ctf_debug_finalize (filename, btf_debuginfo_p ()); + /* Emit BTF late, unless this is an LTO build in which case it was + already done early. */ + if (btf_debuginfo_p () && !flag_lto) + btf_finish (filename); } #include "gt-dwarf2ctf.h" |