[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libunwind] Cursor copying
From: |
David Mosberger |
Subject: |
Re: [libunwind] Cursor copying |
Date: |
Mon, 16 Aug 2004 06:45:20 -0700 |
>>>>> On Mon, 16 Aug 2004 12:29:07 +0100, "Thomas Hallgren" <address@hidden>
>>>>> said:
Thomas> The libunwind overview mentions how bidirectional iteration
Thomas> can be achieved using cursor copies. I'd like to know how to
Thomas> safely copy a cursor.
Yes.
Thomas> A mere memcpy seems unsafe since the cursor contains a
Thomas> pointer to an unw_context_t. The copy needs a state of its
Thomas> own doesn't it?
A shallow copy (i.e., mmcpy) is safe provided the underlying
machine-state remains valid. For local unwinding, that means the
unw_context_t with which the original cursor was created must remain
valid.
Thomas> A suggestion could be to include a copy function in the
Thomas> libunwind. Something like this:
Thomas> unw_copy_cursor(unw_cursor_t* from, unw_cursor_t* to,
Thomas> unw_context_t* toContext);
Thomas> The reason for passing the 'to' and 'toContext' is of course
Thomas> to avoid the need for memory allocation.
Hmmh, can you say a bit more why you need this? I'm not terribly fond
of adding routines which mention unw_context_t, since those by
definition work for local unwinding only. From my perspective, it
would be preferable if applications could manage the life-time of
unw_context_t so it's never necessary to copy such a structure.
--david