public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RE: Regarding Map Files
       [not found] <Pine.LNX.4.21.0112201923580.1871-100000@okinawa.intranet.pspl.co.in>
@ 2001-12-20 20:41 ` Sachin O. Agrawal
  0 siblings, 0 replies; 8+ messages in thread
From: Sachin O. Agrawal @ 2001-12-20 20:41 UTC (permalink / raw)
  To: binutils, 'Shridhar Bhat'; +Cc: 'Devendra Badhani (E-mail)'

Hi

We have two options. One is clear and we are using it. i.e.
Program logs its own flow to debug log which can be enabled
and disabled. There are some problems with this approach

1) Size of debug log. Its cumbersome for support engineer
   or customer to enable logging, duplicate bug and ship
   the huge logs to developer site. Further its a pain
   for developers to trace log entries.

2) Bug which appears while logging is off may not appear
   when the same is enabled even though it can be
   duplicated.

3) Size of executables.

Second approach is that when program finds an error condition
or OS reports to it through signals, programs calls an internal
function which then only logs few numbers which are nothing
but return addresses on the stack. These numbers will be emitted
only in case of bugs. They are definitely shorter than the core dump
given by OS. I agree the core dump already contains these numbers
we are interested in. This is the first obstacle in this approach.

Now second obstacle is that once we have these numbers corresponding
to an optimized executable, is it possible to figure out approximate
range of line numbers in the source code.

Utilities like 'gdb' and 'addr2line' gives this information if these
numbers correspond to the unoptimized executables with debugging info.
For optimized versions can one use map files generated by linker?

First obstacle has a solution in Windows as there is a specific call
for getting stack trace. For second obstacle one need to manually
trace the map files generated by VC++ linker. A tool can be easily
written for the same.

--
Thanks
Sachin
--



> -----Original Message-----
> From: Shridhar Bhat [mailto:penguin@pspl.co.in]
> Sent: Thursday, December 20, 2001 7:28 PM
> To: Sachin O. Agrawal
> Cc: Devendra Badhani (E-mail)
> Subject: RE: Regarding Map Files
> 
> 
> Hi Sachin,
> 
> If the program can detect error conditions on its own then you
> could definitely do this. But the problem is that when the
> program does something wrong, in most cases, it is the OS
> which detects this error and creates the core dump. So, program
> would have no way to figure this out. If you could modify the
> OS (or the run time system) to send a special signal to the 
> program, which the program could catch and intelligently 
> create its own stack trace, then it would work.
> 
> Correct me if I am wrong.
> 
> -Shridhar.
> 
> On Thu, 20 Dec 2001, Sachin O. Agrawal wrote:
> 
> :>Hello,
> :>
> :>Actually my intention is to find the functions and approximate
> :>range of line numbers in sources given an address.
> :>
> :>Usually all commercial products use logging to trace their code
> :>flow in case of error at customer site. My opinion is that in
> :>error conditions program itself can log stack back trace just
> :>like a debugger (but within an optimized code).
> :>
> :>Support engineer or customer will mail these numbers instead of
> :>big and huge core dump to the developers. Developers will then
> :>trace out using map files the backtrace. I agree this trace
> :>won't be as accurate as backtrace reported by debugger but
> :>at least it is better than huge logging.
> :>
> :>--
> :>Thanks
> :>Sachin
> :>--
> :>
> :>
> :>-----Original Message-----
> :>From: ananda.motte@philips.com [mailto:ananda.motte@philips.com]
> :>Sent: Thursday, December 20, 2001 6:34 PM
> :>To: sachin_agrawal@persistent.co.in
> :>Subject: Re: Regarding Map Files
> :>
> :>
> :>
> :>Basically it tells you in what portions of memory your 
> .text .rodata .bss
> :>.data and other sections (read GNU manual) and their 
> respective symbol
> :>contents are loaded and relocated to in case your image 
> address is different
> :>from the load address.
> :>
> :>Ir Motte dit Falisse Ananda
> :>Embedded Software Engineer
> :>Portable Audio
> :>Philips Semiconductors Leuven, Belgium
> :>
> :>> -----Original Message-----
> :>> From: Sachin O. Agrawal [mailto:sachin_agrawal@persistent.co.in]
> :>> Sent: Thursday, December 20, 2001 6:05 PM
> :>> To: 'binutils@sources.redhat.com'
> :>> Subject: Regarding Map Files
> :>>
> :>>
> :>> Hello,
> :>>
> :>> With -M or -Map option to the ld linker, we can create a map file.
> :>> Does any one knows how to interpret them?
> :>>
> :>> --
> :>> Thanks
> :>> Sachin
> :>> --
> :>
> :>
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Regarding Map Files
  2001-12-21  1:19         ` Sachin O. Agrawal
