Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@linaro.org>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: Re: [PATCH v3 2/2] Fix an undefined behavior in record_line
Date: Sat, 4 Apr 2020 13:22:56 -0300	[thread overview]
Message-ID: <37b43cd4-de96-7e5c-7c17-09e5887af5d0@linaro.org> (raw)
In-Reply-To: <AM6PR03MB5170E980989A183245296C4BE4C40@AM6PR03MB5170.eurprd03.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 7697 bytes --]

Hi Bernd,

I messed it up, sorry. Here's the line table information again.

Regards,
Luis

On 4/4/20 1:06 PM, Bernd Edlinger wrote:
> Hi Luis,
> 
> the attachments seem to be twice the lo-cold.c linetables,
> I wonder if the hi-cold.c linetable are missing, to somehow
> make the picture complete?
> 
> Thanks
> Bernd.
> 
> On 4/4/20 3:56 PM, Luis Machado wrote:
>> Hi Bernd,
>>
>> On 4/4/20 4:06 AM, Bernd Edlinger wrote:
>>> On 4/4/20 6:21 AM, Bernd Edlinger wrote:
>>>>
>>>>
>>>> On 4/4/20 12:53 AM, Luis Machado wrote:
>>>>> Hi,
>>>>>
>>>>> This seems to have caused a few regressions for aarch64-linux. I'm seeing the following:
>>>>>
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into foo from main
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into bar from foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of bar to foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into foo_cold from foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into baz from foo_cold
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of baz to foo_cold
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of foo_cold to foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of foo to main
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into foo from main
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into bar from foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of bar to foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into foo_cold from foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into baz from foo_cold
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of baz to foo_cold
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of foo_cold to foo
>>>>> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of foo to main
>>>>>
>>>>> git bisect pointed at this commit:
>>>>>
>>>
>>> Louis,
>>>
>>> So, I cannot do much, to debug aarch64 here.
>>> I would however like to know what the output of the test result is,
>>> when it fails, that is where the step does stop when it is not where it should.
>>
>> On a quick look, we're stopping at the wrong location during an attempt to break at "main". I think things just derail from there.
>>
>> For now, please find attached a couple logs, one without regressions and one with the failing tests.
>>
>> Also, I've attached the decoded/raw line information for both binaries from this testcase. I can play with it further to get more information if you need. Hopefully this data is useful for now.
>>
>> Let me know otherwise.
>>
>>>
>>> And how the line table looks in the test case when it is compiled on aarch64,
>>> btw. which gcc version do you use?
>>
>> The compiler version is gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1).
>>
>>>
>>> Thanks
>>> Bernd.
>>>
>>>>
>>>> Oh, dear.
>>>>
>>>> Andrew, please watch out,
>>>>
>>>> your other patch is also about to
>>>> change something in this area.
>>>>
>>>> I tested on x86_64 where everything looked good,
>>>> (at least for me, but sime test cases are always faling
>>>> or are unstable ...)
>>>>
>>>> It could be that your patch
>>>>
>>>> PATCH 2/2] gdb: Preserve is-stmt lines when switch between files
>>>>
>>>> I just saw in my inbox is also trying to address the same issue.
>>>>
>>>> I was not aware that you were working on the same issue.
>>>>
>>>>
>>>> Thanks
>>>> Bernd.
>>>>
>>>>> ---
>>>>>
>>>>> commit 64dc2d4bd24ff7119c913fff91184414f09b8042
>>>>> Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
>>>>> Date:   Thu Mar 12 11:52:34 2020 +0100
>>>>>
>>>>>       Fix an undefined behavior in record_line
>>>>>
>>>>>       Additionally do not completely remove symbols
>>>>>       at the same PC than the end marker, instead
>>>>>       make them non-is-stmt breakpoints.
>>>>>
>>>>>       2020-04-01  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>>>>>
>>>>>               * buildsym.c (record_line): Fix undefined behavior and preserve lines at eof.
>>>>>
>>>>> ---
>>>>>
>>>>> What i see in the log is stepping through lines not working as expected.
>>>>>
>>>>>
>>>>> On 3/27/20 12:50 AM, Bernd Edlinger wrote:
>>>>>> Additionally do not completely remove symbols
>>>>>> at the same PC than the end marker, instead
>>>>>> make them non-is-stmt breakpoints.
>>>>>>
>>>>>> 2020-03-27  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>>>>>>       * buildsym.c (record_line): Fix undefined behavior and preserve
>>>>>>       lines at eof.
>>>>>> ---
>>>>>>     gdb/buildsym.c | 34 ++++++++++++++++++----------------
>>>>>>     1 file changed, 18 insertions(+), 16 deletions(-)
>>>>>>
>>>>>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>>>>>> index 2d1e441..46c5bb1 100644
>>>>>> --- a/gdb/buildsym.c
>>>>>> +++ b/gdb/buildsym.c
>>>>>> @@ -705,27 +705,29 @@ struct blockvector *
>>>>>>                   * sizeof (struct linetable_entry))));
>>>>>>         }
>>>>>>     -  /* Normally, we treat lines as unsorted.  But the end of sequence
>>>>>> -     marker is special.  We sort line markers at the same PC by line
>>>>>> -     number, so end of sequence markers (which have line == 0) appear
>>>>>> -     first.  This is right if the marker ends the previous function,
>>>>>> -     and there is no padding before the next function.  But it is
>>>>>> -     wrong if the previous line was empty and we are now marking a
>>>>>> -     switch to a different subfile.  We must leave the end of sequence
>>>>>> -     marker at the end of this group of lines, not sort the empty line
>>>>>> -     to after the marker.  The easiest way to accomplish this is to
>>>>>> -     delete any empty lines from our table, if they are followed by
>>>>>> -     end of sequence markers.  All we lose is the ability to set
>>>>>> -     breakpoints at some lines which contain no instructions
>>>>>> -     anyway.  */
>>>>>> +  /* The end of sequence marker is special.  We need to reset the
>>>>>> +     is_stmt flag on previous lines at the same PC, otherwise these
>>>>>> +     lines may cause problems since they might be at the same address
>>>>>> +     as the following function.  For instance suppose a function calls
>>>>>> +     abort there is no reason to emit a ret after that point (no joke).
>>>>>> +     So the label may be at the same address where the following
>>>>>> +     function begins.  A similar problem appears if a label is at the
>>>>>> +     same address where an inline function ends we cannot reliably tell
>>>>>> +     if this is considered part of the inline function or the calling
>>>>>> +     program or even the next inline function, so stack traces may
>>>>>> +     give surprising results.  Expect gdb.cp/step-and-next-inline.exp
>>>>>> +     to fail if these lines are not modified here.  */
>>>>>>       if (line == 0 && subfile->line_vector->nitems > 0)
>>>>>>         {
>>>>>> -      e = subfile->line_vector->item + subfile->line_vector->nitems - 1;
>>>>>> -      while (subfile->line_vector->nitems > 0 && e->pc == pc)
>>>>>> +      e = subfile->line_vector->item + subfile->line_vector->nitems;
>>>>>> +      do
>>>>>>         {
>>>>>>           e--;
>>>>>> -      subfile->line_vector->nitems--;
>>>>>> +      if (e->pc != pc || e->line == 0)
>>>>>> +        break;
>>>>>> +      e->is_stmt = 0;
>>>>>>         }
>>>>>> +      while (e > subfile->line_vector->item);
>>>>>>         }
>>>>>>         e = subfile->line_vector->item + subfile->line_vector->nitems++;
>>>>>>

