gdb: Recognize -1 as a tombstone value in .debug_line

Message ID 20200630231842.508205-1-maskray@google.com
State New
Headers show
Series
  • gdb: Recognize -1 as a tombstone value in .debug_line
Related show

Commit Message

Jose E. Marchesi via Gdb-patches June 30, 2020, 11:18 p.m.
LLD from 11 onwards (https://reviews.llvm.org/D81784) uses -1 to
represent a relocation in .debug_line referencing a discarded symbol.
Recognize -1 to fix gdb.base/break-on-linker-gcd-function.exp when the
linker is a newer LLD.

gdb/ChangeLog:

	* dwarf2/read.c (lnp_state_machine::check_line_address): Test -1.
---
 gdb/dwarf2/read.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
2.27.0.212.ge8ba1cc988-goog

Comments

Andrew Burgess July 1, 2020, 8:26 a.m. | #1
* Fangrui Song via Gdb-patches <gdb-patches@sourceware.org> [2020-06-30 16:18:42 -0700]:

> LLD from 11 onwards (https://reviews.llvm.org/D81784) uses -1 to

> represent a relocation in .debug_line referencing a discarded symbol.

> Recognize -1 to fix gdb.base/break-on-linker-gcd-function.exp when the

> linker is a newer LLD.

> 

> gdb/ChangeLog:

> 

> 	* dwarf2/read.c (lnp_state_machine::check_line_address): Test -1.

> ---

>  gdb/dwarf2/read.c | 8 ++++++--

>  1 file changed, 6 insertions(+), 2 deletions(-)

> 

> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c

> index b097f624b6..7cf2691ae9 100644

> --- a/gdb/dwarf2/read.c

> +++ b/gdb/dwarf2/read.c

> @@ -20380,9 +20380,13 @@ lnp_state_machine::check_line_address (struct dwarf2_cu *cu,

>    /* If ADDRESS < UNRELOCATED_LOWPC then it's not a usable value, it's outside

>       the pc range of the CU.  However, we restrict the test to only ADDRESS

>       values of zero to preserve GDB's previous behaviour which is to handle

> -     the specific case of a function being GC'd by the linker.  */

> +     the specific case of a function being GC'd by the linker.

>  

> -  if (address == 0 && address < unrelocated_lowpc)

> +     LLD from 11 onwards (https://reviews.llvm.org/D81784) uses -1 to represent

> +     the tombstone value.

> +     */


If I understand this correctly then "tombstone value" here is the same
as "a function being GC'd by the linker".  If that's correct then
could you just use that phrase please as it is clearer, and matches
the terminology already used in the comment.

The trailing '*/' should be on the same line as the end of the
comment, with two whitespace before it, so '...value.  */'.

> +

> +  if ((address == 0 && address < unrelocated_lowpc) || address == (CORE_ADDR)-1)


There should be a whitespace after the cast, so '(CORE_ADDR) -1'.

Thanks,
Andrewx

>      {

>        /* This line table is for a function which has been

>  	 GCd by the linker.  Ignore it.  PR gdb/12528 */

> -- 

> 2.27.0.212.ge8ba1cc988-goog

>

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b097f624b6..7cf2691ae9 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20380,9 +20380,13 @@  lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
   /* If ADDRESS < UNRELOCATED_LOWPC then it's not a usable value, it's outside
      the pc range of the CU.  However, we restrict the test to only ADDRESS
      values of zero to preserve GDB's previous behaviour which is to handle
-     the specific case of a function being GC'd by the linker.  */
+     the specific case of a function being GC'd by the linker.
 
-  if (address == 0 && address < unrelocated_lowpc)
+     LLD from 11 onwards (https://reviews.llvm.org/D81784) uses -1 to represent
+     the tombstone value.
+     */
+
+  if ((address == 0 && address < unrelocated_lowpc) || address == (CORE_ADDR)-1)
     {
       /* This line table is for a function which has been
 	 GCd by the linker.  Ignore it.  PR gdb/12528 */