public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5.
@ 2020-04-03 15:01 nitachra
  2020-04-03 17:49 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: nitachra @ 2020-04-03 15:01 UTC (permalink / raw)
  To: gdb-patches, tom; +Cc: JiniSusan.George, nitachra

Thanks for the review. I have made the changes in the formatting and the
commit message.

Regards,
Nitika

---
GDB throws the error 'Unrecognized DWARF opcode 0x02 at 2' when running
Info address command with the executable file compiled with -gdwarf-5 flag.
This patch fixes this error.

Tested by running the testsuite before and after the patch and there is
no increase in the number of test cases that fails. Tested with both
-gdwarf-4 and -gdwarf-5 flags. Also tested -gslit-dwarf along with
-gdwarf-4 as well as -gdwarf-5 flags. Used clang version 10.0.0.
This is the test case used-

void bar(int arr[], int l, int m, int r) {
    int i, j, k, n1= m - l + 1, n2= r - m, L[n1], R[n2];
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];
}

int main()
{
    int arr[] = {12, 11};
    bar(arr,0,1,2);
    return 0;
}

clang -gdwarf-5 test.c -o test.out

gdb test.out
gdb> start
gdb> step
gdb> step
gdb> step
gdb> step
gdb> info address L
Symbol "L" is multi-location:
  Range 0x7c04007902bc5084-0x67fb876440700: a complex DWARF expression:
     0: DW_OP_breg16 1 [$rip]
Unrecognized DWARF opcode 0x02 at 2

gdb/dwarf2/ChangeLog:

*loc.c (loclist_describe_location): Call the function decode_debug_loclists_
 addresses if DWARF version is 5 or more because DW_LLE_start* or DW_LLE_offset_pair
 with DW_LLE_base_addressx are being emitted in DWARFv5.
 Add the newly added kind DW_LOC_OFFSET_PAIR also.
 The length of location description is an unsigned ULEB integer in DWARFv5 instead of
 unsigned integer. A counted location description operand consists of an unsigned ULEB
 integer giving the length of the location description. Location list entries are followed
 by a counted location description. See the section 2.6.2 of DWARF Debugging Information
 Format Version 5.

Signed-off-by: nitachra <Nitika.Achra@amd.com>
---
 gdb/dwarf2/loc.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 62bec79035..7adb13c5c5 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -4453,15 +4453,20 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
       enum debug_loc_kind kind;
       const gdb_byte *new_ptr = NULL; /* init for gcc -Wall */
 
-      if (dlbaton->from_dwo)
+      if (dlbaton->per_cu->version () < 5 && dlbaton->from_dwo)
 	kind = decode_debug_loc_dwo_addresses (dlbaton->per_cu,
 					       loc_ptr, buf_end, &new_ptr,
 					       &low, &high, byte_order);
-      else
+      else if (dlbaton->per_cu->version () < 5)
 	kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr,
 					   &low, &high,
 					   byte_order, addr_size,
 					   signed_addr_p);
+      else
+	kind = decode_debug_loclists_addresses (dlbaton->per_cu,
+						loc_ptr, buf_end, &new_ptr,
+						&low, &high, byte_order,
+						addr_size, signed_addr_p);
       loc_ptr = new_ptr;
       switch (kind)
 	{
@@ -4475,6 +4480,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
 	  continue;
 	case DEBUG_LOC_START_END:
 	case DEBUG_LOC_START_LENGTH:
+	case DEBUG_LOC_OFFSET_PAIR:
 	  break;
 	case DEBUG_LOC_BUFFER_OVERFLOW:
 	case DEBUG_LOC_INVALID_ENTRY:
@@ -4491,8 +4497,17 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
       low = gdbarch_adjust_dwarf2_addr (gdbarch, low);
       high = gdbarch_adjust_dwarf2_addr (gdbarch, high);
 
-      length = extract_unsigned_integer (loc_ptr, 2, byte_order);
-      loc_ptr += 2;
+      if (dlbaton->per_cu->version () < 5)
+	{
+	  length = extract_unsigned_integer (loc_ptr, 2, byte_order);
+	  loc_ptr += 2;
+	}
+      else
+	{
+	  unsigned int bytes_read;
+	  length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read);
+	  loc_ptr += bytes_read;
+	}
 
       /* (It would improve readability to print only the minimum
 	 necessary digits of the second number of the range.)  */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5.
  2020-04-03 15:01 [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5 nitachra
@ 2020-04-03 17:49 ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2020-04-03 17:49 UTC (permalink / raw)
  To: nitachra; +Cc: gdb-patches, tom, JiniSusan.George

>>>>> ">" == nitachra  <Nitika.Achra@amd.com> writes:

>> Thanks for the review. I have made the changes in the formatting and the
>> commit message.

Thank you.  This looks good to me.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5.
  2020-03-30 15:21 ` [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5 nitachra
@ 2020-04-01 19:24   ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2020-04-01 19:24 UTC (permalink / raw)
  To: nitachra; +Cc: gdb-patches, simark, JiniSusan.George, tom

>>>>> ">" == nitachra  <Nitika.Achra@amd.com> writes:

>>  The length of location description is an unsigned ULEB integer in DWARFv5 instead of
>>  unsigned integer.

I'd appreciate a reference to the section here.
Is it 2.6.2?

>> +      if (dlbaton->per_cu->version () < 5)
>> +	{
>> +	length = extract_unsigned_integer (loc_ptr, 2, byte_order);
>> +	loc_ptr += 2;
>> +	}
>> +      else
>> +	{
>> +	unsigned int bytes_read;
>> +	length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read);
>> +	loc_ptr += bytes_read;
>> +	}
 
The formatting looks off here.  See the GNU standards, or the examples
elsewhere in this file, to see how it should be done.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5.
  2020-03-30 15:21 [PATCH v2 1/3] Support for DW_AT_loclists_base and DW_FORM_loclistx nitachra
@ 2020-03-30 15:21 ` nitachra
  2020-04-01 19:24   ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: nitachra @ 2020-03-30 15:21 UTC (permalink / raw)
  To: gdb-patches, simark; +Cc: JiniSusan.George, tom, nitachra

GDB throws the error 'Unrecognized DWARF opcode 0x02 at 2' when running
Info address command with the executable file compiled with -gdwarf-5 flag.
This patch fixes this error.

Tested by running the testsuite before and after the patch and there is
no increase in the number of test cases that fails. Tested with both
-gdwarf-4 and -gdwarf-5 flags. Also tested -gslit-dwarf along with
-gdwarf-4 as well as -gdwarf-5 flags. Used clang version 10.0.0.
This is the test case used-

void bar(int arr[], int l, int m, int r) {
    int i, j, k, n1= m - l + 1, n2= r - m, L[n1], R[n2];
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];
}