[-- Attachment #2: dw2-ranges-func-hi-cold.l --]
[-- Type: text/plain, Size: 3059 bytes --]

Raw dump of debug contents of section .debug_line:

  Offset:                      0x0
  Length:                      413
  DWARF Version:               2
  Prologue Length:             170
  Minimum Instruction Length:  1
  Initial value of 'is_stmt':  1
  Line Base:                   1
  Line Range:                  1
  Opcode Base:                 10

 Opcodes:
  Opcode 1 has 0 args
  Opcode 2 has 1 arg
  Opcode 3 has 1 arg
  Opcode 4 has 1 arg
  Opcode 5 has 1 arg
  Opcode 6 has 0 args
  Opcode 7 has 0 args
  Opcode 8 has 0 args
  Opcode 9 has 1 arg

 The Directory Table (offset 0x18):
  1	/home/user/build/binutils-gdb-master/gdb/testsuite/../../../../repos/binutils-gdb/gdb/testsuite/gdb.dwarf2

 The File Name Table (offset 0x96):
  Entry	Dir	Time	Size	Name
  1	1	0	0	dw2-ranges-func-hi-cold.c

 Line Number Statements:
  [0x000000b4]  Extended opcode 2: set Address to 0x73c
  [0x000000bf]  Advance Line by 75 to 76
  [0x000000c2]  Copy
  [0x000000c3]  Extended opcode 2: set Address to 0x744
  [0x000000ce]  Advance Line by 2 to 78
  [0x000000d0]  Copy
  [0x000000d1]  Extended opcode 2: set Address to 0x748
  [0x000000dc]  Advance Line by 2 to 80
  [0x000000de]  Copy
  [0x000000df]  Extended opcode 2: set Address to 0x754
  [0x000000ea]  Advance Line by 2 to 82
  [0x000000ec]  Copy
  [0x000000ed]  Extended opcode 1: End of Sequence

  [0x000000f0]  Extended opcode 2: set Address to 0x6e4
  [0x000000fb]  Advance Line by 45 to 46
  [0x000000fd]  Copy
  [0x000000fe]  Extended opcode 2: set Address to 0x6ec
  [0x00000109]  Advance Line by 2 to 48
  [0x0000010b]  Copy
  [0x0000010c]  Extended opcode 2: set Address to 0x6f0
  [0x00000117]  Advance Line by 2 to 50
  [0x00000119]  Copy
  [0x0000011a]  Extended opcode 2: set Address to 0x708
  [0x00000125]  Advance Line by 2 to 52
  [0x00000127]  Copy
  [0x00000128]  Extended opcode 2: set Address to 0x714
  [0x00000133]  Advance Line by 1 to 53
  [0x00000135]  Copy
  [0x00000136]  Extended opcode 1: End of Sequence

  [0x00000139]  Extended opcode 2: set Address to 0x714
  [0x00000144]  Advance Line by 57 to 58
  [0x00000146]  Copy
  [0x00000147]  Advance PC by 8 to 0x71c
  [0x00000149]  Advance Line by 1 to 59
  [0x0000014b]  Copy
  [0x0000014c]  Extended opcode 1: End of Sequence

  [0x0000014f]  Extended opcode 2: set Address to 0x734
  [0x0000015a]  Advance Line by 71 to 72
  [0x0000015d]  Copy
  [0x0000015e]  Advance PC by 8 to 0x73c
  [0x00000160]  Advance Line by 1 to 73
  [0x00000162]  Copy
  [0x00000163]  Extended opcode 1: End of Sequence

  [0x00000166]  Extended opcode 2: set Address to 0x71c
  [0x00000171]  Advance Line by 61 to 62
  [0x00000173]  Copy
  [0x00000174]  Extended opcode 2: set Address to 0x724
  [0x0000017f]  Advance Line by 2 to 64
  [0x00000181]  Copy
  [0x00000182]  Extended opcode 2: set Address to 0x728
  [0x0000018d]  Advance Line by 2 to 66
  [0x0000018f]  Copy
  [0x00000190]  Extended opcode 2: set Address to 0x734
  [0x0000019b]  Advance Line by 1 to 67
  [0x0000019d]  Copy
  [0x0000019e]  Extended opcode 1: End of Sequence



[-- Attachment #3: dw2-ranges-func-hi-cold.L --]
[-- Type: text/plain, Size: 1706 bytes --]

Contents of the .debug_line section:

dw2-ranges-func-hi-cold.c:
File name                            Line number    Starting address    View
dw2-ranges-func-hi-cold.c                     76               0x73c
dw2-ranges-func-hi-cold.c                     78               0x744
dw2-ranges-func-hi-cold.c                     80               0x748
dw2-ranges-func-hi-cold.c                     82               0x754
dw2-ranges-func-hi-cold.c                     82               0x754       1

dw2-ranges-func-hi-cold.c                     46               0x6e4
dw2-ranges-func-hi-cold.c                     48               0x6ec
dw2-ranges-func-hi-cold.c                     50               0x6f0
dw2-ranges-func-hi-cold.c                     52               0x708
dw2-ranges-func-hi-cold.c                     53               0x714
dw2-ranges-func-hi-cold.c                     53               0x714       1

dw2-ranges-func-hi-cold.c                     58               0x714
dw2-ranges-func-hi-cold.c                     59               0x71c
dw2-ranges-func-hi-cold.c                     59               0x71c       1

dw2-ranges-func-hi-cold.c                     72               0x734
dw2-ranges-func-hi-cold.c                     73               0x73c
dw2-ranges-func-hi-cold.c                     73               0x73c       1

dw2-ranges-func-hi-cold.c                     62               0x71c
dw2-ranges-func-hi-cold.c                     64               0x724
dw2-ranges-func-hi-cold.c                     66               0x728
dw2-ranges-func-hi-cold.c                     67               0x734
dw2-ranges-func-hi-cold.c                     67               0x734       1



[-- Attachment #4: dw2-ranges-func-lo-cold.l --]
[-- Type: text/plain, Size: 3059 bytes --]

Raw dump of debug contents of section .debug_line:

  Offset:                      0x0
  Length:                      413
  DWARF Version:               2
  Prologue Length:             170
  Minimum Instruction Length:  1
  Initial value of 'is_stmt':  1
  Line Base:                   1
  Line Range:                  1
  Opcode Base:                 10

 Opcodes:
  Opcode 1 has 0 args
  Opcode 2 has 1 arg
  Opcode 3 has 1 arg
  Opcode 4 has 1 arg
  Opcode 5 has 1 arg
  Opcode 6 has 0 args
  Opcode 7 has 0 args
  Opcode 8 has 0 args
  Opcode 9 has 1 arg

 The Directory Table (offset 0x18):
  1	/home/user/build/binutils-gdb-master/gdb/testsuite/../../../../repos/binutils-gdb/gdb/testsuite/gdb.dwarf2

 The File Name Table (offset 0x96):
  Entry	Dir	Time	Size	Name
  1	1	0	0	dw2-ranges-func-lo-cold.c

 Line Number Statements:
  [0x000000b4]  Extended opcode 2: set Address to 0x73c
  [0x000000bf]  Advance Line by 75 to 76
  [0x000000c2]  Copy
  [0x000000c3]  Extended opcode 2: set Address to 0x744
  [0x000000ce]  Advance Line by 2 to 78
  [0x000000d0]  Copy
  [0x000000d1]  Extended opcode 2: set Address to 0x748
  [0x000000dc]  Advance Line by 2 to 80
  [0x000000de]  Copy
  [0x000000df]  Extended opcode 2: set Address to 0x754
  [0x000000ea]  Advance Line by 2 to 82
  [0x000000ec]  Copy
  [0x000000ed]  Extended opcode 1: End of Sequence

  [0x000000f0]  Extended opcode 2: set Address to 0x70c
  [0x000000fb]  Advance Line by 65 to 66
  [0x000000fe]  Copy
  [0x000000ff]  Extended opcode 2: set Address to 0x714
  [0x0000010a]  Advance Line by 2 to 68
  [0x0000010c]  Copy
  [0x0000010d]  Extended opcode 2: set Address to 0x718
  [0x00000118]  Advance Line by 2 to 70
  [0x0000011a]  Copy
  [0x0000011b]  Extended opcode 2: set Address to 0x730
  [0x00000126]  Advance Line by 2 to 72
  [0x00000128]  Copy
  [0x00000129]  Extended opcode 2: set Address to 0x73c
  [0x00000134]  Advance Line by 1 to 73
  [0x00000136]  Copy
  [0x00000137]  Extended opcode 1: End of Sequence

  [0x0000013a]  Extended opcode 2: set Address to 0x704
  [0x00000145]  Advance Line by 61 to 62
  [0x00000147]  Copy
  [0x00000148]  Advance PC by 8 to 0x70c
  [0x0000014a]  Advance Line by 1 to 63
  [0x0000014c]  Copy
  [0x0000014d]  Extended opcode 1: End of Sequence

  [0x00000150]  Extended opcode 2: set Address to 0x6e4
  [0x0000015b]  Advance Line by 47 to 48
  [0x0000015d]  Copy
  [0x0000015e]  Advance PC by 8 to 0x6ec
  [0x00000160]  Advance Line by 1 to 49
  [0x00000162]  Copy
  [0x00000163]  Extended opcode 1: End of Sequence

  [0x00000166]  Extended opcode 2: set Address to 0x6ec
  [0x00000171]  Advance Line by 51 to 52
  [0x00000173]  Copy
  [0x00000174]  Extended opcode 2: set Address to 0x6f4
  [0x0000017f]  Advance Line by 2 to 54
  [0x00000181]  Copy
  [0x00000182]  Extended opcode 2: set Address to 0x6f8
  [0x0000018d]  Advance Line by 2 to 56
  [0x0000018f]  Copy
  [0x00000190]  Extended opcode 2: set Address to 0x704
  [0x0000019b]  Advance Line by 1 to 57
  [0x0000019d]  Copy
  [0x0000019e]  Extended opcode 1: End of Sequence



[-- Attachment #5: dw2-ranges-func-lo-cold.L --]
[-- Type: text/plain, Size: 1706 bytes --]

Contents of the .debug_line section:

dw2-ranges-func-lo-cold.c:
File name                            Line number    Starting address    View
dw2-ranges-func-lo-cold.c                     76               0x73c
dw2-ranges-func-lo-cold.c                     78               0x744
dw2-ranges-func-lo-cold.c                     80               0x748
dw2-ranges-func-lo-cold.c                     82               0x754
dw2-ranges-func-lo-cold.c                     82               0x754       1

dw2-ranges-func-lo-cold.c                     66               0x70c
dw2-ranges-func-lo-cold.c                     68               0x714
dw2-ranges-func-lo-cold.c                     70               0x718
dw2-ranges-func-lo-cold.c                     72               0x730
dw2-ranges-func-lo-cold.c                     73               0x73c
dw2-ranges-func-lo-cold.c                     73               0x73c       1

dw2-ranges-func-lo-cold.c                     62               0x704
dw2-ranges-func-lo-cold.c                     63               0x70c
dw2-ranges-func-lo-cold.c                     63               0x70c       1

dw2-ranges-func-lo-cold.c                     48               0x6e4
dw2-ranges-func-lo-cold.c                     49               0x6ec
dw2-ranges-func-lo-cold.c                     49               0x6ec       1

dw2-ranges-func-lo-cold.c                     52               0x6ec
dw2-ranges-func-lo-cold.c                     54               0x6f4
dw2-ranges-func-lo-cold.c                     56               0x6f8
dw2-ranges-func-lo-cold.c                     57               0x704
dw2-ranges-func-lo-cold.c                     57               0x704       1



  reply	other threads:[~2020-04-04 16:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27  3:50 Bernd Edlinger
2020-04-01 16:23 ` Tom Tromey
2020-04-01 16:52   ` Bernd Edlinger
2020-04-01 18:40     ` Bernd Edlinger
2020-04-01 18:53       ` Tom Tromey
2020-04-01 19:01         ` Bernd Edlinger
2020-04-03 22:53 ` Luis Machado
2020-04-04  4:21   ` Bernd Edlinger
2020-04-04  7:06     ` Bernd Edlinger
2020-04-04 13:56       ` Luis Machado
2020-04-04 16:06         ` Bernd Edlinger
2020-04-04 16:22           ` Luis Machado [this message]
2020-04-04 16:34             ` Bernd Edlinger
2020-04-04 22:55               ` Andrew Burgess
2020-04-05  0:12                 ` Bernd Edlinger
2020-04-04 23:03 ` Andrew Burgess
2020-04-06 17:44   ` Andrew Burgess
2020-04-06 18:48     ` Bernd Edlinger

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=37b43cd4-de96-7e5c-7c17-09e5887af5d0@linaro.org \
    --to=luis.machado@linaro.org \
    --cc=andrew.burgess@embecosm.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=gdb-patches@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