* Core dump information when code is optimized
@ 2009-04-16 7:00 Lennyk
2009-04-16 9:00 ` Joel Brobecker
2009-04-17 7:59 ` Michael Snyder
0 siblings, 2 replies; 4+ messages in thread
From: Lennyk @ 2009-04-16 7:00 UTC (permalink / raw)
To: gdb
Hi,
When I compile only with -O1 flag - my core dump information does not
show line number or offset (when a segmentation fault has occurred).
Only when I add the -g flag does the core dump contain line number
information - but the executable's size grows significantly!
Is there a way to get this information with core dump - but maintain the
optimized sized executable?
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Core dump information when code is optimized
2009-04-16 7:00 Core dump information when code is optimized Lennyk
@ 2009-04-16 9:00 ` Joel Brobecker
2009-04-17 7:59 ` Michael Snyder
1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2009-04-16 9:00 UTC (permalink / raw)
To: Lennyk; +Cc: gdb
> Is there a way to get this information with core dump - but maintain the
> optimized sized executable?
The -O flags are completely independent from debugging information.
In order to do symbolic debugging, GDB needs debugging information,
which is why using the -g switch helps. There might be a way to produce
only line number information if that's what you need, but I don't know
offhand. Check the compiler/linker docs. Regardless, the extra info
will cause the size of your executable to grow, as you have discovered.
--
Joel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Core dump information when code is optimized
2009-04-16 7:00 Core dump information when code is optimized Lennyk
2009-04-16 9:00 ` Joel Brobecker
@ 2009-04-17 7:59 ` Michael Snyder
2009-04-20 14:47 ` Lennyk
1 sibling, 1 reply; 4+ messages in thread
From: Michael Snyder @ 2009-04-17 7:59 UTC (permalink / raw)
To: Lennyk; +Cc: gdb
Lennyk wrote:
> Hi,
>
> When I compile only with -O1 flag - my core dump information does not
> show line number or offset (when a segmentation fault has occurred).
> Only when I add the -g flag does the core dump contain line number
> information - but the executable's size grows significantly!
>
> Is there a way to get this information with core dump - but maintain the
> optimized sized executable?
It is -g that matters, not -O.
-g generates line info. This info goes into your executable, but it
does not increase your memory footprint -- only the size of the file.
In other words this line info is not copied into memory at runtime.
Which means that it also does not appear in the corefile, so your
corefile should not get significantly bigger.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Core dump information when code is optimized
2009-04-17 7:59 ` Michael Snyder
@ 2009-04-20 14:47 ` Lennyk
0 siblings, 0 replies; 4+ messages in thread
From: Lennyk @ 2009-04-20 14:47 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb
Thanks!
In the meantime I found how to separate the debug and symbol information
from the binary executable - using objcopy:
1) Copy only the debug & symbol information from the binary to another file:
objcopy --only-keep-debug <your_binary_filename> <output_file>
2) Strip the original binary file from its debug & symbol information:
objcopy --strip-debug <your_binary_filename>
3) Link between the stripped binary and the debug & symbol information
file created in step (1):
objcopy --add-gnu-debuglink=<file_with_debug_info> <stripped_binary>
That's it! now the binary executable is optimized in size - and the core
dump generates debug & symbol information from the created output file
(in step (1)).
Enjoy,
Lenny.
Michael Snyder wrote:
> Lennyk wrote:
>> Hi,
>>
>> When I compile only with -O1 flag - my core dump information does not
>> show line number or offset (when a segmentation fault has occurred).
>> Only when I add the -g flag does the core dump contain line number
>> information - but the executable's size grows significantly!
>>
>> Is there a way to get this information with core dump - but maintain
>> the optimized sized executable?
>
> It is -g that matters, not -O.
>
> -g generates line info. This info goes into your executable, but it
> does not increase your memory footprint -- only the size of the file.
> In other words this line info is not copied into memory at runtime.
>
> Which means that it also does not appear in the corefile, so your
> corefile should not get significantly bigger.
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-20 8:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 7:00 Core dump information when code is optimized Lennyk
2009-04-16 9:00 ` Joel Brobecker
2009-04-17 7:59 ` Michael Snyder
2009-04-20 14:47 ` Lennyk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox