Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Add gdb.dwarf2/fission-multi-cu-clang.exp
Date: Tue, 10 Nov 2020 14:21:23 -0500	[thread overview]
Message-ID: <09afb982-34dc-0488-1df7-7534042b787f@simark.ca> (raw)
In-Reply-To: <20201105164017.GA26390@delia>

On 2020-11-05 11:40 a.m., Tom de Vries wrote:
> Hi,
>
> Test-case gdb.dwarf2/fission-multi-cu.exp uses an .S file that is
> intended to represent output of clang -g -gsplit-dwarf -flto.
>
> PR26834 - "[gsplit-dwarf] Sharing .debug_line entry between CUs results in too
> many symtabs" is open about the fact that the test-case doesn't seem to be
> properly handled atm.
>
> The question is how serious that is:  the actual output of clang-10 -g
> -gsplit-dwarf -flto seems to be handled ok.  What seems more serious is that
> there's currently no test-case exercising the actual clang output.
>
> Add a dwarf assembly test-case that resembles clang-10 -g -gsplit-dwarf -flto
> output.

So, if gdb.dwarf2/fission-multi-cu.exp was meant to represent the output
of `clang -g -gsplit-dwarf -flto` but does it wrong, why not just fix
that test?  Or does it represent gcc's output, which is different from
clang's?

Concretely, what's the difference between the layout of the two
variants?

> diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.exp b/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.exp
> new file mode 100644
> index 0000000000..db8ef09f21
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.exp
> @@ -0,0 +1,285 @@
> +# Copyright 2020 Free Software Foundation, Inc.
> +
> +# This program 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 of the License, or
> +# (at your option) any later version.
> +#
> +# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

Can you add a short comment at the top of the exp file saying what the
test intends to test?

