This is the mail archive of the
mailing list for the binutils project.
Re: getting the line of a function when walking the stack with libbfd
On Tue, Mar 20, 2012 at 7:39 AM, Alan Modra <firstname.lastname@example.org> wrote:
> On Tue, Mar 20, 2012 at 05:39:08AM +0100, Vincent Torri wrote:
>> On Tue, Mar 20, 2012 at 5:33 AM, Alan Modra <email@example.com> wrote:
>> > On Mon, Mar 19, 2012 at 07:03:04PM +0100, Vincent Torri wrote:
>> >> But all of them do not find the correct line where the function is
>> >> called. It seems that the line is actually the one finishing the
>> >> function (that is a 'return' call or the closing curly bracket)
>> > Does addr2line work?
>> I actually don't know how to use the addr2line program (I have to pass
>> an address and I don't know which value i have to use)
> Disassemble some of your binary with objdump to find call sites, plug
> in those addresses to addr2line. ?Experiment a little with other
> addresses near the calls.
I played a bit with objdump -S and addr2line seems to work.
void fct(Sw *sw)
sw_frames_get(sw, NULL, NULL);
sw = sw_init(NULL); /* This is line 13 */
/* fct2(sw); */
objdump -S sw;exe gives:
sw = sw_init(NULL);
4016c1: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4016c8: e8 2b 00 00 00 call 4016f8 <_sw_init>
4016cd: 89 44 24 1c mov %eax,0x1c(%esp)
and "addr2line 4016c1" returns line 13, which is the line where
sw_init() is called