int main()
{
    int arr[] = {12, 11};
    bar(arr,0,1,2);
    return 0;
}

clang -gdwarf-5 test.c -o test.out

gdb test.out
gdb> start
gdb> step
gdb> step
gdb> step
gdb> step
gdb> info address L
Symbol "L" is multi-location:
  Range 0x7c04007902bc5084-0x67fb876440700: a complex DWARF expression:
     0: DW_OP_breg16 1 [$rip]
Unrecognized DWARF opcode 0x02 at 2

gdb/dwarf2/ChangeLog:

*loc.c (loclist_describe_location): Call the function decode_debug_loclists_
 addresses if DWARF version is 5 or more because DW_LLE_start* or DW_LLE_offset_pair
 with DW_LLE_base_addressx are being emitted in DWARFv5.
 Add the newly added kind DW_LOC_OFFSET_PAIR also.
 The length of location description is an unsigned ULEB integer in DWARFv5 instead of
 unsigned integer.

Signed-off-by: nitachra <Nitika.Achra@amd.com>
---
 gdb/dwarf2/loc.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 62bec79035..94be09a293 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -4453,15 +4453,20 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
       enum debug_loc_kind kind;
       const gdb_byte *new_ptr = NULL; /* init for gcc -Wall */
 
-      if (dlbaton->from_dwo)
+      if (dlbaton->per_cu->version () < 5 && dlbaton->from_dwo)
 	kind = decode_debug_loc_dwo_addresses (dlbaton->per_cu,
 					       loc_ptr, buf_end, &new_ptr,
 					       &low, &high, byte_order);
-      else
+      else if (dlbaton->per_cu->version () < 5)
 	kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr,
 					   &low, &high,
 					   byte_order, addr_size,
 					   signed_addr_p);
+      else
+	kind = decode_debug_loclists_addresses (dlbaton->per_cu,
+						loc_ptr, buf_end, &new_ptr,
+						&low, &high, byte_order,
+						addr_size, signed_addr_p);
       loc_ptr = new_ptr;
       switch (kind)
 	{
@@ -4475,6 +4480,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
 	  continue;
 	case DEBUG_LOC_START_END:
 	case DEBUG_LOC_START_LENGTH:
+	case DEBUG_LOC_OFFSET_PAIR:
 	  break;
 	case DEBUG_LOC_BUFFER_OVERFLOW:
 	case DEBUG_LOC_INVALID_ENTRY:
@@ -4491,8 +4497,17 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
       low = gdbarch_adjust_dwarf2_addr (gdbarch, low);
       high = gdbarch_adjust_dwarf2_addr (gdbarch, high);
 
-      length = extract_unsigned_integer (loc_ptr, 2, byte_order);
-      loc_ptr += 2;
+      if (dlbaton->per_cu->version () < 5)
+	{
+	length = extract_unsigned_integer (loc_ptr, 2, byte_order);
+	loc_ptr += 2;
+	}
+      else
+	{
+	unsigned int bytes_read;
+	length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read);
+	loc_ptr += bytes_read;
+	}
 
       /* (It would improve readability to print only the minimum
 	 necessary digits of the second number of the range.)  */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5.
  2020-03-29 16:07 [PATCH v2 1/3] Support for DW_AT_loclists_base and DW_FORM_loclistx nitachra
