public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "prashant.malladi at amd dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/29967] New: Issue with line number information after symbols read from elf
Date: Fri, 06 Jan 2023 11:16:48 +0000	[thread overview]
Message-ID: <bug-29967-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=29967

            Bug ID: 29967
           Summary: Issue with line number information after symbols read
                    from elf
           Product: gdb
           Version: 10.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: prashant.malladi at amd dot com
  Target Milestone: ---

Created attachment 14559
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14559&action=edit
elf file attached

We’re trying to add debug support for AMD-Xilinx cores to GDB. 
During our testing, we have few observations listed below. I’m attaching the
elf file for reference.
The line number information is not available even after the symbols are read
from the file. Refer below snippet.
-------------------------------------------------------
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file 24_0
Reading symbols from 24_0...
(gdb) info line main
No line number information available for address 0x110 <main ()>
-----------------------------------------------------------------

After some debugging, we were able to identify that the function
check_line_address() in dwarf2/read.c sets the flag m_currently_recording_lines
to false if the address in the CU is 0. 
If we dump the .debug_line section from the elf, we find the line number
statements for every CU starts with this statement - “Extended opcode 2: set
Address to 0x0”.  
-----------------------------------------------------------------
Line Number Statements:
[0x0000021b] Extended opcode 2: set Address to 0x0
[0x00000222] Advance Line by -1 to 0
[0x00000224] Set File Name to entry 1 in the File Name Table
[0x00000226] Advance Line by 33 to 33
[0x00000228] Advance PC by 272 to 0x110
[0x0000022b] Copy
[0x0000022c] Set is stmt to 1
[0x0000022d] Special opcode 5: advance Address by 0 to 0x110 and Line by 0 to
33
-------------------------------------------------------------------

Since the address is set to 0 in every CU, and the address is always < lowPC,
the flag m_currently_recording_lines is always set to false and no line number
information is recorded. If we comment the line which sets the flag to false,
we can read the line number information without any issue. 


After modifying the gdb with the above changes, we can see the line number
information
-------------------------------------------------------------------
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file 24_0
Reading symbols from 24_0...
(gdb) info line main
Line 33 of "../src/24_0.cc" starts at address 0x110 <main ()> and ends at 0x11c
<main () +12>.
-------------------------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-01-06 11:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 11:16 prashant.malladi at amd dot com [this message]
2023-01-06 11:18 ` [Bug gdb/29967] " prashant.malladi at amd dot com
2023-01-06 19:32 ` tromey at sourceware dot org
2023-01-11  5:57 ` prashant.malladi at amd dot com
2023-01-11 20:54 ` tromey at sourceware dot org
2023-09-05 11:00 ` rajesh.palla at amd dot com

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=bug-29967-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).