[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] Inheritance and delegation in libunwind
From: |
Gabriel Corona |
Subject: |
Re: [Libunwind-devel] Inheritance and delegation in libunwind |
Date: |
Mon, 26 Jan 2015 16:09:45 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hello,
It seems I did not send the final version of the mail.
I'm working on an framework [1] which is using libunwind and I'm
trying to extend it in order to support:
- unwinding from a remote process with a user-supplier
ucontext_t/unw_context_t (the process is remote but is using
user-space context switching) instead of using the current
registers of the remote process (PTRACE_GETREGS and friends);
- using ptrace_vm_readv (on Linux) instead of ptrace in order to be
able to debug it at the same time.
Is there any recommended approach for extending the libunwind
implementations out of the libunwind tree (and without
git-submodul-ing libunwind in my application)?
Writing my own unw_addr_space_t implementation is nearly
straightforward: but writing the find_proc_info method is quite
cumbersome. I'd like to reuse the existing code if possible for this
part but the underlying implementation for this is not exposed in a
public API.
I could nearly inherit the libunwind-ptrace implementation and
override the relevant methods. I'd have to extend the _UPT_info
structure but it is an abstract type: I cannot really do this without
maintaining my own branch of libunwind.
Another approach would to use two layers:
- a libunwind-process_vm_readv implementation which overrides the
access_mem method of the libunwind-ptrace implementation;
- another implementation which delegates to the process_vm_readv
implementation.
In order to implement the overridden access_mem method, I need to use
the private structure of _UPT_info in order to find the PID of the
target process. A _UPT_getpid function might be useful for this:
pid_t _UPG_getpid(void*);
I have 3 possible strategies for reusing the existing code in my
implementation:
- reusing the underlying code for find_proc_info;
- inheriting from the libunwind-ptrace implementation (by extending
the private _UPT_info structure);
- implementing libunwind-process_vm_readv and inheriting from it
(by accessing the _UPT_info structure).
In each case, I need to use some private components of libunwind and
probably keep part of the code in my custom libunwind branch.
[1] http://simgrid.gforge.inria.fr/
Bye.
--
Gabriel