> +
> +load_lib dwarf.exp
> +
> +# We run objcopy locally to split out the .dwo file.
> +if [is_remote host] {
> +    return 0
> +}
> +
> +# This test can only be run on targets which support DWARF-2 and use gas.
> +if ![dwarf2_support] {
> +    return 0
> +}
> +
> +# This test can only be run on x86-64 targets.
> +if {![istarget x86_64-*] || ![is_lp64_target]} {
> +    return 0
> +}
> +
> +standard_testfile .c -dw.S
> +
> +# The sources we're pretending to compile.
> +set src1 fission-multi-cu1.c
> +set src2 fission-multi-cu2.c
> +
> +lassign \
> +    [function_range main \
> +	 "${srcdir}/${subdir}/${srcfile}"] \
> +    main_start main_length
> +
> +lassign \
> +    [function_range func \
> +	 "${srcdir}/${subdir}/${srcfile}"] \
> +    func_start func_length
> +
> +set debug_addr \
> +    [list \
> +	 ".Laddr_table_base0:" \
> +         "  .quad $func_start" \
> +         "  .quad $main_start"]
> +
> +set asm_file [standard_output_file $srcfile2]
> +Dwarf::assemble $asm_file {
> +    declare_labels Llines1 Llines2 int_type_cu1 int_type_cu2 Lmain Lfunc
> +    global srcdir subdir srcfile src1 src2
> +    global main_start main_length
> +    global func_start func_length
> +
> +    set dwo_file "fission-multi-cu-clang-dw.dwo"
> +
> +    set debug_gnu_pubtypes \
> +	[list \
> +	     ".long   .LpubTypes_end0-.LpubTypes_begin0" \
> +	     ".LpubTypes_begin0:" \
> +	     ".short  2                       # DWARF Version" \
> +	     ".long   .Lcu1_begin             # Offset of Compilation Unit Info" \
> +	     ".long   .Lcu1_end - .Lcu1_begin # Compilation Unit Length" \
> +	     \
> +	     ".long   $int_type_cu1 - .Lcu3_begin    # DIE offset" \
> +	     ".byte   144                     # Attributes: TYPE, STATIC" \
> +	     ".asciz  \"int\"                 # External Name" \
> +	     \
> +	     ".long   0                       # End Mark" \
> +	     ".LpubTypes_end0:" \
> +	     \
> +	     ".long   .LpubTypes_end1-.LpubTypes_begin1" \
> +	     ".LpubTypes_begin1:" \
> +	     ".short  2                       # DWARF Version" \
> +	     ".long   .Lcu2_begin             # Offset of Compilation Unit Info" \
> +	     ".long   .Lcu2_end - .Lcu2_begin # Compilation Unit Length" \
> +	     \
> +	     ".long   $int_type_cu2 - .Lcu4_begin    # DIE offset" \
> +	     ".byte   144                     # Attributes: TYPE, STATIC" \
> +	     ".asciz  \"int\"                 # External Name" \
> +	     \
> +	     ".long   0                       # End Mark" \
> +	     ".LpubTypes_end1:"]
> +
> +    set debug_gnu_pubnames \
> +	[list \
> +	     ".long   .LpubNames_end0-.LpubNames_begin0" \
> +	     ".LpubNames_begin0:" \
> +	     ".short  2                       # DWARF Version" \
> +	     ".long   .Lcu1_begin             # Offset of Compilation Unit Info" \
> +	     ".long   .Lcu1_end - .Lcu1_begin # Compilation Unit Length" \
> +	     \
> +	     ".long   $Lfunc - .Lcu3_begin     # DIE offset" \
> +	     ".byte   48                      # Attributes: FUNCTION, EXTERNAL" \
> +	     ".asciz  \"func\"                # External Name" \
> +	     \
> +	     ".long   0                       # End Mark" \
> +	     ".LpubNames_end0:" \
> +	     \
> +	     ".long   .LpubNames_end1-.LpubNames_begin1" \
> +	     ".LpubNames_begin1:" \
> +	     ".short  2                       # DWARF Version" \
> +	     ".long   .Lcu2_begin             # Offset of Compilation Unit Info" \
> +	     ".long   .Lcu2_end - .Lcu2_begin # Compilation Unit Length" \
> +	     \
> +	     ".long   $Lmain - .Lcu4_begin     # DIE offset" \
> +	     ".byte   48                      # Attributes: FUNCTION, EXTERNAL" \
> +	     ".asciz  \"main\"                # External Name" \
> +	     \
> +	     ".long   0                       # End Mark" \
> +	     ".LpubNames_end1:" \
> +	    ]
> +
> +    cu { } {
> +	compile_unit {
> +	    {language @DW_LANG_C}
> +	    {name $src1}
> +	    {stmt_list $Llines1 DW_FORM_sec_offset}
> +	    {MACRO_AT_range {func}}
> +	    {GNU_addr_base .Laddr_table_base0}
> +	    {GNU_pubnames 1}
> +	    {GNU_dwo_name $dwo_file}
> +	    {DW_AT_GNU_dwo_id 0x1df972c106d3763d}
> +	} {
> +	}
> +    }
> +
> +    cu {} {
> +	compile_unit {
> +	    {language @DW_LANG_C}
> +	    {name $src2}
> +	    {stmt_list $Llines2 DW_FORM_sec_offset}
> +	    {MACRO_AT_range {main}}
> +	    {GNU_addr_base .Laddr_table_base0}
> +	    {GNU_pubnames 1}
> +	    {GNU_dwo_name $dwo_file}
> +	    {DW_AT_GNU_dwo_id  0xa9964b563d050e18}
> +	} {
> +	}
> +    }
> +
> +    lines {version 2} Llines1 {
> +	include_dir "${srcdir}/${subdir}"
> +	file_name $src1 1
> +
> +	program {
> +	    {DW_LNE_set_address $func_start}
> +	    {line 20}
> +	    {DW_LNS_copy}
> +
> +	    {DW_LNE_set_address func_label}
> +	    {line 21}
> +	    {DW_LNS_copy}
> +
> +	    {DW_LNE_set_address func_label_2}
> +	    {DW_LNE_end_sequence}
> +	}
> +    }
> +
> +    lines {version 2} Llines2 {
> +	include_dir "${srcdir}/${subdir}"
> +	file_name $src2 1
> +
> +	program {
> +	    {DW_LNE_set_address $main_start}
> +	    {line 22}
> +	    {DW_LNS_copy}
> +
> +	    {DW_LNE_set_address main_label}
> +	    {line 23}
> +	    {DW_LNS_copy}
> +
> +	    {DW_LNE_set_address main_label_2}
> +	    {DW_LNE_end_sequence}
> +	}
> +    }
> +
> +    _defer_output .debug_addr {
> +	global debug_addr
> +	_emit [join $debug_addr "\n"]
> +    }
> +
> +    _defer_output .debug_gnu_pubnames {
> +	_emit [join $debug_gnu_pubnames "\n"]
> +    }
> +
> +    _defer_output .debug_gnu_pubtype {
> +	_emit [join $debug_gnu_pubtypes "\n"]
> +    }
> +
> +    cu { fission first } {

After reading the previous patches, I didn't really understand how
what's going on with "fission first" and "fission last" and how it
interacts with share_abbrev.  Can you give me a very brief summary of
how the two .dwo are generated?

> +	compile_unit {
> +	    {language @DW_LANG_C}
> +	    {name $src1}
> +	    {GNU_dwo_name $dwo_file}
> +	    {DW_AT_GNU_dwo_id  0x1df972c106d3763d}
> +	} {
> +	    Lfunc: subprogram {
> +		{external 1 flag}
> +		{name func}
> +		{low_pc 0 DW_FORM_GNU_addr_index}
> +		{high_pc $func_length DW_FORM_data4}
> +		{type :$int_type_cu1}
> +		{decl_file 1 udata}
> +	    } {
> +                DW_TAG_formal_parameter {
> +                    {type :$int_type_cu1}
> +                    {name arg}
> +		    {DW_AT_const_value -1 DW_FORM_sdata}
> +                }
> +	    }
> +	    int_type_cu1: base_type {
> +		{name "int"}
> +		{encoding @DW_ATE_signed}
> +		{byte_size 4 DW_FORM_sdata}
> +	    }
> +	}
> +    }
> +
> +    cu { fission last } {
> +	compile_unit {
> +	    {language @DW_LANG_C}
> +	    {name $src2}
> +	    {GNU_dwo_name $dwo_file}
> +	    {DW_AT_GNU_dwo_id  0xa9964b563d050e18}
> +	} {
> +	    Lmain: subprogram {
> +		{external 1 flag}
> +		{name main}
> +		{low_pc 1 DW_FORM_GNU_addr_index}
> +		{high_pc $main_length DW_FORM_data4}
> +		{type :$int_type_cu2}
> +		{decl_file 1 udata}
> +	    }
> +	    int_type_cu2: base_type {
> +		{name "int"}
> +		{encoding @DW_ATE_signed}
> +		{byte_size 4 DW_FORM_sdata}
> +	    }
> +	}
> +    }
> +
> +}
> +
> +if [build_executable_from_fission_assembler \
> +	"$testfile.exp" "$binfile" [list $asm_file] [list $srcfile] {nodebug}] {
> +    return -1
> +}
> +
> +
> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir

clean_restart?

Simon

  reply	other threads:[~2020-11-10 19:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 16:40 Tom de Vries
2020-11-10 19:21 ` Simon Marchi [this message]
2020-11-11  9:18   ` [PATCH][gdb/testsuite] Use clean_restart where possible Tom de Vries
2020-11-11 15:49     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09afb982-34dc-0488-1df7-7534042b787f@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox