Change in relocation of debug info

"Rodney M. Bates" <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
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
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.