From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7824) id 98CB73857404; Thu, 20 May 2021 19:40:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98CB73857404 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: David Faust To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-950] dwarf: new dwarf_debuginfo_p predicate X-Act-Checkin: gcc X-Git-Author: Indu Bhagat X-Git-Refname: refs/heads/master X-Git-Oldrev: 459d84e9b6e925922246b6aff76a5202b1d4d4ba X-Git-Newrev: 66168f96f07b12bbe0beb6e0e988818f624d56bd Message-Id: <20210520194011.98CB73857404@sourceware.org> Date: Thu, 20 May 2021 19:40:11 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 19:40:11 -0000 https://gcc.gnu.org/g:66168f96f07b12bbe0beb6e0e988818f624d56bd commit r12-950-g66168f96f07b12bbe0beb6e0e988818f624d56bd Author: Indu Bhagat Date: Fri Apr 30 08:03:52 2021 -0700 dwarf: new dwarf_debuginfo_p predicate This patch introduces a dwarf_debuginfo_p predicate that abstracts and replaces complex checks on write_symbols. gcc/c-family/ChangeLog: * c-lex.c (init_c_lex): Use dwarf_debuginfo_p. gcc/ChangeLog: * config/c6x/c6x.c (c6x_output_file_unwind): Use dwarf_debuginfo_p. * config/darwin.c (darwin_override_options): Likewise. * config/i386/cygming.h (DBX_REGISTER_NUMBER): Likewise. * config/i386/darwin.h (DBX_REGISTER_NUMBER): Likewise. (DWARF2_FRAME_REG_OUT): Likewise. * config/mips/mips.c (mips_output_filename): Likewise. * config/rs6000/rs6000.c (rs6000_xcoff_declare_function_name): Likewise. (rs6000_dbx_register_number): Likewise. * dbxout.c: Include flags.h. * dwarf2cfi.c (cfi_label_required_p): Likewise. (dwarf2out_do_frame): Likewise. * except.c: Include flags.h. * final.c (dwarf2_debug_info_emitted_p): Likewise. (final_scan_insn_1): Likewise. * flags.h (dwarf_debuginfo_p): New function declaration. * opts.c (dwarf_debuginfo_p): New function definition. * targhooks.c (default_debug_unwind_info): Use dwarf_debuginfo_p. * toplev.c (process_options): Likewise. Diff: --- gcc/c-family/c-lex.c | 4 ++-- gcc/config/c6x/c6x.c | 4 ++-- gcc/config/darwin.c | 3 ++- gcc/config/i386/cygming.h | 2 +- gcc/config/i386/darwin.h | 4 ++-- gcc/config/mips/mips.c | 3 ++- gcc/config/rs6000/rs6000.c | 4 ++-- gcc/dbxout.c | 1 + gcc/dwarf2cfi.c | 9 ++++----- gcc/except.c | 1 + gcc/final.c | 15 ++++++--------- gcc/flags.h | 4 ++++ gcc/opts.c | 8 ++++++++ gcc/targhooks.c | 2 +- gcc/toplev.c | 6 ++---- 15 files changed, 40 insertions(+), 30 deletions(-) diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 1c66ecd8fc4..c44e7a13489 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "stor-layout.h" #include "c-pragma.h" #include "debug.h" +#include "flags.h" #include "file-prefix-map.h" /* remap_macro_filename() */ #include "langhooks.h" #include "attribs.h" @@ -87,8 +88,7 @@ init_c_lex (void) /* Set the debug callbacks if we can use them. */ if ((debug_info_level == DINFO_LEVEL_VERBOSE - && (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG)) + && dwarf_debuginfo_p ()) || flag_dump_go_spec != NULL) { cb->define = cb_define; diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index e7e1d6c5d05..ce4949516cf 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -59,6 +59,7 @@ #include "regrename.h" #include "dumpfile.h" #include "builtins.h" +#include "flags.h" /* This file should be included last. */ #include "target-def.h" @@ -439,8 +440,7 @@ c6x_output_file_unwind (FILE * f) { if (flag_unwind_tables || flag_exceptions) { - if (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG) + if (dwarf_debuginfo_p ()) asm_fprintf (f, "\t.cfi_sections .debug_frame, .c6xabi.exidx\n"); else asm_fprintf (f, "\t.cfi_sections .c6xabi.exidx\n"); diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index c4016fe20ef..b160c23ea56 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "lto-section-names.h" #include "intl.h" #include "optabs.h" +#include "flags.h" /* Fix and Continue. @@ -3347,7 +3348,7 @@ darwin_override_options (void) && generating_for_darwin_version >= 9 && (flag_gtoggle ? (debug_info_level == DINFO_LEVEL_NONE) : (debug_info_level >= DINFO_LEVEL_NORMAL)) - && write_symbols == DWARF2_DEBUG) + && dwarf_debuginfo_p ()) flag_var_tracking_uninit = flag_var_tracking; /* Final check on PCI options; for Darwin these are not dependent on the PIE diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index cfbca34f996..ac458cdfee1 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -82,7 +82,7 @@ along with GCC; see the file COPYING3. If not see #undef DBX_REGISTER_NUMBER #define DBX_REGISTER_NUMBER(n) \ (TARGET_64BIT ? dbx64_register_map[n] \ - : (write_symbols == DWARF2_DEBUG \ + : (dwarf_debuginfo_p () \ ? svr4_dbx_register_map[n] : dbx_register_map[n])) /* Map gcc register number to DWARF 2 CFA column number. For 32 bit diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index afa9f1bb1a6..5312003a321 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -275,13 +275,13 @@ along with GCC; see the file COPYING3. If not see #undef DBX_REGISTER_NUMBER #define DBX_REGISTER_NUMBER(n) \ (TARGET_64BIT ? dbx64_register_map[n] \ - : write_symbols == DWARF2_DEBUG ? svr4_dbx_register_map[n] \ + : dwarf_debuginfo_p () ? svr4_dbx_register_map[n] \ : dbx_register_map[n]) /* Unfortunately, the 32-bit EH information also doesn't use the standard DWARF register numbers. */ #define DWARF2_FRAME_REG_OUT(n, for_eh) \ - (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n) \ + (! (for_eh) || !dwarf_debuginfo_p () || TARGET_64BIT ? (n) \ : (n) == 5 ? 4 \ : (n) == 4 ? 5 \ : (n) >= 11 && (n) <= 18 ? (n) + 1 \ diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index e5ba27331b0..1f1475cf400 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -65,6 +65,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "builtins.h" #include "rtl-iter.h" +#include "flags.h" /* This file should be included last. */ #include "target-def.h" @@ -9489,7 +9490,7 @@ mips_output_filename (FILE *stream, const char *name) { /* If we are emitting DWARF-2, let dwarf2out handle the ".file" directives. */ - if (write_symbols == DWARF2_DEBUG) + if (dwarf_debuginfo_p ()) return; else if (mips_output_filename_first_time) { diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index dfa517bba6c..af3cc90d7fd 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21588,7 +21588,7 @@ rs6000_xcoff_declare_function_name (FILE *file, const char *name, tree decl) { if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) xcoffout_declare_function (file, decl, buffer); - else if (write_symbols == DWARF2_DEBUG) + else if (dwarf_debuginfo_p ()) { name = (*targetm.strip_name_encoding) (name); fprintf (file, "\t.function .%s,.%s,2,0\n", name, name); @@ -23747,7 +23747,7 @@ rs6000_dbx_register_number (unsigned int regno, unsigned int format) { /* On some platforms, we use the standard DWARF register numbering for .debug_info and .debug_frame. */ - if ((format == 0 && write_symbols == DWARF2_DEBUG) || format == 1) + if ((format == 0 && dwarf_debuginfo_p ()) || format == 1) { #ifdef RS6000_USE_DWARF_NUMBERING if (regno <= 31) diff --git a/gcc/dbxout.c b/gcc/dbxout.c index d20527b2c19..6be282714cf 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -92,6 +92,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "expr.h" #include "file-prefix-map.h" /* remap_debug_filename() */ +#include "flags.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c index 362ff3fdac2..c27ac1960b0 100644 --- a/gcc/dwarf2cfi.c +++ b/gcc/dwarf2cfi.c @@ -39,7 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "expr.h" /* init_return_column_size */ #include "output.h" /* asm_out_file */ #include "debug.h" /* dwarf2out_do_frame, dwarf2out_do_cfi_asm */ - +#include "flags.h" /* dwarf_debuginfo_p */ /* ??? Poison these here until it can be done generically. They've been totally replaced in this file; make sure it stays that way. */ @@ -2289,8 +2289,7 @@ cfi_label_required_p (dw_cfi_ref cfi) if (dwarf_version == 2 && debug_info_level > DINFO_LEVEL_TERSE - && (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG)) + && dwarf_debuginfo_p ()) { switch (cfi->dw_cfi_opc) { @@ -3557,9 +3556,9 @@ bool dwarf2out_do_frame (void) { /* We want to emit correct CFA location expressions or lists, so we - have to return true if we're going to output debug info, even if + have to return true if we're going to generate debug info, even if we're not going to output frame or unwind info. */ - if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG) + if (dwarf_debuginfo_p ()) return true; if (saved_do_cfi_asm > 0) diff --git a/gcc/except.c b/gcc/except.c index a7902bbd555..d481a5ecb4e 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -144,6 +144,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "builtins.h" #include "tree-hash-traits.h" +#include "flags.h" static GTY(()) int call_site_base; diff --git a/gcc/final.c b/gcc/final.c index e0a70fcd830..38c3d704170 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -1428,7 +1428,8 @@ asm_str_count (const char *templ) static bool dwarf2_debug_info_emitted_p (tree decl) { - if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG) + /* When DWARF2 debug info is not generated internally. */ + if (!dwarf_debuginfo_p ()) return false; if (DECL_IGNORED_P (decl)) @@ -2306,10 +2307,8 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, break; case NOTE_INSN_BLOCK_BEG: - if (debug_info_level == DINFO_LEVEL_NORMAL - || debug_info_level == DINFO_LEVEL_VERBOSE - || write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG + if (debug_info_level >= DINFO_LEVEL_NORMAL + || dwarf_debuginfo_p () || write_symbols == VMS_DEBUG) { int n = BLOCK_NUMBER (NOTE_BLOCK (insn)); @@ -2344,10 +2343,8 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, case NOTE_INSN_BLOCK_END: maybe_output_next_view (seen); - if (debug_info_level == DINFO_LEVEL_NORMAL - || debug_info_level == DINFO_LEVEL_VERBOSE - || write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG + if (debug_info_level >= DINFO_LEVEL_NORMAL + || dwarf_debuginfo_p () || write_symbols == VMS_DEBUG) { int n = BLOCK_NUMBER (NOTE_BLOCK (insn)); diff --git a/gcc/flags.h b/gcc/flags.h index 34154931cac..cc7b79b1493 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -40,6 +40,10 @@ unsigned int debug_set_count (uint32_t w_symbols); const char * debug_set_names (uint32_t w_symbols); +/* Return true iff DWARF2 debug info is enabled. */ + +extern bool dwarf_debuginfo_p (); + extern void strip_off_ending (char *, int); extern int base_of_path (const char *path, const char **base_out); diff --git a/gcc/opts.c b/gcc/opts.c index 16042413af7..a751d95d32b 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -126,6 +126,14 @@ debug_set_names (uint32_t w_symbols) return df_set_names; } +/* Return TRUE iff dwarf2 debug info is enabled. */ + +bool +dwarf_debuginfo_p () +{ + return (write_symbols & DWARF2_DEBUG); +} + /* Parse the -femit-struct-debug-detailed option value and set the flag variables. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 2d2de0431f3..08f676b31f6 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -2062,7 +2062,7 @@ default_debug_unwind_info (void) /* Otherwise, only turn it on if dwarf2 debugging is enabled. */ #ifdef DWARF2_DEBUGGING_INFO - if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG) + if (dwarf_debuginfo_p ()) return UI_DWARF2; #endif diff --git a/gcc/toplev.c b/gcc/toplev.c index 1016fb9ee63..6a6ebe9bb8c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1527,8 +1527,7 @@ process_options (void) debug_nonbind_markers_p = (optimize && debug_info_level >= DINFO_LEVEL_NORMAL - && (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG) + && dwarf_debuginfo_p () && !(flag_selective_scheduling || flag_selective_scheduling2)); if (dwarf2out_as_loc_support == AUTODETECT_VALUE) @@ -1543,8 +1542,7 @@ process_options (void) debug_variable_location_views = (flag_var_tracking && debug_info_level >= DINFO_LEVEL_NORMAL - && (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG) + && dwarf_debuginfo_p () && !dwarf_strict && dwarf2out_as_loc_support && dwarf2out_as_locview_support);