gcc/gcc/dwarf2ctf.h
Indu Bhagat 849d5f5929 dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase
DWARF generation is split between early and late phases when LTO is in effect.
This poses challenges for CTF/BTF generation especially if late debug info
generation is desirable, as turns out to be the case for BPF CO-RE.

The approach taken here in this patch is:

1. LTO is disabled for BPF CO-RE
The reason to disable LTO for BPF CO-RE is that if LTO is in effect, BPF CO-RE
relocations need to be generated in the LTO link phase _after_ the optimizations
are done. This means we need to devise way to combine early and late BTF. At
this time, in absence of linker support for BTF sections, it makes sense to
steer clear of LTO for BPF CO-RE and bypass the issue.

2. The BPF backend updates the write_symbols with BPF_WITH_CORE_DEBUG to convey
the case that BTF with CO-RE support needs to be generated.  This information
is used by the debug info emission routines to defer the emission of BTF/CO-RE
until dwarf2out_finish.

So, in other words,

dwarf2out_early_finish
  - Always emit CTF here.
  - if (BTF && !BTF_WITH_CORE), emit BTF now.

dwarf2out_finish
  - if (BTF_WITH_CORE) emit BTF now.

gcc/ChangeLog:

	* dwarf2ctf.c (ctf_debug_finalize): Make it static.
	(ctf_debug_early_finish): New definition.
	(ctf_debug_finish): Likewise.
	* dwarf2ctf.h (ctf_debug_finalize): Remove declaration.
	(ctf_debug_early_finish): New declaration.
	(ctf_debug_finish): Likewise.
	* dwarf2out.c (dwarf2out_finish): Invoke ctf_debug_finish.
	(dwarf2out_early_finish): Invoke ctf_debug_early_finish.
2021-09-07 11:18:54 -07:00

55 lines
1.9 KiB
C

/* dwarf2ctf.h - DWARF interface for CTF/BTF generation.
Copyright (C) 2021 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* This file contains declarations and prototypes to define an interface
between DWARF and CTF/BTF generation. */
#ifndef GCC_DWARF2CTF_H
#define GCC_DWARF2CTF_H 1
#include "dwarf2out.h"
#include "flags.h"
/* Debug Format Interface. Used in dwarf2out.c. */
extern void ctf_debug_init (void);
extern void ctf_debug_init_postprocess (bool);
extern bool ctf_do_die (dw_die_ref);
extern void ctf_debug_early_finish (const char *);
extern void ctf_debug_finish (const char *);
/* Wrappers for CTF/BTF to fetch information from GCC DWARF DIE. Used in
ctfc.c.
A CTF container does not store all debug information internally. Some of
the info is fetched indirectly via the DIE reference available in each CTF
container entry.
These functions will be used by the CTF container to give access to its
consumers (CTF/BTF) to various debug information available in DWARF DIE.
Direct access to debug information in GCC dwarf structures by the consumers
of CTF/BTF information is not ideal. */
/* Source location information. */
extern const char * ctf_get_die_loc_file (dw_die_ref);
extern unsigned int ctf_get_die_loc_line (dw_die_ref);
extern unsigned int ctf_get_die_loc_col (dw_die_ref);
#endif /* GCC_DWARF2CTF_H */