[PATCH 1/9] unwind: make the field type of struct tcb libunwind independent

Masatake YAMATO yamato at redhat.com
Tue Mar 13 17:28:06 UTC 2018


Narrwoing the area where the code refers names abot libunwind is needed
to utilize libdw of elfutils as replaceable alternative unwinder.

* defs.h (struct tcb): Rename a field, "libunwind_ui" to "unwind_ctx".
* unwind.c (unwind_tcb_init): Reflect the above field renaming.
(unwind_tcb_fin)> Ditto.
(stracetrace_walk): Ditto.

Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
 defs.h   |  2 +-
 unwind.c | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/defs.h b/defs.h
index 34261e4b..4d78e0d0 100644
--- a/defs.h
+++ b/defs.h
@@ -223,7 +223,7 @@ struct tcb {
 	unsigned int mmap_cache_generation;
 
 #ifdef USE_LIBUNWIND
-	struct UPT_info *libunwind_ui;
+	void *unwind_ctx;
 	struct queue_t *queue;
 #endif
 };
diff --git a/unwind.c b/unwind.c
index a272fba8..1b06aa3d 100644
--- a/unwind.c
+++ b/unwind.c
@@ -81,11 +81,11 @@ unwind_init(void)
 void
 unwind_tcb_init(struct tcb *tcp)
 {
-	if (tcp->libunwind_ui)
+	if (tcp->unwind_ctx)
 		return;
 
-	tcp->libunwind_ui = _UPT_create(tcp->pid);
-	if (!tcp->libunwind_ui)
+	tcp->unwind_ctx = _UPT_create(tcp->pid);
+	if (!tcp->unwind_ctx)
 		perror_msg_and_die("_UPT_create");
 
 	tcp->queue = xmalloc(sizeof(*tcp->queue));
@@ -100,8 +100,8 @@ unwind_tcb_fin(struct tcb *tcp)
 	free(tcp->queue);
 	tcp->queue = NULL;
 
-	_UPT_destroy(tcp->libunwind_ui);
-	tcp->libunwind_ui = NULL;
+	_UPT_destroy((struct UPT_info *)tcp->unwind_ctx);
+	tcp->unwind_ctx = NULL;
 }
 
 static void
@@ -200,7 +200,8 @@ stacktrace_walk(struct tcb *tcp,
 
 	symbol_name = xmalloc(symbol_name_size);
 
-	if (unw_init_remote(&cursor, libunwind_as, tcp->libunwind_ui) < 0)
+	if (unw_init_remote(&cursor, libunwind_as,
+			    (struct UPT_info *)tcp->unwind_ctx) < 0)
 		perror_msg_and_die("Can't initiate libunwind");
 
 	for (stack_depth = 0; stack_depth < 256; ++stack_depth) {
-- 
2.14.3



More information about the Strace-devel mailing list