🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #2216

RFE: more than 16-bit line numbers

#2216
From: Scott McPeak
Date: Fri, 03 May 2002 07:08
63 lines
3406 bytes
I'm working on a project in which some very long (millions of lines) C
source files get generated.  Since GNU 'as' and 'gdb' cannot store more
than 16 bits of line number information, debugging programs using these
files is tedious.

The reason for the 16-bit limit is the n_desc field of the stabs symbol is
16 bits (see http://www.kashpureff.org/nic/linux/texinfo/stabs_6.html).

As a stopgap, I've hacked 'as' and 'gdb' to put bits 16-23 into the
n_other field, which I understand is usually zero anyway (but
gdb-5.2/include/bout.h suggests that sometimes it's not, at least on some
architectures).  Below are patches to each package (binutils-2.12 and
gdb-5.2) which accomplish the hack.

-Scott

------------------------------------- 8< -------------------------
--- binutils-2.12/gas/stabs.c.orig	Thu May  2 23:36:03 2002
+++ binutils-2.12/gas/stabs.c	Fri May  3 00:03:57 2002
@@ -251,6 +251,20 @@
       input_line_pointer++;
       SKIP_WHITESPACE ();
     }
+
+  /* handle descriptions (line numbers!) which are >0xFFFF */
+  if (desc > 0xFFFF)
+    {
+      if (desc > 0xFFFFFF)
+	as_warn(_("desc is too large to encode in 24 bits: %d"), desc);
+      else if (other != 0)
+	as_warn(_("I want to use 'other', but it is not zero: %d"), other);
+      else
+	/* stick the extra bits in 'other' because it is typically unused;
+	 * of course, downstream tools (like gdb) need to be modified to
+	 * use this information */
+	other = desc >> 16;
+    }

 #ifdef TC_PPC
 #ifdef OBJ_ELF
--- gdb-5.2/gdb/dbxread.c.orig	Thu May  2 23:21:09 2002
+++ gdb-5.2/gdb/dbxread.c	Thu May  2 23:31:43 2002
@@ -970,6 +970,7 @@
       (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value);	\
     else								\
       (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value);	\
+    (intern).n_other = bfd_h_get_8 (abfd, (extern)->e_other);		\
   }

 /* Invariant: The symbol pointed to by symbuf_idx is the first one
@@ -2599,8 +2600,10 @@

       if (type & N_STAB)
 	{
-	  process_one_symbol (type, nlist.n_desc, nlist.n_value,
-			      namestring, section_offsets, objfile);
+	  /* to handle line numbers larger than 0xFFFF, add the 'other'
+	   * field to n_desc (after shifting by 16 bits) */
+	  process_one_symbol (type, nlist.n_desc + (nlist.n_other << 16),
+			      nlist.n_value, namestring, section_offsets, objfile);
 	}
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
Technical Details
Message-ID: <Pine.LNX.4.33.0205022344130.811-100000@seamonkey.pasture.cow>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!news.mathworks.com!uunet!nyc.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!bug-gdb

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,eebaf94dcee3f771,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 2002-05-03 00:10:24 PST
x-uunet-gateway: mr1.ash.ops.us.uu.net from bug-gdb to gnu.gdb.bug; Fri, 3 May 2002 07:10:22 GMT
From: "Scott McPeak" <smcpeak@cs.berkeley.edu>
Date: Fri, 3 May 2002 00:08:22 -0700
Subject: RFE: more than 16-bit line numbers
Message-ID: <Pine.LNX.4.33.0205022344130.811-100000@seamonkey.pasture.cow>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Approved: bug-gdb-request@mail.gnu.org
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!news.mathworks.com!uunet!nyc.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!bug-gdb
Sender: bug-gdb-request@mail.gnu.org
Lines: 65