Re: Can we not gdb investigate inline functions

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

 



Hello,

Ritesh Kumar wrote:
On 7/21/06, *Shrikanth Kamath* <shrikanth07@xxxxxxxxx <mailto:shrikanth07@xxxxxxxxx>> wrote:

    So even if I trace the function starting address ... still I would
    not be able to do a one to one source code mapping and "/stepping/"
     right ...list would be of no use ...???


You threw away that comfort the moment you optimized the code. After optimizations, the native code no longer follows the source code line by line. Since you have the source code with you I think your best bet is to recompile the code with debug flags on.
Not only should you compile your code with debug flags on but without any optimizations i.e. compile your program with gcc -O0. Only then will your compiled code follow source code line by line.

Ritesh

    On 7/21/06, *Ritesh Kumar* <ritesh@xxxxxxxxxx
    <mailto:ritesh@xxxxxxxxxx> > wrote:


        On 7/21/06, *Shriek* < shriek.007@xxxxxxxxx
        <mailto:shriek.007@xxxxxxxxx>> wrote:

            I attaching gdb to a daemon ... so it receives some input
            from a console .. processes the arguments ... and then
            calls an inline function ...the thing is if that function
            is say some func_inline( ) ... I am not able to set the
            breakpoint for it .. it says there is no func_inline( ) in
            the current context ... how to go about it ...
Shrikanth R K



I was under the impression that when you compile a program
        with gcc -g (to enable debugging suport) gcc turns off all
        optimizations.

That is not that case. You need to explicitly use -O0. Turning of optimizations to generate debugging information will mean you can never debug code with optimizations (which is not the case).

        It should also turn inlining off. So that's the reason why you
        are not able to set a breakpoint for the function.
        Secondly, if you're running gdb on an executable without
        debugging support then then figure out the address of the
        function in the executable. Then breakpoint at that address.
        Try help break at gdb console to find out how to break at an
        address.

To set a breakpoint at an address, do break *addr at the gdb prompt. For example, to set a breakpoint at addresss 0x8048ffff do
(gdb) break *0x8048ffff

        Figuring out the exact address for a function might be tricky.
        Basically you stare hard at the disassembly of the not inlined
        functions where you suspect your function to be inlined and
        guess the address out by looking out the assembly instructions
        :). Might not be very easy with optimized code... but what
        more can you do with a binary blob?
        Ritesh




--
Kunal Parmar
Software Developer,
Codito Technologies Pvt. Ltd. (www.codito.com)

Office: +91 20 26051367 ext. 133
Mobile: +91 98230 28171


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux