* [PATCH 1/2] gdb/dwarf: remove line_header::total_length field
@ 2022-04-21 15:20 Simon Marchi
2022-04-21 15:20 ` [PATCH 2/2] gdb/dwarf: remove line_header::header_length field Simon Marchi
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Simon Marchi @ 2022-04-21 15:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This doesn't have to be a field, it can simply be a local variable in
dwarf_decode_line_header. Name the local variable "unit_length", since
that's what the field in called in DWARF 4 and 5. It's always easier to
follow the code with the standard on the side when we use the same
terminology.
Change-Id: I3ad1022afd9410b193ea11b9b5437686c1e4e633
---
| 6 +++---
| 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
--git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index 8f4eb4f124cf..b1dd9afc5f58 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -289,19 +289,19 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz,
line_ptr = section->buffer + to_underlying (sect_off);
/* Read in the header. */
- lh->total_length =
+ LONGEST unit_length =
read_checked_initial_length_and_offset (abfd, line_ptr, cu_header,
&bytes_read, &offset_size);
line_ptr += bytes_read;
const gdb_byte *start_here = line_ptr;
- if (line_ptr + lh->total_length > (section->buffer + section->size))
+ if (line_ptr + unit_length > (section->buffer + section->size))
{
dwarf2_statement_list_fits_in_line_number_section_complaint ();
return 0;
}
- lh->statement_program_end = start_here + lh->total_length;
+ lh->statement_program_end = start_here + unit_length;
lh->version = read_2_bytes (abfd, line_ptr);
line_ptr += 2;
if (lh->version > 5)
--git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index 4adfe91b8ac4..25b9e7c20327 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -136,7 +136,6 @@ struct line_header
/* OFFSET is for struct dwz_file associated with dwarf2_per_objfile. */
unsigned offset_in_dwz : 1; /* Can't initialize bitfields in-class. */
- unsigned int total_length {};
unsigned short version {};
unsigned int header_length {};
unsigned char minimum_instruction_length {};
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] gdb/dwarf: remove line_header::header_length field
2022-04-21 15:20 [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Simon Marchi
@ 2022-04-21 15:20 ` Simon Marchi
2022-04-21 18:43 ` Tom Tromey
2022-04-21 16:46 ` [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Lancelot SIX
2022-04-21 18:43 ` Tom Tromey
2 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2022-04-21 15:20 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This can be a local in dwarf_decode_line_header.
Change-Id: I2ecf4616d1a3197bd1e81ded9f999a2da9a685af
---
| 6 ++++--
| 1 -
2 files changed, 4 insertions(+), 3 deletions(-)
--git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index b1dd9afc5f58..505fd22cd7d9 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -329,11 +329,13 @@ dwarf_decode_line_header (sect_offset sect_off, bool is_dwz,
return NULL;
}
}
- lh->header_length = read_offset (abfd, line_ptr, offset_size);
+
+ LONGEST header_length = read_offset (abfd, line_ptr, offset_size);
line_ptr += offset_size;
- lh->statement_program_start = line_ptr + lh->header_length;
+ lh->statement_program_start = line_ptr + header_length;
lh->minimum_instruction_length = read_1_byte (abfd, line_ptr);
line_ptr += 1;
+
if (lh->version >= 4)
{
lh->maximum_ops_per_instruction = read_1_byte (abfd, line_ptr);
--git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index 25b9e7c20327..59b317d0d727 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -137,7 +137,6 @@ struct line_header
unsigned offset_in_dwz : 1; /* Can't initialize bitfields in-class. */
unsigned short version {};
- unsigned int header_length {};
unsigned char minimum_instruction_length {};
unsigned char maximum_ops_per_instruction {};
unsigned char default_is_stmt {};
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] gdb/dwarf: remove line_header::total_length field
2022-04-21 15:20 [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Simon Marchi
2022-04-21 15:20 ` [PATCH 2/2] gdb/dwarf: remove line_header::header_length field Simon Marchi
@ 2022-04-21 16:46 ` Lancelot SIX
2022-04-21 17:15 ` Simon Marchi
2022-04-21 18:43 ` Tom Tromey
2 siblings, 1 reply; 7+ messages in thread
From: Lancelot SIX @ 2022-04-21 16:46 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
> /* Read in the header. */
> - lh->total_length =
> + LONGEST unit_length =
> read_checked_initial_length_and_offset (abfd, line_ptr, cu_header,
> &bytes_read, &offset_size);
Hi,
Just a styling nit, the line break should be before the "=".
Best,
Lancelot.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] gdb/dwarf: remove line_header::total_length field
2022-04-21 16:46 ` [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Lancelot SIX
@ 2022-04-21 17:15 ` Simon Marchi
0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2022-04-21 17:15 UTC (permalink / raw)
To: Lancelot SIX, Simon Marchi; +Cc: gdb-patches
On 2022-04-21 12:46, Lancelot SIX via Gdb-patches wrote:
>> /* Read in the header. */
>> - lh->total_length =
>> + LONGEST unit_length =
>> read_checked_initial_length_and_offset (abfd, line_ptr, cu_header,
>> &bytes_read, &offset_size);
>
> Hi,
>
> Just a styling nit, the line break should be before the "=".
>
> Best,
> Lancelot.
Thanks, fixed locally.
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] gdb/dwarf: remove line_header::total_length field
2022-04-21 15:20 [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Simon Marchi
2022-04-21 15:20 ` [PATCH 2/2] gdb/dwarf: remove line_header::header_length field Simon Marchi
2022-04-21 16:46 ` [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Lancelot SIX
@ 2022-04-21 18:43 ` Tom Tromey
2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-04-21 18:43 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> This doesn't have to be a field, it can simply be a local variable in
Simon> dwarf_decode_line_header. Name the local variable "unit_length", since
Simon> that's what the field in called in DWARF 4 and 5. It's always easier to
Simon> follow the code with the standard on the side when we use the same
Simon> terminology.
Seems fine to me. Thanks.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] gdb/dwarf: remove line_header::header_length field
2022-04-21 15:20 ` [PATCH 2/2] gdb/dwarf: remove line_header::header_length field Simon Marchi
@ 2022-04-21 18:43 ` Tom Tromey
2022-04-21 19:06 ` Simon Marchi
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2022-04-21 18:43 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> This can be a local in dwarf_decode_line_header.
Looks reasonable.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] gdb/dwarf: remove line_header::header_length field
2022-04-21 18:43 ` Tom Tromey
@ 2022-04-21 19:06 ` Simon Marchi
0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2022-04-21 19:06 UTC (permalink / raw)
To: Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi
On 2022-04-21 14:43, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> This can be a local in dwarf_decode_line_header.
>
> Looks reasonable.
>
> Tom
Thanks, pushed both patches.
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-21 19:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 15:20 [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Simon Marchi
2022-04-21 15:20 ` [PATCH 2/2] gdb/dwarf: remove line_header::header_length field Simon Marchi
2022-04-21 18:43 ` Tom Tromey
2022-04-21 19:06 ` Simon Marchi
2022-04-21 16:46 ` [PATCH 1/2] gdb/dwarf: remove line_header::total_length field Lancelot SIX
2022-04-21 17:15 ` Simon Marchi
2022-04-21 18:43 ` Tom Tromey
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).