Discussion:
[Bug symtab/21695] New: Loss of line info
thopre01 at gcc dot gnu.org
2017-06-30 12:39:20 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Bug ID: 21695
Summary: Loss of line info
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: symtab
Assignee: unassigned at sourceware dot org
Reporter: thopre01 at gcc dot gnu.org
Target Milestone: ---

Hi,

Using a trunk gdb built with:

./configure --target=arm-none-eabi --disable-nls --disable-sim --disable-gas
--disable-binutils --disable-ld --disable-gprof --with-libexpat --with-lzma=no
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-python=no


When loading the gdb_test.elf file attached to this ticket
(https://bugs.launchpad.net/gcc-arm-embedded/+bug/1700646), the following
occurs:

$ ../build-gdb/build-gdb-1/gdb/gdb
GNU gdb (GDB) 8.0.50.20170614-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file gdb_test.elf 0x1fff0000 add symbol table from file
"gdb_test.elf" at
.text_addr = 0x1fff0000
(y or n) y
Reading symbols from gdb_test.elf...done.
(gdb) info line main
No line number information available for address 0x1fff0000 <main>
(gdb)


When the same elf file is run with gdb 7.8 built with the same configure, one
gets:

$ build-gdb-7-8/gdb/gdb
GNU gdb (GDB) 7.8.2.20150113-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file gdb_test.elf 0x1fff0000 add symbol table from file
"gdb_test.elf" at
.text_addr = 0x1fff0000
(y or n) y
Reading symbols from gdb_test.elf...done.
(gdb) info line main
Line 76 of "main.c" starts at address 0x1fff0000 <main> and ends at
0x1fff0006 <main+6>.
(gdb)


So with the same configuration and object file, GDB 7.8 manages to display line
info but not trunk GDB.
--
You are receiving this mail because:
You are on the CC list for the bug.
thopre01 at gcc dot gnu.org
2017-06-30 12:40:13 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Thomas Preud'homme <thopre01 at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Target| |arm-none-eabi
--
You are receiving this mail because:
You are on the CC list for the bug.
stephen.kim at oracle dot com
2017-09-01 00:39:47 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Stephen Kim <stephen.kim at oracle dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |stephen.kim at oracle dot com

--- Comment #1 from Stephen Kim <stephen.kim at oracle dot com> ---
My employer assigned a few engineers to GNU toolchains so that we make some
contribution to the projects. I am one of the engineers, and would like to
start with this bug. As it does not seem that I can assign this bug to myself,
I am leaving this comment here. I would like to take a look at this bug, and
will see if this is in my area or not. If it is, I will do my best to fix this
bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
thopre01 at gcc dot gnu.org
2017-09-01 04:08:29 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

--- Comment #2 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
(In reply to Stephen Kim from comment #1)
Post by stephen.kim at oracle dot com
My employer assigned a few engineers to GNU toolchains so that we make some
contribution to the projects. I am one of the engineers, and would like to
start with this bug. As it does not seem that I can assign this bug to
myself, I am leaving this comment here. I would like to take a look at this
bug, and will see if this is in my area or not. If it is, I will do my best
to fix this bug.
Hi Stephen,

First of all thank you for proposing your help here, that's much appreciated.
You'll find more info on how to contribute at [1]. As to assigning bugzilla
ticket, I believe this is only possible once you get commit approval, at least
that's how it work in GCC bugzilla.

[1] https://sourceware.org/gdb/contribute/

Best regards.
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2017-09-06 09:57:14 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |palves at redhat dot com

--- Comment #3 from Pedro Alves <palves at redhat dot com> ---
Stephen, I've given editbugs privileges to your account and to the accounts of
a a couple of your colleagues that I recognized as contributing upstream
recently. Welcome on board!

Another URL to look at is:
https://sourceware.org/gdb/wiki/ContributionChecklist
--
You are receiving this mail because:
You are on the CC list for the bug.
stephen.kim at oracle dot com
2017-09-11 02:15:14 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

--- Comment #4 from Stephen Kim <stephen.kim at oracle dot com> ---
Hi, all,

I could not reproduce this bug. Here are my configurations:

I have an Ubuntu box:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety

It comes up with a binary package for the cross compiler:
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I think I configured my GDB with the options in this bug report, and the
version is:
$ ./gdb --version
GNU gdb (GDB) 8.0.50.20170908-git

The test case was from:
https://bugs.launchpad.net/gcc-arm-embedded/+bug/1700646

There was a batch file as far as I remember it. I made a bash script from it as
follows:
$ cat ./build.sh
#!/bin/bash
arm-none-eabi-gcc -O0 -fno-common -fpie -ffunction-sections -fdata-sections
-Wall -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -T"linker_script.ld"
-Wl,-Map,gdb_test.map,--gc-sections,-emain -nostdlib main.c -o gdb_test2.elf
arm-none-eabi-objcopy --output-target binary gdb_test2.elf gdb_test2.bin

Then, I did what is described in this bug report:
$ ./gdb
GNU gdb (GDB) 8.0.50.20170908-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file ./gdb_test2.elf 0x1fff0000
add symbol table from file "./gdb_test2.elf" at
.text_addr = 0x1fff0000

The bug was not reproducible. Would you check if the bug is gone in the
8..50-20170908 GDB? Otherwise, I guess the difference would be the compiler we
used.
--
You are receiving this mail because:
You are on the CC list for the bug.
stephen.kim at oracle dot com
2017-09-11 02:48:48 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

--- Comment #5 from Stephen Kim <stephen.kim at oracle dot com> ---
(y or n) y
Reading symbols from ./gdb_test2.elf...done.
(gdb) br main
Breakpoint 1 at 0x1fff0000

I cannot modify my comments. The add-symbol-file command asked a "yes or no"
question above. I answered "y" to it, and was able to set a break point with
the address of main, I believe.
--
You are receiving this mail because:
You are on the CC list for the bug.
omair.javaid at linaro dot org
2018-03-13 00:56:02 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Omair Javaid <omair.javaid at linaro dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |omair.javaid at linaro dot org

--- Comment #6 from Omair Javaid <omair.javaid at linaro dot org> ---
I am able to reproduce this bug on GDB trunk: commit 984c723.

Initial investigation suggests problem is visible only when we dont use default
linker script while compiling .text section that is loaded in gdb at an offset
address.

GDB fails to process line information successfully even though it can properly
calculate symbol address with offset included.

This requires further investigation.
--
You are receiving this mail because:
You are on the CC list for the bug.
weimin.pan at oracle dot com
2018-04-18 19:02:17 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

weimin.pan at oracle dot com changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |UNCONFIRMED
CC| |weimin.pan at oracle dot com
Ever confirmed|1 |0

--- Comment #7 from weimin.pan at oracle dot com ---
Still could not reproduce this bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
omair.javaid at linaro dot org
2018-05-03 11:19:21 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Omair Javaid <omair.javaid at linaro dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |omair.javaid at linaro dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
omair.javaid at linaro dot org
2018-05-15 12:38:21 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

Omair Javaid <omair.javaid at linaro dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2018-05-15
Ever confirmed|0 |1
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-06-27 15:14:02 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21695

--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Omair Javaid <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ab6656f274b450942deb8800257c0d2e060fa84

commit 7ab6656f274b450942deb8800257c0d2e060fa84
Author: Omair Javaid <***@linaro.org>
Date: Tue May 15 19:04:21 2018 +0500

Fix lost line info for symbol at addr zero

This patch fixes a unique condition where GDB fails to provide line
information of symbol at address zero when code is compiled with text
address zero but loaded at an offset > 0.

For example lets compile following code snippet:

int main() {
return 0;
}

gcc -O0 -g3 -nostdlib -emain -Wl,-Ttext=0x00 -o file.out file.c

Start gdb and run:

add-symbol-file file.out 0xffff0000
info line main

GDB will return error saying no line info is available for the symbol.

This is a direct consequence of the fix for PR 12528 where GDB tries to
ignore
line table for a function which has been garbage collected by the linker.

As the garbage collected symbols are sent to address zero GDB assumes a
symbol
actually placed at address zero as garbage collected.

This was fixed with an additional check address < lowpc. But when symbol is
loaded at an offset lowpc becomes lowpc + offset while no offset is added
to
address rather final symbol address is calculated based on baseaddr and
address
added together. So in case where symbols are loaded at an offset the
condition
address < lowpc will always return true.

This patch fixes this by comparing address against a non offset lowpc.

This patch also adds a GDB test case to replicate this behavior.

gdb:

2018-06-27 Omair Javaid <***@linaro.org>

PR gdb/21695
* dwarf2read.c (lnp_state_machine::check_line_address): Update
declaration.
(dwarf_decode_lines_1): Adjust.

gdb/testsuite:

2018-06-27 Omair Javaid <***@linaro.org>

PR gdb/21695
* gdb.base/infoline-reloc-main-from-zero.exp: New test.
* gdb.base/infoline-reloc-main-from-zero.c: New file.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...