[PATCH 2/9] unwind: give the field in tcb used for unwinding longer name
Masatake YAMATO
yamato at redhat.com
Tue Mar 13 17:28:07 UTC 2018
tcb has field named `queue' for unwinding. It is too simple name and
can conflicts with fields introduced in the future.
This change gives `unwind_' as prefix to the field.
* defs.h (struct tcb): Rename a field, `queue' to `unwind_queue'.
Rename its type, `queue_t' to `unwind_queue_t'.
* unwind.c (struct unwind_queue_t): Rename `queue_t'.
(queue_print): Reflect the above field and type renaming.
(unwind_tcb_init, unwind_tcb_fin, queue_put, queue_print,
unwind_print_stacktrace, and unwind_capture_stacktrace): Ditto.
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
defs.h | 2 +-
unwind.c | 40 +++++++++++++++++++++++-----------------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/defs.h b/defs.h
index 4d78e0d0..f8867157 100644
--- a/defs.h
+++ b/defs.h
@@ -224,7 +224,7 @@ struct tcb {
#ifdef USE_LIBUNWIND
void *unwind_ctx;
- struct queue_t *queue;
+ struct unwind_queue_t *unwind_queue;
#endif
};
diff --git a/unwind.c b/unwind.c
index 1b06aa3d..14a656a4 100644
--- a/unwind.c
+++ b/unwind.c
@@ -57,12 +57,12 @@ struct call_t {
char *output_line;
};
-struct queue_t {
+struct unwind_queue_t {
struct call_t *tail;
struct call_t *head;
};
-static void queue_print(struct queue_t *queue);
+static void queue_print(struct unwind_queue_t *queue);
static unw_addr_space_t libunwind_as;
@@ -88,17 +88,17 @@ unwind_tcb_init(struct tcb *tcp)
if (!tcp->unwind_ctx)
perror_msg_and_die("_UPT_create");
- tcp->queue = xmalloc(sizeof(*tcp->queue));
- tcp->queue->head = NULL;
- tcp->queue->tail = NULL;
+ tcp->unwind_queue = xmalloc(sizeof(*tcp->unwind_queue));
+ tcp->unwind_queue->head = NULL;
+ tcp->unwind_queue->tail = NULL;
}
void
unwind_tcb_fin(struct tcb *tcp)
{
- queue_print(tcp->queue);
- free(tcp->queue);
- tcp->queue = NULL;
+ queue_print(tcp->unwind_queue);
+ free(tcp->unwind_queue);
+ tcp->unwind_queue = NULL;
_UPT_destroy((struct UPT_info *)tcp->unwind_ctx);
tcp->unwind_ctx = NULL;
@@ -308,7 +308,7 @@ sprint_call_or_error(const char *binary_filename,
* queue manipulators
*/
static void
-queue_put(struct queue_t *queue,
+queue_put(struct unwind_queue_t *queue,
const char *binary_filename,
const char *symbol_name,
unw_word_t function_offset,
@@ -358,7 +358,7 @@ queue_put_error(void *queue,
}
static void
-queue_print(struct queue_t *queue)
+queue_print(struct unwind_queue_t *queue)
{
struct call_t *call, *tmp;
@@ -387,21 +387,24 @@ queue_print(struct queue_t *queue)
void
unwind_print_stacktrace(struct tcb *tcp)
{
+ struct unwind_queue_t *queue;
+
#if SUPPORTED_PERSONALITIES > 1
if (tcp->currpers != DEFAULT_PERSONALITY) {
/* disable stack trace */
return;
}
#endif
- if (tcp->queue->head) {
- debug_func_msg("head: tcp=%p, queue=%p", tcp, tcp->queue->head);
- queue_print(tcp->queue);
+ queue = tcp->unwind_queue;
+ if (queue->head) {
+ debug_func_msg("head: tcp=%p, queue=%p", tcp, queue->head);
+ queue_print(queue);
} else switch (mmap_cache_rebuild_if_invalid(tcp, __func__)) {
case MMAP_CACHE_REBUILD_RENEWED:
unw_flush_cache(libunwind_as, 0, 0);
ATTRIBUTE_FALLTHROUGH;
case MMAP_CACHE_REBUILD_READY:
- debug_func_msg("walk: tcp=%p, queue=%p", tcp, tcp->queue->head);
+ debug_func_msg("walk: tcp=%p, queue=%p", tcp, queue->head);
stacktrace_walk(tcp, print_call_cb, print_error_cb, NULL);
break;
default:
@@ -416,13 +419,16 @@ unwind_print_stacktrace(struct tcb *tcp)
void
unwind_capture_stacktrace(struct tcb *tcp)
{
+ struct unwind_queue_t *queue;
+
#if SUPPORTED_PERSONALITIES > 1
if (tcp->currpers != DEFAULT_PERSONALITY) {
/* disable stack trace */
return;
}
#endif
- if (tcp->queue->head)
+ queue = tcp->unwind_queue;
+ if (queue->head)
error_msg_and_die("bug: unprinted entries in queue");
switch (mmap_cache_rebuild_if_invalid(tcp, __func__)) {
@@ -431,8 +437,8 @@ unwind_capture_stacktrace(struct tcb *tcp)
ATTRIBUTE_FALLTHROUGH;
case MMAP_CACHE_REBUILD_READY:
stacktrace_walk(tcp, queue_put_call, queue_put_error,
- tcp->queue);
- debug_func_msg("tcp=%p, queue=%p", tcp, tcp->queue->head);
+ queue);
+ debug_func_msg("tcp=%p, queue=%p", tcp, queue->head);
break;
default:
/* Do nothing */
--
2.14.3
More information about the Strace-devel
mailing list