Re: [Q] Line numbers from object files?

"David W. Coppit" <dwc3q@mamba.cs.virginia.edu>
8 Jul 1997 00:33:36 -0400

          From comp.compilers

Related articles
Re: [Q] Line numbers from object files? dwc3q@mamba.cs.virginia.edu (David W. Coppit) (1997-07-08)
Re: [Q] Line numbers from object files? lauther@fubini.mchp.siemens.de (1997-07-13)
| List of all articles for this month |

From: "David W. Coppit" <dwc3q@mamba.cs.virginia.edu>
Newsgroups: comp.compilers,gnu.g++.help,comp.lang.c++
Date: 8 Jul 1997 00:33:36 -0400
Organization: University of Virginia
Keywords: debug

On 1 Jul 1997, David Coppit wrote:


> Well, I'm stumped. How do you get an ASCII dump of the line number
> information for the various functions defined in object files? Basically,
> I'm looking for something like the following, but I'm willing to hack a
> script to format it from other output:
>
> In file main.o:
> Sourcefile Line # Symbol name
> ---------- ------ -----------
> main.cc 12 void main()
> main.cc 32 int foo(char *)


I finally found what I was looking for in "objdump", which is part of the
gnu binutils suite. If you run it as
"objdump --stabs executablefile | c++filt" the output looks like the
following:


3984 FUN 0 7 0001a198 5779 collector_iago::reset(int,int):F16
3985 RSYM 0 7 00000008 5809 this:P144
3986 RSYM 0 7 00000009 5819 set_num_moves:P1
3987 RSYM 0 7 0000000a 5836 inblack:P1
3988 SLINE 0 7 00000000 0
3989 SLINE 0 9 00000000 0
3990 SLINE 0 10 0000002c 0
3991 SLINE 0 12 00000044 0
3992 SLINE 0 13 00000050 0
3993 SLINE 0 14 00000058 0
3994 SLINE 0 15 0000005c 0
3995 SLINE 0 19 00000064 0
3996 SLINE 0 20 0000006c 0
3997 SLINE 0 21 00000070 0
3998 SLINE 0 22 00000074 0
3999 SLINE 0 24 0000008c 0
4000 SLINE 0 25 0000008c 0
4001 LBRAC 0 0 00000000 0
4002 LBRAC 0 0 00000000 0
4003 LBRAC 0 0 00000020 0
4004 LBRAC 0 0 0000002c 0
4005 RBRAC 0 0 00000084 0
4006 RBRAC 0 0 00000084 0
4007 RBRAC 0 0 0000008c 0
4008 RBRAC 0 0 0000008c 0


looking for "FUN" gets you the function name, and the starting line is in
the fourth column. As far as I can tell, the last SLINE contains the last
line of the function (skip any "SOL"'s), but I'll have to learn more about
the STABS format. See


http://minastirith.cip2b.tu-harburg.de/info/html/stabs_toc.html


Regards,
David


_________________________________________________________________________
David Coppit - Graduate Student coppit@cs.virginia.edu
The University of Virginia http://www.cs.virginia.edu/~dwc3q
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.