public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Potharla, Rupesh" <Rupesh.Potharla@amd.com>
Cc: "George, Jini Susan" <JiniSusan.George@amd.com>,
	"Parasuraman, Hariharan" <Hariharan.Parasuraman@amd.com>,
	"Natarajan, Kavitha" <Kavitha.Natarajan@amd.com>,
	"Potharla, Rupesh via Binutils" <binutils@sourceware.org>
Subject: Re: [PATCH] bfd: Fix issues with files in debug_line table with dwarf5.
Date: Mon, 25 Jul 2022 16:30:38 +0200	[thread overview]
Message-ID: <2a305d77-905b-c1e9-c36a-6c25766c5a98@suse.com> (raw)
In-Reply-To: <DM6PR12MB4219BAE1F52ED5DF8E25C954E7819@DM6PR12MB4219.namprd12.prod.outlook.com>

On 05.07.2022 08:46, Potharla, Rupesh via Binutils wrote:
> Patch Inline:

Please note how the inlined version has extra blank lines inserted
between any two actual lines, whereas the attached variant is a
*.docx rather than a *.patch. I'll use the inlined version for the
few comments / questions I have, but you will want to sort your mail
setup.

> --- a/bfd/dwarf2.c
> 
> +++ b/bfd/dwarf2.c
> 
> @@ -1369,7 +1369,7 @@ read_indexed_address (uint64_t idx, struct comp_unit *unit)
> 
>                             &file->dwarf_addr_buffer, &file->dwarf_addr_size))
> 
>      return 0;
> 
> -  if (_bfd_mul_overflow (idx, unit->offset_size, &offset))
> 
> +  if (_bfd_mul_overflow (idx, unit->addr_size, &offset))
> 
>      return 0;
> 
>    offset += unit->dwarf_addr_offset;
> 
> @@ -1380,9 +1380,9 @@ read_indexed_address (uint64_t idx, struct comp_unit *unit)
> 
>    info_ptr = file->dwarf_addr_buffer + offset;
> 
> -  if (unit->offset_size == 4)
> 
> +  if (unit->addr_size == 4)
> 
>      return bfd_get_32 (unit->abfd, info_ptr);
> 
> -  else if (unit->offset_size == 8)
> 
> +  else if (unit->addr_size == 8)
> 
>      return bfd_get_64 (unit->abfd, info_ptr);
> 
>    else
> 
>      return 0;
> 

I have to admit that I don't see the (direct) connection to the
patch title here - are these changes perhaps better to form a
standalone change?

> @@ -1951,6 +1952,8 @@ concat_filename (struct line_info_table *table, unsigned int file)
> 
> {
> 
>    char *filename;
> 
> +  if (table->version >= 5)
> 
> +    file = file + 1;
> 

Don't you need either this ...

>    if (table == NULL || file - 1 >= table->num_files)
> 
>      {
> 
>        /* FILE == 0 means unknown.  */
> 
> @@ -2579,10 +2582,8 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp,
> 
>                }
> 
>            }
> 
> -      /* Skip the first "zero entry", which is the compilation dir/file.  */
> 
> -      if (datai != 0)
> 
> -           if (!callback (table, fe.name, fe.dir, fe.time, fe.size))
> 
> -             return false;
> 
> +      if (!callback (table, fe.name, fe.dir, fe.time, fe.size))
> 
> +          return false;
> 
>      }

... or this adjustment, but not both at the same time?

> --- /dev/null
> 
> +++ b/binutils/testsuite/binutils-all/addr2line.exp
> 
> @@ -0,0 +1,59 @@
> 
> +#   Copyright (C) 2018-2022 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, write to the Free Software
> 
> +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
> 
> +
> 
> +    global $NM
> 
> +    global $ADDR2LINE
> 
> +
> 
> +    set testname "addr2line"
> 
> +    if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {

Could you help me spotting where the Dwarf version to be used it coming
from? (Ideally the new test would be run once for v5 and once with an
earlier version; yet more ideally once per version. Yet I'm not sure
how easy this would be to achieve.)

> +        verbose "Unable to compile test file."
> 
> +        untested "addr2line"
> 
> +        return
> 
> +    }
> 
> +
> 
> +    #testcase for default option.
> 
> +    set output [binutils_run $NM "tmpdir/testprog"]
> 
> +    regexp -line {^[0-9]+\s+[A-Z]\s+main} $output contents
> 
> +    set list [regexp -inline -all -- {\S+} $contents]
> 
> +
> 
> +    set got [binutils_run $ADDR2LINE "-e tmpdir/testprog  [lindex $list 0]"]
> 
> +    set want "$srcdir/$subdir/testprog.c:\[0-9\]+"
> 
> +    if ![regexp $want $got] then {
> 
> +        fail "$testname $got\n"
> 
> +    } else {
> 
> +        pass "$testname"
> 
> +    }

I have to admit that I can't really spot what you're actually looking
for, and hence whether that's sufficient for a test. Rather than all of
this open-coding, did you consider using the pre-cooked run_dump_test?

Jan

  parent reply	other threads:[~2022-07-25 14:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05  6:46 Potharla, Rupesh
2022-07-20  5:03 ` Potharla, Rupesh
2022-07-20  7:59   ` Jan Beulich
2022-07-25 14:30 ` Jan Beulich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-05-09  7:03 Potharla, Rupesh
2022-05-18 12:36 ` Jan Beulich
2022-05-25  4:20   ` Potharla, Rupesh
2022-05-25  6:18     ` Jan Beulich
2022-05-31 18:07       ` Potharla, Rupesh
2022-07-05  5:05         ` Potharla, Rupesh
2022-07-05  6:06           ` Jan Beulich

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=2a305d77-905b-c1e9-c36a-6c25766c5a98@suse.com \
    --to=jbeulich@suse.com \
    --cc=Hariharan.Parasuraman@amd.com \
    --cc=JiniSusan.George@amd.com \
    --cc=Kavitha.Natarajan@amd.com \
    --cc=Rupesh.Potharla@amd.com \
    --cc=binutils@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).