]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/testsuite/ChangeLog
gdb: Restore old annotations behaviour when printing frame info
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 12 May 2020 20:29:23 +0000 (21:29 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 22 May 2020 12:39:50 +0000 (13:39 +0100)
commit7c13f4e875fd5eeb0b7a1c301b4b513051822648
treee1cd0f0c3fcb6892cea4a16c3bf3fe3823e51669
parent6f3fe02b0b8f6865820d8889a8420190063f3235
gdb: Restore old annotations behaviour when printing frame info

This undoes most of the changes from these commits:

  commit ec8e2b6d3051f0b4b2a8eee9917898e95046c62f
  Date:   Fri Jun 14 23:43:00 2019 +0100

      gdb: Don't allow annotations to influence what else GDB prints

  commit 0d3abd8cc936360f8c46502135edd2e646473438
  Date:   Wed Jun 12 22:34:26 2019 +0100

      gdb: Remove an update of current_source_line and current_source_symtab

as a result of the discussion here:

  https://sourceware.org/pipermail/gdb/2020-April/048468.html

Having taken time to reflect on the discussion, and reading the
documentation again I believe we should revert GDB's behaviour back to
how it used to be.

The original concern that triggered the initial patch was that when
annotations were on the current source and line were updated (inside
the annotation code), while when annotations are off this update would
not occur.  This was incorrect, as printing the source with the call
to print_source_lines does also update the current source and line.

Further, the documentation here:
  https://sourceware.org/gdb/current/onlinedocs/gdb/Source-Annotations.html#Source-Annotations

Clearly states:

  "The following annotation is used instead of displaying source code:

   ^Z^Zsource filename:line:character:middle:addr

   ..."

So it is documented that the 'source' annotation is a replacement for,
and not in addition to, actually printing the source lie.

There are still a few issues that I can see, these are:

  1. In source.c:info_line_command, when annotations are on we call
  annotate_source_line, however, if annotations are off then there is
  no corresponding call to print the source line.  This means that a
  if a user uses 'info line ...' with annotations on, and then does a
  'list', they will get different results than if they had done this
  with annotations off.

  2. It bothers me that the call to annotate_source_line returns a
  boolean, and that this controls a call to print_source_line (in
  stack.c:print_frame_info).

  The reason for this is that the source line annotation will only
  print something if the file is found, and the line number is in
  range for the file.

  It seems to me like an annotation should always be printed, either
  one that identifies the file and line, or one that identifies the
  file and line GDB would like to access, but couldn't.

  I considered changing this, but in the end decided not too, if I
  extend the existing 'source' annotation to print something in all
  cases then I risk breaking existing UIs that rely on the file and
  line always being valid.  If I add a new annotation then this might
  also break existing UIs that rely on GDB itself printing the error
  from within print_source_line.

Given that annotations is deprecated (as I understand it) mechanism
for UIs to interact with GDB (in favour of MI) I figure we should just
restore the old behaviour, and leave the mini-bugs in until someone
actually complains.

This isn't a straight revert of the two commits mentioned above.  I've
left annotate_source_line instead of going back to the original
identify_source_line, which lived in source.c, but was really
annotation related.  The API for setting the current source and line
has changed since the original patches, so I updated for that change
too.  Finally I wrote the code in stack.c so that we avoided an extra
level of indentation, which I felt made things easier to read.

gdb/ChangeLog:

* annotate.c (annotate_source_line): Update return type, add call
to update current symtab and line.
* annotate.h (annotate_source_line): Update return type, and
extend header comment.
* source.c (info_line_command): Check annotation_level before
calling annotate_source_line.
* stack.c (print_frame_info): If calling annotate_source_line
returns true, then don't print any other source line information.

gdb/testsuite/ChangeLog:

* gdb.base/annota1.exp: Update expected results.
* gdb.cp/annota2.exp: Update expected results, remove duplicate
test name.
* gdb.cp/annota3.exp: Update expected results.
gdb/ChangeLog
gdb/annotate.c
gdb/annotate.h
gdb/source.c
gdb/stack.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/annota1.exp
gdb/testsuite/gdb.cp/annota2.exp
gdb/testsuite/gdb.cp/annota3.exp