libunwind-devel
[Top][All Lists]
Advanced

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

[libunwind] suggest adding unw_init_local_accessors


From: Mark Young
Subject: [libunwind] suggest adding unw_init_local_accessors
Date: Tue, 12 Nov 2002 15:42:41 -0800
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0

In using libunwind with dynamically generated code, it would be useful to call the register/memory/unwind-info access functions used by unw_init_local to handle frames created by non-dynamic code. Rather than simply making the local access functions externally visible, I suggest adding a new routine "unw_init_local_accessors" to initialize an unw_accessors_t structure in the same manner as unw_init_local. This would allow personalized access functions to be selectively substituted for local access functions, as in this example:

{
   unw_accessors_t *a;
   unw_context_t *u;
   unw_cursor_t *w;
   int (*local_access_mem_func_ptr)(unw_word_t, unw_word_t *, int, void *);
   int my_access_mem_func(unw_word_t, unw_word_t *, int, void *);

   unw_init_local_accessors(a, u);
   local_access_mem_func_ptr = a->access_mem;
   a->access_mem = my_access_mem_func;
   unw_init_remote(w, a);
   ...
}

A patch to implement unw_init_local_accessors is attached.
--Mark

===== include/libunwind-common.h 1.15 vs edited =====
--- 1.15/include/libunwind-common.h    Fri Nov  8 23:59:02 2002
+++ edited/include/libunwind-common.h    Mon Nov 11 23:38:39 2002
@@ -172,6 +172,7 @@
 /* These routines work both for local and remote unwinding.  */
 
 extern int UNW_OBJ(init_local) (unw_cursor_t *c, ucontext_t *u);
+extern int UNW_OBJ(init_local_accessors) (unw_accessors_t *a, ucontext_t *u);
 extern int UNW_OBJ(init_remote) (unw_cursor_t *c, unw_accessors_t *a);
 extern int UNW_OBJ(step) (unw_cursor_t *c);
 extern int UNW_OBJ(resume) (unw_cursor_t *c);
@@ -188,6 +189,9 @@
    represented by the context U.  Returns zero on success, negative
    value on failure.  */
 #define unw_init_local(c,u)    UNW_OBJ(init_local)(c, u)
+
+/* Initialize accessors A to call local access functions with context U.  */
+#define unw_init_local_accessors(a,u)   UNW_OBJ(init_local_accessors)(a, u)
 
 /* Initialize cursor C such that it accesses the unwind target through
    accessors A.  */

===== src/ia64/unw_init_local.c 1.4 vs edited =====
--- 1.4/src/ia64/unw_init_local.c    Thu Apr 11 22:02:40 2002
+++ edited/src/ia64/unw_init_local.c    Tue Nov 12 14:34:14 2002
@@ -265,6 +265,21 @@
               c->eh_args[3]);
 }
 
+#ifndef UNW_LOCAL_ONLY
+int
+unw_init_local_accessors (unw_accessors_t *a, ucontext_t *uc)
+{
+  a->arg = uc;
+  a->acquire_unwind_info = _Uia64_glibc_acquire_unwind_info;
+  a->release_unwind_info = _Uia64_glibc_release_unwind_info;
+  a->access_mem = access_mem;
+  a->access_reg = access_reg;
+  a->access_fpreg = access_fpreg;
+  a->resume = ia64_local_resume;
+  return 0;
+}
+#endif /* !UNW_LOCAL_ONLY */
+
 int
 unw_init_local (unw_cursor_t *cursor, ucontext_t *uc)
 {
@@ -291,13 +306,7 @@
 #ifdef UNW_LOCAL_ONLY
   c->uc = uc;
 #else /* !UNW_LOCAL_ONLY */
-  c->acc.arg = uc;
-  c->acc.acquire_unwind_info = _Uia64_glibc_acquire_unwind_info;
-  c->acc.release_unwind_info = _Uia64_glibc_release_unwind_info;
-  c->acc.access_mem = access_mem;
-  c->acc.access_reg = access_reg;
-  c->acc.access_fpreg = access_fpreg;
-  c->acc.resume = ia64_local_resume;
+  unw_init_local_accessors(&c->acc, uc);
 #endif /* !UNW_LOCAL_ONLY */
   ret = common_init (c);
   STAT(unw.stat.api.init_time += ia64_get_itc() - start;)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]