bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFE: more than 16-bit line numbers


From: Scott McPeak
Subject: RFE: more than 16-bit line numbers
Date: Fri, 3 May 2002 00:08:22 -0700 (PDT)

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. */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]