@ 2001-12-21  9:10           ` Ian Lance Taylor
  0 siblings, 0 replies; 8+ messages in thread
From: Ian Lance Taylor @ 2001-12-21  9:10 UTC (permalink / raw)
  To: sachin_agrawal
  Cc: binutils, 'Devendra Badhani (E-mail)',
	'Shridhar Bhat (E-mail)', Masaoud Taher Moonim (E-mail)

"Sachin O. Agrawal" <sachin_agrawal@persistent.co.in> writes:

> I am able to generate a map file and interpret the same.
> Is there already a tool which can parse these files and
> provide me the information I need?

No.

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Regarding Map Files
  2001-12-21  1:11       ` Ian Lance Taylor
@ 2001-12-21  1:19         ` Sachin O. Agrawal
  2001-12-21  9:10           ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin O. Agrawal @ 2001-12-21  1:19 UTC (permalink / raw)
  To: binutils
  Cc: 'Ian Lance Taylor', 'Devendra Badhani (E-mail)',
	'Shridhar Bhat (E-mail)', Masaoud Taher Moonim (E-mail)

> If that is unacceptable for some reason, then you can indeed use the
> map file to map addresses to functions.  Personally, I think the
> format is pretty obvious, but then I'm obviously biased.  Each output
> section is listed starting in column 0, with name, VMA, and size.
> Each input section is listed starting in column 1 with section name,
> VMA, size, and input file name.  Each global symbol is listed with
> nothing in the first column, then the VMA and the symbol name.
>
> Just pick some address, and find it in the map file.  You'll see the
> file and section it came from, and the global symbols from that file
> with their address.

I am able to generate a map file and interpret the same.
Is there already a tool which can parse these files and
provide me the information I need?

> If you still don't get it, ask a specific question rather than a
> general one.

Thanks!!! Ian. At least now I am sure that this is possible.
Please go through a separate thread regarding stack back trace.

--
Thanks
Sachin
--

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Regarding Map Files
  2001-12-20 22:43     ` Sachin O. Agrawal
@ 2001-12-21  1:11       ` Ian Lance Taylor
  2001-12-21  1:19         ` Sachin O. Agrawal
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2001-12-21  1:11 UTC (permalink / raw)
  To: sachin_agrawal
  Cc: binutils, ananda.motte, 'Devendra Badhani (E-mail)',
	'Shridhar Bhat (E-mail)'

"Sachin O. Agrawal" <sachin_agrawal@persistent.co.in> writes:

> > > Actually my intention is to find the functions and approximate
> > > range of line numbers in sources given an address.
> > 
> > Look at addr2line.
> 
> This works only when debugging info is available.

My understanding is that you want to get the stack backtrace from
units in the field, which you then analyze yourself.  So just build
the executable with full debugging information, and then strip the
version that you send out.  When you get a stack backtrace from the
field, use the executable you saved which has the full debugging
information.

If that is unacceptable for some reason, then you can indeed use the
map file to map addresses to functions.  Personally, I think the
format is pretty obvious, but then I'm obviously biased.  Each output
section is listed starting in column 0, with name, VMA, and size.
Each input section is listed starting in column 1 with section name,
VMA, size, and input file name.  Each global symbol is listed with
nothing in the first column, then the VMA and the symbol name.

Just pick some address, and find it in the map file.  You'll see the
file and section it came from, and the global symbols from that file
with their address.

If you still don't get it, ask a specific question rather than a
general one.

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Regarding Map Files
  2001-12-20 13:13   ` Ian Lance Taylor
@ 2001-12-20 22:43     ` Sachin O. Agrawal
  2001-12-21  1:11       ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin O. Agrawal @ 2001-12-20 22:43 UTC (permalink / raw)
  To: 'Ian Lance Taylor'
  Cc: binutils, ananda.motte, 'Devendra Badhani (E-mail)',
	'Shridhar Bhat (E-mail)'

> > Actually my intention is to find the functions and approximate
> > range of line numbers in sources given an address.
> 
> Look at addr2line.

This works only when debugging info is available.

> 
> > Usually all commercial products use logging to trace their code
> > flow in case of error at customer site. My opinion is that in
> > error conditions program itself can log stack back trace just
> > like a debugger (but within an optimized code).
> 
> Note that doing a stack backtrace on optimized code is nontrivial in
> the general case.  It's obviously possible, and gdb does it, but in
> general you either need debugging information to describe the stack
> frame or you need to disassemble the code to work out the stack frame.
> A running program generally doesn't have easy access to the debugging
> information, and it's hard to disassemble code backward.
> 
> Of course if you are using a processor which uses a consistent frame
> pointer, and you don't compile with -fomit-frame-pointer, then it's
> not too tough.

