From patchwork Fri Nov 14 18:17:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 410961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 72BDA1400D5 for ; Sat, 15 Nov 2014 05:21:02 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=DgYP37d6Yh3Y6pKKwUtZOsY/s62WY3EO26uljTptZIKZdi pKOWZ0XEubS8xC6WZAAFJsYCF/sidcBrplChRbQRa69GEaQoqHHLfeZ8BPXfPSrp Qsf4qlmtwE4jvHp61GZAqNFc9iene9/VQnRM/cNC8UVfjnVQk2eNjyJ4GPyXM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=dNM6etdC2XjNvj0xj1W+bjhPFpM=; b=JjGEiV6vXg4bpNj2495B Qh1wagXN/yT7owIHepfNYoUt+5+nlmlsOTdVN5cFY60KsctLb+2MAsKtCyrgFo+Q /5eUoJUjbfV3l/smlURsRpba8pCQ534qSQTAcYMWGre/eMdOe7Jb2onMYqPF/88/ YJMOEnJkQlgvvRrTMED//k0= Received: (qmail 7297 invoked by alias); 14 Nov 2014 18:20:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7287 invoked by uid 89); 14 Nov 2014 18:20:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Nov 2014 18:20:50 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XpLUE-0003I7-ND from Bernd_Schmidt@mentor.com for gcc-patches@gcc.gnu.org; Fri, 14 Nov 2014 10:20:47 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.181.6; Fri, 14 Nov 2014 18:20:45 +0000 Message-ID: <5466473A.1090809@codesourcery.com> Date: Fri, 14 Nov 2014 19:17:30 +0100 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.0 MIME-Version: 1.0 To: GCC Patches Subject: ptx debugging patch The situation with debugging on ptx is a little strange - it allows .file and .loc directives for line numbers, and it provides a way to define dwarf2 debug sections - but as far as I can tell, there's no way of putting useful or accurate information into the latter. There's also the slight problem that the data output directives used within those sections differ from the ones used everywhere else in ptx code. The following patch adds a variant of dwarf2 debugging that supports just line numbers. I'll need to update the nvptx-as from my tools package, since ptxas is picky and does not allow .file directives within functions, so some more reordering of the assembly output is required. How does this look? Testing currently in progress. An alternative would be to make a PTX_DEBUGGING_OUTPUT macro and a corresponding file cut down from dwarf2out. Bernd * config/nvptx/nvptx.c (nvptx_option_override): Don't override debug options. * config/nvptx/nvptx.h (DWARF2_LINENO_DEBUGGING_INFO): Define. * config/nvptx/nvptx.h (DWARF2_DEBUGGING_INFO): Don't define. * debug.h (dwarf2_lineno_debug_hooks): Declare. * toplev.c (process_options): Add a case for it. * dwarf2out.c (dwarf2_lineno_debug_hooks): New variable. (dwarf2out_init): Skip most initializations if DWARF2_LINENO_DEBUGGING_INFO, but set cur_line_info_table in that case. * defaults.h (PREFERRED_DEBUGGING_TYPE): Also use DWARF2_DEBUG if DWARF2_LINENO_DEBUGGING_INFO. * opts.c (set_debug_level): Likewise. diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index c1fd271..1778570 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -83,8 +83,6 @@ nvptx_option_override (void) flag_toplevel_reorder = 1; /* Assumes that it will see only hard registers. */ flag_var_tracking = 0; - write_symbols = NO_DEBUG; - debug_info_level = DINFO_LEVEL_NONE; declared_fndecls_htab = htab_create_ggc (17, htab_hash_pointer, htab_eq_pointer, NULL); diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index c222375..3d874b4 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -333,7 +333,7 @@ struct GTY(()) machine_function /* Misc. */ -#define DWARF2_DEBUGGING_INFO 1 +#define DWARF2_LINENO_DEBUGGING_INFO 1 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \ ((VALUE) = GET_MODE_BITSIZE ((MODE)), 2) diff --git a/gcc/debug.h b/gcc/debug.h index 3ac7976..7a351bd 100644 --- a/gcc/debug.h +++ b/gcc/debug.h @@ -169,6 +169,7 @@ extern const struct gcc_debug_hooks dbx_debug_hooks; extern const struct gcc_debug_hooks sdb_debug_hooks; extern const struct gcc_debug_hooks xcoff_debug_hooks; extern const struct gcc_debug_hooks dwarf2_debug_hooks; +extern const struct gcc_debug_hooks dwarf2_lineno_debug_hooks; extern const struct gcc_debug_hooks vmsdbg_debug_hooks; /* Dwarf2 frame information. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index d2609e7..1ad257a 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -912,7 +912,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #elif defined SDB_DEBUGGING_INFO #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG -#elif defined DWARF2_DEBUGGING_INFO +#elif defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG #elif defined VMS_DEBUGGING_INFO diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index b16883f..ac7968a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -2497,6 +2497,40 @@ const struct gcc_debug_hooks dwarf2_debug_hooks = 1, /* start_end_main_source_file */ TYPE_SYMTAB_IS_DIE /* tree_type_symtab_field */ }; + +const struct gcc_debug_hooks dwarf2_lineno_debug_hooks = +{ + dwarf2out_init, + debug_nothing_charstar, + debug_nothing_void, + debug_nothing_int_charstar, + debug_nothing_int_charstar, + debug_nothing_int_charstar, + debug_nothing_int, + debug_nothing_int_int, /* begin_block */ + debug_nothing_int_int, /* end_block */ + debug_true_const_tree, /* ignore_block */ + dwarf2out_source_line, /* source_line */ + debug_nothing_int_charstar, /* begin_prologue */ + debug_nothing_int_charstar, /* end_prologue */ + debug_nothing_int_charstar, /* begin_epilogue */ + debug_nothing_int_charstar, /* end_epilogue */ + debug_nothing_tree, /* begin_function */ + debug_nothing_int, /* end_function */ + debug_nothing_tree, /* function_decl */ + debug_nothing_tree, /* global_decl */ + debug_nothing_tree_int, /* type_decl */ + debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree, /* deferred_inline_function */ + debug_nothing_tree, /* outlining_inline_function */ + debug_nothing_rtx_code_label, /* label */ + debug_nothing_int, /* handle_pch */ + debug_nothing_rtx_insn, /* var_location */ + debug_nothing_void, /* switch_text_section */ + debug_nothing_tree_tree, /* set_name */ + 0, /* start_end_main_source_file */ + TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */ +}; /* NOTE: In the comments in this file, many references are made to "Debugging Information Entries". This term is abbreviated as `DIE' @@ -22363,6 +22397,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) /* Allocate the file_table. */ file_table = hash_table::create_ggc (50); +#ifndef DWARF2_LINENO_DEBUGGING_INFO /* Allocate the decl_die_table. */ decl_die_table = hash_table::create_ggc (10); @@ -22478,10 +22513,15 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) switch_to_section (text_section); ASM_OUTPUT_LABEL (asm_out_file, text_section_label); +#endif /* Make sure the line number table for .text always exists. */ text_section_line_info = new_line_info_table (); text_section_line_info->end_label = text_end_label; + +#ifdef DWARF2_LINENO_DEBUGGING_INFO + cur_line_info_table = text_section_line_info; +#endif } /* Called before compile () starts outputtting functions, variables diff --git a/gcc/opts.c b/gcc/opts.c index d22882b..d25852b 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2194,7 +2194,7 @@ set_debug_level (enum debug_info_type type, int extended, const char *arg, if (extended == 2) { -#ifdef DWARF2_DEBUGGING_INFO +#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO opts->x_write_symbols = DWARF2_DEBUG; #elif defined DBX_DEBUGGING_INFO opts->x_write_symbols = DBX_DEBUG; diff --git a/gcc/toplev.c b/gcc/toplev.c index 2ed76bc..a809a36 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1488,6 +1488,10 @@ process_options (void) else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG) debug_hooks = &vmsdbg_debug_hooks; #endif +#ifdef DWARF2_LINENO_DEBUGGING_INFO + else if (write_symbols == DWARF2_DEBUG) + debug_hooks = &dwarf2_lineno_debug_hooks; +#endif else error ("target system does not support the %qs debug format", debug_type_names[write_symbols]);