This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GDB & Solaris Stabs


As you all aware, to debug a program with gdb on solaris systems,
the program has to be compiled with -xs option when compiled
with sun workshop compiler. This option forces the compiler to put 
all the debugging stabs in the executable/library. Otherwise they
will be left in the object files.

Compiling with -xs has become a problem to my project. My application
is very big, and when compiled with -xs option, it occupies morethan 
700MB of disk space. This results in 1 hr of package building and 1 hr of 
installation. The other problem i'm facing is gdb is taking around
15 minutes to attach to the application. Since the stabs are very high
in number, psymtab construction is taking lot of time. 

To overcome these problems i have made some changes to the gdb so that
the target need not be compiled with -xs option. The stabs will be
read from the individual object files(like dbx). After making the
changes gdb is taking lessthan 1 minute to attach, and i could see
the symbols properly.

The changes are mainly in the way psymtabs are constructed.
I would like to get your comments/suggestions on the correctness and
completeness. If the changes are acceptable i will send the patch for this.
I have to make it clean and may take sometime.

Here is the brief overview of the changes i have made.

Normally psymtabs are constructed by looking at the entries in the
.stab section. There will be a psymtab for each of the file that executable/lib
is made from. The beginning and ending offset of the stabs in the .stab 
section corresponding to a source file are maintained in its psymtab. 
Similarly the beginning and ending address of the text in the address 
space is also maintained. A psymtab also maintains all the global 
symbols and static symbols that are defined in its source file.
 
Since the program is not compiled with -xs option there won't be any
.stabs section in the exe/lib. Instead sun compiler maintains a section
called ".stab.index" in each file. This section is similar to .stabs
section, but not as exhaustive as .stabs is. i.e. for a symbol
it simply gives its name. It doesn't tell what its type is or any other
information(we also don't need at the time of psymtab construction).
Only the names of the static functions are not maintained in this. 
But they can be got from the minimal symbol table.
Each minimal symbol maintains the file name from which it came from.
So we got all the symbols that are currently maintained in a psymtab.
We need not maintain the offsets of the stabs in the psymtab.
Since we know all the names of the functions in an object file,
by looking at the minimal symbol table, we can find the beginning
and ending address for each psymtab. we got all the info that is 
currently maintained in psymtabs.
In this approach we will maintain the name of the object file 
in the corresponding psymtab. When a psymtab is mutated to a symtab
this object file will be consulted.

The mutation of symtabs from psymtab is simple. The stab.excl section 
in the object file gives its stabs. Since the psymtab maintains the
name of its corresponding object file, stabs can be read without any 
problem.

With these changes i'm able to debug my application peacefully.

Does gcc permit leaving the stabs in the object files. If not
is there any plan to make it. I think it is a very good feature.

Chitti.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]