public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Improve debugging of optimized code
@ 2021-01-31  9:12 Bernd Edlinger
  2021-02-26 16:49 ` [PING] " Bernd Edlinger
  0 siblings, 1 reply; 6+ messages in thread
From: Bernd Edlinger @ 2021-01-31  9:12 UTC (permalink / raw)
  To: gdb-patches

I've rebased and re-tested the following patches
which are trying to improve the debug experience of
optimized gcc code.  All have been posted previously
but I have been asked to post them again as a patch
series.

Only [2/4] depends on [1/4], these are about stepping
in inlined code.
The patches [3/4] and [4/4] are about breakpoints,
those do not depend on each other.

Bernd Edlinger (4):
  Introduce a new line table flag is_weak
  Fix range end handling of inlined subroutines
  Fix handling of DW_AT_entry_pc of inlined subroutines
  Skip .cold functions in search_minsyms_for_name

 gdb/block.c                                        |  15 ++-
 gdb/buildsym.c                                     | 103 ++++++++++++++++++---
 gdb/buildsym.h                                     |   3 +
 gdb/dwarf2/read.c                                  |  98 +++++++-------------
 gdb/infrun.c                                       |  33 ++++++-
 gdb/jit.c                                          |   1 +
 gdb/linespec.c                                     |  24 +++++
 gdb/symmisc.c                                      |  10 +-
 gdb/symtab.c                                       |  18 ++--
 gdb/symtab.h                                       |   4 +
 gdb/testsuite/gdb.base/empty-inline.c              |  42 +++++++++
 gdb/testsuite/gdb.base/empty-inline.exp            |  48 ++++++++++
 gdb/testsuite/gdb.cp/empty-inline.cc               |  33 +++++++
 gdb/testsuite/gdb.cp/empty-inline.exp              |  57 ++++++++++++
 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp    |  30 ++++++
 gdb/testsuite/gdb.cp/step-and-next-inline.cc       |   6 ++
 gdb/testsuite/gdb.cp/step-and-next-inline.exp      |  93 ++++++++++++-------
 .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp     |   4 +-
 gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp       |   6 +-
 gdb/xcoffread.c                                    |   1 +
 20 files changed, 497 insertions(+), 132 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/empty-inline.c
 create mode 100644 gdb/testsuite/gdb.base/empty-inline.exp
 create mode 100644 gdb/testsuite/gdb.cp/empty-inline.cc
 create mode 100644 gdb/testsuite/gdb.cp/empty-inline.exp
 create mode 100644 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp

-- 
1.9.1

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

* [PING] [PATCH 0/4] Improve debugging of optimized code
  2021-01-31  9:12 [PATCH 0/4] Improve debugging of optimized code Bernd Edlinger
@ 2021-02-26 16:49 ` Bernd Edlinger
  2021-04-05  9:40   ` [PING**2] " Bernd Edlinger
  0 siblings, 1 reply; 6+ messages in thread
From: Bernd Edlinger @ 2021-02-26 16:49 UTC (permalink / raw)
  To: gdb-patches

Ping...

On 1/31/21 10:12 AM, Bernd Edlinger wrote:
> I've rebased and re-tested the following patches
> which are trying to improve the debug experience of
> optimized gcc code.  All have been posted previously
> but I have been asked to post them again as a patch
> series.
> 
> Only [2/4] depends on [1/4], these are about stepping
> in inlined code.
> The patches [3/4] and [4/4] are about breakpoints,
> those do not depend on each other.
> 
> Bernd Edlinger (4):
>   Introduce a new line table flag is_weak
>   Fix range end handling of inlined subroutines
>   Fix handling of DW_AT_entry_pc of inlined subroutines
>   Skip .cold functions in search_minsyms_for_name
> 
>  gdb/block.c                                        |  15 ++-
>  gdb/buildsym.c                                     | 103 ++++++++++++++++++---
>  gdb/buildsym.h                                     |   3 +
>  gdb/dwarf2/read.c                                  |  98 +++++++-------------
>  gdb/infrun.c                                       |  33 ++++++-
>  gdb/jit.c                                          |   1 +
>  gdb/linespec.c                                     |  24 +++++
>  gdb/symmisc.c                                      |  10 +-
>  gdb/symtab.c                                       |  18 ++--
>  gdb/symtab.h                                       |   4 +
>  gdb/testsuite/gdb.base/empty-inline.c              |  42 +++++++++
>  gdb/testsuite/gdb.base/empty-inline.exp            |  48 ++++++++++
>  gdb/testsuite/gdb.cp/empty-inline.cc               |  33 +++++++
>  gdb/testsuite/gdb.cp/empty-inline.exp              |  57 ++++++++++++
>  gdb/testsuite/gdb.cp/step-and-next-inline-1.exp    |  30 ++++++
>  gdb/testsuite/gdb.cp/step-and-next-inline.cc       |   6 ++
>  gdb/testsuite/gdb.cp/step-and-next-inline.exp      |  93 ++++++++++++-------
>  .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp     |   4 +-
>  gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp       |   6 +-
>  gdb/xcoffread.c                                    |   1 +
>  20 files changed, 497 insertions(+), 132 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.c
>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.exp
>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.cc
>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.exp
>  create mode 100644 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
> 

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

* [PING**2] [PATCH 0/4] Improve debugging of optimized code
  2021-02-26 16:49 ` [PING] " Bernd Edlinger
@ 2021-04-05  9:40   ` Bernd Edlinger
  2021-05-09 17:57     ` [PING**3] " Bernd Edlinger
  0 siblings, 1 reply; 6+ messages in thread
From: Bernd Edlinger @ 2021-04-05  9:40 UTC (permalink / raw)
  To: gdb-patches

Ping...

On 2/26/21 5:49 PM, Bernd Edlinger wrote:
> Ping...
> 
> On 1/31/21 10:12 AM, Bernd Edlinger wrote:
>> I've rebased and re-tested the following patches
>> which are trying to improve the debug experience of
>> optimized gcc code.  All have been posted previously
>> but I have been asked to post them again as a patch
>> series.
>>
>> Only [2/4] depends on [1/4], these are about stepping
>> in inlined code.
>> The patches [3/4] and [4/4] are about breakpoints,
>> those do not depend on each other.
>>
>> Bernd Edlinger (4):
>>   Introduce a new line table flag is_weak
>>   Fix range end handling of inlined subroutines
>>   Fix handling of DW_AT_entry_pc of inlined subroutines
>>   Skip .cold functions in search_minsyms_for_name
>>
>>  gdb/block.c                                        |  15 ++-
>>  gdb/buildsym.c                                     | 103 ++++++++++++++++++---
>>  gdb/buildsym.h                                     |   3 +
>>  gdb/dwarf2/read.c                                  |  98 +++++++-------------
>>  gdb/infrun.c                                       |  33 ++++++-
>>  gdb/jit.c                                          |   1 +
>>  gdb/linespec.c                                     |  24 +++++
>>  gdb/symmisc.c                                      |  10 +-
>>  gdb/symtab.c                                       |  18 ++--
>>  gdb/symtab.h                                       |   4 +
>>  gdb/testsuite/gdb.base/empty-inline.c              |  42 +++++++++
>>  gdb/testsuite/gdb.base/empty-inline.exp            |  48 ++++++++++
>>  gdb/testsuite/gdb.cp/empty-inline.cc               |  33 +++++++
>>  gdb/testsuite/gdb.cp/empty-inline.exp              |  57 ++++++++++++
>>  gdb/testsuite/gdb.cp/step-and-next-inline-1.exp    |  30 ++++++
>>  gdb/testsuite/gdb.cp/step-and-next-inline.cc       |   6 ++
>>  gdb/testsuite/gdb.cp/step-and-next-inline.exp      |  93 ++++++++++++-------
>>  .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp     |   4 +-
>>  gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp       |   6 +-
>>  gdb/xcoffread.c                                    |   1 +
>>  20 files changed, 497 insertions(+), 132 deletions(-)
>>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.c
>>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.exp
>>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.cc
>>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.exp
>>  create mode 100644 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
>>

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