@ 2020-03-29 16:07 ` nitachra
  0 siblings, 0 replies; 5+ messages in thread
From: nitachra @ 2020-03-29 16:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: JiniSusan.George, tamur, tom, simark, nitachra

GDB throws the error 'Unrecognized DWARF opcode 0x02 at 2' when running
Info address command with the executable file compiled with -gdwarf-5 and
-O1 flags.This patch fixes this error.

Tested by running the testsuite before and after the patch and there is
no increase in the number of test cases that fails. Tested with both
-gdwarf-4 and -gdwarf-5 flags. Also tested -gslit-dwarf along with
-gdwarf-4 as well as -gdwarf-5 flags. Used clang version 10.0.0.
This is the test case used-

void bar(int arr[], int l, int m, int r) {
    int i, j, k, n1= m - l + 1, n2= r - m, L[n1], R[n2];
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];
}

int main()
{
    int arr[] = {12, 11};
    bar(arr,0,1,2);
    return 0;
}

clang -gdwarf-5 -O1 test.c -o test.out

gdb test.out
gdb> start
gdb> step
gdb> step
gdb> step
gdb> step
gdb> info address L
Symbol "L" is multi-location:
  Range 0x7c04007902bc5084-0x67fb876440700: a complex DWARF expression:
     0: DW_OP_breg16 1 [$rip]
Unrecognized DWARF opcode 0x02 at 2

gdb/ChangeLog:

*dwarf2loc.c (loclist_describe_location): Call the function decode_debug_loclists_
 addresses if DWARF version is 5 or more because DW_LLE_start* or DW_LLE_offset_pair
 with DW_LLE_base_addressx are being emitted in DWARFv5.
 Add the newly added kind DW_LOC_OFFSET_PAIR also.
 The length of location description is an unsigned ULEB integer in DWARFv5 instead of
 unsigned integer.

Signed-off-by: nitachra <Nitika.Achra@amd.com>
---
 gdb/dwarf2/loc.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 62bec79035..94be09a293 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -4453,15 +4453,20 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
       enum debug_loc_kind kind;
       const gdb_byte *new_ptr = NULL; /* init for gcc -Wall */
 
-      if (dlbaton->from_dwo)
+      if (dlbaton->per_cu->version () < 5 && dlbaton->from_dwo)
 	kind = decode_debug_loc_dwo_addresses (dlbaton->per_cu,
 					       loc_ptr, buf_end, &new_ptr,
 					       &low, &high, byte_order);
-      else
+      else if (dlbaton->per_cu->version () < 5)
 	kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr,
 					   &low, &high,
 					   byte_order, addr_size,
 					   signed_addr_p);
+      else
+	kind = decode_debug_loclists_addresses (dlbaton->per_cu,
+						loc_ptr, buf_end, &new_ptr,
+						&low, &high, byte_order,
+						addr_size, signed_addr_p);
       loc_ptr = new_ptr;
       switch (kind)
 	{
@@ -4475,6 +4480,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
 	  continue;
 	case DEBUG_LOC_START_END:
 	case DEBUG_LOC_START_LENGTH:
+	case DEBUG_LOC_OFFSET_PAIR:
 	  break;
 	case DEBUG_LOC_BUFFER_OVERFLOW:
 	case DEBUG_LOC_INVALID_ENTRY:
@@ -4491,8 +4497,17 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
       low = gdbarch_adjust_dwarf2_addr (gdbarch, low);
       high = gdbarch_adjust_dwarf2_addr (gdbarch, high);
 
-      length = extract_unsigned_integer (loc_ptr, 2, byte_order);
-      loc_ptr += 2;
+      if (dlbaton->per_cu->version () < 5)
+	{
+	length = extract_unsigned_integer (loc_ptr, 2, byte_order);
+	loc_ptr += 2;
+	}
+      else
+	{
+	unsigned int bytes_read;
+	length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read);
+	loc_ptr += bytes_read;
+	}
 
       /* (It would improve readability to print only the minimum
 	 necessary digits of the second number of the range.)  */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-03 17:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 15:01 [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5 nitachra
2020-04-03 17:49 ` Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2020-03-30 15:21 [PATCH v2 1/3] Support for DW_AT_loclists_base and DW_FORM_loclistx nitachra
2020-03-30 15:21 ` [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5 nitachra
2020-04-01 19:24   ` Tom Tromey
2020-03-29 16:07 [PATCH v2 1/3] Support for DW_AT_loclists_base and DW_FORM_loclistx nitachra
2020-03-29 16:07 ` [PATCH v2 3/3] DWARFv5: Info address command error in gdb with DWARFfv5 nitachra

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).