From: "Potharla, Rupesh" <Rupesh.Potharla@amd.com>
To: Jan Beulich <jbeulich@suse.com>,
"Potharla, Rupesh via Binutils" <binutils@sourceware.org>
Cc: "George, Jini Susan" <JiniSusan.George@amd.com>,
"Parasuraman, Hariharan" <Hariharan.Parasuraman@amd.com>,
"Natarajan, Kavitha" <Kavitha.Natarajan@amd.com>
Subject: RE: [PATCH] bfd: Fix issues with files in debug_line table with dwarf5.
Date: Wed, 25 May 2022 04:20:04 +0000 [thread overview]
Message-ID: <DM6PR12MB4219508DD0B57228E5A4E4BEE7D69@DM6PR12MB4219.namprd12.prod.outlook.com> (raw)
In-Reply-To: <c96d5d20-10f3-8579-727e-10eebc1f0cb2@suse.com>
[-- Attachment #1: Type: text/plain, Size: 6624 bytes --]
[Public]
Thanks Jan for reviewing the code changes,
>> - /* 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;
>> }
>
>How come this change doesn't add a version check?
>
Since the function read_formatted_entries is only called for version 5 in the file, I thought the version check is not needed. Now I have added the condition and updated the patch.
>To help being certain this is the right way of changing things, can you please
>add up to two testcases (readelf and/or objdump), one for a version < 5
>(unless one such already exists and hence it would be visible there that you
>don't unduly alter handling of those older versions) and one for version 5?
>
Readelf and objdump are not using dwarf2.c file under bfd directory these tools are using dwarf.c under binutils directory. Currently I am using addr2line to test and validate my code changes manually. There are no testcases for addr2line and I did not find any testcases for bfd library as well. Please let me know your suggestions .
Regards,
Rupesh P
---
bfd/dwarf2.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index f6b0183720b..c5b5d14fc9f 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1572,6 +1572,7 @@ struct line_info_table
unsigned int num_files;
unsigned int num_dirs;
unsigned int num_sequences;
+ unsigned int version;
char * comp_dir;
char ** dirs;
struct fileinfo* files;
@@ -1792,6 +1793,8 @@ concat_filename (struct line_info_table *table, unsigned int file)
{
char *filename;
+ if (table->version >= 5)
+ file = file + 1;
if (table == NULL || file - 1 >= table->num_files)
{
/* FILE == 0 means unknown. */
@@ -2414,7 +2417,7 @@ 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 (table->version < 5 && datai != 0)
if (!callback (table, fe.name, fe.dir, fe.time, fe.size))
return false;
}
@@ -2581,6 +2584,7 @@ decode_line_info (struct comp_unit *unit)
table->sequences = NULL;
table->lcl_head = NULL;
+ table->version = lh.version;
if (lh.version >= 5)
{
@@ -2623,7 +2627,12 @@ decode_line_info (struct comp_unit *unit)
/* State machine registers. */
bfd_vma address = 0;
unsigned char op_index = 0;
- char * filename = table->num_files ? concat_filename (table, 1) : NULL;
+ char *filename;
+ if (table->version >= 5)
+ filename = table->num_files ? concat_filename (table, 0) : NULL;
+ else
+ filename = table->num_files ? concat_filename (table, 1) : NULL;
+
unsigned int line = 1;
unsigned int column = 0;
unsigned int discriminator = 0;
--
2.17.1
>-----Original Message-----
>From: Jan Beulich <jbeulich@suse.com>
>Sent: Wednesday, May 18, 2022 6:07 PM
>To: Potharla, Rupesh <Rupesh.Potharla@amd.com>; Potharla, Rupesh via
>Binutils <binutils@sourceware.org>
>Cc: George, Jini Susan <JiniSusan.George@amd.com>; Parasuraman,
>Hariharan <Hariharan.Parasuraman@amd.com>; Natarajan, Kavitha
><Kavitha.Natarajan@amd.com>
>Subject: Re: [PATCH] bfd: Fix issues with files in debug_line table with dwarf5.
>
>[CAUTION: External Email]
>
>On 09.05.2022 09:03, Potharla, Rupesh via Binutils wrote:
>> [Public]
>>
>>
>>
>> While working on the implementation of DW_FORM_strx forms could not
>print file names even after the implementation of strx forms. I found an issue
>with adding the file names to the file table with dwarf5 and clang.
>>
>> With dwarf5 debug line version the file index is starting with zero, but the
>code is expecting it to be 1 which is the case with other dwarf versions.
>>
>> From the contents of .debug_line compiled with clang and dwarf5, the file
>names array index is starting with zero.
>>
>> standard_opcode_lengths[DW_LNS_set_isa] = 1 include_directories[ 0] =
>> "/home/rupesh/addr2line"
>> file_names[ 0]:
>> name: "prog1.c"
>> dir_index: 0
>> md5_checksum: da4ea4c312af96d39b13557acdf23f05
>>
>> Address Line Column File ISA Discriminator Flags
>> ------------------ ------ ------ ------ --- -------------
>> -------------
>>
>>
>> The below line skipping zero entry was added as part of commit
>19d80e5fec548e681c453d15b4ae5b49bc080acc is ignoring the file names in
>the zeroth index. I have no idea why this line was added. Removing the line is
>working for programs compiled with clang using dwarf5. With my fix, I am not
>seeing any issues with GCC and dwarf5 moreover currently GCC's debug_line
>version is 3 even when compiled with dwarf5.
>>
>> /* 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;
>>
>> Made code changes to fix this issue. Can you review the code changes and
>send in your comments/suggestions?
>>
>> Regards,
>> Rupesh P
>
>Much of the above wants to go ...
>
>> From 28e92539dfe5319e7bdfea32c4ee46f55ff51053 Mon Sep 17 00:00:00
>2001
>> From: rupothar
>rupesh.potharla@amd.com<mailto:rupesh.potharla@amd.com>
>> Date: Mon, 9 May 2022 12:10:48 +0530
>> Subject: [PATCH] bfd: Fix issues with files in debug_line table with dwarf5.
>>
>> ---
>
>... above this marker, to become the actual commit message.
>
>> @@ -2270,10 +2273,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;
>> }
>
>How come this change doesn't add a version check?
>
>To help being certain this is the right way of changing things, can you please
>add up to two testcases (readelf and/or objdump), one for a version < 5
>(unless one such already exists and hence it would be visible there that you
>don't unduly alter handling of those older versions) and one for version 5?
>
>Jan
[-- Attachment #2: 0001-bfd-Fix-issues-with-files-in-debug_line-table-with-d.patch --]
[-- Type: application/octet-stream, Size: 1994 bytes --]
From 1898ad99680a70e81e9cc2ca4aa69285599fea21 Mon Sep 17 00:00:00 2001
From: rupothar <rupesh.potharla@amd.com>
Date: Wed, 25 May 2022 09:22:48 +0530
Subject: [PATCH] bfd: Fix issues with files in debug_line table with dwarf5.
---
bfd/dwarf2.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index f6b0183720b..c5b5d14fc9f 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1572,6 +1572,7 @@ struct line_info_table
unsigned int num_files;
unsigned int num_dirs;
unsigned int num_sequences;
+ unsigned int version;
char * comp_dir;
char ** dirs;
struct fileinfo* files;
@@ -1792,6 +1793,8 @@ concat_filename (struct line_info_table *table, unsigned int file)
{
char *filename;
+ if (table->version >= 5)
+ file = file + 1;
if (table == NULL || file - 1 >= table->num_files)
{
/* FILE == 0 means unknown. */
@@ -2414,7 +2417,7 @@ 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 (table->version < 5 && datai != 0)
if (!callback (table, fe.name, fe.dir, fe.time, fe.size))
return false;
}
@@ -2581,6 +2584,7 @@ decode_line_info (struct comp_unit *unit)
table->sequences = NULL;
table->lcl_head = NULL;
+ table->version = lh.version;
if (lh.version >= 5)
{
@@ -2623,7 +2627,12 @@ decode_line_info (struct comp_unit *unit)
/* State machine registers. */
bfd_vma address = 0;
unsigned char op_index = 0;
- char * filename = table->num_files ? concat_filename (table, 1) : NULL;
+ char *filename;
+ if (table->version >= 5)
+ filename = table->num_files ? concat_filename (table, 0) : NULL;
+ else
+ filename = table->num_files ? concat_filename (table, 1) : NULL;
+
unsigned int line = 1;
unsigned int column = 0;
unsigned int discriminator = 0;
--
2.17.1
next prev parent reply other threads:[~2022-05-25 4:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 7:03 Potharla, Rupesh
2022-05-18 12:36 ` Jan Beulich
2022-05-25 4:20 ` Potharla, Rupesh [this message]
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
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
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=DM6PR12MB4219508DD0B57228E5A4E4BEE7D69@DM6PR12MB4219.namprd12.prod.outlook.com \
--to=rupesh.potharla@amd.com \
--cc=Hariharan.Parasuraman@amd.com \
--cc=JiniSusan.George@amd.com \
--cc=Kavitha.Natarajan@amd.com \
--cc=binutils@sourceware.org \
--cc=jbeulich@suse.com \
/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).