[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] ptrace-unwind not working at head
From: |
Humberto Abdelnur |
Subject: |
[Libunwind-devel] ptrace-unwind not working at head |
Date: |
Thu, 18 Feb 2010 18:13:50 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Hello all,
I'm having some problems to unwind the IPs from a ptrace child.
Actually, using the version libunwind-0.99 it worked out.
Now that I move to the head version and the unwind IP is only one.
I did a tiniest poc (attached to the mail) so you can see the results.
The target application was opera.
After digging into the libunwind code I found that the problem was in the
file src/os-linux.h at line 269
if (!cp)
continue;
cp = scan_string (cp, NULL, 0);
if (!cp || dash != '-' || colon != ':')
continue;
since scan_string with buf_size 0 always returns 0. So for me it does
not make sense, does it?
So, i removed and it works well afterwards.
Now my real problem is when I call my upt_backtrace function (the one in
the poc file) repetitively,
then the virtual memory of the process keeps increasing.
I do not know if i'm missing something in my code, but I realized that
the mempool (src/mi/mempool.c) it does
a mmap but never a munmap.
I'm not quite sure where I should do the munmap (if it is that i m not
getting confused), so can somebody help me out with it?
Thanks in advance,
Humberto Abdelnur
ps: Can you please put me in cc when replying as i m not registered in
the mailing list
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <libunwind.h>
#include <libunwind-ptrace.h>
void upt_backtrace(pid_t pid) {
unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, 0);
unw_word_t bt;
void *upt = _UPT_create(pid);
unw_cursor_t orig_cursor, curr_cursor;
unw_init_remote(&orig_cursor, as, upt);
curr_cursor = orig_cursor;
int i = 0;
do {
unw_get_reg(&curr_cursor, UNW_REG_IP, &bt);
printf("%lx\n", bt);
} while (unw_step(&curr_cursor) > 0);
_UPT_destroy(upt);
unw_destroy_addr_space(as);
}
int main(int argc, char **argv) {
pid_t pid = atoi(argv[1]);
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL)) {
return 1;
}
upt_backtrace(pid);
ptrace(PTRACE_DETACH, pid, NULL, NULL);
return 0;
}
- [Libunwind-devel] ptrace-unwind not working at head,
Humberto Abdelnur <=