* [PING**3] [PATCH 0/4] Improve debugging of optimized code
  2021-04-05  9:40   ` [PING**2] " Bernd Edlinger
@ 2021-05-09 17:57     ` Bernd Edlinger
  2021-05-21 12:42       ` Willgerodt, Felix
  0 siblings, 1 reply; 6+ messages in thread
From: Bernd Edlinger @ 2021-05-09 17:57 UTC (permalink / raw)
  To: gdb-patches

Ping...

I'm pinging for this patch series (I've re-tested the patches today and they still work):

[PATCH 0/4] Improve debugging of optimized code
https://sourceware.org/pipermail/gdb-patches/2021-January/175617.html

[PATCH 1/4] Introduce a new line table flag is_weak
https://sourceware.org/pipermail/gdb-patches/2021-January/175618.html

[PATCH 2/4] Fix range end handling of inlined subroutines
https://sourceware.org/pipermail/gdb-patches/2021-January/175619.html

[PATCH 3/4] Fix handling of DW_AT_entry_pc of inlined subroutines
https://sourceware.org/pipermail/gdb-patches/2021-January/175620.html

[PATCH 4/4] Skip .cold functions in search_minsyms_for_name
https://sourceware.org/pipermail/gdb-patches/2021-January/175621.html

To summarize the problem here you need to know
that gcc produces sometimes line numbers at the very end
of an inline range.  Currently when the program stops at such a line,
the debugger shows usually the return statement of an inline function
that was just stepped over.  Most annoying is that step over seems to
step into the subroutine, but the call stack printed by "bt" is not
correct, and does not show the subroutine.

But as the test cases show, if the correct call stack would be known,
this breakpoint can be used to display local values of the subroutine
at the moment when the subroutine returns.  That is also the case in the
corner case of an completely empty subroutine.


Thanks
Bernd.


On 4/5/21 11:40 AM, Bernd Edlinger wrote:
> Ping...
> 
> On 2/26/21 5:49 PM, Bernd Edlinger wrote:
>> Ping...
>>
>> On 1/31/21 10:12 AM, Bernd Edlinger wrote:
>>> I've rebased and re-tested the following patches
>>> which are trying to improve the debug experience of
>>> optimized gcc code.  All have been posted previously
>>> but I have been asked to post them again as a patch
>>> series.
>>>
>>> Only [2/4] depends on [1/4], these are about stepping
>>> in inlined code.
>>> The patches [3/4] and [4/4] are about breakpoints,
>>> those do not depend on each other.
>>>
>>> Bernd Edlinger (4):
>>>   Introduce a new line table flag is_weak
>>>   Fix range end handling of inlined subroutines
>>>   Fix handling of DW_AT_entry_pc of inlined subroutines
>>>   Skip .cold functions in search_minsyms_for_name
>>>
>>>  gdb/block.c                                        |  15 ++-
>>>  gdb/buildsym.c                                     | 103 ++++++++++++++++++---
>>>  gdb/buildsym.h                                     |   3 +
>>>  gdb/dwarf2/read.c                                  |  98 +++++++-------------
>>>  gdb/infrun.c                                       |  33 ++++++-
>>>  gdb/jit.c                                          |   1 +
>>>  gdb/linespec.c                                     |  24 +++++
>>>  gdb/symmisc.c                                      |  10 +-
>>>  gdb/symtab.c                                       |  18 ++--
>>>  gdb/symtab.h                                       |   4 +
>>>  gdb/testsuite/gdb.base/empty-inline.c              |  42 +++++++++
>>>  gdb/testsuite/gdb.base/empty-inline.exp            |  48 ++++++++++
>>>  gdb/testsuite/gdb.cp/empty-inline.cc               |  33 +++++++
>>>  gdb/testsuite/gdb.cp/empty-inline.exp              |  57 ++++++++++++
>>>  gdb/testsuite/gdb.cp/step-and-next-inline-1.exp    |  30 ++++++
>>>  gdb/testsuite/gdb.cp/step-and-next-inline.cc       |   6 ++
>>>  gdb/testsuite/gdb.cp/step-and-next-inline.exp      |  93 ++++++++++++-------
>>>  .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp     |   4 +-
>>>  gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp       |   6 +-
>>>  gdb/xcoffread.c                                    |   1 +
>>>  20 files changed, 497 insertions(+), 132 deletions(-)
>>>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.c
>>>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.exp
>>>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.cc
>>>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.exp
>>>  create mode 100644 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
>>>

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

* RE: [PING**3] [PATCH 0/4] Improve debugging of optimized code
  2021-05-09 17:57     ` [PING**3] " Bernd Edlinger
@ 2021-05-21 12:42       ` Willgerodt, Felix
  2021-05-23 11:57         ` Bernd Edlinger
  0 siblings, 1 reply; 6+ messages in thread
From: Willgerodt, Felix @ 2021-05-21 12:42 UTC (permalink / raw)
  To: Bernd Edlinger, gdb-patches

Hi Bernd,

Thanks for this series. I think some of the improvements are very valuable.

I noticed that the empty-inline.exp tests show one failure with clang.
I am using:

$ clang -v
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu

I think we should do something about this. I haven't looked at the cause really though.
It might be that we need a bug ticket with clang and/or just limit the tests more for now.

Thanks,
Felix


-----Original Message-----
From: Gdb-patches <gdb-patches-bounces@sourceware.org> On Behalf Of Bernd Edlinger
Sent: Sonntag, 9. Mai 2021 19:58
To: gdb-patches@sourceware.org
Subject: [PING**3] [PATCH 0/4] Improve debugging of optimized code

Ping...

I'm pinging for this patch series (I've re-tested the patches today and they still work):

[PATCH 0/4] Improve debugging of optimized code https://sourceware.org/pipermail/gdb-patches/2021-January/175617.html

[PATCH 1/4] Introduce a new line table flag is_weak https://sourceware.org/pipermail/gdb-patches/2021-January/175618.html

[PATCH 2/4] Fix range end handling of inlined subroutines https://sourceware.org/pipermail/gdb-patches/2021-January/175619.html

[PATCH 3/4] Fix handling of DW_AT_entry_pc of inlined subroutines https://sourceware.org/pipermail/gdb-patches/2021-January/175620.html

[PATCH 4/4] Skip .cold functions in search_minsyms_for_name https://sourceware.org/pipermail/gdb-patches/2021-January/175621.html

To summarize the problem here you need to know that gcc produces sometimes line numbers at the very end of an inline range.  Currently when the program stops at such a line, the debugger shows usually the return statement of an inline function that was just stepped over.  Most annoying is that step over seems to step into the subroutine, but the call stack printed by "bt" is not correct, and does not show the subroutine.

But as the test cases show, if the correct call stack would be known, this breakpoint can be used to display local values of the subroutine at the moment when the subroutine returns.  That is also the case in the corner case of an completely empty subroutine.


Thanks
Bernd.


On 4/5/21 11:40 AM, Bernd Edlinger wrote:
> Ping...
> 
> On 2/26/21 5:49 PM, Bernd Edlinger wrote:
>> Ping...
>>
>> On 1/31/21 10:12 AM, Bernd Edlinger wrote:
>>> I've rebased and re-tested the following patches which are trying to 
>>> improve the debug experience of optimized gcc code.  All have been 
>>> posted previously but I have been asked to post them again as a 
>>> patch series.
>>>
>>> Only [2/4] depends on [1/4], these are about stepping in inlined 
>>> code.
>>> The patches [3/4] and [4/4] are about breakpoints, those do not 
>>> depend on each other.
>>>
>>> Bernd Edlinger (4):
>>>   Introduce a new line table flag is_weak
>>>   Fix range end handling of inlined subroutines
>>>   Fix handling of DW_AT_entry_pc of inlined subroutines
>>>   Skip .cold functions in search_minsyms_for_name
>>>
>>>  gdb/block.c                                        |  15 ++-
>>>  gdb/buildsym.c                                     | 103 ++++++++++++++++++---
>>>  gdb/buildsym.h                                     |   3 +
>>>  gdb/dwarf2/read.c                                  |  98 +++++++-------------
>>>  gdb/infrun.c                                       |  33 ++++++-
>>>  gdb/jit.c                                          |   1 +
>>>  gdb/linespec.c                                     |  24 +++++
>>>  gdb/symmisc.c                                      |  10 +-
>>>  gdb/symtab.c                                       |  18 ++--
>>>  gdb/symtab.h                                       |   4 +
>>>  gdb/testsuite/gdb.base/empty-inline.c              |  42 +++++++++
>>>  gdb/testsuite/gdb.base/empty-inline.exp            |  48 ++++++++++
>>>  gdb/testsuite/gdb.cp/empty-inline.cc               |  33 +++++++
>>>  gdb/testsuite/gdb.cp/empty-inline.exp              |  57 ++++++++++++
>>>  gdb/testsuite/gdb.cp/step-and-next-inline-1.exp    |  30 ++++++
>>>  gdb/testsuite/gdb.cp/step-and-next-inline.cc       |   6 ++
>>>  gdb/testsuite/gdb.cp/step-and-next-inline.exp      |  93 ++++++++++++-------
>>>  .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp     |   4 +-
>>>  gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp       |   6 +-
>>>  gdb/xcoffread.c                                    |   1 +
>>>  20 files changed, 497 insertions(+), 132 deletions(-)  create mode 
>>> 100644 gdb/testsuite/gdb.base/empty-inline.c
>>>  create mode 100644 gdb/testsuite/gdb.base/empty-inline.exp
>>>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.cc
>>>  create mode 100644 gdb/testsuite/gdb.cp/empty-inline.exp
>>>  create mode 100644 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
>>>
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

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

* Re: [PING**3] [PATCH 0/4] Improve debugging of optimized code
  2021-05-21 12:42       ` Willgerodt, Felix
@ 2021-05-23 11:57         ` Bernd Edlinger
  0 siblings, 0 replies; 6+ messages in thread
From: Bernd Edlinger @ 2021-05-23 11:57 UTC (permalink / raw)
  To: Willgerodt, Felix, gdb-patches

Hi,

On 5/21/21 2:42 PM, Willgerodt, Felix wrote:
> Hi Bernd,
> 
> Thanks for this series. I think some of the improvements are very valuable.
> 
> I noticed that the empty-inline.exp tests show one failure with clang.
> I am using:
> 
> $ clang -v
> clang version 10.0.0-4ubuntu1 
> Target: x86_64-pc-linux-gnu
> 
> I think we should do something about this. I haven't looked at the cause really though.
> It might be that we need a bug ticket with clang and/or just limit the tests more for now.
> 
> Thanks,
> Felix
> 
> 

Thanks for looking into this.

I think clang does never emit breakpoints at the end of an inline block,
therefore in all test cases I see never a weak line in the "maint into line" output.
I see a minor issue with the line numbers, in the empty-inline.c.

(gdb) b main
Breakpoint 1 at 0x401121: file empty-inline.c, line 40.
(gdb) r
Starting program: /home/ed/gnu/binutils-gdb/gdb/testsuite/gdb.base/a.out 

Breakpoint 1, main () at empty-inline.c:40
40	  test1 (test0 ()); /* line 40 */
(gdb) s
test0 () at empty-inline.c:40   (**)
40	  test1 (test0 ()); /* line 40 */
(gdb) s
test1 (x=1) at empty-inline.c:31
31	  return x+1; /* line 31 */
(gdb) s
main () at empty-inline.c:41
41	  return 0;
(gdb) 

** = this line is not there without my patch, is shows the right call stack "test0"
but unfortunately the wrong line number, the test fails because it expects line 21 here.

CU: empty-inline.c:
File name                            Line number    Starting address    View    Stmt
empty-inline.c                                29            0x401110               x
empty-inline.c                                30            0x401110       1       x
empty-inline.c                                31            0x401110       2       x
empty-inline.c                                31            0x401113        
empty-inline.c                                39            0x401120               x
empty-inline.c                                20            0x401121               x
empty-inline.c                                40            0x401121       1       x
empty-inline.c                                41            0x40112b               x
empty-inline.c                                41            0x40112f               x

so there is no line 21, only line 20, but since it is followed by the is_stmt line 40,
at the same address, this line is displayed instead.

I think this looks bogus, since if the asm statement in line 20 would contain some
real instructions, the effect of break at line 40 would stop after test0 executed
but before test1, so in the middle of line 40.

Of course this test case is a bit artificial and normally clang sems to avoid constructs
like empty inline functions, or breakpoint locations at the end of an inline range.


Thanks,
Bernd.

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

end of thread, other threads:[~2021-05-23 11:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31  9:12 [PATCH 0/4] Improve debugging of optimized code Bernd Edlinger
2021-02-26 16:49 ` [PING] " Bernd Edlinger
2021-04-05  9:40   ` [PING**2] " Bernd Edlinger
2021-05-09 17:57     ` [PING**3] " Bernd Edlinger
2021-05-21 12:42       ` Willgerodt, Felix
2021-05-23 11:57         ` Bernd Edlinger

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