We can compile without -fomit-frame-pointer. Since it is more beneficial
than the compile/run time and space overhead of normal logging.

As regard to processor, the specifications are already fixed at design time
for embedded systems or for appliances. x86 family as a dedicated 'ebp'
register for the same.

--
Thanks
Sachin
--

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Regarding Map Files
  2001-12-20  6:54 ` Sachin O. Agrawal
@ 2001-12-20 13:13   ` Ian Lance Taylor
  2001-12-20 22:43     ` Sachin O. Agrawal
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2001-12-20 13:13 UTC (permalink / raw)
  To: sachin_agrawal
  Cc: binutils, ananda.motte, Devendra Badhani (E-mail),
	Shridhar Bhat (E-mail)

"Sachin O. Agrawal" <sachin_agrawal@persistent.co.in> writes:

> Actually my intention is to find the functions and approximate
> range of line numbers in sources given an address.

Look at addr2line.

> Usually all commercial products use logging to trace their code
> flow in case of error at customer site. My opinion is that in
> error conditions program itself can log stack back trace just
> like a debugger (but within an optimized code).

Note that doing a stack backtrace on optimized code is nontrivial in
the general case.  It's obviously possible, and gdb does it, but in
general you either need debugging information to describe the stack
frame or you need to disassemble the code to work out the stack frame.
A running program generally doesn't have easy access to the debugging
information, and it's hard to disassemble code backward.

Of course if you are using a processor which uses a consistent frame
pointer, and you don't compile with -fomit-frame-pointer, then it's
not too tough.

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Regarding Map Files
       [not found] <OF87D49C08.95941499-ONC1256B28.00473E4C@diamond.philips.com>
@ 2001-12-20  6:54 ` Sachin O. Agrawal
  2001-12-20 13:13   ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin O. Agrawal @ 2001-12-20  6:54 UTC (permalink / raw)
  To: binutils; +Cc: ananda.motte, Devendra Badhani (E-mail), Shridhar Bhat (E-mail)

Hello,

Actually my intention is to find the functions and approximate
range of line numbers in sources given an address.

Usually all commercial products use logging to trace their code
flow in case of error at customer site. My opinion is that in
error conditions program itself can log stack back trace just
like a debugger (but within an optimized code).

Support engineer or customer will mail these numbers instead of
big and huge core dump to the developers. Developers will then
trace out using map files the backtrace. I agree this trace
won't be as accurate as backtrace reported by debugger but
at least it is better than huge logging.

--
Thanks
Sachin
--


-----Original Message-----
From: ananda.motte@philips.com [mailto:ananda.motte@philips.com]
Sent: Thursday, December 20, 2001 6:34 PM
To: sachin_agrawal@persistent.co.in
Subject: Re: Regarding Map Files



Basically it tells you in what portions of memory your .text .rodata .bss
.data and other sections (read GNU manual) and their respective symbol
contents are loaded and relocated to in case your image address is different
from the load address.

Ir Motte dit Falisse Ananda
Embedded Software Engineer
Portable Audio
Philips Semiconductors Leuven, Belgium

> -----Original Message-----
> From: Sachin O. Agrawal [mailto:sachin_agrawal@persistent.co.in]
> Sent: Thursday, December 20, 2001 6:05 PM
> To: 'binutils@sources.redhat.com'
> Subject: Regarding Map Files
>
>
> Hello,
>
> With -M or -Map option to the ld linker, we can create a map file.
> Does any one knows how to interpret them?
>
> --
> Thanks
> Sachin
> --

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Regarding Map Files
@ 2001-12-20  5:19 Sachin O. Agrawal
  0 siblings, 0 replies; 8+ messages in thread
From: Sachin O. Agrawal @ 2001-12-20  5:19 UTC (permalink / raw)
  To: binutils

Hello,

With -M or -Map option to the ld linker, we can create a map file.
Does any one knows how to interpret them?

--
Thanks
Sachin
--

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-12-21 16:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.21.0112201923580.1871-100000@okinawa.intranet.pspl.co.in>
2001-12-20 20:41 ` Regarding Map Files Sachin O. Agrawal
     [not found] <OF87D49C08.95941499-ONC1256B28.00473E4C@diamond.philips.com>
2001-12-20  6:54 ` Sachin O. Agrawal
2001-12-20 13:13   ` Ian Lance Taylor
2001-12-20 22:43     ` Sachin O. Agrawal
2001-12-21  1:11       ` Ian Lance Taylor
2001-12-21  1:19         ` Sachin O. Agrawal
2001-12-21  9:10           ` Ian Lance Taylor
2001-12-20  5:19 Sachin O. Agrawal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).