public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "Rodney M. Bates" <rodney_bates@lcwb.coop>
To: gdb@sourceware.org
Subject: Change in relocation of debug info
Date: Sun, 30 May 2021 12:51:31 -0500	[thread overview]
Message-ID: <f183a233-a401-17c4-32e4-74c479860510@lcwb.coop> (raw)

I am maintaining a debugger, derived from gdb-6.4, with
additions for Modula-3.  A recent change in the way gcc
and gdb handle addresses of souce code line numbers in
stabs notation has broken breakpoint insertion.  I need
help understanding what has happened.

This could be a gcc problem, but I am starting here, because
modern gdb appears to at least partly overcome what has
changed in gcc, suggesting at least a coordinated change.

In a reduced example, I have an object file SetElem_m.o,
with the following:

   $objdump -g SetElem_m.o:
     ...
     /* file ../src/SetElem.m3 line 11 addr 0x11 */
     ...

When I link using gcc 5.4:

   $gcc --version:
   gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609,

giving executable named prog I see:

   $objdump -g prog
   ...
   /* file ../src/SetElem.m3 line 11 addr 0x4008ee */
   ...

I can set a breakpoint at SetElem.m3:11, and all works as
expected using either m3gdb or gdb:

   $m3gdb prog
   GNU gdb plus Modula-3 6.4
   ...
   (m3gdb) break SetElem.m3:11
   Breakpoint 1 at 0x4008ee: file ../src/SetElem.m3, line 11.
   (m3gdb) run
   Breakpoint 1, P (...) at ../src/SetElem.m3:11
   11	      RETURN SetTyp { Elem }
   (m3gdb) info reg rip
   rip            0x4008ee	0x4008ee <P+17>

But when linking with gcc 9.3:

   $gcc --version:
   gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

I see:

   $objdump -g prog
   ...
   /* file ../src/SetElem.m3 line 11 addr 0x9b1 */
   ...

neither unrelocated from the .o file nor where line 11
ends up (I think).  m3gdb tries to insert the breakpoint
at this address, failing, I presume because it is
not a writable address:

   $m3gdb prog
   GNU gdb plus Modula-3 6.4
   ...
   (m3gdb) break SetElem.m3:11
   Breakpoint 1 at 0x9b1: file ../src/SetElem.m3, line 11.
   (m3gdb) run
   Starting program: /home/rodney/proj/m3/exp/setelem/AMD64_LINUX-ig-m3cc/prog
   Warning:
   Cannot insert breakpoint 1.
   Error accessing memory address 0x9b1: Input/output error.

In constast, modern gdb inserts the breakpoint and stops,
showing the correct source line number, although not all is
right here either:

   $ gdb prog
   GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
   ...
   (gdb) break SetElem.m3:11
   Breakpoint 1 at 0x9b1: file ../src/SetElem.m3, line 11.
   (gdb) run
   Starting program: /home/rodney/proj/m3/exp/setelem/AMD64_LINUX-ig-m3cc/prog
   ...
   Breakpoint 1, SetElem__P (M3_AuNps8_Elem=<error reading variable>,
     M3_A6gO1v__result=<error reading variable>) at ../src/SetElem.m3:11
   11	      RETURN SetTyp { Elem }
   (gdb) info reg rip
   rip            <error reading variable> <error reading variable>

So I can't tell where the actual code was relocated to.  But it runs
to completion normally, by itself or under either debugger without
breakpoints.

Any help would be appreciated.

-- 
Rodney Bates
rodney.m.bates@acm.org

             reply	other threads:[~2021-05-30 17:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-30 17:51 Rodney M. Bates [this message]
2021-05-31 15:08 ` Simon Marchi
2021-06-03 18:54   ` Rodney M. Bates
2021-06-03 19:02     ` Simon Marchi
2021-06-03 19:41       ` Rodney M. Bates

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=f183a233-a401-17c4-32e4-74c479860510@lcwb.coop \
    --to=rodney_bates@lcwb.coop \
    --cc=gdb@sourceware.org \
    --cc=rodney.m.bates@acm.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).